Added base work for the timeline popup.

This commit is contained in:
2026-03-01 16:16:18 -08:00
parent 6ef2416d96
commit b891b8730e

23
main.c
View File

@@ -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.