From 8bddf33ab5690c2f8d85602635be00b5c076f924 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 9 Jul 2014 14:23:13 +0200 Subject: [PATCH] Context menu for the Placement Tool. --- pcbnew/router/router_tool.cpp | 2 +- pcbnew/tools/placement_tool.cpp | 11 ++++++++++- pcbnew/tools/selection_tool.cpp | 6 ++++++ pcbnew/tools/selection_tool.h | 9 +++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index f961722180..312b060920 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -220,7 +220,7 @@ public: Add( ACT_CustomTrackWidth ); - AppendSeparator ( ); + AppendSeparator(); Add( ACT_RouterOptions ); } }; diff --git a/pcbnew/tools/placement_tool.cpp b/pcbnew/tools/placement_tool.cpp index 05ac2522ba..5305d855ee 100644 --- a/pcbnew/tools/placement_tool.cpp +++ b/pcbnew/tools/placement_tool.cpp @@ -54,7 +54,16 @@ bool PLACEMENT_TOOL::Init() return false; } - // TODO create a context menu and add it to the selection tool + // Create a context menu and make it available through selection tool + CONTEXT_MENU* menu = new CONTEXT_MENU; + menu->Add( COMMON_ACTIONS::alignTop ); + menu->Add( COMMON_ACTIONS::alignBottom ); + menu->Add( COMMON_ACTIONS::alignLeft ); + menu->Add( COMMON_ACTIONS::alignRight ); + menu->AppendSeparator(); + menu->Add( COMMON_ACTIONS::distributeHorizontally ); + menu->Add( COMMON_ACTIONS::distributeVertically ); + m_selectionTool->AddSubMenu( menu, wxString( "Placement" ) ); setTransitions(); diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index ac9f1aa51c..d0abb1d60a 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -198,6 +198,12 @@ void SELECTION_TOOL::AddMenuItem( const TOOL_ACTION& aAction ) } +void SELECTION_TOOL::AddSubMenu( CONTEXT_MENU* aMenu, const wxString& aLabel ) +{ + m_menu.AppendSubMenu( aMenu, aLabel ); +} + + void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem ) { if( aItem->IsSelected() ) diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 6f5e06606d..4891610d16 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -122,6 +122,15 @@ public: */ void AddMenuItem( const TOOL_ACTION& aAction ); + /** + * Function AddSubMenu() + * + * Adds a submenu to the selection tool right-click context menu. + * @param aMenu is the submenu to be added. + * @param aLabel is the label of added submenu. + */ + void AddSubMenu( CONTEXT_MENU* aMenu, const wxString& aLabel ); + /** * Function EditModules() * Toggles edit module mode. When enabled, one may select parts of modules individually