From 613dce3d4bc4d9da9d1d3a4da61f51b536ae3a1b Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 4 Mar 2021 19:12:33 +0100 Subject: [PATCH] Adjust picker button size for generic wxDirPickerCtrl and wxFilePickerCtrl For generic wx{Dir|File}PickerCtrl with text field the picker button should be as high as the associated text field also when wx{FLP|DIRP}_SMALL flag is set. Closes #19087. --- src/common/pickerbase.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/common/pickerbase.cpp b/src/common/pickerbase.cpp index b3a9a2c786..8905d8d0ce 100644 --- a/src/common/pickerbase.cpp +++ b/src/common/pickerbase.cpp @@ -107,18 +107,22 @@ void wxPickerBase::PostCreation() // For aesthetic reasons, make sure the picker is at least as high as the // associated text control and is always at least square, unless we are - // explicitly using wxPB_SMALL style to force it to take as little space as - // possible. - if ( !HasFlag(wxPB_SMALL) ) + // explicitly using wxPB_SMALL style to force it to take as little + // horizontal space as possible. + const wxSize pickerBestSize(m_picker->GetBestSize()); + const wxSize textBestSize( HasTextCtrl() ? m_text->GetBestSize() : wxSize()); + wxSize pickerMinSize; + pickerMinSize.y = wxMax(pickerBestSize.y, textBestSize.y); + if ( HasFlag(wxPB_SMALL) ) { - const wxSize pickerBestSize(m_picker->GetBestSize()); - const wxSize textBestSize( HasTextCtrl() ? m_text->GetBestSize() : wxSize()); - wxSize pickerMinSize; - pickerMinSize.y = wxMax(pickerBestSize.y, textBestSize.y); - pickerMinSize.x = wxMax(pickerBestSize.x, pickerMinSize.y); - if ( pickerMinSize != pickerBestSize ) - m_picker->SetMinSize(pickerMinSize); + pickerMinSize.x = pickerBestSize.x; } + else + { + pickerMinSize.x = wxMax(pickerBestSize.x, pickerMinSize.y); + } + if ( pickerMinSize != pickerBestSize ) + m_picker->SetMinSize(pickerMinSize); SetSizer(m_sizer);