mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-08-03 16:22:08 +00:00
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:
@@ -192,7 +192,7 @@ PingCodeBindDialog::PingCodeBindDialog(Plater* plater /*= nullptr*/)
|
||||
|
||||
|
||||
|
||||
SetSizer(sizer_main);
|
||||
SetSizerAndFit(sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
|
||||
@@ -670,7 +670,7 @@ PingCodeBindDialog::~PingCodeBindDialog() {
|
||||
m_sizer_main->Add(m_sw_bind_failed_info, 0, wxALIGN_CENTER, 0);
|
||||
m_sizer_main->Add(m_simplebook, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, ButtonProps::ChoiceButtonGap());
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
Centre(wxBOTH);
|
||||
@@ -992,7 +992,7 @@ UnBindMachineDialog::UnBindMachineDialog(Plater *plater /*= nullptr*/)
|
||||
m_sizer_main->Add(m_sizer_button, 0, wxALIGN_RIGHT | wxRIGHT, ButtonProps::ChoiceButtonGap());
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(20));
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
Centre(wxBOTH);
|
||||
|
||||
@@ -632,9 +632,8 @@ EditCalibrationHistoryDialog::EditCalibrationHistoryDialog(wxWindow
|
||||
|
||||
main_sizer->Add(top_panel, 1, wxEXPAND | wxALL, FromDIP(20));
|
||||
|
||||
SetSizer(main_sizer);
|
||||
SetSizerAndFit(main_sizer);
|
||||
Layout();
|
||||
Fit();
|
||||
CenterOnParent();
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
@@ -910,9 +909,8 @@ NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const
|
||||
|
||||
main_sizer->Add(top_panel, 1, wxEXPAND | wxALL, FromDIP(20));
|
||||
|
||||
SetSizer(main_sizer);
|
||||
SetSizerAndFit(main_sizer);
|
||||
Layout();
|
||||
Fit();
|
||||
CenterOnParent();
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
|
||||
@@ -162,7 +162,7 @@ CalibrationDialog::CalibrationDialog(Plater *plater)
|
||||
body_panel->Layout();
|
||||
|
||||
m_sizer_main->Add(body_panel, 0, wxEXPAND | wxALL, FromDIP(25));
|
||||
SetSizer(m_sizer_main);
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
|
||||
|
||||
@@ -112,9 +112,8 @@ CloneDialog::CloneDialog(wxWindow *parent)
|
||||
|
||||
v_sizer->Add(bottom_sizer, 0, wxEXPAND);
|
||||
|
||||
this->SetSizer(v_sizer);
|
||||
this->SetSizerAndFit(v_sizer);
|
||||
this->Layout();
|
||||
v_sizer->Fit(this);
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
|
||||
|
||||
@@ -80,9 +80,8 @@ ConnectPrinterDialog::ConnectPrinterDialog(wxWindow *parent, wxWindowID id, cons
|
||||
|
||||
main_sizer->Add(sizer_top);
|
||||
|
||||
this->SetSizer(main_sizer);
|
||||
this->SetSizerAndFit(main_sizer);
|
||||
this->Layout();
|
||||
this->Fit();
|
||||
CentreOnParent();
|
||||
|
||||
m_textCtrl_code->Bind(wxEVT_TEXT, &ConnectPrinterDialog::on_input_enter, this);
|
||||
|
||||
@@ -112,9 +112,8 @@ DownloadProgressDialog::DownloadProgressDialog(wxString title)
|
||||
m_simplebook_status->AddPage(m_panel_download_failed, wxEmptyString, false);
|
||||
m_simplebook_status->AddPage(m_panel_install_failed, wxEmptyString, false);
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
CentreOnParent();
|
||||
|
||||
Bind(wxEVT_CLOSE_WINDOW, &DownloadProgressDialog::on_close, this);
|
||||
|
||||
@@ -261,7 +261,7 @@ void ExtrusionCalibration::create()
|
||||
top_sizer->Add(FromDIP(24), 0);
|
||||
top_sizer->Add(sizer_main, 1, wxEXPAND);
|
||||
top_sizer->Add(FromDIP(24), 0);
|
||||
SetSizer(top_sizer);
|
||||
SetSizerAndFit(top_sizer);
|
||||
|
||||
// set default nozzle
|
||||
m_comboBox_nozzle_dia->SetSelection(1);
|
||||
@@ -271,7 +271,6 @@ void ExtrusionCalibration::create()
|
||||
set_step(1);
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
|
||||
m_k_val->GetTextCtrl()->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent& e) {
|
||||
input_value_finish();
|
||||
|
||||
@@ -105,9 +105,8 @@ FilamentPickerDialog::FilamentPickerDialog(wxWindow *parent, const wxString& fil
|
||||
container_sizer->Add(main_sizer, 1, wxEXPAND | wxALL, FromDIP(10));
|
||||
container_sizer->Add(dlg_btns, 0, wxEXPAND);
|
||||
|
||||
SetSizer(container_sizer);
|
||||
SetSizerAndFit(container_sizer);
|
||||
Layout();
|
||||
container_sizer->Fit(this);
|
||||
|
||||
// Position the dialog relative to the parent window
|
||||
if (GetParent()) {
|
||||
|
||||
@@ -65,7 +65,7 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he
|
||||
main_sizer->Add(btn_sizer, 0, wxBOTTOM | wxRIGHT | wxEXPAND | wxTOP, FromDIP(10));
|
||||
|
||||
apply_style(style);
|
||||
SetSizerAndFit(main_sizer);
|
||||
SetSizer(main_sizer);
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
}
|
||||
|
||||
@@ -221,6 +221,7 @@ void MsgDialog::apply_style(long style)
|
||||
|
||||
void MsgDialog::finalize()
|
||||
{
|
||||
GetSizer()->SetSizeHints(this);
|
||||
Layout();
|
||||
Fit();
|
||||
CenterOnParent();
|
||||
@@ -547,7 +548,7 @@ DeleteConfirmDialog::DeleteConfirmDialog(wxWindow *parent, const wxString &title
|
||||
m_del_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_OK); });
|
||||
m_cancel_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) { EndModal(wxID_CANCEL); });
|
||||
|
||||
SetSizer(m_main_sizer);
|
||||
SetSizerAndFit(m_main_sizer);
|
||||
Layout();
|
||||
Fit();
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
@@ -582,7 +583,7 @@ Newer3mfVersionDialog::Newer3mfVersionDialog(wxWindow *parent, const Semver *fil
|
||||
main_sizer->Add(content_sizer, 0, wxEXPAND | wxALL, FromDIP(5));
|
||||
main_sizer->Add(get_btn_sizer(), 0, wxEXPAND | wxALL, FromDIP(5));
|
||||
|
||||
this->SetSizer(main_sizer);
|
||||
this->SetSizerAndFit(main_sizer);
|
||||
Layout();
|
||||
Fit();
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
@@ -745,9 +746,8 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent)
|
||||
sizer_main->Add(sizer_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 15);
|
||||
sizer_main->Add(0, 0, 0, wxTOP, 18);
|
||||
|
||||
SetSizer(sizer_main);
|
||||
SetSizerAndFit(sizer_main);
|
||||
Layout();
|
||||
sizer_main->Fit(this);
|
||||
Centre(wxBOTH);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ NetworkPluginDownloadDialog::NetworkPluginDownloadDialog(wxWindow* parent, Mode
|
||||
} else {
|
||||
create_missing_plugin_ui();
|
||||
}
|
||||
main_sizer->SetSizeHints(this);
|
||||
Layout();
|
||||
Fit();
|
||||
CentreOnParent();
|
||||
|
||||
@@ -47,7 +47,7 @@ NetworkTestDialog::NetworkTestDialog(wxWindow* parent, wxWindowID id, const wxSt
|
||||
|
||||
init_bind();
|
||||
|
||||
this->SetSizer(main_sizer);
|
||||
this->SetSizerAndFit(main_sizer);
|
||||
this->Layout();
|
||||
|
||||
this->Centre(wxBOTH);
|
||||
|
||||
@@ -270,7 +270,7 @@ PartSkipDialog::PartSkipDialog(wxWindow *parent) : DPIDialog(parent, wxID_ANY, _
|
||||
m_simplebook->AddPage(m_book_third_panel, _("dialog page"), false);
|
||||
m_sizer->Add(m_simplebook, 1, wxEXPAND | wxALL, 5);
|
||||
|
||||
SetSizer(m_sizer);
|
||||
SetSizerAndFit(m_sizer);
|
||||
m_zoom_in_btn->Bind(wxEVT_BUTTON, &PartSkipDialog::OnZoomIn, this);
|
||||
m_zoom_out_btn->Bind(wxEVT_BUTTON, &PartSkipDialog::OnZoomOut, this);
|
||||
m_switch_drag_btn->Bind(wxEVT_BUTTON, &PartSkipDialog::OnSwitchDrag, this);
|
||||
@@ -281,7 +281,6 @@ PartSkipDialog::PartSkipDialog(wxWindow *parent) : DPIDialog(parent, wxID_ANY, _
|
||||
m_all_checkbox->Bind(wxEVT_TOGGLEBUTTON, &PartSkipDialog::OnAllCheckbox, this);
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
CentreOnParent();
|
||||
}
|
||||
|
||||
|
||||
@@ -15134,7 +15134,7 @@ ProjectDropDialog::ProjectDropDialog(const std::string &filename)
|
||||
|
||||
m_sizer_main->Add(dlg_btns, 0, wxEXPAND);
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
Centre(wxBOTH);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ PublishDialog::PublishDialog(Plater *plater)
|
||||
top_sizer->Add(m_main_sizer, 1, wxALL | wxEXPAND, 0);
|
||||
top_sizer->Add(FromDIP(30), 0, 0, wxEXPAND, 0);
|
||||
|
||||
this->SetSizer(top_sizer);
|
||||
this->SetSizerAndFit(top_sizer);
|
||||
this->Layout();
|
||||
|
||||
this->Centre(wxBOTH);
|
||||
|
||||
@@ -310,10 +310,9 @@ StepMeshDialog::StepMeshDialog(wxWindow* parent, Slic3r::Step& file, double line
|
||||
|
||||
bSizer->Add(bSizer_button, 1, wxEXPAND);
|
||||
|
||||
this->SetSizer(bSizer);
|
||||
this->SetSizerAndFit(bSizer);
|
||||
update_mesh_number_text();
|
||||
this->Layout();
|
||||
bSizer->Fit(this);
|
||||
|
||||
this->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
|
||||
SetFocusIgnoringChildren();
|
||||
|
||||
@@ -354,7 +354,7 @@ TroubleshootDialog::TroubleshootDialog()
|
||||
m_sizer->AddSpacer(FromDIP(20));
|
||||
m_sizer->Add(right_sizer, 0, wxEXPAND | wxTOP | wxBOTTOM | wxRIGHT, FromDIP(15));
|
||||
|
||||
SetSizer(m_sizer);
|
||||
SetSizerAndFit(m_sizer);
|
||||
Layout();
|
||||
Fit();
|
||||
CenterOnParent();
|
||||
|
||||
@@ -168,6 +168,9 @@ private:
|
||||
}
|
||||
wxClientDC dc(this);
|
||||
int cWidth = GetClientSize().GetWidth();
|
||||
// Don't compute/commit a size based on a not-yet-laid-out width
|
||||
// Mirrors the guard in OnPaint() so both use the same wrap results
|
||||
if (cWidth < 50) return;
|
||||
|
||||
int y = 0;
|
||||
for (size_t i = 0; i < m_lines.size(); ++i) {
|
||||
|
||||
@@ -773,7 +773,7 @@ std::vector<std::string> DiffViewCtrl::selected_options()
|
||||
|
||||
static std::string none{"none"};
|
||||
#define UNSAVE_CHANGE_DIALOG_SCROLL_WINDOW_SIZE wxSize(FromDIP(490), FromDIP(374))
|
||||
#define UNSAVE_CHANGE_DIALOG_ACTION_LINE_SIZE wxSize(FromDIP(490), FromDIP(60))
|
||||
#define UNSAVE_CHANGE_DIALOG_ACTION_LINE_SIZE wxSize(FromDIP(490), -1)
|
||||
#define UNSAVE_CHANGE_DIALOG_FIRST_VALUE_WIDTH FromDIP(190)
|
||||
#define UNSAVE_CHANGE_DIALOG_VALUE_WIDTH FromDIP(150)
|
||||
#define UNSAVE_CHANGE_DIALOG_ITEM_HEIGHT FromDIP(24)
|
||||
@@ -1075,11 +1075,6 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_
|
||||
m_sizer_main->Add(m_sizer_button, 0, wxEXPAND | wxTOP, 6);
|
||||
m_sizer_main->Add(0, 0, 1, wxTOP, 18);
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
Centre(wxBOTH);
|
||||
|
||||
if (params) {
|
||||
if (params->left_to_right)
|
||||
update_tree(type, params->config, params->from, params->to);
|
||||
@@ -1095,6 +1090,11 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection *dependent_
|
||||
//topSizer->SetSizeHints(this);
|
||||
|
||||
show_info_line(Action::Undef);
|
||||
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
// Centre(wxBOTH);
|
||||
}
|
||||
|
||||
void UnsavedChangesDialog::show_info_line(Action action, std::string preset_name)
|
||||
@@ -1499,6 +1499,7 @@ void UnsavedChangesDialog::update(Preset::Type type, PresetCollection* dependent
|
||||
}
|
||||
|
||||
m_action_line->SetLabel(action_msg);
|
||||
m_action_line->Wrap(UNSAVE_CHANGE_DIALOG_SCROLL_WINDOW_SIZE.x);
|
||||
|
||||
update_tree(type, presets);
|
||||
update_list();
|
||||
|
||||
@@ -213,9 +213,8 @@ MsgUpdateConfig::MsgUpdateConfig(const std::vector<Update> &updates, bool force_
|
||||
m_scrollwindw_release_note->Layout();
|
||||
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
m_sizer_main->Fit(this);
|
||||
|
||||
Centre(wxBOTH);
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
|
||||
Reference in New Issue
Block a user