From 5cc9eb8df2f1dbfe1ea8f5c8f5a48be1f8ec4c7b Mon Sep 17 00:00:00 2001 From: igor Date: Sun, 1 Mar 2026 16:24:09 -0800 Subject: [PATCH] Activity timeline popup is done. --- main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/main.c b/main.c index d31758a..a641d3e 100644 --- a/main.c +++ b/main.c @@ -437,7 +437,6 @@ int main(int argc, char *argv[]) DrawTextEx(state.font, index_buf, (Vector2){ rect.x + 10.0f, rect.y + 10.0f }, state.font_size - 5.0f, 2, BLACK); } - // TODO: Display a popup on mouse hover over activity line. // NOTE: This is rendered last because a popup has to flow above everything else. for(U32 i = 0; i <= current_activity; i++) { F32 start_x = floor((F32)(activities[i].began - lower_bound_s) / (F32)(upper_bound_s - lower_bound_s) * (F32)(state.window_w)); @@ -445,18 +444,18 @@ int main(int argc, char *argv[]) Rectangle rect = {start_x, 0, end_x - start_x, 40}; if(CheckCollisionPointRec(state.mouse_pos, rect)) { - // TOOD: This should be its own component. + // TOOD: A general popup should be its own component. char *str_activity_type = activity_type_string_representation[i]; - Vector2 activity_type_d = MeasureTextEx(state.font, str_activity_type, state.font_size - 5.0f, 2); - DrawRectangleRounded((Rectangle){ start_x, 40, (F32)(activity_type_d.x), (F32)(activity_type_d.y) }, 0.3f, 100, BLACK); - DrawRectangleRoundedLinesEx((Rectangle){ start_x, 40, (F32)(activity_type_d.x), (F32)(activity_type_d.y) }, 0.3f, 100, 2.0f, DARKGRAY); + Vector2 activity_type_d = MeasureTextEx(state.font, str_activity_type, state.font_size - 5.0f, 2); + Vector2 activity_time_d = MeasureTextEx(state.font, activities_stats[i].seconds_str, state.font_size - 10.0f, 2); + + S32 rect_w = (S32)((activity_type_d.x >= activity_time_d.x) ? activity_type_d.x : activity_time_d.x); + DrawRectangleRounded((Rectangle){ start_x, 40, rect_w, (F32)(activity_time_d.y + activity_type_d.y) }, 0.3f, 100, BLACK); + DrawRectangleRoundedLinesEx((Rectangle){ start_x, 40, rect_w, (F32)(activity_time_d.y + activity_type_d.y) }, 0.3f, 100, 2.0f, DARKGRAY); DrawTextEx(state.font, str_activity_type, (Vector2){ start_x, 40.0f }, state.font_size - 5.0f, 2, WHITE); - - //local_persist char index_buf[8]; - //snprintf(index_buf, sizeof(index_buf), "%d", i + 1); - //DrawTextEx(state.font, index_buf, (Vector2){ rect.x + 10.0f, rect.y + 10.0f }, state.font_size - 5.0f, 2, BLACK); + DrawTextEx(state.font, activities_stats[i].seconds_str, (Vector2){ start_x, 40.0f + (F32)(activity_type_d.y) }, state.font_size - 10.0f, 2, WHITE); } } EndDrawing();