From fd4388710dce172f6b27b4b899fe6f57b2f5f163 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Fri, 7 Aug 2020 00:03:58 +0100 Subject: [PATCH] Migrate eeschema, libview and libedit to the UI condition framework Also, fix some issues in other frames identified along the way. --- common/tool/editor_conditions.cpp | 2 +- cvpcb/display_footprints_frame.cpp | 2 +- eeschema/lib_view_frame.cpp | 75 +++++- eeschema/lib_view_frame.h | 6 +- eeschema/libedit/lib_edit_frame.cpp | 160 +++++++++++++ eeschema/libedit/lib_edit_frame.h | 7 +- eeschema/libedit/menubar_libedit.cpp | 198 ++++++---------- eeschema/libedit/toolbars_libedit.cpp | 55 +---- eeschema/menubar.cpp | 315 +++++++++++--------------- eeschema/sch_edit_frame.cpp | 102 +++++++++ eeschema/sch_edit_frame.h | 6 +- eeschema/toolbars_lib_view.cpp | 50 ++-- eeschema/toolbars_sch_editor.cpp | 43 ---- gerbview/gerbview_frame.cpp | 2 +- pagelayout_editor/pl_editor_frame.cpp | 8 +- 15 files changed, 565 insertions(+), 466 deletions(-) diff --git a/common/tool/editor_conditions.cpp b/common/tool/editor_conditions.cpp index f95717913f..5ed02ea379 100644 --- a/common/tool/editor_conditions.cpp +++ b/common/tool/editor_conditions.cpp @@ -94,7 +94,7 @@ SELECTION_CONDITION EDITOR_CONDITIONS::FullscreenCursor() wxASSERT( drwFrame ); - return std::bind( &EDITOR_CONDITIONS::gridFunc, _1, drwFrame ); + return std::bind( &EDITOR_CONDITIONS::cursorFunc, _1, drwFrame ); } diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index a0f672e95c..00e0255c24 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -183,7 +183,7 @@ DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME() void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions() { - EDA_BASE_FRAME::setupUIConditions(); + PCB_BASE_FRAME::setupUIConditions(); ACTION_MANAGER* mgr = m_toolManager->GetActionManager(); EDITOR_CONDITIONS cond( this ); diff --git a/eeschema/lib_view_frame.cpp b/eeschema/lib_view_frame.cpp index c92d387504..5e66086cc1 100644 --- a/eeschema/lib_view_frame.cpp +++ b/eeschema/lib_view_frame.cpp @@ -42,11 +42,13 @@ #include #include #include -#include #include -#include -#include #include +#include +#include +#include +#include +#include #include #include #include @@ -140,6 +142,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame GetRenderSettings()->SetDefaultPenWidth( DEFAULT_LINE_THICKNESS * IU_PER_MILS ); setupTools(); + setupUIConditions(); ReCreateHToolbar(); ReCreateVToolbar(); @@ -244,6 +247,67 @@ void LIB_VIEW_FRAME::setupTools() } +void LIB_VIEW_FRAME::setupUIConditions() +{ + SCH_BASE_FRAME::setupUIConditions(); + + ACTION_MANAGER* mgr = m_toolManager->GetActionManager(); + EDITOR_CONDITIONS cond( this ); + + wxASSERT( mgr ); + +#define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) +#define CHECK( x ) ACTION_CONDITIONS().Check( x ) + + mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) ); + + auto electricalTypesShownCondition = + [this] ( const SELECTION& aSel ) + { + return GetRenderSettings()->m_ShowPinsElectricalType; + }; + + auto demorganCond = + [this] ( const SELECTION& ) + { + LIB_PART* symbol = GetSelectedSymbol(); + + return symbol && symbol->HasConversion(); + }; + + auto demorganStandardCond = + [] ( const SELECTION& ) + { + return m_convert == LIB_ITEM::LIB_CONVERT::BASE; + }; + + auto demorganAlternateCond = + [] ( const SELECTION& ) + { + return m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN; + }; + + auto haveDatasheetCond = + [this] ( const SELECTION& ) + { + LIB_PART* symbol = GetSelectedSymbol(); + + return symbol && !symbol->GetDatasheetField().GetText().IsEmpty(); + }; + + mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) ); + mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( electricalTypesShownCondition ) ); + + mgr->SetConditions( EE_ACTIONS::showDeMorganStandard, + ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) ); + mgr->SetConditions( EE_ACTIONS::showDeMorganAlternate, + ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) ); + +#undef CHECK +#undef ENABLE +} + + void LIB_VIEW_FRAME::SetUnitAndConvert( int aUnit, int aConvert ) { m_unit = aUnit > 0 ? aUnit : 1; @@ -836,3 +900,8 @@ void LIB_VIEW_FRAME::DisplayLibInfos() } } + +SELECTION& LIB_VIEW_FRAME::GetCurrentSelection() +{ + return m_toolManager->GetTool()->GetSelection(); +} diff --git a/eeschema/lib_view_frame.h b/eeschema/lib_view_frame.h index 05ff5b62aa..950852ac4d 100644 --- a/eeschema/lib_view_frame.h +++ b/eeschema/lib_view_frame.h @@ -29,6 +29,7 @@ #include #include +#include class wxListBox; class SCHLIB_FILTER; @@ -144,7 +145,10 @@ public: const BOX2I GetDocumentExtents() const override; - void SyncToolbars() override; + SELECTION& GetCurrentSelection() override; + +protected: + void setupUIConditions() override; private: // Sets up the tool framework diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 93e60021bc..8a631683c0 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -42,10 +42,13 @@ #include #include #include +#include #include #include #include +#include #include +#include #include #include #include @@ -123,6 +126,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : GetRenderSettings()->LoadColors( GetColorSettings() ); setupTools(); + setupUIConditions(); m_libMgr = new LIB_MANAGER( *this ); SyncLibraries( true ); @@ -274,6 +278,158 @@ void LIB_EDIT_FRAME::setupTools() } +void LIB_EDIT_FRAME::setupUIConditions() +{ + SCH_BASE_FRAME::setupUIConditions(); + + ACTION_MANAGER* mgr = m_toolManager->GetActionManager(); + EDITOR_CONDITIONS cond( this ); + + wxASSERT( mgr ); + +#define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) +#define CHECK( x ) ACTION_CONDITIONS().Check( x ) + + auto haveSymbolCond = + [this] ( const SELECTION& ) + { + return m_my_part; + }; + + auto libMgrModifiedCond = + [this] ( const SELECTION& ) + { + return m_libMgr->HasModifications(); + }; + + auto modifiedDocumentCondition = + [this] ( const SELECTION& sel ) + { + LIB_ID libId = getTargetLibId(); + const wxString& libName = libId.GetLibNickname(); + const wxString& partName = libId.GetLibItemName(); + + bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName ); + + if( partName.IsEmpty() ) + return ( !readOnly && m_libMgr->IsLibraryModified( libName ) ); + else + return ( !readOnly && m_libMgr->IsPartModified( partName, libName ) ); + }; + + mgr->SetConditions( ACTIONS::saveAll, ENABLE( libMgrModifiedCond ) ); + mgr->SetConditions( ACTIONS::save, ENABLE( haveSymbolCond && modifiedDocumentCondition ) ); + mgr->SetConditions( ACTIONS::undo, ENABLE( haveSymbolCond && cond.UndoAvailable() ) ); + mgr->SetConditions( ACTIONS::redo, ENABLE( haveSymbolCond && cond.RedoAvailable() ) ); + mgr->SetConditions( ACTIONS::revert, ENABLE( haveSymbolCond && modifiedDocumentCondition ) ); + + mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) ); + mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) ); + mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) ); + mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) ); + mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) ); + mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) ); + + mgr->SetConditions( ACTIONS::cut, ENABLE( haveSymbolCond && SELECTION_CONDITIONS::NotEmpty ) ); + mgr->SetConditions( ACTIONS::copy, ENABLE( haveSymbolCond && SELECTION_CONDITIONS::NotEmpty ) ); + mgr->SetConditions( ACTIONS::paste, ENABLE( haveSymbolCond && SELECTION_CONDITIONS::Idle ) ); + mgr->SetConditions( ACTIONS::doDelete, ENABLE( haveSymbolCond && SELECTION_CONDITIONS::NotEmpty ) ); + mgr->SetConditions( ACTIONS::duplicate, ENABLE( haveSymbolCond && SELECTION_CONDITIONS::NotEmpty ) ); + + mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) ); + mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) ); + + auto pinTypeCond = + [this] ( const SELECTION& ) + { + return GetRenderSettings()->m_ShowPinsElectricalType; + }; + + auto showCompTreeCond = + [this] ( const SELECTION& ) + { + return IsSearchTreeShown(); + }; + + mgr->SetConditions( EE_ACTIONS::showElectricalTypes, CHECK( pinTypeCond ) ); + mgr->SetConditions( EE_ACTIONS::showComponentTree, CHECK( showCompTreeCond ) ); + + auto isEditableCond = + [this] ( const SELECTION& ) + { + // Only root symbols are editable + return m_my_part && m_my_part->IsRoot(); + }; + + auto demorganCond = + [this] ( const SELECTION& ) + { + return GetShowDeMorgan(); + }; + + auto demorganStandardCond = + [this] ( const SELECTION& ) + { + return m_convert == LIB_ITEM::LIB_CONVERT::BASE; + }; + + auto demorganAlternateCond = + [this] ( const SELECTION& ) + { + return m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN; + }; + + auto multiUnitModeCond = + [this] ( const SELECTION& ) + { + return m_my_part && m_my_part->IsMulti() && !m_my_part->UnitsLocked(); + }; + + auto syncedPinsModeCond = + [this] ( const SELECTION& ) + { + return m_SyncPinEdit; + }; + + auto haveDatasheetCond = + [this] ( const SELECTION& ) + { + return m_my_part && !m_my_part->GetDatasheetField().GetText().IsEmpty(); + }; + + mgr->SetConditions( EE_ACTIONS::showDatasheet, ENABLE( haveDatasheetCond ) ); + mgr->SetConditions( EE_ACTIONS::symbolProperties, ENABLE( haveSymbolCond ) ); + mgr->SetConditions( EE_ACTIONS::runERC, ENABLE( isEditableCond) ); + mgr->SetConditions( EE_ACTIONS::pinTable, ENABLE( isEditableCond) ); + + mgr->SetConditions( EE_ACTIONS::showDeMorganStandard, + ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganStandardCond ) ); + mgr->SetConditions( EE_ACTIONS::showDeMorganAlternate, + ACTION_CONDITIONS().Enable( demorganCond ).Check( demorganAlternateCond ) ); + mgr->SetConditions( EE_ACTIONS::toggleSyncedPinsMode, + ACTION_CONDITIONS().Enable( multiUnitModeCond ).Check( syncedPinsModeCond ) ); + +// Only enable a tool if the part is edtable +#define EDIT_TOOL( tool ) ACTION_CONDITIONS().Enable( isEditableCond ).Check( cond.CurrentTool( tool ) ) + + mgr->SetConditions( ACTIONS::deleteTool, EDIT_TOOL( ACTIONS::deleteTool ) ); + mgr->SetConditions( EE_ACTIONS::placeSymbolPin, EDIT_TOOL( EE_ACTIONS::placeSymbolPin ) ); + mgr->SetConditions( EE_ACTIONS::placeSymbolText, EDIT_TOOL( EE_ACTIONS::placeSymbolText ) ); + mgr->SetConditions( EE_ACTIONS::drawSymbolRectangle, EDIT_TOOL( EE_ACTIONS::drawSymbolRectangle ) ); + mgr->SetConditions( EE_ACTIONS::drawSymbolCircle, EDIT_TOOL( EE_ACTIONS::drawSymbolCircle ) ); + mgr->SetConditions( EE_ACTIONS::drawSymbolArc, EDIT_TOOL( EE_ACTIONS::drawSymbolArc ) ); + mgr->SetConditions( EE_ACTIONS::drawSymbolLines, EDIT_TOOL( EE_ACTIONS::drawSymbolLines ) ); + mgr->SetConditions( EE_ACTIONS::placeSymbolAnchor, EDIT_TOOL( EE_ACTIONS::placeSymbolAnchor ) ); + + RegisterUIUpdateHandler( ID_LIBEDIT_IMPORT_BODY_BUTT, ENABLE( isEditableCond ) ); + RegisterUIUpdateHandler( ID_LIBEDIT_EXPORT_BODY_BUTT, ENABLE( isEditableCond ) ); + +#undef CHECK +#undef ENABLE +#undef EDIT_TOOL +} + + void LIB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) { // Shutdown blocks must be determined and vetoed as early as possible @@ -944,3 +1100,7 @@ void LIB_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCou } +SELECTION& LIB_EDIT_FRAME::GetCurrentSelection() +{ + return m_toolManager->GetTool()->GetSelection(); +} diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 1f4525a7a0..07427d85af 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -145,6 +145,8 @@ public: LIB_MANAGER& GetLibManager(); + SELECTION& GetCurrentSelection() override; + void ReCreateMenuBar() override; // See comments for m_SyncPinEdit. @@ -256,6 +258,9 @@ public: void ClearMsgPanel() override { DisplayCmpDoc(); } +protected: + void setupUIConditions() override; + private: // Sets up the tool framework void setupTools(); @@ -421,8 +426,6 @@ public: void ShowChangedLanguage() override; - void SyncToolbars() override; - void SetScreen( BASE_SCREEN* aScreen ) override; const BOX2I GetDocumentExtents() const override; diff --git a/eeschema/libedit/menubar_libedit.cpp b/eeschema/libedit/menubar_libedit.cpp index b53b38b271..0ada2de16e 100644 --- a/eeschema/libedit/menubar_libedit.cpp +++ b/eeschema/libedit/menubar_libedit.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -42,38 +42,22 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() wxMenuBar* oldMenuBar = GetMenuBar(); WX_MENUBAR* menuBar = new WX_MENUBAR(); - auto modifiedDocumentCondition = [ this ] ( const SELECTION& sel ) { - LIB_ID libId = getTargetLibId(); - const wxString& libName = libId.GetLibNickname(); - const wxString& partName = libId.GetLibItemName(); - bool readOnly = libName.IsEmpty() || m_libMgr->IsLibraryReadOnly( libName ); - - if( partName.IsEmpty() ) - return ( !readOnly && m_libMgr->IsLibraryModified( libName ) ); - else - return ( !readOnly && m_libMgr->IsPartModified( partName, libName ) ); - }; - - auto saveAllEnableCondition = [this] ( const SELECTION& sel ) { - return m_libMgr->HasModifications(); - }; - //-- File menu ----------------------------------------------- // - CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool ); - fileMenu->AddItem( ACTIONS::newLibrary, EE_CONDITIONS::ShowAlways ); - fileMenu->AddItem( ACTIONS::addLibrary, EE_CONDITIONS::ShowAlways ); - fileMenu->AddItem( EE_ACTIONS::newSymbol, EE_CONDITIONS::ShowAlways ); + fileMenu->Add( ACTIONS::newLibrary ); + fileMenu->Add( ACTIONS::addLibrary ); + fileMenu->Add( EE_ACTIONS::newSymbol ); - fileMenu->AddSeparator(); - fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition ); - fileMenu->AddItem( ACTIONS::saveCopyAs, EE_CONDITIONS::ShowAlways ); - fileMenu->AddItem( ACTIONS::saveAll, saveAllEnableCondition ); - fileMenu->AddItem( ACTIONS::revert, modifiedDocumentCondition ); + fileMenu->AppendSeparator(); + fileMenu->Add( ACTIONS::save ); + fileMenu->Add( ACTIONS::saveCopyAs ); + fileMenu->Add( ACTIONS::saveAll ); + fileMenu->Add( ACTIONS::revert ); - fileMenu->AddSeparator(); - fileMenu->AddItem( EE_ACTIONS::importSymbol, EE_CONDITIONS::ShowAlways ); + fileMenu->AppendSeparator(); + fileMenu->Add( EE_ACTIONS::importSymbol ); // Export submenu ACTION_MENU* submenuExport = new ACTION_MENU( false ); @@ -83,151 +67,109 @@ void LIB_EDIT_FRAME::ReCreateMenuBar() submenuExport->Add( EE_ACTIONS::exportSymbol ); submenuExport->Add( EE_ACTIONS::exportSymbolView ); submenuExport->Add( EE_ACTIONS::exportSymbolAsSVG ); - fileMenu->AddMenu( submenuExport, EE_CONDITIONS::ShowAlways ); + fileMenu->Add( submenuExport ); - fileMenu->AddSeparator(); + fileMenu->AppendSeparator(); fileMenu->AddClose( _( "Library Editor" ) ); - fileMenu->Resolve(); //-- Edit menu ----------------------------------------------- // - CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* editMenu = new ACTION_MENU( false, selTool ); - auto enableUndoCondition = [ this ] ( const SELECTION& sel ) { - return m_my_part && GetUndoCommandCount() != 0; - }; - auto enableRedoCondition = [ this ] ( const SELECTION& sel ) { - return m_my_part && GetRedoCommandCount() != 0; - }; - auto haveSymbolCondition = [ this ] ( const SELECTION& sel ) { - return m_my_part != nullptr; - }; - auto isRootSymbolCondition = [ this ] ( const SELECTION& sel ) { - return m_my_part != nullptr && m_my_part->IsRoot(); - }; + editMenu->Add( ACTIONS::undo ); + editMenu->Add( ACTIONS::redo ); - editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); - editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); + editMenu->AppendSeparator(); + editMenu->Add( ACTIONS::cut ); + editMenu->Add( ACTIONS::copy ); + editMenu->Add( ACTIONS::paste ); + editMenu->Add( ACTIONS::doDelete ); + editMenu->Add( ACTIONS::duplicate ); - editMenu->AddSeparator(); - editMenu->AddItem( ACTIONS::cut, EE_CONDITIONS::NotEmpty ); - editMenu->AddItem( ACTIONS::copy, EE_CONDITIONS::NotEmpty ); - editMenu->AddItem( ACTIONS::paste, EE_CONDITIONS::Idle ); - editMenu->AddItem( ACTIONS::doDelete, EE_CONDITIONS::NotEmpty ); - editMenu->AddItem( ACTIONS::duplicate, EE_CONDITIONS::NotEmpty ); + editMenu->AppendSeparator(); + editMenu->Add( EE_ACTIONS::symbolProperties ); + editMenu->Add( EE_ACTIONS::pinTable ); - editMenu->AddSeparator(); - editMenu->AddItem( EE_ACTIONS::symbolProperties, haveSymbolCondition ); - editMenu->AddItem( EE_ACTIONS::pinTable, isRootSymbolCondition ); - - editMenu->Resolve(); //-- View menu ----------------------------------------------- // - CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool ); - auto gridShownCondition = [ this ] ( const SELECTION& aSel ) { - return IsGridVisible(); - }; - auto imperialUnitsCondition = [this]( const SELECTION& aSel ) { - return GetUserUnits() == EDA_UNITS::INCHES; - }; - auto metricUnitsCondition = [this]( const SELECTION& aSel ) { - return GetUserUnits() == EDA_UNITS::MILLIMETRES; - }; - auto fullCrosshairCondition = [ this ] ( const SELECTION& aSel ) { - return GetGalDisplayOptions().m_fullscreenCursor; - }; - auto compTreeShownCondition = [ this ] ( const SELECTION& aSel ) { - return IsSearchTreeShown(); - }; + viewMenu->Add( ACTIONS::showSymbolBrowser ); - viewMenu->AddItem( ACTIONS::showSymbolBrowser, EE_CONDITIONS::ShowAlways ); + viewMenu->AppendSeparator(); + viewMenu->Add( ACTIONS::zoomInCenter ); + viewMenu->Add( ACTIONS::zoomOutCenter ); + viewMenu->Add( ACTIONS::zoomFitScreen ); + viewMenu->Add( ACTIONS::zoomTool ); + viewMenu->Add( ACTIONS::zoomRedraw ); - viewMenu->AddSeparator(); - viewMenu->AddItem( ACTIONS::zoomInCenter, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomOutCenter, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomFitScreen, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomTool, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomRedraw, EE_CONDITIONS::ShowAlways ); - - viewMenu->AddSeparator(); - viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition ); - viewMenu->AddItem( ACTIONS::gridProperties, EE_CONDITIONS::ShowAlways ); + viewMenu->AppendSeparator(); + viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK ); + viewMenu->Add( ACTIONS::gridProperties ); // Units submenu - CONDITIONAL_MENU* unitsSubMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool ); unitsSubMenu->SetTitle( _( "&Units" ) ); unitsSubMenu->SetIcon( unit_mm_xpm ); - unitsSubMenu->AddCheckItem( ACTIONS::imperialUnits, imperialUnitsCondition ); - unitsSubMenu->AddCheckItem( ACTIONS::metricUnits, metricUnitsCondition ); - viewMenu->AddMenu( unitsSubMenu ); + unitsSubMenu->Add( ACTIONS::imperialUnits, ACTION_MENU::CHECK ); + unitsSubMenu->Add( ACTIONS::metricUnits, ACTION_MENU::CHECK ); + viewMenu->Add( unitsSubMenu ); - viewMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition ); + viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK ); - viewMenu->AddSeparator(); - viewMenu->AddCheckItem( EE_ACTIONS::showComponentTree, compTreeShownCondition ); + viewMenu->AppendSeparator(); + viewMenu->Add( EE_ACTIONS::showComponentTree, ACTION_MENU::CHECK ); - viewMenu->Resolve(); //-- Place menu ----------------------------------------------- // - CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool ); - placeMenu->AddItem( EE_ACTIONS::placeSymbolPin, isRootSymbolCondition ); - placeMenu->AddItem( EE_ACTIONS::placeSymbolText, isRootSymbolCondition ); - placeMenu->AddItem( EE_ACTIONS::drawSymbolRectangle, isRootSymbolCondition ); - placeMenu->AddItem( EE_ACTIONS::drawSymbolCircle, isRootSymbolCondition ); - placeMenu->AddItem( EE_ACTIONS::drawSymbolArc, isRootSymbolCondition ); - placeMenu->AddItem( EE_ACTIONS::drawSymbolLines, isRootSymbolCondition ); + placeMenu->Add( EE_ACTIONS::placeSymbolPin ); + placeMenu->Add( EE_ACTIONS::placeSymbolText ); + placeMenu->Add( EE_ACTIONS::drawSymbolRectangle ); + placeMenu->Add( EE_ACTIONS::drawSymbolCircle ); + placeMenu->Add( EE_ACTIONS::drawSymbolArc ); + placeMenu->Add( EE_ACTIONS::drawSymbolLines ); - placeMenu->Resolve(); //-- Inspect menu ----------------------------------------------- // - CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool ); - inspectMenu->AddItem( EE_ACTIONS::showDatasheet, haveSymbolCondition ); - inspectMenu->AddItem( EE_ACTIONS::runERC, isRootSymbolCondition ); + inspectMenu->Add( EE_ACTIONS::showDatasheet ); + inspectMenu->Add( EE_ACTIONS::runERC ); - inspectMenu->Resolve(); //-- Preferences menu ----------------------------------------------- // - CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool ); - auto acceleratedGraphicsCondition = [ this ] ( const SELECTION& aSel ) { - return GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; - }; - auto standardGraphicsCondition = [ this ] ( const SELECTION& aSel ) { - return GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; - }; + prefsMenu->Add( ACTIONS::configurePaths ); + prefsMenu->Add( ACTIONS::showSymbolLibTable ); + prefsMenu->Add( _( "Preferences...\tCTRL+," ), + _( "Show preferences for all open tools" ), + wxID_PREFERENCES, + preference_xpm ); - prefsMenu->AddItem( ACTIONS::configurePaths, EE_CONDITIONS::ShowAlways ); - prefsMenu->AddItem( ACTIONS::showSymbolLibTable, EE_CONDITIONS::ShowAlways ); - prefsMenu->AddItem( wxID_PREFERENCES, - _( "Preferences...\tCTRL+," ), - _( "Show preferences for all open tools" ), - preference_xpm, EE_CONDITIONS::ShowAlways ); - - prefsMenu->AddSeparator(); + prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, selTool ); - prefsMenu->AddSeparator(); - prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition ); - prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition ); + prefsMenu->AppendSeparator(); + prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); + prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); - prefsMenu->Resolve(); //-- Menubar ------------------------------------------------------------- // - menuBar->Append( fileMenu, _( "&File" ) ); - menuBar->Append( editMenu, _( "&Edit" ) ); - menuBar->Append( viewMenu, _( "&View" ) ); - menuBar->Append( placeMenu, _( "&Place" ) ); + menuBar->Append( fileMenu, _( "&File" ) ); + menuBar->Append( editMenu, _( "&Edit" ) ); + menuBar->Append( viewMenu, _( "&View" ) ); + menuBar->Append( placeMenu, _( "&Place" ) ); menuBar->Append( inspectMenu, _( "&Inspect" ) ); - menuBar->Append( prefsMenu, _( "P&references" ) ); + menuBar->Append( prefsMenu, _( "P&references" ) ); AddStandardHelpMenu( menuBar ); SetMenuBar( menuBar ); diff --git a/eeschema/libedit/toolbars_libedit.cpp b/eeschema/libedit/toolbars_libedit.cpp index 68d007e429..1a09cbe377 100644 --- a/eeschema/libedit/toolbars_libedit.cpp +++ b/eeschema/libedit/toolbars_libedit.cpp @@ -108,7 +108,7 @@ void LIB_EDIT_FRAME::ReCreateHToolbar() m_mainToolBar->Add( EE_ACTIONS::runERC ); m_mainToolBar->AddScaledSeparator( this ); - m_mainToolBar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE ); + m_mainToolBar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE ); m_mainToolBar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE ); m_mainToolBar->AddScaledSeparator( this ); @@ -148,56 +148,3 @@ void LIB_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Realize(); } - - -void LIB_EDIT_FRAME::SyncToolbars() -{ - KIGFX::SCH_RENDER_SETTINGS* settings = GetRenderSettings(); - KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions(); - - bool isEditable = m_my_part && m_my_part->IsRoot(); - - m_mainToolBar->Toggle( ACTIONS::saveAll, m_libMgr->HasModifications() ); - m_mainToolBar->Toggle( ACTIONS::undo, GetUndoCommandCount() > 0 ); - m_mainToolBar->Toggle( ACTIONS::redo, GetRedoCommandCount() > 0 ); - m_mainToolBar->Toggle( ACTIONS::zoomTool, IsCurrentTool( ACTIONS::zoomTool ) ); - m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, (bool) m_my_part ); - m_mainToolBar->Toggle( EE_ACTIONS::runERC, isEditable ); - m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard, - GetShowDeMorgan(), - m_convert == LIB_ITEM::LIB_CONVERT::BASE ); - m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganAlternate, - GetShowDeMorgan(), - m_convert == LIB_ITEM::LIB_CONVERT::DEMORGAN ); - m_mainToolBar->Toggle( EE_ACTIONS::pinTable, isEditable ); - m_mainToolBar->Toggle( EE_ACTIONS::toggleSyncedPinsMode, - m_my_part && m_my_part->IsMulti() && !m_my_part->UnitsLocked(), - m_SyncPinEdit ); - m_mainToolBar->Refresh(); - - m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); - m_optionsToolBar->Toggle( ACTIONS::metricUnits, - GetUserUnits() != EDA_UNITS::INCHES ); - m_optionsToolBar->Toggle( ACTIONS::imperialUnits, - GetUserUnits() == EDA_UNITS::INCHES ); - m_optionsToolBar->Toggle( ACTIONS::toggleCursorStyle, galOpts.m_fullscreenCursor ); - m_optionsToolBar->Toggle( EE_ACTIONS::showElectricalTypes, settings->m_ShowPinsElectricalType ); - m_optionsToolBar->Toggle( EE_ACTIONS::showComponentTree, IsSearchTreeShown() ); - m_optionsToolBar->Refresh(); - -#define TOGGLE_TOOL( toolbar, enable, tool ) toolbar->Toggle( tool, enable, IsCurrentTool( tool ) ) - - TOGGLE_TOOL( m_drawToolBar, isEditable, ACTIONS::selectionTool ); - TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::placeSymbolPin ); - TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::placeSymbolText ); - TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::drawSymbolRectangle ); - TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::drawSymbolCircle ); - TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::drawSymbolArc ); - TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::drawSymbolLines ); - TOGGLE_TOOL( m_drawToolBar, isEditable, EE_ACTIONS::placeSymbolAnchor ); - TOGGLE_TOOL( m_drawToolBar, isEditable, ACTIONS::deleteTool ); - m_drawToolBar->EnableTool( ID_LIBEDIT_IMPORT_BODY_BUTT, isEditable ); - m_drawToolBar->EnableTool( ID_LIBEDIT_EXPORT_BODY_BUTT, isEditable ); - - m_drawToolBar->Refresh(); -} diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index adb797d952..28f6ebacea 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -46,14 +46,9 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() wxMenuBar* oldMenuBar = GetMenuBar(); WX_MENUBAR* menuBar = new WX_MENUBAR(); - auto modifiedDocumentCondition = [&]( const SELECTION& sel ) - { - return Schematic().GetSheets().IsModified(); - }; - //-- File menu ----------------------------------------------------------- // - CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool ); static ACTION_MENU* openRecentMenu; if( Kiface().IsSingle() ) // When not under a project mgr @@ -73,22 +68,29 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() fileHistory.AddFilesToMenu( openRecentMenu ); } - fileMenu->AddItem( ACTIONS::doNew, EE_CONDITIONS::ShowAlways ); - fileMenu->AddItem( ACTIONS::open, EE_CONDITIONS::ShowAlways ); - fileMenu->AddMenu( openRecentMenu, FILE_HISTORY::FileHistoryNotEmpty( fileHistory ) ); - fileMenu->AddSeparator(); + fileMenu->Add( ACTIONS::doNew ); + fileMenu->Add( ACTIONS::open ); + + wxMenuItem* item = fileMenu->Add( openRecentMenu ); + + // Add the file menu condition here since it needs the item ID for the submenu + ACTION_CONDITIONS cond; + cond.Enable( FILE_HISTORY::FileHistoryNotEmpty( fileHistory ) ); + RegisterUIUpdateHandler( item->GetId(), cond ); + fileMenu->AppendSeparator(); } - fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition ); - fileMenu->AddItem( ACTIONS::saveAs, EE_CONDITIONS::ShowAlways ); + fileMenu->Add( ACTIONS::save ); + fileMenu->Add( ACTIONS::saveAs ); - fileMenu->AddSeparator(); + fileMenu->AppendSeparator(); - fileMenu->AddItem( ID_APPEND_PROJECT, _( "Append Schematic Sheet Content..." ), - _( "Append schematic sheet content from another project to the current sheet" ), - add_document_xpm, EE_CONDITIONS::ShowAlways ); + fileMenu->Add( _( "Append Schematic Sheet Content..." ), + _( "Append schematic sheet content from another project to the current sheet" ), + ID_APPEND_PROJECT, + add_document_xpm ); - fileMenu->AddSeparator(); + fileMenu->AppendSeparator(); // Import submenu ACTION_MENU* submenuImport = new ACTION_MENU( false ); @@ -97,10 +99,11 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() submenuImport->SetIcon( import_xpm ); submenuImport->Add( _( "Import Non KiCad Schematic..." ), _( "Replace current schematic sheet with one imported from another application" ), - ID_IMPORT_NON_KICAD_SCH, import_document_xpm ); + ID_IMPORT_NON_KICAD_SCH, + import_document_xpm ); submenuImport->Add( EE_ACTIONS::importFPAssignments ); - fileMenu->AddMenu( submenuImport, EE_CONDITIONS::ShowAlways ); + fileMenu->Add( submenuImport ); // Export submenu @@ -110,238 +113,172 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() submenuExport->SetIcon( export_xpm ); submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard ); submenuExport->Add( EE_ACTIONS::exportNetlist ); - fileMenu->AddMenu( submenuExport, EE_CONDITIONS::ShowAlways ); + fileMenu->Add( submenuExport ); - fileMenu->AddSeparator(); - fileMenu->AddItem( EE_ACTIONS::schematicSetup, EE_CONDITIONS::ShowAlways ); + fileMenu->AppendSeparator(); + fileMenu->Add( EE_ACTIONS::schematicSetup ); - fileMenu->AddSeparator(); - fileMenu->AddItem( ACTIONS::pageSettings, EE_CONDITIONS::ShowAlways ); - fileMenu->AddItem( ACTIONS::print, EE_CONDITIONS::ShowAlways ); - fileMenu->AddItem( ACTIONS::plot, EE_CONDITIONS::ShowAlways ); + fileMenu->AppendSeparator(); + fileMenu->Add( ACTIONS::pageSettings ); + fileMenu->Add( ACTIONS::print ); + fileMenu->Add( ACTIONS::plot ); - fileMenu->AddSeparator(); + fileMenu->AppendSeparator(); fileMenu->AddQuitOrClose( &Kiface(), _( "Eeschema" ) ); - fileMenu->Resolve(); //-- Edit menu ----------------------------------------------------------- // - CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* editMenu = new ACTION_MENU( false, selTool ); - auto enableUndoCondition = [ this ] ( const SELECTION& sel ) { - return GetUndoCommandCount() > 0; - }; - auto enableRedoCondition = [ this ] ( const SELECTION& sel ) { - return GetRedoCommandCount() > 0; - }; + editMenu->Add( ACTIONS::undo ); + editMenu->Add( ACTIONS::redo ); - editMenu->AddItem( ACTIONS::undo, enableUndoCondition ); - editMenu->AddItem( ACTIONS::redo, enableRedoCondition ); + editMenu->AppendSeparator(); + editMenu->Add( ACTIONS::cut ); + editMenu->Add( ACTIONS::copy ); + editMenu->Add( ACTIONS::paste ); + editMenu->Add( ACTIONS::pasteSpecial ); + editMenu->Add( ACTIONS::doDelete ); + editMenu->Add( ACTIONS::duplicate ); - editMenu->AddSeparator(); - editMenu->AddItem( ACTIONS::cut, EE_CONDITIONS::NotEmpty ); - editMenu->AddItem( ACTIONS::copy, EE_CONDITIONS::NotEmpty ); - editMenu->AddItem( ACTIONS::paste, EE_CONDITIONS::Idle ); - editMenu->AddItem( ACTIONS::pasteSpecial, EE_CONDITIONS::Idle ); - editMenu->AddItem( ACTIONS::doDelete, EE_CONDITIONS::NotEmpty ); - editMenu->AddItem( ACTIONS::duplicate, EE_CONDITIONS::NotEmpty ); + editMenu->AppendSeparator(); + editMenu->Add( ACTIONS::find ); + editMenu->Add( ACTIONS::findAndReplace ); - editMenu->AddSeparator(); - editMenu->AddItem( ACTIONS::find, EE_CONDITIONS::ShowAlways ); - editMenu->AddItem( ACTIONS::findAndReplace, EE_CONDITIONS::ShowAlways ); + editMenu->AppendSeparator(); + editMenu->Add( ACTIONS::deleteTool ); + editMenu->Add( EE_ACTIONS::editTextAndGraphics ); + editMenu->Add( EE_ACTIONS::updateFieldsFromLibrary ); + editMenu->Add( EE_ACTIONS::changeSymbols ); + editMenu->Add( EE_ACTIONS::updateSymbols ); - editMenu->AddSeparator(); - editMenu->AddItem( ACTIONS::deleteTool, EE_CONDITIONS::ShowAlways ); - editMenu->AddItem( EE_ACTIONS::editTextAndGraphics, EE_CONDITIONS::ShowAlways ); - editMenu->AddItem( EE_ACTIONS::updateFieldsFromLibrary, EE_CONDITIONS::ShowAlways ); - editMenu->AddItem( EE_ACTIONS::changeSymbols, EE_CONDITIONS::ShowAlways ); - editMenu->AddItem( EE_ACTIONS::updateSymbols, EE_CONDITIONS::ShowAlways ); - - editMenu->Resolve(); //-- View menu ----------------------------------------------------------- // - CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* viewMenu = new ACTION_MENU( false, selTool ); - auto belowRootSheetCondition = - [this]( const SELECTION& aSel ) - { - return GetCurrentSheet().Last() != &Schematic().Root(); - }; + viewMenu->Add( ACTIONS::showSymbolBrowser ); + viewMenu->Add( EE_ACTIONS::navigateHierarchy ); + viewMenu->Add( EE_ACTIONS::leaveSheet ); - auto gridShownCondition = - [this]( const SELECTION& aSel ) - { - return IsGridVisible(); - }; + viewMenu->AppendSeparator(); + viewMenu->Add( ACTIONS::zoomInCenter ); + viewMenu->Add( ACTIONS::zoomOutCenter ); + viewMenu->Add( ACTIONS::zoomFitScreen ); + viewMenu->Add( ACTIONS::zoomTool ); + viewMenu->Add( ACTIONS::zoomRedraw ); - auto imperialUnitsCondition = - [this]( const SELECTION& aSel ) - { - return GetUserUnits() == EDA_UNITS::INCHES; - }; - - auto metricUnitsCondition = - [this]( const SELECTION& aSel ) - { - return GetUserUnits() == EDA_UNITS::MILLIMETRES; - }; - - auto fullCrosshairCondition = - [this]( const SELECTION& aSel ) - { - return GetGalDisplayOptions().m_fullscreenCursor; - }; - auto hiddenPinsCondition = - [this]( const SELECTION& aSel ) - { - return GetShowAllPins(); - }; - - viewMenu->AddItem( ACTIONS::showSymbolBrowser, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( EE_ACTIONS::navigateHierarchy, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition ); - - viewMenu->AddSeparator(); - viewMenu->AddItem( ACTIONS::zoomInCenter, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomOutCenter, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomFitScreen, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomTool, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomRedraw, EE_CONDITIONS::ShowAlways ); - - viewMenu->AddSeparator(); - viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition ); - viewMenu->AddItem( ACTIONS::gridProperties, EE_CONDITIONS::ShowAlways ); + viewMenu->AppendSeparator(); + viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK ); + viewMenu->Add( ACTIONS::gridProperties ); // Units submenu - CONDITIONAL_MENU* unitsSubMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* unitsSubMenu = new ACTION_MENU( false, selTool ); unitsSubMenu->SetTitle( _( "&Units" ) ); unitsSubMenu->SetIcon( unit_mm_xpm ); - unitsSubMenu->AddCheckItem( ACTIONS::imperialUnits, imperialUnitsCondition ); - unitsSubMenu->AddCheckItem( ACTIONS::metricUnits, metricUnitsCondition ); - viewMenu->AddMenu( unitsSubMenu ); + unitsSubMenu->Add( ACTIONS::imperialUnits, ACTION_MENU::CHECK ); + unitsSubMenu->Add( ACTIONS::metricUnits, ACTION_MENU::CHECK ); + viewMenu->Add( unitsSubMenu ); - viewMenu->AddCheckItem( ACTIONS::toggleCursorStyle, fullCrosshairCondition ); + viewMenu->Add( ACTIONS::toggleCursorStyle, ACTION_MENU::CHECK ); - viewMenu->AddSeparator(); - viewMenu->AddCheckItem( EE_ACTIONS::toggleHiddenPins, hiddenPinsCondition ); + viewMenu->AppendSeparator(); + viewMenu->Add( EE_ACTIONS::toggleHiddenPins, ACTION_MENU::CHECK ); #ifdef __APPLE__ - viewMenu->AddSeparator(); + viewMenu->AppendSeparator(); #endif - viewMenu->Resolve(); - //-- Place menu ----------------------------------------------------------- // - CONDITIONAL_MENU* placeMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* placeMenu = new ACTION_MENU( false, selTool ); - placeMenu->AddItem( EE_ACTIONS::placeSymbol, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::placePower, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::drawWire, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::drawBus, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::placeBusWireEntry, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::placeNoConnect, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::placeJunction, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::placeLabel, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::placeGlobalLabel, EE_CONDITIONS::ShowAlways ); + placeMenu->Add( EE_ACTIONS::placeSymbol ); + placeMenu->Add( EE_ACTIONS::placePower ); + placeMenu->Add( EE_ACTIONS::drawWire ); + placeMenu->Add( EE_ACTIONS::drawBus ); + placeMenu->Add( EE_ACTIONS::placeBusWireEntry ); + placeMenu->Add( EE_ACTIONS::placeNoConnect ); + placeMenu->Add( EE_ACTIONS::placeJunction ); + placeMenu->Add( EE_ACTIONS::placeLabel ); + placeMenu->Add( EE_ACTIONS::placeGlobalLabel ); - placeMenu->AddSeparator(); - placeMenu->AddItem( EE_ACTIONS::placeHierLabel, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::drawSheet, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::importSheetPin, EE_CONDITIONS::ShowAlways ); + placeMenu->AppendSeparator(); + placeMenu->Add( EE_ACTIONS::placeHierLabel ); + placeMenu->Add( EE_ACTIONS::drawSheet ); + placeMenu->Add( EE_ACTIONS::importSheetPin ); - placeMenu->AddSeparator(); - placeMenu->AddItem( EE_ACTIONS::drawLines, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::placeSchematicText, EE_CONDITIONS::ShowAlways ); - placeMenu->AddItem( EE_ACTIONS::placeImage, EE_CONDITIONS::ShowAlways ); + placeMenu->AppendSeparator(); + placeMenu->Add( EE_ACTIONS::drawLines ); + placeMenu->Add( EE_ACTIONS::placeSchematicText ); + placeMenu->Add( EE_ACTIONS::placeImage ); - placeMenu->Resolve(); //-- Inspect menu ----------------------------------------------- // - CONDITIONAL_MENU* inspectMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* inspectMenu = new ACTION_MENU( false, selTool ); - inspectMenu->AddItem( EE_ACTIONS::runERC, EE_CONDITIONS::ShowAlways ); + inspectMenu->Add( EE_ACTIONS::runERC ); #ifdef KICAD_SPICE - inspectMenu->AddItem( EE_ACTIONS::runSimulation, EE_CONDITIONS::ShowAlways ); + inspectMenu->Add( EE_ACTIONS::runSimulation ); #endif - inspectMenu->Resolve(); //-- Tools menu ----------------------------------------------- // - CONDITIONAL_MENU* toolsMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* toolsMenu = new ACTION_MENU( false, selTool ); - auto remapSymbolsCondition = - [&]( const SELECTION& aSel ) - { - SCH_SCREENS schematic( Schematic().Root() ); + toolsMenu->Add( ACTIONS::updatePcbFromSchematic ); + toolsMenu->Add( ACTIONS::updateSchematicFromPcb ); + toolsMenu->Add( EE_ACTIONS::showPcbNew ); - // The remapping can only be performed on legacy projects. - return schematic.HasNoFullyDefinedLibIds(); - }; + toolsMenu->AppendSeparator(); + toolsMenu->Add( ACTIONS::showSymbolEditor ); + toolsMenu->Add( EE_ACTIONS::rescueSymbols ); + toolsMenu->Add( EE_ACTIONS::remapSymbols ); - toolsMenu->AddItem( ACTIONS::updatePcbFromSchematic, EE_CONDITIONS::ShowAlways ); - toolsMenu->AddItem( ACTIONS::updateSchematicFromPcb, EE_CONDITIONS::ShowAlways ); - toolsMenu->AddItem( EE_ACTIONS::showPcbNew, EE_CONDITIONS::ShowAlways ); + toolsMenu->AppendSeparator(); + toolsMenu->Add( EE_ACTIONS::editSymbolFields ); + toolsMenu->Add( EE_ACTIONS::editSymbolLibraryLinks ); - toolsMenu->AddSeparator(); - toolsMenu->AddItem( ACTIONS::showSymbolEditor, EE_CONDITIONS::ShowAlways ); - toolsMenu->AddItem( EE_ACTIONS::rescueSymbols, EE_CONDITIONS::ShowAlways ); - toolsMenu->AddItem( EE_ACTIONS::remapSymbols, remapSymbolsCondition ); + toolsMenu->AppendSeparator(); + toolsMenu->Add( EE_ACTIONS::annotate ); + toolsMenu->Add( EE_ACTIONS::showBusManager ); - toolsMenu->AddSeparator(); - toolsMenu->AddItem( EE_ACTIONS::editSymbolFields, EE_CONDITIONS::ShowAlways ); - toolsMenu->AddItem( EE_ACTIONS::editSymbolLibraryLinks, EE_CONDITIONS::ShowAlways ); + toolsMenu->AppendSeparator(); + toolsMenu->Add( EE_ACTIONS::assignFootprints ); + toolsMenu->Add( EE_ACTIONS::generateBOM ); - toolsMenu->AddSeparator(); - toolsMenu->AddItem( EE_ACTIONS::annotate, EE_CONDITIONS::ShowAlways ); - toolsMenu->AddItem( EE_ACTIONS::showBusManager, EE_CONDITIONS::ShowAlways ); - - toolsMenu->AddSeparator(); - toolsMenu->AddItem( EE_ACTIONS::assignFootprints, EE_CONDITIONS::ShowAlways ); - toolsMenu->AddItem( EE_ACTIONS::generateBOM, EE_CONDITIONS::ShowAlways ); - - toolsMenu->Resolve(); //-- Preferences menu ----------------------------------------------- // - CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, selTool ); + ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool ); - auto acceleratedGraphicsCondition = [ this ] ( const SELECTION& aSel ) { - return GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL; - }; - auto standardGraphicsCondition = [ this ] ( const SELECTION& aSel ) { - return GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO; - }; + prefsMenu->Add( ACTIONS::configurePaths ); + prefsMenu->Add( ACTIONS::showSymbolLibTable ); + prefsMenu->Add( _( "Preferences...\tCTRL+," ), + _( "Show preferences for all open tools" ), + wxID_PREFERENCES, + preference_xpm ); - prefsMenu->AddItem( ACTIONS::configurePaths, EE_CONDITIONS::ShowAlways ); - prefsMenu->AddItem( ACTIONS::showSymbolLibTable, EE_CONDITIONS::ShowAlways ); - prefsMenu->AddItem( wxID_PREFERENCES, - _( "Preferences...\tCTRL+," ), - _( "Show preferences for all open tools" ), - preference_xpm, EE_CONDITIONS::ShowAlways ); - - prefsMenu->AddSeparator(); + prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, selTool ); - prefsMenu->AddSeparator(); - prefsMenu->AddCheckItem( ACTIONS::acceleratedGraphics, acceleratedGraphicsCondition ); - prefsMenu->AddCheckItem( ACTIONS::standardGraphics, standardGraphicsCondition ); + prefsMenu->AppendSeparator(); + prefsMenu->Add( ACTIONS::acceleratedGraphics, ACTION_MENU::CHECK ); + prefsMenu->Add( ACTIONS::standardGraphics, ACTION_MENU::CHECK ); - prefsMenu->Resolve(); //-- Menubar ------------------------------------------------------------- // - menuBar->Append( fileMenu, _( "&File" ) ); - menuBar->Append( editMenu, _( "&Edit" ) ); - menuBar->Append( viewMenu, _( "&View" ) ); - menuBar->Append( placeMenu, _( "&Place" ) ); + menuBar->Append( fileMenu, _( "&File" ) ); + menuBar->Append( editMenu, _( "&Edit" ) ); + menuBar->Append( viewMenu, _( "&View" ) ); + menuBar->Append( placeMenu, _( "&Place" ) ); menuBar->Append( inspectMenu, _( "&Inspect" ) ); - menuBar->Append( toolsMenu, _( "&Tools" ) ); - menuBar->Append( prefsMenu, _( "P&references" ) ); + menuBar->Append( toolsMenu, _( "&Tools" ) ); + menuBar->Append( prefsMenu, _( "P&references" ) ); AddStandardHelpMenu( menuBar ); SetMenuBar( menuBar ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 22117755fc..f5cc2482a2 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -55,10 +55,13 @@ #include #include #include +#include #include #include #include +#include #include +#include #include #include #include @@ -234,6 +237,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ): LoadProjectSettings(); setupTools(); + setupUIConditions(); ReCreateMenuBar(); ReCreateHToolbar(); ReCreateVToolbar(); @@ -345,6 +349,98 @@ void SCH_EDIT_FRAME::setupTools() } +void SCH_EDIT_FRAME::setupUIConditions() +{ + SCH_BASE_FRAME::setupUIConditions(); + + ACTION_MANAGER* mgr = m_toolManager->GetActionManager(); + EDITOR_CONDITIONS cond( this ); + + wxASSERT( mgr ); + +#define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) +#define CHECK( x ) ACTION_CONDITIONS().Check( x ) + + mgr->SetConditions( ACTIONS::save, ENABLE( cond.ContentModified() ) ); + mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) ); + mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) ); + + mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) ); + mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) ); + mgr->SetConditions( ACTIONS::metricUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) ); + mgr->SetConditions( ACTIONS::imperialUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) ); + mgr->SetConditions( ACTIONS::acceleratedGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) ) ); + mgr->SetConditions( ACTIONS::standardGraphics, CHECK( cond.CanvasType( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO ) ) ); + + mgr->SetConditions( ACTIONS::cut, ENABLE( SELECTION_CONDITIONS::NotEmpty ) ); + mgr->SetConditions( ACTIONS::copy, ENABLE( SELECTION_CONDITIONS::NotEmpty ) ); + mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle ) ); + mgr->SetConditions( ACTIONS::pasteSpecial, ENABLE( SELECTION_CONDITIONS::Idle ) ); + mgr->SetConditions( ACTIONS::doDelete, ENABLE( SELECTION_CONDITIONS::NotEmpty ) ); + mgr->SetConditions( ACTIONS::duplicate, ENABLE( SELECTION_CONDITIONS::NotEmpty ) ); + + mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) ); + mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) ); + + auto showHiddenPinsCond = + [this] ( const SELECTION& ) + { + return GetShowAllPins(); + }; + + auto forceHVCond = + [this] ( const SELECTION& ) + { + return eeconfig()->m_Drawing.hv_lines_only; + }; + + auto remapSymbolsCondition = + [&]( const SELECTION& aSel ) + { + SCH_SCREENS schematic( Schematic().Root() ); + + // The remapping can only be performed on legacy projects. + return schematic.HasNoFullyDefinedLibIds(); + }; + + auto belowRootSheetCondition = + [this]( const SELECTION& aSel ) + { + return GetCurrentSheet().Last() != &Schematic().Root(); + }; + + mgr->SetConditions( EE_ACTIONS::leaveSheet, ENABLE( belowRootSheetCondition ) ); + mgr->SetConditions( EE_ACTIONS::remapSymbols, ENABLE( remapSymbolsCondition ) ); + mgr->SetConditions( EE_ACTIONS::toggleHiddenPins, CHECK( showHiddenPinsCond ) ); + mgr->SetConditions( EE_ACTIONS::toggleForceHV, CHECK( forceHVCond ) ); + + +#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) ) + + CURRENT_TOOL( ACTIONS::deleteTool ); + CURRENT_TOOL( EE_ACTIONS::highlightNetTool ); + CURRENT_TOOL( EE_ACTIONS::placeSymbol ); + CURRENT_TOOL( EE_ACTIONS::placePower ); + CURRENT_TOOL( EE_ACTIONS::drawWire ); + CURRENT_TOOL( EE_ACTIONS::drawBus ); + CURRENT_TOOL( EE_ACTIONS::placeBusWireEntry ); + CURRENT_TOOL( EE_ACTIONS::placeNoConnect ); + CURRENT_TOOL( EE_ACTIONS::placeJunction ); + CURRENT_TOOL( EE_ACTIONS::placeLabel ); + CURRENT_TOOL( EE_ACTIONS::placeGlobalLabel ); + CURRENT_TOOL( EE_ACTIONS::placeHierLabel ); + CURRENT_TOOL( EE_ACTIONS::drawSheet ); + CURRENT_TOOL( EE_ACTIONS::importSheetPin ); + CURRENT_TOOL( EE_ACTIONS::drawLines ); + CURRENT_TOOL( EE_ACTIONS::placeSchematicText ); + CURRENT_TOOL( EE_ACTIONS::placeImage ); + +#undef CURRENT_TOOL +#undef CHECK +#undef ENABLE +} + + void SCH_EDIT_FRAME::SaveCopyForRepeatItem( SCH_ITEM* aItem ) { // we cannot store a pointer to an item in the display list here since @@ -1241,3 +1337,9 @@ wxString SCH_EDIT_FRAME::GetCurrentFileName() const { return Schematic().GetFileName(); } + + +SELECTION& SCH_EDIT_FRAME::GetCurrentSelection() +{ + return m_toolManager->GetTool()->GetSelection(); +} diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index e6fc9b3c33..ae040fa56a 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -160,6 +160,8 @@ public: SCH_SCREEN* GetScreen() const override; + SELECTION& GetCurrentSelection() override; + SCHEMATIC& Schematic() const; void OnCloseWindow( wxCloseEvent& Event ); @@ -215,6 +217,8 @@ public: void ReCreateOptToolbar() override; void ReCreateMenuBar() override; + void setupUIConditions() override; + /** * Get if the current schematic has been modified but not saved. * @@ -943,8 +947,6 @@ public: void ShowChangedLanguage() override; - void SyncToolbars() override; - void SetScreen( BASE_SCREEN* aScreen ) override; const BOX2I GetDocumentExtents() const override; diff --git a/eeschema/toolbars_lib_view.cpp b/eeschema/toolbars_lib_view.cpp index 74542d4773..15d44f2fa5 100644 --- a/eeschema/toolbars_lib_view.cpp +++ b/eeschema/toolbars_lib_view.cpp @@ -27,8 +27,8 @@ #include "lib_view_frame.h" #include "sch_painter.h" #include +#include #include -#include #include #include #include @@ -63,7 +63,7 @@ void LIB_VIEW_FRAME::ReCreateHToolbar() m_mainToolBar->Add( ACTIONS::zoomFitScreen ); m_mainToolBar->AddScaledSeparator( this ); - m_mainToolBar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE ); + m_mainToolBar->Add( EE_ACTIONS::showDeMorganStandard, ACTION_TOOLBAR::TOGGLE ); m_mainToolBar->Add( EE_ACTIONS::showDeMorganAlternate, ACTION_TOOLBAR::TOGGLE ); m_mainToolBar->AddScaledSeparator( this ); @@ -101,37 +101,27 @@ void LIB_VIEW_FRAME::ReCreateMenuBar() //-- File menu ----------------------------------------------------------- // - CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, libControl ); + ACTION_MENU* fileMenu = new ACTION_MENU( false, libControl ); fileMenu->AddClose( _( "Footprint Viewer" ) ); - fileMenu->Resolve(); - //-- View menu ----------------------------------------------------------- // - CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, libControl ); + ACTION_MENU* viewMenu = new ACTION_MENU( false, libControl ); - auto gridShownCondition = [ this ] ( const SELECTION& aSel ) { - return IsGridVisible(); - }; - auto electricalTypesShownCondition = [ this ] ( const SELECTION& aSel ) { - return GetRenderSettings()->m_ShowPinsElectricalType; - }; + viewMenu->Add( ACTIONS::zoomInCenter ); + viewMenu->Add( ACTIONS::zoomOutCenter ); + viewMenu->Add( ACTIONS::zoomFitScreen ); + viewMenu->Add( ACTIONS::zoomRedraw ); - viewMenu->AddItem( ACTIONS::zoomInCenter, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomOutCenter, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomFitScreen, EE_CONDITIONS::ShowAlways ); - viewMenu->AddItem( ACTIONS::zoomRedraw, EE_CONDITIONS::ShowAlways ); + viewMenu->AppendSeparator(); + viewMenu->Add( ACTIONS::toggleGrid, ACTION_MENU::CHECK ); + viewMenu->Add( ACTIONS::gridProperties ); - viewMenu->AddSeparator(); - viewMenu->AddCheckItem( ACTIONS::toggleGrid, gridShownCondition ); - viewMenu->AddItem( ACTIONS::gridProperties, EE_CONDITIONS::ShowAlways ); + viewMenu->AppendSeparator(); + viewMenu->Add( EE_ACTIONS::showElectricalTypes, ACTION_MENU::CHECK ); - viewMenu->AddSeparator(); - viewMenu->AddCheckItem( EE_ACTIONS::showElectricalTypes, electricalTypesShownCondition ); - - viewMenu->Resolve(); //-- Menubar ------------------------------------------------------------- // @@ -142,17 +132,3 @@ void LIB_VIEW_FRAME::ReCreateMenuBar() SetMenuBar( menuBar ); delete oldMenuBar; } - - -void LIB_VIEW_FRAME::SyncToolbars() -{ - LIB_PART* symbol = GetSelectedSymbol(); - - m_mainToolBar->Toggle( EE_ACTIONS::showDatasheet, - symbol && !symbol->GetDatasheetField().GetText().IsEmpty() ); - m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganStandard, symbol && symbol->HasConversion(), - m_convert == LIB_FIELD::LIB_CONVERT::BASE ); - m_mainToolBar->Toggle( EE_ACTIONS::showDeMorganAlternate, symbol && symbol->HasConversion(), - m_convert == LIB_FIELD::LIB_CONVERT::DEMORGAN ); - m_mainToolBar->Refresh(); -} diff --git a/eeschema/toolbars_sch_editor.cpp b/eeschema/toolbars_sch_editor.cpp index 59f5552051..694f4e6025 100644 --- a/eeschema/toolbars_sch_editor.cpp +++ b/eeschema/toolbars_sch_editor.cpp @@ -162,46 +162,3 @@ void SCH_EDIT_FRAME::ReCreateOptToolbar() m_optionsToolBar->Realize(); } - - -void SCH_EDIT_FRAME::SyncToolbars() -{ -#define TOGGLE_TOOL( toolbar, tool ) toolbar->Toggle( tool, IsCurrentTool( tool ) ) - - KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions(); - - - m_mainToolBar->Toggle( ACTIONS::save, IsContentModified() ); - m_mainToolBar->Toggle( ACTIONS::undo, GetUndoCommandCount() > 0 ); - m_mainToolBar->Toggle( ACTIONS::redo, GetRedoCommandCount() > 0 ); - TOGGLE_TOOL( m_mainToolBar, ACTIONS::zoomTool ); - m_mainToolBar->Refresh(); - - m_optionsToolBar->Toggle( ACTIONS::toggleGrid, IsGridVisible() ); - m_optionsToolBar->Toggle( ACTIONS::metricUnits, GetUserUnits() != EDA_UNITS::INCHES ); - m_optionsToolBar->Toggle( ACTIONS::imperialUnits, GetUserUnits() == EDA_UNITS::INCHES ); - m_optionsToolBar->Toggle( ACTIONS::toggleCursorStyle, galOpts.m_fullscreenCursor ); - m_optionsToolBar->Toggle( EE_ACTIONS::toggleHiddenPins, GetShowAllPins() ); - m_optionsToolBar->Toggle( EE_ACTIONS::toggleForceHV, eeconfig()->m_Drawing.hv_lines_only ); - m_optionsToolBar->Refresh(); - - TOGGLE_TOOL( m_drawToolBar, ACTIONS::selectionTool ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::highlightNetTool ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeSymbol ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placePower ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawWire ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawBus ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeBusWireEntry ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeNoConnect ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeJunction ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeLabel ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeGlobalLabel ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeHierLabel ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawSheet ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::importSheetPin ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::drawLines ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeSchematicText ); - TOGGLE_TOOL( m_drawToolBar, EE_ACTIONS::placeImage ); - TOGGLE_TOOL( m_drawToolBar, ACTIONS::deleteTool ); - m_drawToolBar->Refresh(); -} diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index aed0a68278..3afdf55eed 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -1175,7 +1175,7 @@ void GERBVIEW_FRAME::setupTools() void GERBVIEW_FRAME::setupUIConditions() { - EDA_BASE_FRAME::setupUIConditions(); + EDA_DRAW_FRAME::setupUIConditions(); ACTION_MANAGER* mgr = m_toolManager->GetActionManager(); EDITOR_CONDITIONS cond( this ); diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 251ee45233..08b9f7bfba 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -242,7 +242,7 @@ void PL_EDITOR_FRAME::setupTools() void PL_EDITOR_FRAME::setupUIConditions() { - EDA_BASE_FRAME::setupUIConditions(); + EDA_DRAW_FRAME::setupUIConditions(); ACTION_MANAGER* mgr = m_toolManager->GetActionManager(); EDITOR_CONDITIONS cond( this ); @@ -259,10 +259,10 @@ void PL_EDITOR_FRAME::setupUIConditions() mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) ); mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) ); - mgr->SetConditions( ACTIONS::cut, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) ); - mgr->SetConditions( ACTIONS::copy, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) ); + mgr->SetConditions( ACTIONS::cut, ENABLE( SELECTION_CONDITIONS::NotEmpty ) ); + mgr->SetConditions( ACTIONS::copy, ENABLE( SELECTION_CONDITIONS::NotEmpty ) ); mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle ) ); - mgr->SetConditions( ACTIONS::doDelete, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) ); + mgr->SetConditions( ACTIONS::doDelete, ENABLE( SELECTION_CONDITIONS::NotEmpty ) ); mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) ); mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );