diff --git a/openpilot/tools/cabana/ui/chart/chart.cc b/openpilot/tools/cabana/ui/chart/chart.cc index 4f1d7891ea..1c319b4faf 100644 --- a/openpilot/tools/cabana/ui/chart/chart.cc +++ b/openpilot/tools/cabana/ui/chart/chart.cc @@ -504,13 +504,13 @@ void ChartView::draw(float width) { updateLayout(); paint(); drawContextMenu(); + // Keep the tip above the plot, but below popup menus and other windows. + ImRect visible_rect = charts_widget_->chartVisibleRect(this); + visible_rect.ClipWith(ImRect(ImVec2(layout_.rect.Min.x, layout_.plot_area.Min.y), + ImVec2(layout_.rect.Max.x, layout_.plot_area.Max.y))); + if (!drawing_ghost_ && visible_rect.GetWidth() > 0 && visible_rect.GetHeight() > 0) tip_label_.draw(visible_rect); } ImGui::EndChild(); - // a chart scrolled out of the viewport draws no tip - ImRect visible_rect = charts_widget_->chartVisibleRect(this); - visible_rect.ClipWith(ImRect(ImVec2(layout_.rect.Min.x, layout_.plot_area.Min.y), - ImVec2(layout_.rect.Max.x, layout_.plot_area.Max.y))); - if (!drawing_ghost_ && visible_rect.GetWidth() > 0 && visible_rect.GetHeight() > 0) tip_label_.draw(visible_rect); ImGui::PopID(); } @@ -575,7 +575,8 @@ void ChartView::drawAxes() { layout_.plot_area = ImRect(ImPlot::GetPlotPos(), ImPlot::GetPlotPos() + ImPlot::GetPlotSize()); // ImPlotFlags_NoInputs disables implot's own hover tracking - layout_.plot_hovered = layout_.plot_area.Contains(ImGui::GetMousePos()) && ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem); + // A popup is a descendant of the chart, but hovering its menu must not hover the plot underneath. + layout_.plot_hovered = layout_.plot_area.Contains(ImGui::GetMousePos()) && ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem); drawSeries(); if (!drawing_ghost_) { // Own plot clicks so custom scrubbing/zooming cannot also move the floating window. diff --git a/openpilot/tools/cabana/ui/chart/chartswidget.cc b/openpilot/tools/cabana/ui/chart/chartswidget.cc index 12bf656a68..c89dc702db 100644 --- a/openpilot/tools/cabana/ui/chart/chartswidget.cc +++ b/openpilot/tools/cabana/ui/chart/chartswidget.cc @@ -551,7 +551,7 @@ void ChartsWidget::handleEvents() { if (!value_tip_visible_) return; - // the tip is drawn on the foreground draw list, so the mouse is never "on the tip" + // The tip is drawn without an input item, so the mouse is never "on the tip". const ImVec2 delta = ImGui::GetIO().MouseDelta; if (!any_plot_hovered_ && (delta.x != 0 || delta.y != 0 || !ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows))) { diff --git a/openpilot/tools/cabana/ui/chart/tiplabel.cc b/openpilot/tools/cabana/ui/chart/tiplabel.cc index 6f3a1ee54e..83c693babf 100644 --- a/openpilot/tools/cabana/ui/chart/tiplabel.cc +++ b/openpilot/tools/cabana/ui/chart/tiplabel.cc @@ -134,7 +134,7 @@ void TipLabel::draw(const ImRect &rect) { updateLayout(); if (!visible_) return; - ImDrawList *p = ImGui::GetForegroundDrawList(); + ImDrawList *p = ImGui::GetWindowDrawList(); p->PushClipRect(area_.Min, area_.Max, true); // filled panel with a 1px frame p->AddRectFilled(pos_, pos_ + size_, ImGui::GetColorU32(ImGuiCol_PopupBg), ImGui::GetStyle().PopupRounding); diff --git a/openpilot/tools/cabana/ui/chart/tiplabel.h b/openpilot/tools/cabana/ui/chart/tiplabel.h index 48f20b59f8..7128a56384 100644 --- a/openpilot/tools/cabana/ui/chart/tiplabel.h +++ b/openpilot/tools/cabana/ui/chart/tiplabel.h @@ -20,7 +20,7 @@ public: void showText(const ImVec2 &pt, const std::vector &text, const ImRect &rect); void hide() { visible_ = false; } bool isVisible() const { return visible_; } - void draw(const ImRect &rect); // draws the tip on the foreground draw list; call once per frame + void draw(const ImRect &rect); // call inside the owning chart window, after drawing the plot private: // lays the lines out from origin, drawing them when p is given; returns the size of the text block