Smooth out redrawing of toolbars by not letting wx pointlessly calculate both orientations
Monkey patch Fix #5705
This commit is contained in:
parent
670fc645de
commit
08ca80a2d8
|
@ -48,7 +48,7 @@ void EDA_3D_VIEWER::ReCreateMainToolbar()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
||||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
|
||||||
m_mainToolBar->SetAuiManager( &m_auimgr );
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,5 +101,5 @@ void EDA_3D_VIEWER::ReCreateMainToolbar()
|
||||||
m_mainToolBar->AddScaledSeparator( this );
|
m_mainToolBar->AddScaledSeparator( this );
|
||||||
m_mainToolBar->Add( EDA_3D_ACTIONS::toggleOrtho, ACTION_TOOLBAR::TOGGLE );
|
m_mainToolBar->Add( EDA_3D_ACTIONS::toggleOrtho, ACTION_TOOLBAR::TOGGLE );
|
||||||
|
|
||||||
m_mainToolBar->Realize();
|
m_mainToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -699,3 +699,54 @@ void ACTION_TOOLBAR::OnCustomRender(wxDC& aDc, const wxAuiToolBarItem& aItem,
|
||||||
|
|
||||||
aDc.DrawPolygon( &points );
|
aDc.DrawPolygon( &points );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ACTION_TOOLBAR::KiRealize()
|
||||||
|
{
|
||||||
|
wxClientDC dc( this );
|
||||||
|
if( !dc.IsOk() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// calculate hint sizes for both horizontal and vertical
|
||||||
|
// in the order that leaves toolbar in correct final state
|
||||||
|
|
||||||
|
// however, skip calculating alternate orientations if we dont need them due to window style
|
||||||
|
bool retval = true;
|
||||||
|
if( m_orientation == wxHORIZONTAL )
|
||||||
|
{
|
||||||
|
if( !( GetWindowStyle() & wxAUI_TB_HORIZONTAL ) )
|
||||||
|
{
|
||||||
|
m_vertHintSize = GetSize();
|
||||||
|
retval = RealizeHelper( dc, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( retval && RealizeHelper( dc, true ) )
|
||||||
|
{
|
||||||
|
m_horzHintSize = GetSize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retval = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( !( GetWindowStyle() & wxAUI_TB_VERTICAL ) )
|
||||||
|
{
|
||||||
|
m_horzHintSize = GetSize();
|
||||||
|
retval = RealizeHelper( dc, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( retval && RealizeHelper( dc, false ) )
|
||||||
|
{
|
||||||
|
m_vertHintSize = GetSize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retval = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Refresh( false );
|
||||||
|
return retval;
|
||||||
|
}
|
|
@ -44,7 +44,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
|
||||||
{
|
{
|
||||||
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR,
|
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR,
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
|
||||||
m_mainToolBar->SetAuiManager( &m_auimgr );
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar()
|
||||||
m_mainToolBar->Add( EE_ACTIONS::addSymbolToSchematic );
|
m_mainToolBar->Add( EE_ACTIONS::addSymbolToSchematic );
|
||||||
|
|
||||||
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
||||||
m_mainToolBar->Realize();
|
m_mainToolBar->KiRealize();
|
||||||
|
|
||||||
m_mainToolBar->Refresh();
|
m_mainToolBar->Refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
|
||||||
{
|
{
|
||||||
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR,
|
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR,
|
||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
|
||||||
m_mainToolBar->SetAuiManager( &m_auimgr );
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
|
||||||
m_mainToolBar->Add( EE_ACTIONS::showPcbNew );
|
m_mainToolBar->Add( EE_ACTIONS::showPcbNew );
|
||||||
|
|
||||||
// after adding the tools to the toolbar, must call Realize() to reflect the changes
|
// after adding the tools to the toolbar, must call Realize() to reflect the changes
|
||||||
m_mainToolBar->Realize();
|
m_mainToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ void SCH_EDIT_FRAME::ReCreateVToolbar()
|
||||||
m_drawToolBar->Add( EE_ACTIONS::placeImage, ACTION_TOOLBAR::TOGGLE );
|
m_drawToolBar->Add( EE_ACTIONS::placeImage, ACTION_TOOLBAR::TOGGLE );
|
||||||
m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE );
|
m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE );
|
||||||
|
|
||||||
m_drawToolBar->Realize();
|
m_drawToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,5 +182,5 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar()
|
||||||
gridMenu->Add( ACTIONS::gridProperties );
|
gridMenu->Add( ACTIONS::gridProperties );
|
||||||
m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
|
m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
|
||||||
|
|
||||||
m_optionsToolBar->Realize();
|
m_optionsToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ void GERBVIEW_FRAME::ReCreateHToolbar()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
||||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
|
||||||
m_mainToolBar->SetAuiManager( &m_auimgr );
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ void GERBVIEW_FRAME::ReCreateHToolbar()
|
||||||
m_mainToolBar->AddControl( m_TextInfo );
|
m_mainToolBar->AddControl( m_TextInfo );
|
||||||
|
|
||||||
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
||||||
m_mainToolBar->Realize();
|
m_mainToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ void GERBVIEW_FRAME::ReCreateAuxiliaryToolbar()
|
||||||
item->SetMinSize( m_zoomSelectBox->GetBestSize() );
|
item->SetMinSize( m_zoomSelectBox->GetBestSize() );
|
||||||
|
|
||||||
// after adding the buttons to the toolbar, must call Realize()
|
// after adding the buttons to the toolbar, must call Realize()
|
||||||
m_auxiliaryToolBar->Realize();
|
m_auxiliaryToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ void GERBVIEW_FRAME::ReCreateOptToolbar()
|
||||||
m_optionsToolBar->AddScaledSeparator( this );
|
m_optionsToolBar->AddScaledSeparator( this );
|
||||||
m_optionsToolBar->Add( GERBVIEW_ACTIONS::toggleLayerManager, ACTION_TOOLBAR::TOGGLE );
|
m_optionsToolBar->Add( GERBVIEW_ACTIONS::toggleLayerManager, ACTION_TOOLBAR::TOGGLE );
|
||||||
|
|
||||||
m_optionsToolBar->Realize();
|
m_optionsToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -271,6 +271,17 @@ public:
|
||||||
|
|
||||||
void Toggle( const TOOL_ACTION& aAction, bool aEnabled, bool aChecked );
|
void Toggle( const TOOL_ACTION& aAction, bool aEnabled, bool aChecked );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars
|
||||||
|
*
|
||||||
|
* The standard Realize() draws both horizontal and vertical to determine sizing
|
||||||
|
* However with many icons, potato PCs, etc, you can actually see that double draw
|
||||||
|
* We don't actually need to determine the opposite sizing if we are doing fixed orientation
|
||||||
|
*
|
||||||
|
* This function handles the fixed orientation sizing and passes off to the original Realize() otherwise
|
||||||
|
*/
|
||||||
|
bool KiRealize();
|
||||||
|
|
||||||
static constexpr bool TOGGLE = true;
|
static constexpr bool TOGGLE = true;
|
||||||
static constexpr bool CANCEL = true;
|
static constexpr bool CANCEL = true;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ void PL_EDITOR_FRAME::ReCreateHToolbar()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
||||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
|
||||||
m_mainToolBar->SetAuiManager( &m_auimgr );
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ void PL_EDITOR_FRAME::ReCreateHToolbar()
|
||||||
|
|
||||||
|
|
||||||
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
||||||
m_mainToolBar->Realize();
|
m_mainToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ void PL_EDITOR_FRAME::ReCreateVToolbar()
|
||||||
m_drawToolBar->AddScaledSeparator( this );
|
m_drawToolBar->AddScaledSeparator( this );
|
||||||
m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE );
|
m_drawToolBar->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE );
|
||||||
|
|
||||||
m_drawToolBar->Realize();
|
m_drawToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
||||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL);
|
||||||
m_mainToolBar->SetAuiManager( &m_auimgr );
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
|
||||||
m_mainToolBar->AddControl( m_selLayerBox );
|
m_mainToolBar->AddControl( m_selLayerBox );
|
||||||
|
|
||||||
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
||||||
m_mainToolBar->Realize();
|
m_mainToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateVToolbar()
|
||||||
m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE );
|
m_drawToolBar->Add( PCB_ACTIONS::gridSetOrigin, ACTION_TOOLBAR::TOGGLE );
|
||||||
m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
|
m_drawToolBar->Add( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE );
|
||||||
|
|
||||||
m_drawToolBar->Realize();
|
m_drawToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar()
|
||||||
gridMenu->Add( ACTIONS::gridProperties );
|
gridMenu->Add( ACTIONS::gridProperties );
|
||||||
m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
|
m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
|
||||||
|
|
||||||
m_optionsToolBar->Realize();
|
m_optionsToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_mainToolBar = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
m_mainToolBar = new ACTION_TOOLBAR( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
|
||||||
m_mainToolBar->SetAuiManager( &m_auimgr );
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar()
|
||||||
|
|
||||||
// after adding the buttons to the toolbar, must call Realize() to
|
// after adding the buttons to the toolbar, must call Realize() to
|
||||||
// reflect the changes
|
// reflect the changes
|
||||||
m_mainToolBar->Realize();
|
m_mainToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateOptToolbar()
|
||||||
m_optionsToolBar->Add( PCB_ACTIONS::textOutlines, ACTION_TOOLBAR::TOGGLE );
|
m_optionsToolBar->Add( PCB_ACTIONS::textOutlines, ACTION_TOOLBAR::TOGGLE );
|
||||||
m_optionsToolBar->Add( PCB_ACTIONS::graphicsOutlines, ACTION_TOOLBAR::TOGGLE );
|
m_optionsToolBar->Add( PCB_ACTIONS::graphicsOutlines, ACTION_TOOLBAR::TOGGLE );
|
||||||
|
|
||||||
m_optionsToolBar->Realize();
|
m_optionsToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
m_mainToolBar = new ACTION_TOOLBAR( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
||||||
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
|
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT | wxAUI_TB_HORIZONTAL );
|
||||||
m_mainToolBar->SetAuiManager( &m_auimgr );
|
m_mainToolBar->SetAuiManager( &m_auimgr );
|
||||||
|
|
||||||
// The layer indicator is special, so we register a callback directly that will regenerate the
|
// The layer indicator is special, so we register a callback directly that will regenerate the
|
||||||
|
@ -308,7 +308,7 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
|
||||||
m_mainToolBar->Realize();
|
m_mainToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ void PCB_EDIT_FRAME::ReCreateOptToolbar()
|
||||||
gridMenu->Add( ACTIONS::gridProperties );
|
gridMenu->Add( ACTIONS::gridProperties );
|
||||||
m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
|
m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) );
|
||||||
|
|
||||||
m_optionsToolBar->Realize();
|
m_optionsToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ void PCB_EDIT_FRAME::ReCreateVToolbar()
|
||||||
zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
|
zoneMenu->Add( PCB_ACTIONS::zoneUnfillAll );
|
||||||
m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
|
m_drawToolBar->AddToolContextMenu( PCB_ACTIONS::drawZone, std::move( zoneMenu ) );
|
||||||
|
|
||||||
m_drawToolBar->Realize();
|
m_drawToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar()
|
||||||
item = m_auxiliaryToolBar->FindTool( ID_AUX_TOOLBAR_PCB_VIA_SIZE );
|
item = m_auxiliaryToolBar->FindTool( ID_AUX_TOOLBAR_PCB_VIA_SIZE );
|
||||||
item->SetMinSize( m_SelViaSizeBox->GetBestSize() );
|
item->SetMinSize( m_SelViaSizeBox->GetBestSize() );
|
||||||
|
|
||||||
m_auxiliaryToolBar->Realize();
|
m_auxiliaryToolBar->KiRealize();
|
||||||
m_auimgr.Update();
|
m_auimgr.Update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -546,7 +546,7 @@ void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar()
|
||||||
m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
|
m_auxiliaryToolBar->AddControl( m_zoomSelectBox );
|
||||||
|
|
||||||
// after adding the buttons to the toolbar, must call Realize()
|
// after adding the buttons to the toolbar, must call Realize()
|
||||||
m_auxiliaryToolBar->Realize();
|
m_auxiliaryToolBar->KiRealize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue