Don't force an entire refresh of toolbars to update sizes
Forcing an entire refresh of the toolbars is wasteful, so instead just update the sizers directly.
This commit is contained in:
parent
ecb39f1e0f
commit
1db5e2bc96
|
@ -40,6 +40,7 @@
|
|||
#include <widgets/wx_aui_art_providers.h>
|
||||
#include <wx/popupwin.h>
|
||||
#include <wx/renderer.h>
|
||||
#include <wx/sizer.h>
|
||||
|
||||
|
||||
ACTION_GROUP::ACTION_GROUP( std::string aName, const std::vector<const TOOL_ACTION*>& aActions )
|
||||
|
@ -342,7 +343,27 @@ void ACTION_TOOLBAR::UpdateControlWidth( int aID )
|
|||
wxASSERT_MSG( control, wxString::Format( "No control located in toolbar item with ID %d", aID ) );
|
||||
|
||||
// Update the size the item has stored using the best size of the control
|
||||
item->SetMinSize( control->GetBestSize() );
|
||||
wxSize bestSize = control->GetBestSize();
|
||||
item->SetMinSize( bestSize );
|
||||
|
||||
// Update the sizer item sizes
|
||||
// This is a bit convoluted because there are actually 2 sizers that need to be updated:
|
||||
// 1. The main sizer that is used for the entire toolbar (this sizer item can be found in the
|
||||
// toolbar item)
|
||||
if( wxSizerItem* szrItem = item->GetSizerItem() )
|
||||
szrItem->SetMinSize( bestSize );
|
||||
|
||||
// 2. The controls have a second sizer that allows for padding above/below the control with stretch
|
||||
// space, so we also need to update the sizer item for the control in that sizer with the new size.
|
||||
// We let wx do the search for us, since SetItemMinSize is recursive and will locate the control
|
||||
// on that sizer.
|
||||
if( m_sizer )
|
||||
{
|
||||
m_sizer->SetItemMinSize( control, bestSize );
|
||||
|
||||
// Now actually update the toolbar with the new sizes
|
||||
m_sizer->Layout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -335,9 +335,6 @@ void DISPLAY_FOOTPRINTS_FRAME::UpdateToolbarControlSizes()
|
|||
// Update the item widths
|
||||
m_mainToolBar->UpdateControlWidth( ID_ON_GRID_SELECT );
|
||||
m_mainToolBar->UpdateControlWidth( ID_ON_ZOOM_SELECT );
|
||||
|
||||
// Update the toolbar with the new widths
|
||||
m_mainToolBar->KiRealize();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -262,9 +262,6 @@ void GERBVIEW_FRAME::UpdateToolbarControlSizes()
|
|||
// Update the item widths
|
||||
m_mainToolBar->UpdateControlWidth( ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER );
|
||||
m_mainToolBar->UpdateControlWidth( ID_TOOLBARH_GERBER_DATA_TEXT_BOX );
|
||||
|
||||
// Update the toolbar with the new widths
|
||||
m_mainToolBar->KiRealize();
|
||||
}
|
||||
|
||||
if( m_auxiliaryToolBar )
|
||||
|
@ -275,9 +272,6 @@ void GERBVIEW_FRAME::UpdateToolbarControlSizes()
|
|||
m_auxiliaryToolBar->UpdateControlWidth( ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE );
|
||||
m_auxiliaryToolBar->UpdateControlWidth( ID_ON_GRID_SELECT );
|
||||
m_auxiliaryToolBar->UpdateControlWidth( ID_ON_ZOOM_SELECT );
|
||||
|
||||
// Update the toolbar with the new widths
|
||||
m_auxiliaryToolBar->KiRealize();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -186,8 +186,5 @@ void PL_EDITOR_FRAME::UpdateToolbarControlSizes()
|
|||
// Update the item widths
|
||||
m_mainToolBar->UpdateControlWidth( ID_SELECT_COORDINATE_ORIGIN );
|
||||
m_mainToolBar->UpdateControlWidth( ID_SELECT_PAGE_NUMBER );
|
||||
|
||||
// Update the toolbar with the new widths
|
||||
m_mainToolBar->KiRealize();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -299,7 +299,6 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
|||
// Ensure the controls on the toolbars all are correctly sized
|
||||
UpdateToolbarControlSizes();
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -226,9 +226,6 @@ void FOOTPRINT_EDIT_FRAME::UpdateToolbarControlSizes()
|
|||
m_mainToolBar->UpdateControlWidth( ID_TOOLBARH_PCB_SELECT_LAYER );
|
||||
m_mainToolBar->UpdateControlWidth( ID_ON_ZOOM_SELECT );
|
||||
m_mainToolBar->UpdateControlWidth( ID_ON_GRID_SELECT );
|
||||
|
||||
// Update the toolbar with the new widths
|
||||
m_mainToolBar->KiRealize();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -561,9 +561,6 @@ void PCB_EDIT_FRAME::UpdateToolbarControlSizes()
|
|||
{
|
||||
// Update the item widths
|
||||
m_mainToolBar->UpdateControlWidth( ID_TOOLBARH_PCB_SELECT_LAYER );
|
||||
|
||||
// Update the toolbar with the new widths
|
||||
m_mainToolBar->KiRealize();
|
||||
}
|
||||
|
||||
if( m_auxiliaryToolBar )
|
||||
|
@ -573,9 +570,6 @@ void PCB_EDIT_FRAME::UpdateToolbarControlSizes()
|
|||
m_auxiliaryToolBar->UpdateControlWidth( ID_AUX_TOOLBAR_PCB_VIA_SIZE );
|
||||
m_auxiliaryToolBar->UpdateControlWidth( ID_ON_ZOOM_SELECT );
|
||||
m_auxiliaryToolBar->UpdateControlWidth( ID_ON_GRID_SELECT );
|
||||
|
||||
// Update the toolbar with the new widths
|
||||
m_auxiliaryToolBar->KiRealize();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue