From 4f8293938417583165b1bf9cb030a667af922170 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 2 Feb 2020 15:25:39 +0000 Subject: [PATCH] Fix layout in color dialog on GTK Don't initially set the minimum widget size, and instead let it be computed at launch. Fixes https://gitlab.com/kicad/code/kicad/issues/2617 --- common/dialogs/dialog_color_picker.cpp | 18 ++++++++++++++++++ common/dialogs/dialog_color_picker_base.cpp | 12 +----------- common/dialogs/dialog_color_picker_base.fbp | 10 +++++----- common/dialogs/dialog_color_picker_base.h | 2 +- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/common/dialogs/dialog_color_picker.cpp b/common/dialogs/dialog_color_picker.cpp index 4f8c47ac8d..f4daa7cb71 100644 --- a/common/dialogs/dialog_color_picker.cpp +++ b/common/dialogs/dialog_color_picker.cpp @@ -23,6 +23,17 @@ #define ALPHA_MAX 100 // the max value returned by the alpha (opacity) slider +// Configure the spin controls contained inside the dialog +void configureSpinCtrl( wxSpinCtrl* aCtrl ) +{ + wxSize textLength = aCtrl->GetTextExtent( "999" ); + wxSize ctrlSize = aCtrl->GetSizeFromTextSize( textLength ); + + aCtrl->SetMinSize( ctrlSize ); + aCtrl->SetSize( ctrlSize ); +} + + DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor, bool aAllowOpacityControl, CUSTOM_COLORS_LIST* aUserColors, const KIGFX::COLOR4D& aDefaultColor ) @@ -137,6 +148,13 @@ bool DIALOG_COLOR_PICKER::TransferDataToWindow() SetEditVals( ALL_CHANGED ); drawAll(); + // Configure the spin control sizes + configureSpinCtrl( m_spinCtrlGreen ); + configureSpinCtrl( m_spinCtrlBlue ); + configureSpinCtrl( m_spinCtrlRed ); + configureSpinCtrl( m_spinCtrlHue ); + configureSpinCtrl( m_spinCtrlSaturation ); + m_notebook->GetPage( 0 )->Layout(); m_notebook->GetPage( 1 )->Layout(); diff --git a/common/dialogs/dialog_color_picker_base.cpp b/common/dialogs/dialog_color_picker_base.cpp index 82803ae3d4..37d7890200 100644 --- a/common/dialogs/dialog_color_picker_base.cpp +++ b/common/dialogs/dialog_color_picker_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version v3.8.0) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -56,18 +56,12 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID fgSizerRGB->Add( m_staticTextB, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_spinCtrlRed = new wxSpinCtrl( sbSizerViewRGB->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 255, 128 ); - m_spinCtrlRed->SetMinSize( wxSize( 80,-1 ) ); - fgSizerRGB->Add( m_spinCtrlRed, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_spinCtrlGreen = new wxSpinCtrl( sbSizerViewRGB->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 255, 128 ); - m_spinCtrlGreen->SetMinSize( wxSize( 80,-1 ) ); - fgSizerRGB->Add( m_spinCtrlGreen, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_spinCtrlBlue = new wxSpinCtrl( sbSizerViewRGB->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 255, 128 ); - m_spinCtrlBlue->SetMinSize( wxSize( 80,-1 ) ); - fgSizerRGB->Add( m_spinCtrlBlue, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); @@ -103,13 +97,9 @@ DIALOG_COLOR_PICKER_BASE::DIALOG_COLOR_PICKER_BASE( wxWindow* parent, wxWindowID fgSizerHSV->Add( m_staticTextSat, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_spinCtrlHue = new wxSpinCtrl( sbSizerViewHSV->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS|wxSP_WRAP, 0, 359, 0 ); - m_spinCtrlHue->SetMinSize( wxSize( 80,-1 ) ); - fgSizerHSV->Add( m_spinCtrlHue, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_spinCtrlSaturation = new wxSpinCtrl( sbSizerViewHSV->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 255, 128 ); - m_spinCtrlSaturation->SetMinSize( wxSize( 80,-1 ) ); - fgSizerHSV->Add( m_spinCtrlSaturation, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); diff --git a/common/dialogs/dialog_color_picker_base.fbp b/common/dialogs/dialog_color_picker_base.fbp index bebd793ef4..a3e2f57a7d 100644 --- a/common/dialogs/dialog_color_picker_base.fbp +++ b/common/dialogs/dialog_color_picker_base.fbp @@ -504,7 +504,7 @@ 0 0 - 80,-1 + -1,-1 1 m_spinCtrlRed 1 @@ -567,7 +567,7 @@ 0 0 - 80,-1 + -1,-1 1 m_spinCtrlGreen 1 @@ -630,7 +630,7 @@ 0 0 - 80,-1 + -1,-1 1 m_spinCtrlBlue 1 @@ -916,7 +916,7 @@ 0 0 - 80,-1 + -1,-1 1 m_spinCtrlHue 1 @@ -979,7 +979,7 @@ 0 0 - 80,-1 + -1,-1 1 m_spinCtrlSaturation 1 diff --git a/common/dialogs/dialog_color_picker_base.h b/common/dialogs/dialog_color_picker_base.h index 741d4c3fee..8d5c1f4b7e 100644 --- a/common/dialogs/dialog_color_picker_base.h +++ b/common/dialogs/dialog_color_picker_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version v3.8.0) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE!