From d15f49a7c00beb55de3ec946755dbb6b1adcd8a2 Mon Sep 17 00:00:00 2001 From: "wenjie.guo" Date: Mon, 11 Dec 2023 14:19:55 +0800 Subject: [PATCH] FIX: file name is not fully displayed if it is too long Jira: STUDIO-5230 Signed-off-by: wenjie.guo Change-Id: I992fa0c0575afbd2eecb2af02c8a305eda028f7f (cherry picked from commit d0d7fb0b1394429ee9d28d8ef4060a286ba0112d) --- src/slic3r/GUI/Widgets/ProgressDialog.cpp | 15 +++++++++++++-- src/slic3r/GUI/Widgets/ProgressDialog.hpp | 5 ++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Widgets/ProgressDialog.cpp b/src/slic3r/GUI/Widgets/ProgressDialog.cpp index 1a0f3672d..1b42c912a 100644 --- a/src/slic3r/GUI/Widgets/ProgressDialog.cpp +++ b/src/slic3r/GUI/Widgets/ProgressDialog.cpp @@ -100,12 +100,14 @@ wxString ProgressDialog::FormatString(wxString title) break; } } - // set mode if (m_mode == 0) { m_simplebook->SetSelection(0); m_msg->SetLabel(title); } else { + wxSize content_size = m_msg->GetTextExtent(title); + int resized_height = (int(content_size.x / PROGRESSDIALOG_GAUGE_SIZE.x) + 1) * content_size.y; + set_panel_height(resized_height); m_simplebook->SetSelection(1); m_msg_2line->SetLabel(title); } @@ -188,7 +190,7 @@ bool ProgressDialog::Create(const wxString &title, const wxString &message, int m_msg_2line->Wrap(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x); m_msg_2line->SetFont(::Label::Body_13); m_msg_2line->SetForegroundColour(PROGRESSDIALOG_GREY_700); - m_msg_2line->SetMaxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE); + m_msg_2line->SetMaxSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, -1)); sizer_2line->Add(m_msg_2line, 1, wxALL, 0); m_panel_2line->SetSizer(sizer_2line); m_panel_2line->Layout(); @@ -684,6 +686,15 @@ void ProgressDialog::SetRange(int maximum) SetMaximum(maximum); } +void ProgressDialog::set_panel_height(int height) { + m_simplebook->SetSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height)); + m_simplebook->SetMinSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height)); + m_panel_2line->SetSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height)); + m_panel_2line->SetMinSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height)); + m_msg_2line->SetSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height)); + m_msg_2line->SetMinSize(wxSize(PROGRESSDIALOG_SIMPLEBOOK_SIZE.x, height)); +} + void ProgressDialog::SetMaximum(int maximum) { m_maximum = maximum; diff --git a/src/slic3r/GUI/Widgets/ProgressDialog.hpp b/src/slic3r/GUI/Widgets/ProgressDialog.hpp index eb62d27bd..597ec7f80 100644 --- a/src/slic3r/GUI/Widgets/ProgressDialog.hpp +++ b/src/slic3r/GUI/Widgets/ProgressDialog.hpp @@ -14,7 +14,7 @@ class WXDLLIMPEXP_FWD_CORE wxGauge; class WXDLLIMPEXP_FWD_CORE wxStaticText; class WXDLLIMPEXP_FWD_CORE wxWindowDisabler; -#define PROGRESSDIALOG_SIMPLEBOOK_SIZE wxSize(FromDIP(320), FromDIP(38)) +#define PROGRESSDIALOG_SIMPLEBOOK_SIZE wxSize(FromDIP(320),FromDIP(38)) #define PROGRESSDIALOG_GAUGE_SIZE wxSize(FromDIP(320), FromDIP(6)) #define PROGRESSDIALOG_CANCEL_BUTTON_SIZE wxSize(FromDIP(60), FromDIP(24)) #define PROGRESSDIALOG_DEF_BK wxColour(255,255,255) @@ -47,7 +47,6 @@ public: virtual wxString GetMessage() const; virtual void SetRange(int maximum); - // Return whether "Cancel" or "Skip" button was pressed, always return // false if the corresponding button is not shown. virtual bool WasCancelled() const; @@ -89,7 +88,6 @@ protected: // both this class and its derived classes that don't use m_gauge to // display progress. void SetMaximum(int maximum); - // Return the labels to use for showing the elapsed/estimated/remaining // times respectively. static wxString GetElapsedLabel() { return wxGetTranslation("Elapsed time:"); } @@ -103,6 +101,7 @@ protected: // Return the progress dialog style. Prefer to use HasPDFlag() if possible. int GetPDStyle() const { return m_pdStyle; } void SetPDStyle(int pdStyle) { m_pdStyle = pdStyle; } + void set_panel_height(int height); // Updates estimated times from a given progress bar value and stores the // results in provided arguments.