Access tools' TOOL_MENUs rather than CONDITIONAL_MENUs
This means that non-top-level tools, for example EDIT_TOOL and PCB_EDITOR_CONTROL can submit their own menus to the top-level tool's TOOL_MENU, which will then retain a reference to it and make it available for the CONTEXT_MENU that is shown.
This commit is contained in:
parent
d7db84e282
commit
c50d28d94d
|
@ -58,9 +58,9 @@ public:
|
|||
void Reset( RESET_REASON aReason ) override;
|
||||
|
||||
///> Get the DRAWING_TOOL top-level context menu
|
||||
inline CONDITIONAL_MENU& GetMenu()
|
||||
inline TOOL_MENU& GetToolMenu()
|
||||
{
|
||||
return m_menu.GetMenu();
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
///> The possible drawing modes of DRAWING_TOOL
|
||||
|
|
|
@ -87,7 +87,7 @@ bool EDIT_TOOL::Init()
|
|||
}
|
||||
|
||||
// Add context menu entries that are displayed when selection tool is active
|
||||
CONDITIONAL_MENU& menu = m_selectionTool->GetMenu();
|
||||
CONDITIONAL_MENU& menu = m_selectionTool->GetToolMenu().GetMenu();
|
||||
menu.AddItem( COMMON_ACTIONS::editActivate, SELECTION_CONDITIONS::NotEmpty );
|
||||
menu.AddItem( COMMON_ACTIONS::rotate, SELECTION_CONDITIONS::NotEmpty );
|
||||
menu.AddItem( COMMON_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
|
||||
|
|
|
@ -96,7 +96,7 @@ bool MODULE_TOOLS::Init()
|
|||
return false;
|
||||
}
|
||||
|
||||
selectionTool->GetMenu().AddItem( COMMON_ACTIONS::enumeratePads );
|
||||
selectionTool->GetToolMenu().GetMenu().AddItem( COMMON_ACTIONS::enumeratePads );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
|
||||
PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
|
||||
TOOL_INTERACTIVE( "pcbnew.EditorControl" ),
|
||||
m_frame( NULL ), m_zoneMenu( NULL ), m_lockMenu( NULL )
|
||||
m_frame( nullptr )
|
||||
{
|
||||
m_placeOrigin = new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
|
||||
KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS );
|
||||
|
@ -118,8 +118,6 @@ PCB_EDITOR_CONTROL::~PCB_EDITOR_CONTROL()
|
|||
getView()->Remove( m_placeOrigin );
|
||||
|
||||
delete m_placeOrigin;
|
||||
delete m_zoneMenu;
|
||||
delete m_lockMenu;
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,11 +136,11 @@ void PCB_EDITOR_CONTROL::Reset( RESET_REASON aReason )
|
|||
|
||||
bool PCB_EDITOR_CONTROL::Init()
|
||||
{
|
||||
m_zoneMenu = new ZONE_CONTEXT_MENU;
|
||||
m_zoneMenu->SetTool( this );
|
||||
auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
|
||||
zoneMenu->SetTool( this );
|
||||
|
||||
m_lockMenu = new LOCK_CONTEXT_MENU;
|
||||
m_lockMenu->SetTool( this );
|
||||
auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
|
||||
lockMenu->SetTool( this );
|
||||
|
||||
// Add the PCB control menus to relevant other tools
|
||||
|
||||
|
@ -150,17 +148,28 @@ bool PCB_EDITOR_CONTROL::Init()
|
|||
|
||||
if( selTool )
|
||||
{
|
||||
selTool->GetMenu().AddMenu( m_zoneMenu, _( "Zones" ), false,
|
||||
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
|
||||
auto& toolMenu = selTool->GetToolMenu();
|
||||
auto& menu = toolMenu.GetMenu();
|
||||
|
||||
selTool->GetMenu().AddMenu( m_lockMenu, _( "Locking" ), false,
|
||||
SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
||||
toolMenu.AddSubMenu( zoneMenu );
|
||||
toolMenu.AddSubMenu( lockMenu );
|
||||
|
||||
menu.AddMenu( zoneMenu.get(), _( "Zones" ), false,
|
||||
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
|
||||
|
||||
menu.AddMenu( lockMenu.get(), _( "Locking" ), false,
|
||||
SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
||||
}
|
||||
|
||||
DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
|
||||
|
||||
if( drawingTool )
|
||||
{
|
||||
auto& toolMenu = drawingTool->GetToolMenu();
|
||||
auto& menu = toolMenu.GetMenu();
|
||||
|
||||
toolMenu.AddSubMenu( zoneMenu );
|
||||
|
||||
// Functor to say if the PCB_EDIT_FRAME is in a given mode
|
||||
// Capture the tool pointer and tool mode by value
|
||||
auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
|
||||
|
@ -171,8 +180,8 @@ bool PCB_EDITOR_CONTROL::Init()
|
|||
};
|
||||
};
|
||||
|
||||
drawingTool->GetMenu().AddMenu( m_zoneMenu, _( "Zones" ), false,
|
||||
toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
|
||||
menu.AddMenu( zoneMenu.get(), _( "Zones" ), false,
|
||||
toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -32,8 +32,6 @@ namespace KIGFX {
|
|||
}
|
||||
|
||||
class PCB_EDIT_FRAME;
|
||||
class ZONE_CONTEXT_MENU;
|
||||
class LOCK_CONTEXT_MENU;
|
||||
|
||||
/**
|
||||
* Class PCB_EDITOR_CONTROL
|
||||
|
@ -121,9 +119,6 @@ private:
|
|||
|
||||
// How does line width change after one -/+ key press.
|
||||
static const int WIDTH_STEP;
|
||||
|
||||
ZONE_CONTEXT_MENU* m_zoneMenu;
|
||||
LOCK_CONTEXT_MENU* m_lockMenu;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -77,8 +77,9 @@ bool PLACEMENT_TOOL::Init()
|
|||
item = m_placementMenu->Add( COMMON_ACTIONS::distributeVertically );
|
||||
SET_BITMAP( KiBitmap( distribute_vertical_xpm ) );
|
||||
|
||||
m_selectionTool->GetMenu().AddMenu( m_placementMenu, _( "Align/distribute" ), false,
|
||||
SELECTION_CONDITIONS::MoreThan( 1 ) );
|
||||
m_selectionTool->GetToolMenu().GetMenu().AddMenu(
|
||||
m_placementMenu, _( "Align/distribute" ), false,
|
||||
SELECTION_CONDITIONS::MoreThan( 1 ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -211,10 +211,11 @@ bool POINT_EDITOR::Init()
|
|||
return false;
|
||||
}
|
||||
|
||||
m_selectionTool->GetMenu().AddItem( COMMON_ACTIONS::pointEditorAddCorner,
|
||||
POINT_EDITOR::addCornerCondition );
|
||||
m_selectionTool->GetMenu().AddItem( COMMON_ACTIONS::pointEditorRemoveCorner,
|
||||
std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
|
||||
auto& menu = m_selectionTool->GetToolMenu().GetMenu();
|
||||
menu.AddItem( COMMON_ACTIONS::pointEditorAddCorner,
|
||||
POINT_EDITOR::addCornerCondition );
|
||||
menu.AddItem( COMMON_ACTIONS::pointEditorRemoveCorner,
|
||||
std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -193,9 +193,9 @@ public:
|
|||
*/
|
||||
SELECTION& GetSelection();
|
||||
|
||||
inline CONDITIONAL_MENU& GetMenu()
|
||||
inline TOOL_MENU& GetToolMenu()
|
||||
{
|
||||
return m_menu.GetMenu();
|
||||
return m_menu;
|
||||
}
|
||||
|
||||
///> Checks if the user has agreed to modify locked items for the given selection.
|
||||
|
|
Loading…
Reference in New Issue