diff --git a/3d-viewer/3d_viewer/3d_toolbar.cpp b/3d-viewer/3d_viewer/3d_toolbar.cpp index 45cc2bd38b..270aae9a55 100644 --- a/3d-viewer/3d_viewer/3d_toolbar.cpp +++ b/3d-viewer/3d_viewer/3d_toolbar.cpp @@ -48,7 +48,7 @@ void EDA_3D_VIEWER::ReCreateMainToolbar() else { 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 ); } @@ -101,5 +101,5 @@ void EDA_3D_VIEWER::ReCreateMainToolbar() m_mainToolBar->AddScaledSeparator( this ); m_mainToolBar->Add( EDA_3D_ACTIONS::toggleOrtho, ACTION_TOOLBAR::TOGGLE ); - m_mainToolBar->Realize(); + m_mainToolBar->KiRealize(); } diff --git a/common/tool/action_toolbar.cpp b/common/tool/action_toolbar.cpp index 1ccee355ff..b773716de6 100644 --- a/common/tool/action_toolbar.cpp +++ b/common/tool/action_toolbar.cpp @@ -699,3 +699,54 @@ void ACTION_TOOLBAR::OnCustomRender(wxDC& aDc, const wxAuiToolBarItem& aItem, 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; +} \ No newline at end of file diff --git a/eeschema/toolbars_lib_view.cpp b/eeschema/toolbars_lib_view.cpp index 9434c25aa0..51b403b8e5 100644 --- a/eeschema/toolbars_lib_view.cpp +++ b/eeschema/toolbars_lib_view.cpp @@ -44,7 +44,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() { 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 ); } @@ -85,7 +85,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() m_mainToolBar->Add( EE_ACTIONS::addSymbolToSchematic ); // after adding the buttons to the toolbar, must call Realize() to reflect the changes - m_mainToolBar->Realize(); + m_mainToolBar->KiRealize(); m_mainToolBar->Refresh(); } diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index 3b6a426897..305bb1f6b8 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -46,7 +46,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar() { 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 ); } @@ -106,7 +106,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->Add( EE_ACTIONS::showPcbNew ); // 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( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Realize(); + m_drawToolBar->KiRealize(); } @@ -182,5 +182,5 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar() gridMenu->Add( ACTIONS::gridProperties ); m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); - m_optionsToolBar->Realize(); + m_optionsToolBar->KiRealize(); } diff --git a/gerbview/toolbars_gerber.cpp b/gerbview/toolbars_gerber.cpp index 8a83dad23f..c94c07b5c5 100644 --- a/gerbview/toolbars_gerber.cpp +++ b/gerbview/toolbars_gerber.cpp @@ -50,7 +50,7 @@ void GERBVIEW_FRAME::ReCreateHToolbar() else { 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 ); } @@ -88,7 +88,7 @@ void GERBVIEW_FRAME::ReCreateHToolbar() m_mainToolBar->AddControl( m_TextInfo ); // 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() ); // 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->Add( GERBVIEW_ACTIONS::toggleLayerManager, ACTION_TOOLBAR::TOGGLE ); - m_optionsToolBar->Realize(); + m_optionsToolBar->KiRealize(); } diff --git a/include/tool/action_toolbar.h b/include/tool/action_toolbar.h index 8b5c63f934..d6d41ea3f0 100644 --- a/include/tool/action_toolbar.h +++ b/include/tool/action_toolbar.h @@ -271,6 +271,17 @@ public: 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 CANCEL = true; diff --git a/pagelayout_editor/toolbars_pl_editor.cpp b/pagelayout_editor/toolbars_pl_editor.cpp index aaf37103a2..e352ee16aa 100644 --- a/pagelayout_editor/toolbars_pl_editor.cpp +++ b/pagelayout_editor/toolbars_pl_editor.cpp @@ -35,7 +35,7 @@ void PL_EDITOR_FRAME::ReCreateHToolbar() else { 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 ); } @@ -118,7 +118,7 @@ void PL_EDITOR_FRAME::ReCreateHToolbar() // 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->Add( ACTIONS::deleteTool, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Realize(); + m_drawToolBar->KiRealize(); } diff --git a/pcbnew/toolbars_footprint_editor.cpp b/pcbnew/toolbars_footprint_editor.cpp index ed8b0d5313..219f6417a0 100644 --- a/pcbnew/toolbars_footprint_editor.cpp +++ b/pcbnew/toolbars_footprint_editor.cpp @@ -48,7 +48,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() else { 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 ); } @@ -138,7 +138,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->AddControl( m_selLayerBox ); // 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( ACTIONS::measureTool, ACTION_TOOLBAR::TOGGLE ); - m_drawToolBar->Realize(); + m_drawToolBar->KiRealize(); } @@ -211,7 +211,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar() gridMenu->Add( ACTIONS::gridProperties ); m_optionsToolBar->AddToolContextMenu( ACTIONS::toggleGrid, std::move( gridMenu ) ); - m_optionsToolBar->Realize(); + m_optionsToolBar->KiRealize(); } diff --git a/pcbnew/toolbars_footprint_viewer.cpp b/pcbnew/toolbars_footprint_viewer.cpp index c6b8c0e05e..0d0686323c 100644 --- a/pcbnew/toolbars_footprint_viewer.cpp +++ b/pcbnew/toolbars_footprint_viewer.cpp @@ -49,7 +49,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar() else { 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 ); } @@ -97,7 +97,7 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar() // after adding the buttons to the toolbar, must call Realize() to // 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::graphicsOutlines, ACTION_TOOLBAR::TOGGLE ); - m_optionsToolBar->Realize(); + m_optionsToolBar->KiRealize(); } diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index 6004053952..948e6a37c2 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -223,7 +223,7 @@ void PCB_EDIT_FRAME::ReCreateHToolbar() else { 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 ); // 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 // 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 ); 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 ); 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->SetMinSize( m_SelViaSizeBox->GetBestSize() ); - m_auxiliaryToolBar->Realize(); + m_auxiliaryToolBar->KiRealize(); m_auimgr.Update(); return; } @@ -546,7 +546,7 @@ void PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar() m_auxiliaryToolBar->AddControl( m_zoomSelectBox ); // after adding the buttons to the toolbar, must call Realize() - m_auxiliaryToolBar->Realize(); + m_auxiliaryToolBar->KiRealize(); }