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
This commit is contained in:
Ian McInerney 2020-02-02 15:25:39 +00:00
parent 79e7a27492
commit 4f82939384
4 changed files with 25 additions and 17 deletions

View File

@ -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();

View File

@ -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 );

View File

@ -504,7 +504,7 @@
<property name="min">0</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">80,-1</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_spinCtrlRed</property>
<property name="pane_border">1</property>
@ -567,7 +567,7 @@
<property name="min">0</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">80,-1</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_spinCtrlGreen</property>
<property name="pane_border">1</property>
@ -630,7 +630,7 @@
<property name="min">0</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">80,-1</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_spinCtrlBlue</property>
<property name="pane_border">1</property>
@ -916,7 +916,7 @@
<property name="min">0</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">80,-1</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_spinCtrlHue</property>
<property name="pane_border">1</property>
@ -979,7 +979,7 @@
<property name="min">0</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">80,-1</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_spinCtrlSaturation</property>
<property name="pane_border">1</property>

View File

@ -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!