@@ -105,8 +105,6 @@ void Timeline::Draw() {
105105
106106 ImGui::EndTable ();
107107
108- DrawSelectedTimeRanges (timeline_width, px_per_time_unit_val);
109-
110108 HandleEventDeselection ();
111109
112110 // Handle continuous keyboard and mouse wheel input for timeline navigation.
@@ -118,6 +116,13 @@ void Timeline::Draw() {
118116 HandleWheel ();
119117 HandleMouse ();
120118
119+ // Keep this at the end.
120+ // `DrawSelectedTimeRanges` should be called after all other timeline content
121+ // (events, ruler, etc.) has been drawn. This ensures that the selected time
122+ // range is rendered on top of everything else within the current ImGui
123+ // window, without affecting global foreground elements like tooltips.
124+ DrawSelectedTimeRanges (timeline_width, px_per_time_unit_val);
125+
121126 ImGui::EndChild ();
122127 ImGui::PopStyleVar (); // ItemSpacing
123128 ImGui::PopStyleVar (); // CellPadding
@@ -615,8 +620,8 @@ void Timeline::DrawSelectedTimeRange(const TimeRange& range,
615620 std::min (time_range_x_end, timeline_x_start + timeline_width);
616621
617622 if (clipped_x_end > clipped_x_start) {
618- // Use the foreground draw list to render over all other timeline content.
619- ImDrawList* const draw_list = ImGui::GetForegroundDrawList ();
623+ // Use the window draw list to render over all other timeline content.
624+ ImDrawList* const draw_list = ImGui::GetWindowDrawList ();
620625 draw_list->AddRectFilled (ImVec2 (clipped_x_start, table_rect_min.y ),
621626 ImVec2 (clipped_x_end, table_rect_max.y ),
622627 kSelectedTimeRangeColor );
0 commit comments