From fba3ab060f5dcfeaf5cc36f14eb5ec46414fdbc8 Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Sun, 27 Apr 2025 16:13:57 +0800 Subject: [PATCH] FIX: messureSize after set max size; the text is the default tooltip jira: [STUDIO-11878] Change-Id: I1945779d620a01fff4cfb29b5592eed0490dbbd5 --- src/slic3r/GUI/Widgets/Button.cpp | 14 +++++++++++++- src/slic3r/GUI/Widgets/Button.hpp | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Widgets/Button.cpp b/src/slic3r/GUI/Widgets/Button.cpp index 2c8cba910..bf3851a38 100644 --- a/src/slic3r/GUI/Widgets/Button.cpp +++ b/src/slic3r/GUI/Widgets/Button.cpp @@ -110,6 +110,12 @@ void Button::SetMinSize(const wxSize& size) messureSize(); } +void Button::SetMaxSize(const wxSize& size) +{ + wxWindow::SetMaxSize(size); + messureSize(); +} + void Button::SetPaddingSize(const wxSize& size) { paddingSize = size; @@ -310,9 +316,15 @@ void Button::messureSize() if (minSize.GetHeight() > 0) size.SetHeight(minSize.GetHeight()); - if (auto w = GetMaxWidth(); w > 0 && size.GetWidth() > w) + if (auto w = GetMaxWidth(); w > 0 && size.GetWidth() > w) { size.SetWidth(GetMaxWidth()); + const wxString& tip_str = GetToolTipText(); + if (tip_str.IsEmpty()) { + SetToolTip(GetLabel()); + } + } + if (minSize.GetWidth() > size.GetWidth()) wxWindow::SetMinSize(minSize); else diff --git a/src/slic3r/GUI/Widgets/Button.hpp b/src/slic3r/GUI/Widgets/Button.hpp index 10b44f160..26b26d86b 100644 --- a/src/slic3r/GUI/Widgets/Button.hpp +++ b/src/slic3r/GUI/Widgets/Button.hpp @@ -39,6 +39,7 @@ public: void SetInactiveIcon(const wxString& icon); void SetMinSize(const wxSize& size) override; + void SetMaxSize(const wxSize& size) override; void SetPaddingSize(const wxSize& size);