diff --git a/common/lib_tree_model_adapter.h b/common/lib_tree_model_adapter.h index 1446cd70ce..c51d11dbf3 100644 --- a/common/lib_tree_model_adapter.h +++ b/common/lib_tree_model_adapter.h @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Chris Pavlina * Copyright (C) 2014 Henner Zeller - * Copyright (C) 2014-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2014-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -23,16 +23,13 @@ #define LIB_TREE_MODEL_ADAPTER_H #include - #include - #include #include #include #include #include - /** * Adapter class in the component selector Model-View-Adapter (mediated MVC) * architecture. The other pieces are in: @@ -90,6 +87,9 @@ * - `Compare()` - compare two rows, for sorting * - `HasDefaultCompare()` - whether sorted by default */ + +class TOOL_INTERACTIVE; + class LIB_TREE_MODEL_ADAPTER: public wxDataViewModel { public: @@ -251,6 +251,9 @@ public: void Thaw() { m_freeze--; } bool IsFrozen() const { return m_freeze; } + // Allows subclasses to nominate a context menu handler. + virtual TOOL_INTERACTIVE* GetContextMenuTool() { return nullptr; } + protected: static wxDataViewItem ToItem( LIB_TREE_NODE const* aNode ); static LIB_TREE_NODE const* ToNode( wxDataViewItem aItem ); @@ -258,40 +261,31 @@ protected: LIB_TREE_NODE_ROOT m_tree; - /** - * Constructor - */ LIB_TREE_MODEL_ADAPTER(); /** * Check whether a container has columns too */ - virtual bool HasContainerColumns( wxDataViewItem const& aItem ) const override; + bool HasContainerColumns( wxDataViewItem const& aItem ) const override; /** * Check whether an item can have children. */ - virtual bool IsContainer( wxDataViewItem const& aItem ) const override; + bool IsContainer( wxDataViewItem const& aItem ) const override; /** * Get the parent of an item. * - * @param aItem item to get the parent of * @return parent of aItem, or an invalid wxDataViewItem if parent is root */ - virtual wxDataViewItem GetParent( wxDataViewItem const& aItem ) const override; + wxDataViewItem GetParent( wxDataViewItem const& aItem ) const override; - /** - * Return the number of columns in the model - */ - virtual unsigned int GetColumnCount() const override { return 2; } + unsigned int GetColumnCount() const override { return 2; } /** - * Return the type of data stored in the column - * - * @return type of data as indicated by wxVariant::GetType() + * Return the type of data stored in the column as indicated by wxVariant::GetType() */ - virtual wxString GetColumnType( unsigned int aCol ) const override { return "string"; } + wxString GetColumnType( unsigned int aCol ) const override { return "string"; } /** * Get the value of an item. @@ -300,17 +294,17 @@ protected: * @param aItem item whose data will be placed into aVariant * @param aCol column number of the data */ - virtual void GetValue( wxVariant& aVariant, - wxDataViewItem const& aItem, - unsigned int aCol ) const override; + void GetValue( wxVariant& aVariant, + wxDataViewItem const& aItem, + unsigned int aCol ) const override; /** * Set the value of an item. Does nothing - this model doesn't support * editing. */ - virtual bool SetValue( wxVariant const& aVariant, - wxDataViewItem const& aItem, - unsigned int aCol ) override { return false; } + bool SetValue( wxVariant const& aVariant, + wxDataViewItem const& aItem, + unsigned int aCol ) override { return false; } /** * Get any formatting for an item. @@ -320,9 +314,9 @@ protected: * @param aAttr receiver for attributes * @return true iff the item has non-default attributes */ - virtual bool GetAttr( wxDataViewItem const& aItem, - unsigned int aCol, - wxDataViewItemAttr& aAttr ) const override; + bool GetAttr( wxDataViewItem const& aItem, + unsigned int aCol, + wxDataViewItemAttr& aAttr ) const override; private: CMP_FILTER_TYPE m_filter; diff --git a/common/tool/tool_interactive.cpp b/common/tool/tool_interactive.cpp index 5264684d66..a994f17a4b 100644 --- a/common/tool/tool_interactive.cpp +++ b/common/tool/tool_interactive.cpp @@ -30,13 +30,15 @@ #include TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) : - TOOL_BASE( INTERACTIVE, aId, aName ) + TOOL_BASE( INTERACTIVE, aId, aName ), + m_menu( *this ) { } TOOL_INTERACTIVE::TOOL_INTERACTIVE( const std::string& aName ) : - TOOL_BASE( INTERACTIVE, TOOL_MANAGER::MakeToolId( aName ), aName ) + TOOL_BASE( INTERACTIVE, TOOL_MANAGER::MakeToolId( aName ), aName ), + m_menu( *this ) { } diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index a8cbd57be3..a3353a7bd3 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -653,7 +653,7 @@ bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent ) return false; } -void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent ) +void TOOL_MANAGER::DispatchContextMenu( const TOOL_EVENT& aEvent ) { for( TOOL_ID toolId : m_activeTools ) { @@ -887,7 +887,7 @@ void TOOL_MANAGER::saveViewControls( TOOL_STATE* aState ) if( m_menuActive ) { - // Context menu is active, so the cursor settings are overridden (see dispatchContextMenu()) + // Context menu is active, so the cursor settings are overridden (see DispatchContextMenu()) auto it = m_cursorSettings.find( aState->theTool->GetId() ); if( it != m_cursorSettings.end() ) @@ -935,7 +935,7 @@ bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent ) dispatchInternal( aEvent ); dispatchActivation( aEvent ); - dispatchContextMenu( aEvent ); + DispatchContextMenu( aEvent ); // Dispatch queue while( !m_eventQueue.empty() ) diff --git a/common/widgets/lib_tree.cpp b/common/widgets/lib_tree.cpp index 2810a26851..9ca0c0025e 100644 --- a/common/widgets/lib_tree.cpp +++ b/common/widgets/lib_tree.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014 Henner Zeller - * Copyright (C) 2014-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2014-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,14 +24,12 @@ #include "lib_tree.h" #include - #include #include #include #include - -#include - +#include +#include LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, LIB_TREE_MODEL_ADAPTER::PTR& aAdapter, WIDGETS aWidgets, wxHtmlWindow* aDetails ) @@ -40,12 +38,8 @@ LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, LIB_TREE_MODEL_ADAP m_lib_table( aLibTable ), m_adapter( aAdapter ), m_query_ctrl( nullptr ), - m_details_ctrl( nullptr ), - m_menuActive( false ) + m_details_ctrl( nullptr ) { - // create space for context menu pointers, INVALID is the max value - m_menus.resize( LIB_TREE_NODE::TYPE::INVALID + 1 ); - auto sizer = new wxBoxSizer( wxVERTICAL ); // Search text control @@ -412,14 +406,15 @@ void LIB_TREE::onPreselect( wxCommandEvent& aEvent ) void LIB_TREE::onContextMenu( wxDataViewEvent& aEvent ) { - auto const sel = m_tree_ctrl->GetSelection(); - auto type = sel.IsOk() ? m_adapter->GetTypeFor( sel ) : LIB_TREE_NODE::INVALID; - - if( m_menus[type] ) + TOOL_INTERACTIVE* tool = m_adapter->GetContextMenuTool(); + + if( tool ) { - m_menuActive = true; - PopupMenu( m_menus[type].get() ); - m_menuActive = false; + tool->Activate(); + tool->GetToolMenu().ShowContextMenu(); + + TOOL_EVENT evt( TC_MOUSE, TA_MOUSE_CLICK, BUT_RIGHT ); + tool->GetManager()->DispatchContextMenu( evt ); } } diff --git a/common/widgets/lib_tree.h b/common/widgets/lib_tree.h index 9b0e01ee9c..fef7e7af15 100644 --- a/common/widgets/lib_tree.h +++ b/common/widgets/lib_tree.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014 Henner Zeller - * Copyright (C) 2014-2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2014-2019 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -32,10 +32,10 @@ class wxDataViewCtrl; class wxTextCtrl; class wxHtmlWindow; class wxHtmlLinkEvent; +class ACTION_MENU; class LIB_ID; class LIB_TABLE; - /** * Widget displaying a tree of components with optional search text control and description panel. */ @@ -89,25 +89,6 @@ public: */ void ExpandLibId( const LIB_ID& aLibId ); - /** - * Associates a right click context menu for a specific node type. - * @param aType is the node type to have a menu associated. - * @param aMenu is the associated menu. - */ - void SetMenu( LIB_TREE_NODE::TYPE aType, std::unique_ptr aMenu ) - { - m_menus[aType] = std::move( aMenu ); - } - - /** - * Returns the status of right-click context menu. - * @return True in case a right-click context menu is active. - */ - bool IsMenuActive() const - { - return m_menuActive; - } - /** * Regenerates the tree. */ @@ -170,7 +151,6 @@ protected: void onTreeSelect( wxDataViewEvent& aEvent ); void onTreeActivate( wxDataViewEvent& aEvent ); void onExpandCollapse( wxDataViewEvent& aEvent ); - void onUpdateUI( wxUpdateUIEvent& aEvent ); void onDetailsLink( wxHtmlLinkEvent& aEvent ); void onPreselect( wxCommandEvent& aEvent ); @@ -183,12 +163,6 @@ protected: wxDataViewCtrl* m_tree_ctrl; wxHtmlWindow* m_details_ctrl; - ///> Right click context menus for each tree level - std::vector> m_menus; - - ///> Flag indicating whether a right-click context menu is active - bool m_menuActive; - ///> State of the widget before any filters applied STATE m_unfilteredState; }; diff --git a/cvpcb/tools/cvpcb_selection_tool.cpp b/cvpcb/tools/cvpcb_selection_tool.cpp index e527055431..90820c074f 100644 --- a/cvpcb/tools/cvpcb_selection_tool.cpp +++ b/cvpcb/tools/cvpcb_selection_tool.cpp @@ -40,8 +40,7 @@ TOOL_ACTION CVPCB_ACTIONS::selectionActivate( "cvpcb.InteractiveSelection", CVPCB_SELECTION_TOOL::CVPCB_SELECTION_TOOL() : TOOL_INTERACTIVE( "cvpcb.InteractiveSelection" ), - m_frame( nullptr ), - m_menu( *this ) + m_frame( nullptr ) { } diff --git a/cvpcb/tools/cvpcb_selection_tool.h b/cvpcb/tools/cvpcb_selection_tool.h index 0bcc6adf39..481d9c5509 100644 --- a/cvpcb/tools/cvpcb_selection_tool.h +++ b/cvpcb/tools/cvpcb_selection_tool.h @@ -45,8 +45,6 @@ public: /// @copydoc TOOL_BASE::Reset() void Reset( RESET_REASON aReason ) override; - inline TOOL_MENU& GetToolMenu() { return m_menu; } - /** * Function Main() * @@ -72,8 +70,6 @@ private: /// Current state of selection (not really used: no selection in display footprints frame). SELECTION m_selection; - - TOOL_MENU m_menu; }; #endif diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 5bef4d7235..f924ca8184 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -35,12 +35,10 @@ #include #include #include - #include #include #include #include - #include #include #include @@ -136,7 +134,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SetShowElectricalType( true ); m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs - m_my_part = NULL; + m_my_part = nullptr; m_treePane = nullptr; m_libMgr = nullptr; m_unit = 1; @@ -169,11 +167,12 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); + setupTools(); + m_libMgr = new LIB_MANAGER( *this ); SyncLibraries( true ); m_treePane = new SYMBOL_TREE_PANE( this, m_libMgr ); - setupTools(); ReCreateMenuBar(); ReCreateHToolbar(); ReCreateVToolbar(); @@ -298,7 +297,7 @@ double LIB_EDIT_FRAME::BestZoom() void LIB_EDIT_FRAME::RebuildSymbolUnitsList() { - if( m_partSelectBox == NULL ) + if( !m_partSelectBox ) return; if( m_partSelectBox->GetCount() != 0 ) @@ -372,10 +371,10 @@ void LIB_EDIT_FRAME::OnUpdateSyncPinEdit( wxUpdateUIEvent& event ) void LIB_EDIT_FRAME::OnUpdatePartNumber( wxUpdateUIEvent& event ) { - if( m_partSelectBox == NULL ) + if( !m_partSelectBox ) return; - LIB_PART* part = GetCurPart(); + LIB_PART* part = GetCurPart(); // Using the typical event.Enable() call doesn't seem to work with wxGTK // so use the pointer to alias combobox to directly enable or disable. @@ -447,9 +446,7 @@ void LIB_EDIT_FRAME::SetCurPart( LIB_PART* aPart ) if( m_my_part != aPart ) { - if( m_my_part ) - delete m_my_part; - + delete m_my_part; m_my_part = aPart; } @@ -512,7 +509,7 @@ void LIB_EDIT_FRAME::OnAddPartToSchematic( wxCommandEvent& event ) { SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false ); - if( schframe == NULL ) // happens when the schematic editor is not active (or closed) + if( !schframe ) // happens when the schematic editor is not active (or closed) { DisplayErrorMessage( this, _( "No schematic currently open." ) ); return; @@ -525,7 +522,7 @@ void LIB_EDIT_FRAME::OnAddPartToSchematic( wxCommandEvent& event ) component->Resolve( *Prj().SchSymbolLibTable() ); if( schframe->GetAutoplaceFields() ) - component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false ); + component->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false ); schframe->Raise(); schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, component ); @@ -595,30 +592,31 @@ bool LIB_EDIT_FRAME::AddLibraryFile( bool aCreateNew ) } -LIB_PART* LIB_EDIT_FRAME::getTargetPart() const +LIB_ID LIB_EDIT_FRAME::GetTreeLIBID() const { - LIB_ALIAS* alias = nullptr; + return m_treePane->GetLibTree()->GetSelectedLibId(); +} - if( m_treePane->GetLibTree()->IsMenuActive() ) - { - LIB_ID libId = m_treePane->GetLibTree()->GetSelectedLibId(); - alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() ); - } - else if( LIB_PART* part = GetCurPart() ) + +LIB_PART* LIB_EDIT_FRAME::getTargetPart() const +{ + LIB_ID libId = GetTreeLIBID(); + + if( libId.IsValid() ) { - alias = part->GetAlias( 0 ); + LIB_ALIAS* alias = m_libMgr->GetAlias( libId.GetLibItemName(), libId.GetLibNickname() ); + return alias ? alias->GetPart() : nullptr; } - return alias ? alias->GetPart() : nullptr; + return GetCurPart(); } LIB_ID LIB_EDIT_FRAME::getTargetLibId() const { - LIB_ID id = m_treePane->GetLibTree()->GetSelectedLibId(); - wxString nickname = id.GetLibNickname(); + LIB_ID id = GetTreeLIBID(); - if( nickname.IsEmpty() && GetCurPart() ) + if( id.GetLibNickname().empty() && GetCurPart() ) id = GetCurPart()->GetLibId(); return id; diff --git a/eeschema/libedit/lib_edit_frame.h b/eeschema/libedit/lib_edit_frame.h index 018aa9ec44..3fdd671f52 100644 --- a/eeschema/libedit/lib_edit_frame.h +++ b/eeschema/libedit/lib_edit_frame.h @@ -124,7 +124,7 @@ public: public: LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ); - ~LIB_EDIT_FRAME(); + ~LIB_EDIT_FRAME() override; /** * switches currently used canvas ( Cairo / OpenGL). @@ -137,6 +137,11 @@ public: /** Sets the current library nickname and returns the old library nickname. */ wxString SetCurLib( const wxString& aLibNickname ); + /** + * Return the LIB_ID of the library or symbol selected in the symbol tree. + */ + LIB_ID GetTreeLIBID() const; + /** * Return the current part being edited or NULL if none selected. * @@ -471,9 +476,9 @@ public: void SyncMenusAndToolbars() override; - virtual void SetScreen( BASE_SCREEN* aScreen ) override; + void SetScreen( BASE_SCREEN* aScreen ) override; - virtual const BOX2I GetDocumentExtents() const override; + const BOX2I GetDocumentExtents() const override; void RebuildView(); diff --git a/eeschema/libedit/lib_manager.cpp b/eeschema/libedit/lib_manager.cpp index 3c73a6c4ba..cbe1046521 100644 --- a/eeschema/libedit/lib_manager.cpp +++ b/eeschema/libedit/lib_manager.cpp @@ -36,10 +36,11 @@ #include -LIB_MANAGER::LIB_MANAGER( LIB_EDIT_FRAME& aFrame ) - : m_frame( aFrame ), m_syncHash( 0 ) +LIB_MANAGER::LIB_MANAGER( LIB_EDIT_FRAME& aFrame ) : + m_frame( aFrame ), + m_syncHash( 0 ) { - m_adapter = SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( this ); + m_adapter = SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( &m_frame, this ); m_adapter->ShowUnits( false ); } @@ -560,7 +561,8 @@ bool LIB_MANAGER::PartExists( const wxString& aAlias, const wxString& aLibrary ) try { alias = symTable()->LoadSymbol( aLibrary, aAlias ); - } catch( IO_ERROR& ) + } + catch( IO_ERROR& ) { // checking if certain symbol exists, so its absence is perfectly fine } @@ -686,8 +688,8 @@ std::set LIB_MANAGER::getOriginalParts( const wxString& aLibrary ) } catch( const IO_ERROR& e ) { - DisplayErrorMessage( &m_frame, wxString::Format( _( "Cannot enumerate library \"%s\"" ), - aLibrary ), + DisplayErrorMessage( &m_frame, + wxString::Format( _( "Cannot enumerate library \"%s\"" ), aLibrary ), e.What() ); } @@ -713,8 +715,9 @@ LIB_MANAGER::LIB_BUFFER& LIB_MANAGER::getLibraryBuffer( const wxString& aLibrary } -LIB_MANAGER::PART_BUFFER::PART_BUFFER( LIB_PART* aPart, std::unique_ptr aScreen ) - : m_screen( std::move( aScreen ) ), m_part( aPart ) +LIB_MANAGER::PART_BUFFER::PART_BUFFER( LIB_PART* aPart, std::unique_ptr aScreen ) : + m_screen( std::move( aScreen ) ), + m_part( aPart ) { m_original = new LIB_PART( *aPart ); } diff --git a/eeschema/symbol_tree_synchronizing_adapter.cpp b/eeschema/symbol_tree_synchronizing_adapter.cpp index 8d432482d4..944d331d0a 100644 --- a/eeschema/symbol_tree_synchronizing_adapter.cpp +++ b/eeschema/symbol_tree_synchronizing_adapter.cpp @@ -26,21 +26,32 @@ #include #include #include +#include +#include -LIB_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( LIB_MANAGER* aLibMgr ) +LIB_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( LIB_EDIT_FRAME* aParent, + LIB_MANAGER* aLibMgr ) { - return PTR( new SYMBOL_TREE_SYNCHRONIZING_ADAPTER( aLibMgr ) ); + return PTR( new SYMBOL_TREE_SYNCHRONIZING_ADAPTER( aParent, aLibMgr ) ); } -SYMBOL_TREE_SYNCHRONIZING_ADAPTER::SYMBOL_TREE_SYNCHRONIZING_ADAPTER( LIB_MANAGER* aLibMgr ) - : m_libMgr( aLibMgr ), - m_lastSyncHash( -1 ) +SYMBOL_TREE_SYNCHRONIZING_ADAPTER::SYMBOL_TREE_SYNCHRONIZING_ADAPTER( LIB_EDIT_FRAME* aParent, + LIB_MANAGER* aLibMgr ) : + m_frame( aParent ), + m_libMgr( aLibMgr ), + m_lastSyncHash( -1 ) { } +TOOL_INTERACTIVE* SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetContextMenuTool() +{ + return m_frame->GetToolManager()->GetTool(); +} + + bool SYMBOL_TREE_SYNCHRONIZING_ADAPTER::IsContainer( const wxDataViewItem& aItem ) const { const LIB_TREE_NODE* node = ToNode( aItem ); @@ -181,18 +192,6 @@ LIB_TREE_NODE::PTR_VECTOR::iterator SYMBOL_TREE_SYNCHRONIZING_ADAPTER::deleteLib } -LIB_TREE_NODE* SYMBOL_TREE_SYNCHRONIZING_ADAPTER::findLibrary( const wxString& aLibNickName ) -{ - for( auto& lib : m_tree.Children ) - { - if( lib->Name == aLibNickName ) - return lib.get(); - } - - return nullptr; -} - - void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewItem const& aItem, unsigned int aCol ) const { diff --git a/eeschema/symbol_tree_synchronizing_adapter.h b/eeschema/symbol_tree_synchronizing_adapter.h index 4b1c8b6eeb..6e0563f1a4 100644 --- a/eeschema/symbol_tree_synchronizing_adapter.h +++ b/eeschema/symbol_tree_synchronizing_adapter.h @@ -28,12 +28,13 @@ #include #include +class LIB_EDIT_FRAME; class LIB_MANAGER; class SYMBOL_TREE_SYNCHRONIZING_ADAPTER : public LIB_TREE_MODEL_ADAPTER { public: - static PTR Create( LIB_MANAGER* aLibs ); + static PTR Create( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibs ); bool IsContainer( const wxDataViewItem& aItem ) const override; @@ -41,21 +42,23 @@ public: std::function aProgressCallback = [](int, int, const wxString&){} ); int GetLibrariesCount() const override; + + TOOL_INTERACTIVE* GetContextMenuTool() override; protected: void updateLibrary( LIB_TREE_NODE_LIB& aLibNode ); LIB_TREE_NODE::PTR_VECTOR::iterator deleteLibrary( LIB_TREE_NODE::PTR_VECTOR::iterator& aLibNodeIt ); - LIB_TREE_NODE* findLibrary( const wxString& aLibNickName ); - void GetValue( wxVariant& aVariant, wxDataViewItem const& aItem, unsigned int aCol ) const override; bool GetAttr( wxDataViewItem const& aItem, unsigned int aCol, wxDataViewItemAttr& aAttr ) const override; - SYMBOL_TREE_SYNCHRONIZING_ADAPTER( LIB_MANAGER* aLibMgr ); + SYMBOL_TREE_SYNCHRONIZING_ADAPTER( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMgr ); +protected: + LIB_EDIT_FRAME* m_frame; LIB_MANAGER* m_libMgr; ///> Hashes to decide whether a library needs an update diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 3fb90cd4eb..e2d02bd362 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -160,8 +160,7 @@ EE_SELECTION_TOOL::EE_SELECTION_TOOL() : m_isLibEdit( false ), m_isLibView( false ), m_unit( 0 ), - m_convert( 0 ), - m_menu( *this ) + m_convert( 0 ) { } diff --git a/eeschema/tools/ee_selection_tool.h b/eeschema/tools/ee_selection_tool.h index c3e5cfa5a6..89600444c8 100644 --- a/eeschema/tools/ee_selection_tool.h +++ b/eeschema/tools/ee_selection_tool.h @@ -81,8 +81,6 @@ public: */ SELECTION& GetSelection(); - inline TOOL_MENU& GetToolMenu() { return m_menu; } - /** * Function RequestSelection() * @@ -251,8 +249,6 @@ private: bool m_isLibView; // True when libview is the parent frame int m_unit; // Fixed unit filter (for symbol editor) int m_convert; // Fixed DeMorgan filter (for symbol editor) - - TOOL_MENU m_menu; }; #endif //KICAD_SCH_SELECTION_TOOL_H diff --git a/eeschema/tools/ee_tool_base.h b/eeschema/tools/ee_tool_base.h index e3b4efe0e8..4a3ff73468 100644 --- a/eeschema/tools/ee_tool_base.h +++ b/eeschema/tools/ee_tool_base.h @@ -59,11 +59,10 @@ public: m_frame( nullptr ), m_view( nullptr ), m_selectionTool( nullptr ), - m_isLibEdit( false ), - m_menu( *this ) + m_isLibEdit( false ) {}; - virtual ~EE_TOOL_BASE() {}; + ~EE_TOOL_BASE() override {}; /// @copydoc TOOL_INTERACTIVE::Init() bool Init() override @@ -99,9 +98,6 @@ public: m_view = static_cast( getView() ); } - ///> Get the tool's top-level context menu - inline TOOL_MENU& GetToolMenu() { return m_menu; } - protected: ///> Similar to getView()->Update(), but handles items that are redrawn by their parents. void updateView( EDA_ITEM* aItem ) const @@ -142,9 +138,6 @@ protected: KIGFX::SCH_VIEW* m_view; EE_SELECTION_TOOL* m_selectionTool; bool m_isLibEdit; - - /// Menu model displayed by the tool. - TOOL_MENU m_menu; }; #endif diff --git a/eeschema/tools/lib_control.cpp b/eeschema/tools/lib_control.cpp index f75950f418..d70136e9ee 100644 --- a/eeschema/tools/lib_control.cpp +++ b/eeschema/tools/lib_control.cpp @@ -25,9 +25,10 @@ #include #include #include +#include +#include #include #include -#include TOOL_ACTION EE_ACTIONS::showElectricalTypes( "eeschema.SymbolLibraryControl.showElectricalTypes", @@ -42,6 +43,63 @@ TOOL_ACTION EE_ACTIONS::showComponentTree( "eeschema.SymbolLibraryControl.showCo search_tree_xpm ); +bool LIB_CONTROL::Init() +{ + if( m_isLibEdit ) + { + CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu(); + LIB_EDIT_FRAME* editFrame = getEditFrame(); + + auto libSelectedCondition = [ editFrame ] ( const SELECTION& aSel ) { + LIB_ID sel = editFrame->GetTreeLIBID(); + return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty(); + }; + auto symbolSelectedCondition = [ editFrame ] ( const SELECTION& aSel ) { + LIB_ID sel = editFrame->GetTreeLIBID(); + return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty(); + }; + + ctxMenu.AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ACTIONS::save, libSelectedCondition ); + ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition ); + ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition ); + + ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( EE_ACTIONS::newSymbol, SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ID_LIBEDIT_EDIT_PART, + _( "Edit Symbol" ), _( "Show selected symbol on editor canvas" ), + edit_xpm, symbolSelectedCondition ); + + ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ACTIONS::save, symbolSelectedCondition ); + ctxMenu.AddItem( ACTIONS::saveCopyAs, symbolSelectedCondition ); + ctxMenu.AddItem( ID_LIBEDIT_DUPLICATE_PART, + _( "Duplicate" ), _( "Make a copy of the selected symbol" ), + duplicate_xpm, symbolSelectedCondition ); + ctxMenu.AddItem( ID_LIBEDIT_REMOVE_PART, + _( "Delete" ), _( "Remove the selected symbol from the library" ), + delete_xpm, symbolSelectedCondition ); + ctxMenu.AddItem( ACTIONS::revert, symbolSelectedCondition ); + + ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ID_LIBEDIT_CUT_PART, _( "Cut Symbol" ), "", + cut_xpm, symbolSelectedCondition ); + ctxMenu.AddItem( ID_LIBEDIT_COPY_PART, _( "Copy Symbol" ), "", + copy_xpm, symbolSelectedCondition ); + ctxMenu.AddItem( ID_LIBEDIT_PASTE_PART, _( "Paste Symbol" ), "", + paste_xpm, SELECTION_CONDITIONS::ShowAlways ); + + ctxMenu.AddSeparator( symbolSelectedCondition ); + ctxMenu.AddItem( EE_ACTIONS::importSymbol, SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ID_LIBEDIT_EXPORT_PART, _( "Export Symbol..." ), "", + export_part_xpm, symbolSelectedCondition ); + } + + return true; +} + + int LIB_CONTROL::AddLibrary( const TOOL_EVENT& aEvent ) { bool createNew = aEvent.IsAction( &ACTIONS::newLibrary ); diff --git a/eeschema/tools/lib_control.h b/eeschema/tools/lib_control.h index 88cac782f1..fe51c384f5 100644 --- a/eeschema/tools/lib_control.h +++ b/eeschema/tools/lib_control.h @@ -44,6 +44,9 @@ public: virtual ~LIB_CONTROL() { } + /// @copydoc TOOL_INTERACTIVE::Init() + bool Init() override; + int AddLibrary( const TOOL_EVENT& aEvent ); int AddSymbol( const TOOL_EVENT& aEvent ); diff --git a/eeschema/widgets/symbol_tree_pane.cpp b/eeschema/widgets/symbol_tree_pane.cpp index 7e951afaa1..c35eeaca6f 100644 --- a/eeschema/widgets/symbol_tree_pane.cpp +++ b/eeschema/widgets/symbol_tree_pane.cpp @@ -25,14 +25,9 @@ #include "symbol_tree_pane.h" #include -#include #include #include #include -#include -#include -#include -#include SYMBOL_TREE_PANE::SYMBOL_TREE_PANE( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMgr ) : wxPanel( aParent ), @@ -50,46 +45,6 @@ SYMBOL_TREE_PANE::SYMBOL_TREE_PANE( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMg Layout(); boxSizer->Fit( this ); - // Setup right click-context menus - std::unique_ptr menuLibrary = std::make_unique(); - - menuLibrary->Add( ACTIONS::newLibrary ); - menuLibrary->Add( ACTIONS::addLibrary ); - menuLibrary->Add( ACTIONS::save ); - menuLibrary->Add( ACTIONS::saveAs ); - menuLibrary->Add( ACTIONS::revert ); - - menuLibrary->AppendSeparator(); - menuLibrary->Add( EE_ACTIONS::newSymbol ); - menuLibrary->Add( EE_ACTIONS::importSymbol ); - menuLibrary->Add( _( "Paste Symbol" ), ID_LIBEDIT_PASTE_PART, paste_xpm ); - - std::unique_ptr menuPart = std::make_unique(); - menuPart->Add( _( "Edit Symbol" ), ID_LIBEDIT_EDIT_PART, edit_xpm ); - - menuPart->AppendSeparator(); - menuPart->Add( ACTIONS::save ); - menuPart->Add( ACTIONS::saveCopyAs ); - menuPart->Add( _( "Duplicate" ), ID_LIBEDIT_DUPLICATE_PART, duplicate_xpm ); - menuPart->Add( _( "Delete" ), ID_LIBEDIT_REMOVE_PART, delete_xpm ); - menuPart->Add( ACTIONS::revert ); - - menuPart->AppendSeparator(); - menuPart->Add( _( "Cut" ), ID_LIBEDIT_CUT_PART, cut_xpm ); - menuPart->Add( _( "Copy" ), ID_LIBEDIT_COPY_PART, copy_xpm ); - - menuPart->AppendSeparator(); - menuPart->Add( _( "Export Symbol..." ), ID_LIBEDIT_EXPORT_PART, export_part_xpm ); - - // Menu displayed when nothing is selected - std::unique_ptr menuNoSelection = std::make_unique(); - menuLibrary->Add( ACTIONS::newLibrary ); - menuLibrary->Add( ACTIONS::addLibrary ); - - m_tree->SetMenu( LIB_TREE_NODE::LIBID, std::move( menuPart ) ); - m_tree->SetMenu( LIB_TREE_NODE::LIB, std::move( menuLibrary ) ); - m_tree->SetMenu( LIB_TREE_NODE::INVALID, std::move( menuNoSelection ) ); - // Event handlers Bind( COMPONENT_SELECTED, &SYMBOL_TREE_PANE::onComponentSelected, this ); } @@ -110,8 +65,8 @@ void SYMBOL_TREE_PANE::Regenerate() void SYMBOL_TREE_PANE::onComponentSelected( wxCommandEvent& aEvent ) { - wxCommandEvent evt( ID_LIBEDIT_EDIT_PART ); - m_libEditFrame->OnEditPart( evt ); + wxCommandEvent dummy; + m_libEditFrame->OnEditPart( dummy ); // Make sure current-part highlighting doesn't get lost in seleciton highlighting m_tree->Unselect(); diff --git a/gerbview/tools/gerbview_selection_tool.cpp b/gerbview/tools/gerbview_selection_tool.cpp index 597a26ed48..32e23377c1 100644 --- a/gerbview/tools/gerbview_selection_tool.cpp +++ b/gerbview/tools/gerbview_selection_tool.cpp @@ -136,8 +136,7 @@ private: GERBVIEW_SELECTION_TOOL::GERBVIEW_SELECTION_TOOL() : TOOL_INTERACTIVE( "gerbview.InteractiveSelection" ), m_frame( NULL ), m_additive( false ), m_subtractive( false ), - m_multiple( false ), - m_menu( *this ) + m_multiple( false ) { // these members are initialized to avoid warnings about non initialized vars m_preliminary = true; diff --git a/gerbview/tools/gerbview_selection_tool.h b/gerbview/tools/gerbview_selection_tool.h index 1ee0d77b9b..c868ad0ff0 100644 --- a/gerbview/tools/gerbview_selection_tool.h +++ b/gerbview/tools/gerbview_selection_tool.h @@ -75,11 +75,6 @@ public: */ SELECTION& GetSelection(); - inline TOOL_MENU& GetToolMenu() - { - return m_menu; - } - ///> Select a single item under cursor event handler. int CursorSelection( const TOOL_EVENT& aEvent ); @@ -233,9 +228,6 @@ private: /// Determines if the selection is preliminary or final. bool m_preliminary; - - /// Menu model displayed by the tool. - TOOL_MENU m_menu; }; #endif diff --git a/include/tool/tool_interactive.h b/include/tool/tool_interactive.h index beffec4910..c943a26005 100644 --- a/include/tool/tool_interactive.h +++ b/include/tool/tool_interactive.h @@ -27,7 +27,7 @@ #define __TOOL_INTERACTIVE_H #include - +#include #include #include @@ -55,6 +55,8 @@ public: */ void Activate(); + TOOL_MENU& GetToolMenu() { return m_menu; } + /** * Function SetContextMenu() * @@ -103,15 +105,7 @@ public: void Yield( const T& returnValue );*/ protected: - /* helper functions for constructing events for Wait() and Go() with less typing */ - const TOOL_EVENT evActivate( std::string aToolName = "" ); - const TOOL_EVENT evCommand( int aCommandId = -1 ); - const TOOL_EVENT evCommand( std::string aCommandStr = "" ); - const TOOL_EVENT evMotion(); - const TOOL_EVENT evClick( int aButton = BUT_ANY ); - const TOOL_EVENT evDrag( int aButton = BUT_ANY ); - const TOOL_EVENT evButtonUp( int aButton = BUT_ANY ); - const TOOL_EVENT evButtonDown(int aButton = BUT_ANY ); + TOOL_MENU m_menu; private: /** diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index ac3e6f1221..bbd6e24ef2 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -387,6 +387,11 @@ public: m_warpMouseAfterContextMenu = false; } + /** + * Function DispatchContextMenu() + * Handles context menu related events. + */ + void DispatchContextMenu( const TOOL_EVENT& aEvent ); private: typedef std::pair TRANSITION; @@ -413,12 +418,6 @@ private: */ bool dispatchActivation( const TOOL_EVENT& aEvent ); - /** - * Function dispatchContextMenu() - * Handles context menu related events. - */ - void dispatchContextMenu( const TOOL_EVENT& aEvent ); - /** * Function invokeTool() * Invokes a tool by sending a proper event (in contrary to runTool, which makes the tool run diff --git a/pagelayout_editor/tools/pl_drawing_tools.cpp b/pagelayout_editor/tools/pl_drawing_tools.cpp index ad1130d72d..9346b469b4 100644 --- a/pagelayout_editor/tools/pl_drawing_tools.cpp +++ b/pagelayout_editor/tools/pl_drawing_tools.cpp @@ -83,8 +83,7 @@ TOOL_ACTION PL_ACTIONS::addImage( "plEditor.InteractiveDrawing.addImage", PL_DRAWING_TOOLS::PL_DRAWING_TOOLS() : TOOL_INTERACTIVE( "plEditor.InteractiveDrawing" ), m_frame( nullptr ), - m_selectionTool( nullptr ), - m_menu( *this ) + m_selectionTool( nullptr ) { } diff --git a/pagelayout_editor/tools/pl_drawing_tools.h b/pagelayout_editor/tools/pl_drawing_tools.h index ec769a0633..31452a13d6 100644 --- a/pagelayout_editor/tools/pl_drawing_tools.h +++ b/pagelayout_editor/tools/pl_drawing_tools.h @@ -50,8 +50,6 @@ public: /// @copydoc TOOL_INTERACTIVE::Reset() void Reset( RESET_REASON aReason ) override; - TOOL_MENU& GetToolMenu() { return m_menu; } - int DrawShape( const TOOL_EVENT& aEvent ); int PlaceItem( const TOOL_EVENT& aEvent ); @@ -62,9 +60,6 @@ private: private: PL_EDITOR_FRAME* m_frame; PL_SELECTION_TOOL* m_selectionTool; - - /// Menu model displayed by the tool. - TOOL_MENU m_menu; }; #endif /* PL_DRAWING_TOOLS_H */ diff --git a/pagelayout_editor/tools/pl_edit_tool.cpp b/pagelayout_editor/tools/pl_edit_tool.cpp index 71af7e1c41..a0b894def1 100644 --- a/pagelayout_editor/tools/pl_edit_tool.cpp +++ b/pagelayout_editor/tools/pl_edit_tool.cpp @@ -59,8 +59,7 @@ TOOL_ACTION PL_ACTIONS::deleteItemCursor( "plEditor.InteractiveEdit.deleteTool", PL_EDIT_TOOL::PL_EDIT_TOOL() : TOOL_INTERACTIVE( "plEditor.InteractiveEdit" ), m_frame( nullptr ), - m_selectionTool( nullptr ), - m_menu( *this ) + m_selectionTool( nullptr ) { } diff --git a/pagelayout_editor/tools/pl_edit_tool.h b/pagelayout_editor/tools/pl_edit_tool.h index b74d5238c3..87ed7f2630 100644 --- a/pagelayout_editor/tools/pl_edit_tool.h +++ b/pagelayout_editor/tools/pl_edit_tool.h @@ -80,9 +80,6 @@ private: PL_EDITOR_FRAME* m_frame; PL_SELECTION_TOOL* m_selectionTool; - /// Menu model displayed by the tool. - TOOL_MENU m_menu; - ///> Flag determining if anything is being dragged right now bool m_moveInProgress; diff --git a/pagelayout_editor/tools/pl_picker_tool.cpp b/pagelayout_editor/tools/pl_picker_tool.cpp index 5e7945df09..aa6238a5b9 100644 --- a/pagelayout_editor/tools/pl_picker_tool.cpp +++ b/pagelayout_editor/tools/pl_picker_tool.cpp @@ -34,7 +34,6 @@ TOOL_ACTION PL_ACTIONS::pickerTool( "plEditor.Picker", AS_GLOBAL, 0, "", "", NUL PL_PICKER_TOOL::PL_PICKER_TOOL() : TOOL_INTERACTIVE( "plEditor.Picker" ), m_frame( nullptr ), - m_menu( *this ), m_cursorCapture( false ), m_autoPanning( false ) { diff --git a/pagelayout_editor/tools/pl_picker_tool.h b/pagelayout_editor/tools/pl_picker_tool.h index 4643d12810..94f4085ceb 100644 --- a/pagelayout_editor/tools/pl_picker_tool.h +++ b/pagelayout_editor/tools/pl_picker_tool.h @@ -116,9 +116,6 @@ private: private: PL_EDITOR_FRAME* m_frame; - /// Menu model displayed by the tool. - TOOL_MENU m_menu; - bool m_cursorCapture; bool m_autoPanning; diff --git a/pagelayout_editor/tools/pl_selection_tool.cpp b/pagelayout_editor/tools/pl_selection_tool.cpp index 7dab7a81d1..c0a91003fa 100644 --- a/pagelayout_editor/tools/pl_selection_tool.cpp +++ b/pagelayout_editor/tools/pl_selection_tool.cpp @@ -83,8 +83,7 @@ PL_SELECTION_TOOL::PL_SELECTION_TOOL() : m_additive( false ), m_subtractive( false ), m_multiple( false ), - m_skip_heuristics( false ), - m_menu( *this ) + m_skip_heuristics( false ) { } diff --git a/pagelayout_editor/tools/pl_selection_tool.h b/pagelayout_editor/tools/pl_selection_tool.h index 04a0c0c538..962ca8c9aa 100644 --- a/pagelayout_editor/tools/pl_selection_tool.h +++ b/pagelayout_editor/tools/pl_selection_tool.h @@ -74,8 +74,6 @@ public: */ SELECTION& GetSelection(); - inline TOOL_MENU& GetToolMenu() { return m_menu; } - /** * Function RequestSelection() * @@ -210,8 +208,6 @@ private: bool m_subtractive; // Items should be removed from selection bool m_multiple; // Multiple selection mode is active bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor - - TOOL_MENU m_menu; }; #endif //PL_SELECTION_TOOL_H diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 7ad1ab4e6c..dbdb6b77d7 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -35,10 +35,8 @@ #include #include #include - #include #include - #include #include #include @@ -47,17 +45,14 @@ #include #include #include - #include #include #include #include - #include #include #include #include - #include #include #include @@ -191,12 +186,12 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); - initLibraryTree(); - m_treePane = new FOOTPRINT_TREE_PANE( this ); - // Create the manager and dispatcher & route draw panel events to the dispatcher setupTools(); + initLibraryTree(); + m_treePane = new FOOTPRINT_TREE_PANE( this ); + ReCreateMenuBar(); ReCreateHToolbar(); ReCreateVToolbar(); @@ -296,12 +291,17 @@ BOARD_ITEM_CONTAINER* FOOTPRINT_EDIT_FRAME::GetModel() const } +LIB_ID FOOTPRINT_EDIT_FRAME::GetTreeFPID() const +{ + return m_treePane->GetLibTree()->GetSelectedLibId(); +} + + LIB_ID FOOTPRINT_EDIT_FRAME::GetTargetFPID() const { - LIB_ID id = m_treePane->GetLibTree()->GetSelectedLibId(); - wxString nickname = id.GetLibNickname(); + LIB_ID id = GetTreeFPID(); - if( nickname.IsEmpty() ) + if( id.GetLibNickname().empty() ) return GetLoadedFPID(); return id; diff --git a/pcbnew/footprint_edit_frame.h b/pcbnew/footprint_edit_frame.h index f1a27777fd..7422725ae6 100644 --- a/pcbnew/footprint_edit_frame.h +++ b/pcbnew/footprint_edit_frame.h @@ -193,12 +193,16 @@ public: */ bool Clear_Pcb( bool aQuery ); - /// Return the LIB_ID of the part selected in the footprint or the part being edited. - LIB_ID GetTargetFPID() const; + /// Return the LIB_ID of the part or library selected in the footprint tree. + LIB_ID GetTreeFPID() const; /// Return the LIB_ID of the part being edited. LIB_ID GetLoadedFPID() const; + /// Return the LIB_ID of the part selected in the footprint tree, or the loaded part if + /// there is no selection in the tree. + LIB_ID GetTargetFPID() const; + /** * Perform a geometric transform on the current footprint. */ diff --git a/pcbnew/footprint_tree_pane.cpp b/pcbnew/footprint_tree_pane.cpp index fafe086d56..58fea2b464 100644 --- a/pcbnew/footprint_tree_pane.cpp +++ b/pcbnew/footprint_tree_pane.cpp @@ -23,14 +23,10 @@ #include "footprint_tree_pane.h" #include "fp_tree_synchronizing_adapter.h" -#include -#include #include #include #include #include -#include -#include FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent ) : wxPanel( aParent ), @@ -45,47 +41,7 @@ FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent ) SetSizer( boxSizer ); // should remove the previous sizer according to wxWidgets docs Layout(); boxSizer->Fit( this ); - - // Setup right click-context menus - std::unique_ptr menuLibrary = std::make_unique(); - menuLibrary->Add( ACTIONS::newLibrary ); - menuLibrary->Add( ACTIONS::addLibrary ); - menuLibrary->Add( ACTIONS::save ); - menuLibrary->Add( ACTIONS::saveAs ); - - menuLibrary->AppendSeparator(); - menuLibrary->Add( PCB_ACTIONS::newFootprint ); -#ifdef KICAD_SCRIPTING - menuLibrary->Add( PCB_ACTIONS::createFootprint ); -#endif - menuLibrary->Add( _( "Import Footprint..." ), ID_MODEDIT_IMPORT_PART, import_module_xpm ); - menuLibrary->Add( _( "Paste Footprint" ), ID_MODEDIT_PASTE_PART, paste_xpm ); - - std::unique_ptr menuPart = std::make_unique(); - menuPart->Add( _( "Edit Footprint" ), ID_MODEDIT_EDIT_MODULE, edit_xpm ); - - menuPart->AppendSeparator(); - menuPart->Add( ACTIONS::save ); - menuPart->Add( ACTIONS::saveCopyAs ); - menuPart->Add( PCB_ACTIONS::deleteFootprint ); - menuPart->Add( ACTIONS::revert ); - - menuPart->AppendSeparator(); - menuPart->Add( _( "Cut" ), ID_MODEDIT_CUT_PART, cut_xpm ); - menuPart->Add( _( "Copy" ), ID_MODEDIT_COPY_PART, copy_xpm ); - - menuPart->AppendSeparator(); - menuPart->Add( _( "Export Footprint..." ), ID_MODEDIT_EXPORT_PART, export_module_xpm ); - - // Menu displayed when nothing is selected - std::unique_ptr menuNoSelection = std::make_unique(); - menuNoSelection->Add( ACTIONS::newLibrary ); - menuNoSelection->Add( ACTIONS::addLibrary ); - - m_tree->SetMenu( LIB_TREE_NODE::LIBID, std::move( menuPart ) ); - m_tree->SetMenu( LIB_TREE_NODE::LIB, std::move( menuLibrary ) ); - m_tree->SetMenu( LIB_TREE_NODE::INVALID, std::move( menuNoSelection ) ); - + // Event handlers Bind( COMPONENT_SELECTED, &FOOTPRINT_TREE_PANE::onComponentSelected, this ); m_tree->Bind( wxEVT_UPDATE_UI, &FOOTPRINT_TREE_PANE::onUpdateUI, this ); diff --git a/pcbnew/fp_tree_synchronizing_adapter.cpp b/pcbnew/fp_tree_synchronizing_adapter.cpp index 048b52d23c..9fbd31b4d0 100644 --- a/pcbnew/fp_tree_synchronizing_adapter.cpp +++ b/pcbnew/fp_tree_synchronizing_adapter.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include LIB_TREE_MODEL_ADAPTER::PTR FP_TREE_SYNCHRONIZING_ADAPTER::Create( FOOTPRINT_EDIT_FRAME* aFrame, @@ -45,6 +47,12 @@ FP_TREE_SYNCHRONIZING_ADAPTER::FP_TREE_SYNCHRONIZING_ADAPTER( FOOTPRINT_EDIT_FRA } +TOOL_INTERACTIVE* FP_TREE_SYNCHRONIZING_ADAPTER::GetContextMenuTool() +{ + return m_frame->GetToolManager()->GetTool(); +} + + bool FP_TREE_SYNCHRONIZING_ADAPTER::IsContainer( const wxDataViewItem& aItem ) const { const LIB_TREE_NODE* node = ToNode( aItem ); diff --git a/pcbnew/fp_tree_synchronizing_adapter.h b/pcbnew/fp_tree_synchronizing_adapter.h index 7d5358a1be..016e8d2ef6 100644 --- a/pcbnew/fp_tree_synchronizing_adapter.h +++ b/pcbnew/fp_tree_synchronizing_adapter.h @@ -41,6 +41,8 @@ public: int GetLibrariesCount() const override; + TOOL_INTERACTIVE* GetContextMenuTool() override; + protected: FP_TREE_SYNCHRONIZING_ADAPTER( FOOTPRINT_EDIT_FRAME* aFrame, FP_LIB_TABLE* aLibs ); @@ -53,6 +55,7 @@ protected: bool GetAttr( wxDataViewItem const& aItem, unsigned int aCol, wxDataViewItemAttr& aAttr ) const override; +protected: FOOTPRINT_EDIT_FRAME* m_frame; std::set m_libMap; // Set to indicate libraries currently in tree }; diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index b4b008e322..3c8222b37b 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -58,12 +58,6 @@ public: /// @copydoc TOOL_INTERACTIVE::Reset() void Reset( RESET_REASON aReason ) override; - ///> Get the DRAWING_TOOL top-level context menu - inline TOOL_MENU& GetToolMenu() - { - return m_menu; - } - ///> The possible drawing modes of DRAWING_TOOL enum class MODE { diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index e5ad845b8b..033c95152f 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -207,12 +207,7 @@ bool EDIT_TOOL::Init() { // Find the selection tool, so they can cooperate m_selectionTool = static_cast( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) ); - - if( !m_selectionTool ) - { - DisplayError( NULL, _( "pcbnew.InteractiveSelection tool is not available" ) ); - return false; - } + wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" ); auto editingModuleCondition = [ this ] ( const SELECTION& aSelection ) { return m_editModules; diff --git a/pcbnew/tools/footprint_editor_tools.cpp b/pcbnew/tools/footprint_editor_tools.cpp index 5b0146249d..b0536a373c 100644 --- a/pcbnew/tools/footprint_editor_tools.cpp +++ b/pcbnew/tools/footprint_editor_tools.cpp @@ -115,7 +115,8 @@ TOOL_ACTION PCB_ACTIONS::defaultPadProperties( "pcbnew.ModuleEditor.defaultPadPr MODULE_EDITOR_TOOLS::MODULE_EDITOR_TOOLS() : - PCB_TOOL_BASE( "pcbnew.ModuleEditor" ) + PCB_TOOL_BASE( "pcbnew.ModuleEditor" ), + m_frame( nullptr ) { } @@ -127,6 +128,61 @@ MODULE_EDITOR_TOOLS::~MODULE_EDITOR_TOOLS() void MODULE_EDITOR_TOOLS::Reset( RESET_REASON aReason ) { + m_frame = getEditFrame(); +} + + +bool MODULE_EDITOR_TOOLS::Init() +{ + // Build a context menu for the footprint tree + // + CONDITIONAL_MENU& ctxMenu = m_menu.GetMenu(); + + auto libSelectedCondition = [ this ] ( const SELECTION& aSel ) { + LIB_ID sel = m_frame->GetTreeFPID(); + return !sel.GetLibNickname().empty() && sel.GetLibItemName().empty(); + }; + auto fpSelectedCondition = [ this ] ( const SELECTION& aSel ) { + LIB_ID sel = m_frame->GetTreeFPID(); + return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty(); + }; + + ctxMenu.AddItem( ACTIONS::newLibrary, SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ACTIONS::addLibrary, SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ACTIONS::save, libSelectedCondition ); + ctxMenu.AddItem( ACTIONS::saveAs, libSelectedCondition ); + ctxMenu.AddItem( ACTIONS::revert, libSelectedCondition ); + + ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( PCB_ACTIONS::newFootprint, SELECTION_CONDITIONS::ShowAlways ); +#ifdef KICAD_SCRIPTING + ctxMenu.AddItem( PCB_ACTIONS::createFootprint, SELECTION_CONDITIONS::ShowAlways ); +#endif + ctxMenu.AddItem( ID_MODEDIT_EDIT_MODULE, + _( "Edit Footprint" ), _( "Show selected footprint on editor canvas" ), + edit_xpm, fpSelectedCondition ); + + ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ACTIONS::save, fpSelectedCondition ); + ctxMenu.AddItem( ACTIONS::saveCopyAs, fpSelectedCondition ); + ctxMenu.AddItem( PCB_ACTIONS::deleteFootprint, fpSelectedCondition ); + ctxMenu.AddItem( ACTIONS::revert, fpSelectedCondition ); + + ctxMenu.AddSeparator( SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ID_MODEDIT_CUT_PART, _( "Cut Footprint" ), "", + cut_xpm, fpSelectedCondition ); + ctxMenu.AddItem( ID_MODEDIT_COPY_PART, _( "Copy Footprint" ), "", + copy_xpm, fpSelectedCondition ); + ctxMenu.AddItem( ID_MODEDIT_PASTE_PART, _( "Paste Footprint" ), "", + paste_xpm, SELECTION_CONDITIONS::ShowAlways ); + + ctxMenu.AddSeparator( fpSelectedCondition ); + ctxMenu.AddItem( ID_MODEDIT_IMPORT_PART, _( "Import Footprint..." ), "", + import_module_xpm, SELECTION_CONDITIONS::ShowAlways ); + ctxMenu.AddItem( ID_MODEDIT_EXPORT_PART, _( "Export Footprint..." ), "", + export_module_xpm, fpSelectedCondition ); + + return true; } @@ -187,12 +243,12 @@ int MODULE_EDITOR_TOOLS::Delete( const TOOL_EVENT& aEvent ) int MODULE_EDITOR_TOOLS::Properties( const TOOL_EVENT& aEvent ) { - MODULE* footprint = frame()->GetBoard()->GetFirstModule(); + MODULE* footprint = m_frame->GetBoard()->GetFirstModule(); if( footprint ) { getEditFrame()->OnEditItemRequest( footprint ); - frame()->GetGalCanvas()->Refresh(); + m_frame->GetGalCanvas()->Refresh(); } return 0; } @@ -235,13 +291,13 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent ) PAD_PLACER placer; - frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) ); + m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) ); wxASSERT( board()->GetFirstModule() ); doInteractiveItemPlacement( &placer, _( "Place pad" ), IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP ); - frame()->SetNoToolSelected(); + m_frame->SetNoToolSelected(); return 0; } @@ -252,7 +308,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent ) if( !board()->GetFirstModule() || !board()->GetFirstModule()->Pads().empty() ) return 0; - DIALOG_ENUM_PADS settingsDlg( frame() ); + DIALOG_ENUM_PADS settingsDlg( m_frame ); if( settingsDlg.ShowModal() != wxID_OK ) return 0; @@ -262,7 +318,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent ) GENERAL_COLLECTOR collector; const KICAD_T types[] = { PCB_PAD_T, EOT }; - GENERAL_COLLECTORS_GUIDE guide = frame()->GetCollectorsGuide(); + GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide(); guide.SetIgnoreMTextsMarkedNoShow( true ); guide.SetIgnoreMTextsOnBack( true ); guide.SetIgnoreMTextsOnFront( true ); @@ -273,7 +329,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent ) wxString padPrefix = settingsDlg.GetPrefix(); std::deque storedPadNumbers; - frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_HAND, + m_frame->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_HAND, _( "Click on successive pads to renumber them" ) ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); @@ -282,11 +338,11 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent ) KIGFX::VIEW* view = m_toolMgr->GetView(); VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag std::list selectedPads; - BOARD_COMMIT commit( frame() ); + BOARD_COMMIT commit( m_frame ); std::map> oldNames; bool isFirstPoint = true; // used to be sure oldCursorPos will be initialized at least once. - STATUS_TEXT_POPUP statusPopup( frame() ); + STATUS_TEXT_POPUP statusPopup( m_frame ); statusPopup.SetText( wxString::Format( _( "Click on pad %s%d\nPress Escape to cancel or double-click to commit" ), padPrefix.c_str(), seqPadNum ) ); @@ -432,8 +488,8 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent ) } statusPopup.Hide(); - frame()->SetNoToolSelected(); - frame()->GetGalCanvas()->SetCursor( wxCURSOR_ARROW ); + m_frame->SetNoToolSelected(); + m_frame->GetGalCanvas()->SetCursor( wxCURSOR_ARROW ); return 0; } @@ -442,7 +498,7 @@ int MODULE_EDITOR_TOOLS::EnumeratePads( const TOOL_EVENT& aEvent ) int MODULE_EDITOR_TOOLS::ExplodePadToShapes( const TOOL_EVENT& aEvent ) { SELECTION& selection = m_toolMgr->GetTool()->GetSelection(); - BOARD_COMMIT commit( frame() ); + BOARD_COMMIT commit( m_frame ); if( selection.Size() != 1 ) return 0; @@ -499,7 +555,7 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) std::vector shapes; - BOARD_COMMIT commit( frame() ); + BOARD_COMMIT commit( m_frame ); for( auto item : selection ) { @@ -549,18 +605,17 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) if( multipleRefPadsFound ) { - DisplayErrorMessage( frame(), - _( "Cannot convert items to a custom-shaped pad:\n" - "selection contains more than one reference pad." ) ); + DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n" + "selection contains more than one reference pad." ) ); return 0; } if( illegalItemsFound ) { - DisplayErrorMessage( frame(), - _( "Cannot convert items to a custom-shaped pad:\n" - "selection contains unsupported items.\n" - "Only graphical lines, circles, arcs and polygons are allowed." ) ); + DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n" + "selection contains unsupported items.\n" + "Only graphical lines, circles, arcs and polygons " + "are allowed." ) ); return 0; } @@ -603,10 +658,10 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) if( !anchor ) { - DisplayErrorMessage( frame(), - _( "Cannot convert items to a custom-shaped pad:\n" - "unable to determine the anchor point position.\n" - "Consider adding a small anchor pad to the selection and try again.") ); + DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n" + "unable to determine the anchor point position.\n" + "Consider adding a small anchor pad to the selection " + "and try again.") ); return 0; } @@ -626,9 +681,8 @@ int MODULE_EDITOR_TOOLS::CreatePadFromShapes( const TOOL_EVENT& aEvent ) if( !result ) { - DisplayErrorMessage( frame(), - _( "Cannot convert items to a custom-shaped pad:\n" - "selected items do not form a single solid shape.") ); + DisplayErrorMessage( m_frame, _( "Cannot convert items to a custom-shaped pad:\n" + "selected items do not form a single solid shape.") ); return 0; } diff --git a/pcbnew/tools/footprint_editor_tools.h b/pcbnew/tools/footprint_editor_tools.h index e360dcea22..1837a75a26 100644 --- a/pcbnew/tools/footprint_editor_tools.h +++ b/pcbnew/tools/footprint_editor_tools.h @@ -27,13 +27,9 @@ #include -namespace KIGFX -{ - class VIEW; - class VIEW_CONTROLS; -} -class BOARD; -class PCB_EDIT_FRAME; + +class FOOTPRINT_EDIT_FRAME; + /** * Class MODULE_EDITOR_TOOLS @@ -44,11 +40,14 @@ class MODULE_EDITOR_TOOLS : public PCB_TOOL_BASE { public: MODULE_EDITOR_TOOLS(); - ~MODULE_EDITOR_TOOLS(); + ~MODULE_EDITOR_TOOLS() override; /// @copydoc TOOL_INTERACTIVE::Reset() void Reset( RESET_REASON aReason ) override; + /// @copydoc TOOL_INTERACTIVE::Init() + bool Init() override; + int NewFootprint( const TOOL_EVENT& aEvent ); int CreateFootprint( const TOOL_EVENT& aEvent ); @@ -101,6 +100,8 @@ private: ///> Sets up handlers for various events. void setTransitions() override; +private: + FOOTPRINT_EDIT_FRAME* m_frame; }; #endif diff --git a/pcbnew/tools/global_edit_tool.cpp b/pcbnew/tools/global_edit_tool.cpp index 579d9f0c70..ffbe8ab70b 100644 --- a/pcbnew/tools/global_edit_tool.cpp +++ b/pcbnew/tools/global_edit_tool.cpp @@ -101,7 +101,6 @@ bool GLOBAL_EDIT_TOOL::Init() { // Find the selection tool, so they can cooperate m_selectionTool = static_cast( m_toolMgr->FindTool( "pcbnew.InteractiveSelection" ) ); - wxASSERT_MSG( m_selectionTool, "pcbnew.InteractiveSelection tool is not available" ); return true; diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index be1ada17fd..82f340a1fd 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -329,8 +329,7 @@ public: PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() : PCB_TOOL_BASE( "pcbnew.EditorControl" ), - m_frame( nullptr ), - m_menu( *this ) + m_frame( nullptr ) { m_placeOrigin.reset( new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ), KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS ) ); diff --git a/pcbnew/tools/pcb_editor_control.h b/pcbnew/tools/pcb_editor_control.h index 4cf279c8b7..8a7675737f 100644 --- a/pcbnew/tools/pcb_editor_control.h +++ b/pcbnew/tools/pcb_editor_control.h @@ -159,9 +159,6 @@ private: ///> Pointer to the currently used edit frame. PCB_EDIT_FRAME* m_frame; - /// Menu model displayed by the tool. - TOOL_MENU m_menu; - std::unique_ptr m_placeOrigin; ///> Place & drill origin marker bool m_probingSchToPcb; ///> Recursion guard when cross-probing to EESchema diff --git a/pcbnew/tools/pcb_tool_base.cpp b/pcbnew/tools/pcb_tool_base.cpp index c61a111274..16c534065b 100644 --- a/pcbnew/tools/pcb_tool_base.cpp +++ b/pcbnew/tools/pcb_tool_base.cpp @@ -21,24 +21,20 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - #include "pcb_tool_base.h" #include #include #include #include - #include #include - #include "selection_tool.h" #include "pcb_actions.h" #include "tool_event_utils.h" void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer, - const wxString& aCommitMessage, - int aOptions ) + const wxString& aCommitMessage, int aOptions ) { using namespace std::placeholders; std::unique_ptr newItem; @@ -211,6 +207,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer view()->Remove( &preview ); } + bool PCB_TOOL_BASE::Init() { // A basic context manu. Many (but not all) tools will choose to override this. @@ -230,14 +227,14 @@ bool PCB_TOOL_BASE::Init() void PCB_TOOL_BASE::Reset( RESET_REASON aReason ) { - } + void PCB_TOOL_BASE::setTransitions() { - } + PCB_DISPLAY_OPTIONS* PCB_TOOL_BASE::displayOptions() const { return static_cast( frame()->GetDisplayOptions() ); @@ -248,6 +245,7 @@ PCB_DRAW_PANEL_GAL* PCB_TOOL_BASE::canvas() const return static_cast( frame()->GetGalCanvas() ); } + const SELECTION& PCB_TOOL_BASE::selection() const { auto selTool = m_toolMgr->GetTool(); @@ -255,6 +253,7 @@ const SELECTION& PCB_TOOL_BASE::selection() const return selection; } + SELECTION& PCB_TOOL_BASE::selection() { auto selTool = m_toolMgr->GetTool(); @@ -268,6 +267,7 @@ void INTERACTIVE_PLACER_BASE::SnapItem( BOARD_ITEM *aItem ) // Base implementation performs no snapping } + bool INTERACTIVE_PLACER_BASE::PlaceItem( BOARD_ITEM *aItem, BOARD_COMMIT& aCommit ) { aCommit.Add( aItem ); diff --git a/pcbnew/tools/pcb_tool_base.h b/pcbnew/tools/pcb_tool_base.h index 5143a5f7fd..d0702feb5b 100644 --- a/pcbnew/tools/pcb_tool_base.h +++ b/pcbnew/tools/pcb_tool_base.h @@ -70,8 +70,8 @@ public: * Creates a tool with given id & name. The name must be unique. */ PCB_TOOL_BASE( TOOL_ID aId, const std::string& aName ) : TOOL_INTERACTIVE ( aId, aName ), - m_menu( *this ), - m_editModules( false ) {}; + m_editModules( false ) + {}; /** * Constructor @@ -79,8 +79,8 @@ public: * Creates a tool with given name. The name must be unique. */ PCB_TOOL_BASE( const std::string& aName ) : TOOL_INTERACTIVE ( aName ), - m_menu( *this ), - m_editModules( false ) {}; + m_editModules( false ) + {}; virtual ~PCB_TOOL_BASE() {}; @@ -147,9 +147,6 @@ protected: const SELECTION& selection() const; SELECTION& selection(); - /// Menu model displayed by the tool. - TOOL_MENU m_menu; - bool m_editModules; }; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index f4c12ba97b..035208956f 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -194,7 +194,6 @@ SELECTION_TOOL::SELECTION_TOOL() : m_multiple( false ), m_skip_heuristics( false ), m_locked( true ), - m_menu( *this ), m_priv( std::make_unique() ) { } diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index bffae6e918..b0d75ebde9 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -96,13 +96,7 @@ public: * @param aFiltered is an optional vector, that is filled with items removed by the filter */ SELECTION& RequestSelection( CLIENT_SELECTION_FILTER aClientFilter, - std::vector* aFiltered = NULL, bool aConfirmLockedItems = false ); - - - inline TOOL_MENU& GetToolMenu() - { - return m_menu; - } + std::vector* aFiltered = nullptr, bool aConfirmLockedItems = false ); ///> Checks if the user has agreed to modify locked items for the given selection. SELECTION_LOCK_FLAGS CheckLock(); @@ -354,8 +348,6 @@ private: bool m_skip_heuristics; // Heuristics are not allowed when choosing item under cursor bool m_locked; // Other tools are not allowed to modify locked items - TOOL_MENU m_menu; - /// Private state (opaque pointer/compilation firewall) class PRIV; std::unique_ptr m_priv;