From b891b8730e0b416d38dc916f8c89b1d82a3d9058 Mon Sep 17 00:00:00 2001 From: igor Date: Sun, 1 Mar 2026 16:16:18 -0800 Subject: [PATCH] Added base work for the timeline popup. --- main.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/main.c b/main.c index aa18e3b..d31758a 100644 --- a/main.c +++ b/main.c @@ -436,6 +436,29 @@ int main(int argc, char *argv[]) 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); } + + // 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)); + F32 end_x = floor(((F32)(activities[i].ended - lower_bound_s) / (F32)(upper_bound_s - lower_bound_s)) * (F32)(state.window_w)); + Rectangle rect = {start_x, 0, end_x - start_x, 40}; + + if(CheckCollisionPointRec(state.mouse_pos, rect)) { + // TOOD: This 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); + + 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); + } + } EndDrawing(); // Reset statistics as we will accumulate seconds again.