From aabbc4152709f51d80eb589900b25790703284ef Mon Sep 17 00:00:00 2001 From: yw4z Date: Wed, 11 Mar 2026 15:36:19 +0300 Subject: [PATCH] Update BBLTopbar.cpp --- src/slic3r/GUI/BBLTopbar.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/BBLTopbar.cpp b/src/slic3r/GUI/BBLTopbar.cpp index 62c20e65cc..d097fa2c2d 100644 --- a/src/slic3r/GUI/BBLTopbar.cpp +++ b/src/slic3r/GUI/BBLTopbar.cpp @@ -51,13 +51,12 @@ CenteredTitle::CenteredTitle(wxWindow* parent) wxFontMetrics fm = dc.GetFontMetrics(); int textHeight = fm.ascent + fm.descent; - wxRect rect = GetClientRect(); - + wxRect rect = GetClientRect(); wxString ellipsized = wxControl::Ellipsize(m_title, dc, wxELLIPSIZE_END, rect.GetWidth() - FromDIP(8)); int y = rect.y + (rect.height - textHeight) / 2; - int x = rect.x + (ellipsized != m_title) - ? FromDIP(4) // fixed left when clipped + int x = rect.x + (ellipsized != m_title) // is ellipsized + ? FromDIP(4) // fixed left when clipped : (rect.width - dc.GetTextExtent(m_title).GetWidth()) / 2; // centered when full dc.DrawText(ellipsized, x, y); @@ -69,15 +68,14 @@ CenteredTitle::CenteredTitle(wxWindow* parent) e.Skip(); }); - Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) { + auto forwardMouseEvent = [this](wxMouseEvent& e) { + if (e.LeftDown() && e.GetClickCount() > 1) return; // prevent duplicate event e.SetPosition(GetParent()->ScreenToClient(ClientToScreen(e.GetPosition()))); GetParent()->GetEventHandler()->ProcessEvent(e); - }); + }; - Bind(wxEVT_LEFT_DCLICK, [this](wxMouseEvent& e) { - e.SetPosition(GetParent()->ScreenToClient(ClientToScreen(e.GetPosition()))); - GetParent()->GetEventHandler()->ProcessEvent(e); - }); + Bind(wxEVT_LEFT_DOWN, forwardMouseEvent); + Bind(wxEVT_LEFT_DCLICK, forwardMouseEvent); } void CenteredTitle::SetTitle(const wxString& title) {