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;
|
void Reset( RESET_REASON aReason ) override;
|
||||||
|
|
||||||
///> Get the DRAWING_TOOL top-level context menu
|
///> 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
|
///> 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
|
// 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::editActivate, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( COMMON_ACTIONS::rotate, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( COMMON_ACTIONS::rotate, SELECTION_CONDITIONS::NotEmpty );
|
||||||
menu.AddItem( COMMON_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
|
menu.AddItem( COMMON_ACTIONS::flip, SELECTION_CONDITIONS::NotEmpty );
|
||||||
|
|
|
@ -96,7 +96,7 @@ bool MODULE_TOOLS::Init()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectionTool->GetMenu().AddItem( COMMON_ACTIONS::enumeratePads );
|
selectionTool->GetToolMenu().GetMenu().AddItem( COMMON_ACTIONS::enumeratePads );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public:
|
||||||
|
|
||||||
PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
|
PCB_EDITOR_CONTROL::PCB_EDITOR_CONTROL() :
|
||||||
TOOL_INTERACTIVE( "pcbnew.EditorControl" ),
|
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 ),
|
m_placeOrigin = new KIGFX::ORIGIN_VIEWITEM( KIGFX::COLOR4D( 0.8, 0.0, 0.0, 1.0 ),
|
||||||
KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS );
|
KIGFX::ORIGIN_VIEWITEM::CIRCLE_CROSS );
|
||||||
|
@ -118,8 +118,6 @@ PCB_EDITOR_CONTROL::~PCB_EDITOR_CONTROL()
|
||||||
getView()->Remove( m_placeOrigin );
|
getView()->Remove( m_placeOrigin );
|
||||||
|
|
||||||
delete 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()
|
bool PCB_EDITOR_CONTROL::Init()
|
||||||
{
|
{
|
||||||
m_zoneMenu = new ZONE_CONTEXT_MENU;
|
auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
|
||||||
m_zoneMenu->SetTool( this );
|
zoneMenu->SetTool( this );
|
||||||
|
|
||||||
m_lockMenu = new LOCK_CONTEXT_MENU;
|
auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
|
||||||
m_lockMenu->SetTool( this );
|
lockMenu->SetTool( this );
|
||||||
|
|
||||||
// Add the PCB control menus to relevant other tools
|
// Add the PCB control menus to relevant other tools
|
||||||
|
|
||||||
|
@ -150,17 +148,28 @@ bool PCB_EDITOR_CONTROL::Init()
|
||||||
|
|
||||||
if( selTool )
|
if( selTool )
|
||||||
{
|
{
|
||||||
selTool->GetMenu().AddMenu( m_zoneMenu, _( "Zones" ), false,
|
auto& toolMenu = selTool->GetToolMenu();
|
||||||
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
|
auto& menu = toolMenu.GetMenu();
|
||||||
|
|
||||||
selTool->GetMenu().AddMenu( m_lockMenu, _( "Locking" ), false,
|
toolMenu.AddSubMenu( zoneMenu );
|
||||||
SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
|
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>();
|
DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
|
||||||
|
|
||||||
if( drawingTool )
|
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
|
// Functor to say if the PCB_EDIT_FRAME is in a given mode
|
||||||
// Capture the tool pointer and tool mode by value
|
// Capture the tool pointer and tool mode by value
|
||||||
auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
|
auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
|
||||||
|
@ -171,8 +180,8 @@ bool PCB_EDITOR_CONTROL::Init()
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
drawingTool->GetMenu().AddMenu( m_zoneMenu, _( "Zones" ), false,
|
menu.AddMenu( zoneMenu.get(), _( "Zones" ), false,
|
||||||
toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
|
toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -32,8 +32,6 @@ namespace KIGFX {
|
||||||
}
|
}
|
||||||
|
|
||||||
class PCB_EDIT_FRAME;
|
class PCB_EDIT_FRAME;
|
||||||
class ZONE_CONTEXT_MENU;
|
|
||||||
class LOCK_CONTEXT_MENU;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PCB_EDITOR_CONTROL
|
* Class PCB_EDITOR_CONTROL
|
||||||
|
@ -121,9 +119,6 @@ private:
|
||||||
|
|
||||||
// How does line width change after one -/+ key press.
|
// How does line width change after one -/+ key press.
|
||||||
static const int WIDTH_STEP;
|
static const int WIDTH_STEP;
|
||||||
|
|
||||||
ZONE_CONTEXT_MENU* m_zoneMenu;
|
|
||||||
LOCK_CONTEXT_MENU* m_lockMenu;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -77,8 +77,9 @@ bool PLACEMENT_TOOL::Init()
|
||||||
item = m_placementMenu->Add( COMMON_ACTIONS::distributeVertically );
|
item = m_placementMenu->Add( COMMON_ACTIONS::distributeVertically );
|
||||||
SET_BITMAP( KiBitmap( distribute_vertical_xpm ) );
|
SET_BITMAP( KiBitmap( distribute_vertical_xpm ) );
|
||||||
|
|
||||||
m_selectionTool->GetMenu().AddMenu( m_placementMenu, _( "Align/distribute" ), false,
|
m_selectionTool->GetToolMenu().GetMenu().AddMenu(
|
||||||
SELECTION_CONDITIONS::MoreThan( 1 ) );
|
m_placementMenu, _( "Align/distribute" ), false,
|
||||||
|
SELECTION_CONDITIONS::MoreThan( 1 ) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,10 +211,11 @@ bool POINT_EDITOR::Init()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_selectionTool->GetMenu().AddItem( COMMON_ACTIONS::pointEditorAddCorner,
|
auto& menu = m_selectionTool->GetToolMenu().GetMenu();
|
||||||
POINT_EDITOR::addCornerCondition );
|
menu.AddItem( COMMON_ACTIONS::pointEditorAddCorner,
|
||||||
m_selectionTool->GetMenu().AddItem( COMMON_ACTIONS::pointEditorRemoveCorner,
|
POINT_EDITOR::addCornerCondition );
|
||||||
std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
|
menu.AddItem( COMMON_ACTIONS::pointEditorRemoveCorner,
|
||||||
|
std::bind( &POINT_EDITOR::removeCornerCondition, this, _1 ) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,9 +193,9 @@ public:
|
||||||
*/
|
*/
|
||||||
SELECTION& GetSelection();
|
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.
|
///> Checks if the user has agreed to modify locked items for the given selection.
|
||||||
|
|
Loading…
Reference in New Issue