Skip to content

Commit 7fea553

Browse files
committed
fix hack to stop busted animation when minimized - just bounds check the content rectangle
1 parent 6682613 commit 7fea553

File tree

2 files changed

+22
-36
lines changed

2 files changed

+22
-36
lines changed

src/raddbg/raddbg_core.c

+22-35
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,6 @@ rd_entity_from_handle(RD_Handle handle)
206206
return result;
207207
}
208208

209-
internal RD_HandleList
210-
rd_handle_list_from_entity_list(Arena *arena, RD_EntityList entities)
211-
{
212-
RD_HandleList result = {0};
213-
for(RD_EntityNode *n = entities.first; n != 0; n = n->next)
214-
{
215-
RD_Handle handle = rd_handle_from_entity(n->entity);
216-
rd_handle_list_push(arena, &result, handle);
217-
}
218-
return result;
219-
}
220-
221209
//- rjf: entity recursion iterators
222210

223211
internal RD_EntityRec
@@ -6889,34 +6877,33 @@ rd_window_frame(RD_Window *ws)
68896877
////////////////////////////
68906878
//- rjf: animate panels
68916879
//
6892-
// TODO(rjf): @hack investigate why we were ever animating to a busted
6893-
// rectangle when minimized...
6894-
//
6895-
if(!os_window_is_minimized(ws->os))
68966880
{
68976881
F32 rate = rd_setting_val_from_code(RD_SettingCode_MenuAnimations).s32 ? 1 - pow_f32(2, (-50.f * rd_state->frame_dt)) : 1.f;
68986882
Vec2F32 content_rect_dim = dim_2f32(content_rect);
6899-
for(RD_Panel *panel = ws->root_panel; !rd_panel_is_nil(panel); panel = rd_panel_rec_depth_first_pre(panel).next)
6883+
if(content_rect_dim.x > 0 && content_rect_dim.y > 0)
69006884
{
6901-
Rng2F32 target_rect_px = rd_target_rect_from_panel(content_rect, ws->root_panel, panel);
6902-
Rng2F32 target_rect_pct = r2f32p(target_rect_px.x0/content_rect_dim.x,
6903-
target_rect_px.y0/content_rect_dim.y,
6904-
target_rect_px.x1/content_rect_dim.x,
6905-
target_rect_px.y1/content_rect_dim.y);
6906-
if(abs_f32(target_rect_pct.x0 - panel->animated_rect_pct.x0) > 0.005f ||
6907-
abs_f32(target_rect_pct.y0 - panel->animated_rect_pct.y0) > 0.005f ||
6908-
abs_f32(target_rect_pct.x1 - panel->animated_rect_pct.x1) > 0.005f ||
6909-
abs_f32(target_rect_pct.y1 - panel->animated_rect_pct.y1) > 0.005f)
6910-
{
6911-
rd_request_frame();
6912-
}
6913-
panel->animated_rect_pct.x0 += rate * (target_rect_pct.x0 - panel->animated_rect_pct.x0);
6914-
panel->animated_rect_pct.y0 += rate * (target_rect_pct.y0 - panel->animated_rect_pct.y0);
6915-
panel->animated_rect_pct.x1 += rate * (target_rect_pct.x1 - panel->animated_rect_pct.x1);
6916-
panel->animated_rect_pct.y1 += rate * (target_rect_pct.y1 - panel->animated_rect_pct.y1);
6917-
if(ws->frames_alive < 5 || is_changing_panel_boundaries)
6885+
for(RD_Panel *panel = ws->root_panel; !rd_panel_is_nil(panel); panel = rd_panel_rec_depth_first_pre(panel).next)
69186886
{
6919-
panel->animated_rect_pct = target_rect_pct;
6887+
Rng2F32 target_rect_px = rd_target_rect_from_panel(content_rect, ws->root_panel, panel);
6888+
Rng2F32 target_rect_pct = r2f32p(target_rect_px.x0/content_rect_dim.x,
6889+
target_rect_px.y0/content_rect_dim.y,
6890+
target_rect_px.x1/content_rect_dim.x,
6891+
target_rect_px.y1/content_rect_dim.y);
6892+
if(abs_f32(target_rect_pct.x0 - panel->animated_rect_pct.x0) > 0.005f ||
6893+
abs_f32(target_rect_pct.y0 - panel->animated_rect_pct.y0) > 0.005f ||
6894+
abs_f32(target_rect_pct.x1 - panel->animated_rect_pct.x1) > 0.005f ||
6895+
abs_f32(target_rect_pct.y1 - panel->animated_rect_pct.y1) > 0.005f)
6896+
{
6897+
rd_request_frame();
6898+
}
6899+
panel->animated_rect_pct.x0 += rate * (target_rect_pct.x0 - panel->animated_rect_pct.x0);
6900+
panel->animated_rect_pct.y0 += rate * (target_rect_pct.y0 - panel->animated_rect_pct.y0);
6901+
panel->animated_rect_pct.x1 += rate * (target_rect_pct.x1 - panel->animated_rect_pct.x1);
6902+
panel->animated_rect_pct.y1 += rate * (target_rect_pct.y1 - panel->animated_rect_pct.y1);
6903+
if(ws->frames_alive < 5 || is_changing_panel_boundaries)
6904+
{
6905+
panel->animated_rect_pct = target_rect_pct;
6906+
}
69206907
}
69216908
}
69226909
}

src/raddbg/raddbg_core.h

-1
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,6 @@ internal B32 rd_entity_is_nil(RD_Entity *entity);
998998
internal U64 rd_index_from_entity(RD_Entity *entity);
999999
internal RD_Handle rd_handle_from_entity(RD_Entity *entity);
10001000
internal RD_Entity *rd_entity_from_handle(RD_Handle handle);
1001-
internal RD_HandleList rd_handle_list_from_entity_list(Arena *arena, RD_EntityList entities);
10021001

10031002
//- rjf: entity recursion iterators
10041003
internal RD_EntityRec rd_entity_rec_depth_first(RD_Entity *entity, RD_Entity *subtree_root, U64 sib_off, U64 child_off);

0 commit comments

Comments
 (0)