From fba6152709cbe15b771a77ea4cd633abd6fadbd1 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 24 Aug 2020 00:41:14 +0100 Subject: [PATCH] Force wxWidgets to set widths smaller than BestWidth(). --- pcbnew/pcb_edit_frame.cpp | 27 ++++++++++++-------- pcbnew/widgets/appearance_controls_base.cpp | 22 ++++++++-------- pcbnew/widgets/appearance_controls_base.fbp | 28 ++++++++++----------- pcbnew/widgets/appearance_controls_base.h | 2 +- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 1ad150a122..f5a48068cd 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -256,12 +256,12 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( m_appearancePanel, EDA_PANE().Name( "LayersManager" ).Right().Layer( 4 ) .Caption( _( "Appearance" ) ).PaneBorder( false ) - .MinSize( 160, -1 ).BestSize( m_appearancePanel->GetBestSize() ) ); + .MinSize( 180, -1 ).BestSize( 180, -1 ) ); m_auimgr.AddPane( m_selectionFilterPanel, EDA_PANE().Name( "SelectionFilter" ).Right().Layer( 4 ) .Caption( _( "Selection Filter" ) ).PaneBorder( false ).Position( 2 ) - .MinSize( 160, -1 ).BestSize( m_selectionFilterPanel->GetBestSize() ) ); + .MinSize( 180, -1 ).BestSize( 180, -1 ) ); m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); @@ -272,23 +272,30 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // The selection filter doesn't need to grow in the vertical direction when docked m_auimgr.GetPane( "SelectionFilter" ).dock_proportion = 0; + // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before + // hidding it. + m_auimgr.Update(); + if( PCBNEW_SETTINGS* settings = dynamic_cast( config() ) ) { if( settings->m_AuiPanels.right_panel_width > 0 ) { - wxSize size = m_appearancePanel->GetBestSize(); - size.x = settings->m_AuiPanels.right_panel_width; - m_auimgr.GetPane( "LayersManager" ).BestSize( size ); - m_appearancePanel->SetSize( size ); + wxAuiPaneInfo& layersManager = m_auimgr.GetPane( "LayersManager" ); + + // wxAUI hack: force width by setting MinSize() and then Fixed() + // thanks to ZenJu http://trac.wxwidgets.org/ticket/13180 + layersManager.MinSize( settings->m_AuiPanels.right_panel_width, -1 ); + layersManager.Fixed(); + m_auimgr.Update(); + + // now make it resizable again + layersManager.Resizable(); + m_auimgr.Update(); } m_appearancePanel->SetTabIndex( settings->m_AuiPanels.appearance_panel_tab ); } - // Call Update() to fix all pane default sizes, especially the "InfoBar" pane before - // hidding it. - m_auimgr.Update(); - // We don't want the infobar displayed right away m_auimgr.GetPane( "InfoBar" ).Hide(); m_auimgr.Update(); diff --git a/pcbnew/widgets/appearance_controls_base.cpp b/pcbnew/widgets/appearance_controls_base.cpp index fc8d54683d..b1e3a0bc16 100644 --- a/pcbnew/widgets/appearance_controls_base.cpp +++ b/pcbnew/widgets/appearance_controls_base.cpp @@ -12,7 +12,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { this->SetFont( wxFont( 10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxEmptyString ) ); - this->SetMinSize( wxSize( 200,360 ) ); + this->SetMinSize( wxSize( 160,360 ) ); m_sizerOuter = new wxBoxSizer( wxVERTICAL ); @@ -31,7 +31,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID m_staticText13 = new wxStaticText( m_paneLayerDisplay->GetPane(), wxID_ANY, wxT("Non-active layers:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText13->Wrap( -1 ); - bSizer121->Add( m_staticText13, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizer121->Add( m_staticText13, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); wxBoxSizer* bSizer19; bSizer19 = new wxBoxSizer( wxHORIZONTAL ); @@ -40,17 +40,17 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID m_rbHighContrastNormal->SetValue( true ); m_rbHighContrastNormal->SetToolTip( wxT("Non-active layers will be shown in full color") ); - bSizer19->Add( m_rbHighContrastNormal, 1, wxRIGHT|wxLEFT, 5 ); + bSizer19->Add( m_rbHighContrastNormal, 0, wxRIGHT|wxLEFT, 5 ); m_rbHighContrastDim = new wxRadioButton( m_paneLayerDisplay->GetPane(), wxID_ANY, wxT("Dim"), wxDefaultPosition, wxDefaultSize, 0 ); m_rbHighContrastDim->SetToolTip( wxT("Non-active layers will be dimmed") ); - bSizer19->Add( m_rbHighContrastDim, 1, wxRIGHT|wxLEFT, 5 ); + bSizer19->Add( m_rbHighContrastDim, 0, wxRIGHT|wxLEFT, 5 ); m_rbHighContrastOff = new wxRadioButton( m_paneLayerDisplay->GetPane(), wxID_ANY, wxT("Hide"), wxDefaultPosition, wxDefaultSize, 0 ); m_rbHighContrastOff->SetToolTip( wxT("Non-active layers will be hidden") ); - bSizer19->Add( m_rbHighContrastOff, 1, wxRIGHT|wxLEFT, 5 ); + bSizer19->Add( m_rbHighContrastOff, 0, wxRIGHT|wxLEFT, 5 ); bSizer121->Add( bSizer19, 0, wxEXPAND, 5 ); @@ -65,7 +65,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID m_paneLayerDisplay->GetPane()->SetSizer( bSizer121 ); m_paneLayerDisplay->GetPane()->Layout(); bSizer121->Fit( m_paneLayerDisplay->GetPane() ); - m_panelLayersSizer->Add( m_paneLayerDisplay, 0, wxBOTTOM|wxEXPAND|wxTOP, 5 ); + m_panelLayersSizer->Add( m_paneLayerDisplay, 0, wxBOTTOM|wxTOP|wxEXPAND, 5 ); m_panelLayers->SetSizer( m_panelLayersSizer ); @@ -130,6 +130,7 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID m_netsGrid->SetMargins( 0, 0 ); // Columns + m_netsGrid->AutoSizeColumns(); m_netsGrid->EnableDragColMove( false ); m_netsGrid->EnableDragColSize( false ); m_netsGrid->SetColLabelSize( 0 ); @@ -206,18 +207,18 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID m_rbNetColorAll = new wxRadioButton( m_paneNetDisplay->GetPane(), wxID_ANY, wxT("All"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP ); m_rbNetColorAll->SetToolTip( wxT("Net and netclass colors are shown on all copper items") ); - bSizer191->Add( m_rbNetColorAll, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + bSizer191->Add( m_rbNetColorAll, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_rbNetColorRatsnest = new wxRadioButton( m_paneNetDisplay->GetPane(), wxID_ANY, wxT("Ratsnest"), wxDefaultPosition, wxDefaultSize, 0 ); m_rbNetColorRatsnest->SetValue( true ); m_rbNetColorRatsnest->SetToolTip( wxT("Net and netclass colors are shown on the ratsnest only") ); - bSizer191->Add( m_rbNetColorRatsnest, 1, wxBOTTOM|wxLEFT, 5 ); + bSizer191->Add( m_rbNetColorRatsnest, 0, wxBOTTOM|wxLEFT, 5 ); m_rbNetColorOff = new wxRadioButton( m_paneNetDisplay->GetPane(), wxID_ANY, wxT("None"), wxDefaultPosition, wxDefaultSize, 0 ); m_rbNetColorOff->SetToolTip( wxT("Net and netclass colors are not shown") ); - bSizer191->Add( m_rbNetColorOff, 1, wxBOTTOM|wxLEFT, 5 ); + bSizer191->Add( m_rbNetColorOff, 0, wxBOTTOM|wxLEFT, 5 ); bSizerNetDisplay->Add( bSizer191, 0, wxEXPAND, 5 ); @@ -268,11 +269,12 @@ APPEARANCE_CONTROLS_BASE::APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID bBottomMargin->Add( bPresets, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_sizerOuter->Add( bBottomMargin, 0, wxEXPAND|wxBOTTOM, 2 ); + m_sizerOuter->Add( bBottomMargin, 0, wxBOTTOM|wxEXPAND, 2 ); this->SetSizer( m_sizerOuter ); this->Layout(); + m_sizerOuter->Fit( this ); // Connect Events this->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( APPEARANCE_CONTROLS_BASE::OnSetFocus ) ); diff --git a/pcbnew/widgets/appearance_controls_base.fbp b/pcbnew/widgets/appearance_controls_base.fbp index 2cfc146d5b..818c5b26a2 100644 --- a/pcbnew/widgets/appearance_controls_base.fbp +++ b/pcbnew/widgets/appearance_controls_base.fbp @@ -40,10 +40,10 @@ 0 wxID_ANY - 200,360 + 160,360 APPEARANCE_CONTROLS_BASE - 548,563 + -1,-1 ; ; forward_declare @@ -240,7 +240,7 @@ 5 - wxBOTTOM|wxEXPAND|wxTOP + wxBOTTOM|wxTOP|wxEXPAND 0 1 @@ -309,7 +309,7 @@ none 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND 0 1 @@ -380,7 +380,7 @@ 5 wxRIGHT|wxLEFT - 1 + 0 1 1 @@ -444,7 +444,7 @@ 5 wxRIGHT|wxLEFT - 1 + 0 1 1 @@ -508,7 +508,7 @@ 5 wxRIGHT|wxLEFT - 1 + 0 1 1 @@ -1006,11 +1006,11 @@ bSizer192 wxVERTICAL none - + 5 wxEXPAND 0 - + bSizer17 wxHORIZONTAL @@ -1228,7 +1228,7 @@ - 0 + 1 0 @@ -1725,7 +1725,7 @@ 5 wxBOTTOM|wxRIGHT|wxLEFT - 1 + 0 1 1 @@ -1789,7 +1789,7 @@ 5 wxBOTTOM|wxLEFT - 1 + 0 1 1 @@ -1853,7 +1853,7 @@ 5 wxBOTTOM|wxLEFT - 1 + 0 1 1 @@ -1926,7 +1926,7 @@ 2 - wxEXPAND|wxBOTTOM + wxBOTTOM|wxEXPAND 0 diff --git a/pcbnew/widgets/appearance_controls_base.h b/pcbnew/widgets/appearance_controls_base.h index 51822b6ff0..7271e328ed 100644 --- a/pcbnew/widgets/appearance_controls_base.h +++ b/pcbnew/widgets/appearance_controls_base.h @@ -95,7 +95,7 @@ class APPEARANCE_CONTROLS_BASE : public wxPanel public: - APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 548,563 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); + APPEARANCE_CONTROLS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString ); ~APPEARANCE_CONTROLS_BASE(); void m_netsTabSplitterOnIdle( wxIdleEvent& )