From 067e128651a6a1cb5d8eadc8e4d31ca4bb828261 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 18 Mar 2020 13:23:07 +0100 Subject: [PATCH] Suppress tooltips when the mouse is processed by an ImGUI dialog. --- src/slic3r/GUI/GLCanvas3D.cpp | 11 ++++++++--- src/slic3r/GUI/GLCanvas3D.hpp | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index c2901ba2b..16cce24ed 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1376,12 +1376,14 @@ void GLCanvas3D::Labels::render(const std::vector& sorted_ #if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI void GLCanvas3D::Tooltip::set_text(const std::string& text) { - if (m_text != text) + // If the mouse is inside an ImGUI dialog, then the tooltip is suppressed. + const std::string &new_text = m_in_imgui ? std::string() : text; + if (m_text != new_text) { if (m_text.empty()) m_start_time = std::chrono::steady_clock::now(); - m_text = text; + m_text = new_text; } } #endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI @@ -3310,15 +3312,18 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) Point pos(evt.GetX(), evt.GetY()); ImGuiWrapper* imgui = wxGetApp().imgui(); + m_tooltip.set_in_imgui(false); if (imgui->update_mouse_data(evt)) { m_mouse.position = evt.Leaving() ? Vec2d(-1.0, -1.0) : pos.cast(); + m_tooltip.set_in_imgui(true); render(); #ifdef SLIC3R_DEBUG_MOUSE_EVENTS printf((format_mouse_event_debug_message(evt) + " - Consumed by ImGUI\n").c_str()); #endif /* SLIC3R_DEBUG_MOUSE_EVENTS */ // do not return if dragging or tooltip not empty to allow for tooltip update #if ENABLE_CANVAS_TOOLTIP_USING_IMGUI - if (!m_mouse.dragging && m_tooltip.is_empty()) + // Replaced with the m_tooltip.is_in_imgui() flag. +// if (!m_mouse.dragging && had_tooltip && m_tooltip.is_empty()) #else if (!m_mouse.dragging && m_canvas->GetToolTipText().empty()) #endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 578166351..0f9cf7d63 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -399,6 +399,8 @@ private: #if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI std::chrono::steady_clock::time_point m_start_time; #endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI + // Indicator that the mouse is inside an ImGUI dialog, therefore the tooltip should be suppressed. + bool m_in_imgui = false; public: bool is_empty() const { return m_text.empty(); } @@ -409,6 +411,8 @@ private: void set_text(const std::string& text) { m_text = text; } void render(const Vec2d& mouse_position) const; #endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI + // Indicates that the mouse is inside an ImGUI dialog, therefore the tooltip should be suppressed. + void set_in_imgui(bool b) { m_in_imgui = b; } }; #endif // ENABLE_CANVAS_TOOLTIP_USING_IMGUI