Fix layout in color dialog on GTK

Don't initially set the minimum widget size, and instead let it be
computed at launch.

Fixes #2617

(Partial cherry-pick of 4f82939384)
This commit is contained in:
Ian McInerney 2020-02-02 15:40:42 +00:00
parent 5b58dbc980
commit cb711a648f
4 changed files with 26 additions and 19 deletions

View File

@ -23,6 +23,18 @@
#define ALPHA_MAX 100 // the max value returned by the alpha (opacity) slider #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, DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, KIGFX::COLOR4D& aCurrentColor,
bool aAllowOpacityControl, CUSTOM_COLORS_LIST* aUserColors ) bool aAllowOpacityControl, CUSTOM_COLORS_LIST* aUserColors )
: DIALOG_COLOR_PICKER_BASE( aParent ) : DIALOG_COLOR_PICKER_BASE( aParent )
@ -131,6 +143,13 @@ bool DIALOG_COLOR_PICKER::TransferDataToWindow()
SetEditVals( ALL_CHANGED ); SetEditVals( ALL_CHANGED );
drawAll(); 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( 0 )->Layout();
m_notebook->GetPage( 1 )->Layout(); m_notebook->GetPage( 1 )->Layout();

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 28 2019) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // 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 ); 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 = 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 ); 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 = 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 ); 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 = 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 ); 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 ); 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 = 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 ); 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 = 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 ); fgSizerHSV->Add( m_spinCtrlSaturation, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );

View File

@ -14,7 +14,6 @@
<property name="file">dialog_color_picker_base</property> <property name="file">dialog_color_picker_base</property>
<property name="first_id">1000</property> <property name="first_id">1000</property>
<property name="help_provider">none</property> <property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property> <property name="indent_with_spaces"></property>
<property name="internationalize">1</property> <property name="internationalize">1</property>
<property name="name">DIALOG_COLOR_PICKER_BASE</property> <property name="name">DIALOG_COLOR_PICKER_BASE</property>
@ -26,7 +25,6 @@
<property name="skip_php_events">1</property> <property name="skip_php_events">1</property>
<property name="skip_python_events">1</property> <property name="skip_python_events">1</property>
<property name="ui_table">UI</property> <property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">0</property> <property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property> <property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1"> <object class="Dialog" expanded="1">
@ -506,7 +504,7 @@
<property name="min">0</property> <property name="min">0</property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</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="moveable">1</property>
<property name="name">m_spinCtrlRed</property> <property name="name">m_spinCtrlRed</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
@ -569,7 +567,7 @@
<property name="min">0</property> <property name="min">0</property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</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="moveable">1</property>
<property name="name">m_spinCtrlGreen</property> <property name="name">m_spinCtrlGreen</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
@ -632,7 +630,7 @@
<property name="min">0</property> <property name="min">0</property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</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="moveable">1</property>
<property name="name">m_spinCtrlBlue</property> <property name="name">m_spinCtrlBlue</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
@ -918,7 +916,7 @@
<property name="min">0</property> <property name="min">0</property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</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="moveable">1</property>
<property name="name">m_spinCtrlHue</property> <property name="name">m_spinCtrlHue</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
@ -981,7 +979,7 @@
<property name="min">0</property> <property name="min">0</property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</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="moveable">1</property>
<property name="name">m_spinCtrlSaturation</property> <property name="name">m_spinCtrlSaturation</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 28 2019) // C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!