Fix GTK3 dialog min size: SetSizer → SetSizerAndFit for dialogs without explicit SetMinSize (#14948)

* For dialog without explicitly `SetMinSize`, we should use `SetSizerAndFit` instead, otherwise the dialog will not show correctly on GTK3. (OrcaSlicer/OrcaSlicer#14561)
- and if `SetSizer` is called before the full layout has been built, then an extra `SetSizeHints` should be called before layout/fit so the min size can be properly set automatically based on children's min sizes accordingly.

* Fix GTK3 dialog min size: SetSizer → SetSizerAndFit for dialogs without explicit SetMinSize

Replace SetSizer() with SetSizerAndFit() in 11 dialog constructors that
neither call SetMinSize() nor SetSizeHints(), ensuring proper minimum
size propagation from child widgets on GTK3.

SetSizerAndFit internally calls sizer->SetSizeHints(window), which
sets the window's minimum size based on children — the same fix
applied to ProjectDropDialog in 8a7662083e.

Also drop sizer->Fit(this) calls where present, since they only
resize but don't set the min size hint needed by GTK3.

Co-Authored-By: Claude <noreply@anthropic.com>

* Update code style

* Update TroubleshootDialog.hpp

* Fix unsaved preset dialog layout

* Fix MsgDialog layout

* Fix other 3 instances in MsgDialog.cpp

* Fix a few more instances

* Fix printer option dialog too big on Windows

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: yw4z <ywsyildiz@gmail.com>
This commit is contained in:
Noisyfox
2026-07-28 14:32:55 +08:00
committed by GitHub
parent 6bcb809dd0
commit 5ede9711f5
21 changed files with 41 additions and 46 deletions

View File

@@ -28,7 +28,7 @@ PrintOptionsDialog::PrintOptionsDialog(wxWindow* parent)
{
this->SetDoubleBuffered(true);
SetBackgroundColour(*wxWHITE);
SetSize(FromDIP(480),FromDIP(520));
// SetMinSize(FromDIP(wxSize{wxDefaultCoord,520}));
m_scrollwindow = new wxScrolledWindow(this, wxID_ANY);
@@ -50,7 +50,8 @@ PrintOptionsDialog::PrintOptionsDialog(wxWindow* parent)
m_scrollwindow->FitInside();
this->Layout();
// mainSizer->Fit(this);
mainSizer->SetMinSize(wxDefaultCoord, FromDIP(520));
mainSizer->Fit(this);
//this->Fit();
m_cb_ai_monitoring->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent &evt) {
@@ -1670,12 +1671,9 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent)
/*inset data*/
sizer->Add(single_panel, 0, wxEXPAND, 0);
sizer->Add(multiple_panel, 0, wxEXPAND, 0);
SetSizer(sizer);
Layout();
Fit();
single_panel->Hide();
SetSizerAndFit(sizer);
Layout();
wxGetApp().UpdateDlgDarkUI(this);
}
@@ -1752,6 +1750,7 @@ bool PrinterPartsDialog::Show(bool show)
}
}
GetSizer()->SetSizeHints(this);
Layout();
Fit();
}