KiCad PCB EDA Suite
TOOL_MENU Class Reference

Manage a CONDITIONAL_MENU and some number of CONTEXT_MENUs as sub-menus. More...

#include <tool_menu.h>

Public Member Functions

 TOOL_MENU (TOOL_INTERACTIVE &aTool)
 Construct a new TOOL_MENU for a specific tool. More...
 
 ~TOOL_MENU ()
 Destruct any submenus created with TOOL_MENU::CreateSubMenu(). More...
 
CONDITIONAL_MENUGetMenu ()
 
void RegisterSubMenu (std::shared_ptr< ACTION_MENU > aSubMenu)
 Store a submenu of this menu model. More...
 
std::vector< std::shared_ptr< ACTION_MENU > > & GetSubMenus ()
 
void ShowContextMenu (SELECTION &aSelection)
 Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION. More...
 
void ShowContextMenu ()
 Helper function to show a context menu without any selection for tools that can't make selections. More...
 

Private Attributes

CONDITIONAL_MENU m_menu
 The conditional menu displayed by the tool. More...
 
TOOL_INTERACTIVEm_tool
 The tool that owns this menu. More...
 
std::vector< std::shared_ptr< ACTION_MENU > > m_subMenus
 Lifetime-managing container of submenus. More...
 

Detailed Description

Manage a CONDITIONAL_MENU and some number of CONTEXT_MENUs as sub-menus.

Each "top-level" interactive tool can have one of these, and other tools can contribute #CONTEXT_MENUS to it. There are also helper functions for adding common sets of menu items, for example zoom and grid controls.

Definition at line 42 of file tool_menu.h.

Constructor & Destructor Documentation

◆ TOOL_MENU()

TOOL_MENU::TOOL_MENU ( TOOL_INTERACTIVE aTool)

Construct a new TOOL_MENU for a specific tool.

This menu will be empty - it's up to the caller to add the relevant items. This can be done directly, using the reference returned by TOOL_MENU::GetMenu(), or the helpers for common command sets can be used, or a combination of the two.

Definition at line 32 of file tool_menu.cpp.

32 :
33 m_menu( &aTool ),
34 m_tool( aTool )
35{
36}
TOOL_INTERACTIVE & m_tool
The tool that owns this menu.
Definition: tool_menu.h:110
CONDITIONAL_MENU m_menu
The conditional menu displayed by the tool.
Definition: tool_menu.h:105

◆ ~TOOL_MENU()

TOOL_MENU::~TOOL_MENU ( )

Destruct any submenus created with TOOL_MENU::CreateSubMenu().

Definition at line 39 of file tool_menu.cpp.

40{
41}

Member Function Documentation

◆ GetMenu()

◆ GetSubMenus()

std::vector< std::shared_ptr< ACTION_MENU > > & TOOL_MENU::GetSubMenus ( )
inline
Returns
the list of submenus from this menu

Definition at line 80 of file tool_menu.h.

81 {
82 return m_subMenus;
83 }
std::vector< std::shared_ptr< ACTION_MENU > > m_subMenus
Lifetime-managing container of submenus.
Definition: tool_menu.h:115

References m_subMenus.

◆ RegisterSubMenu()

void TOOL_MENU::RegisterSubMenu ( std::shared_ptr< ACTION_MENU aSubMenu)

Store a submenu of this menu model.

This can be shared with other menu models.

It is the callers responsibility to add the submenu to m_menu (via GetMenu() ) in the right way, as well as to set the tool with SetTool(), since it's not a given that the menu's tool is the tool that directly owns this TOOL_MENU.

Parameters
aSubMenua sub menu to add

Definition at line 50 of file tool_menu.cpp.

51{
52 // store a copy of the menu (keeps a reference)
53 m_subMenus.push_back( std::move( aSubMenu ) );
54}

References m_subMenus.

Referenced by EDA_DRAW_FRAME::AddStandardSubMenus(), SCH_EDIT_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), GERBVIEW_SELECTION_TOOL::Init(), ROUTER_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), BOARD_INSPECTION_TOOL::Init(), DRAWING_TOOL::Init(), EDIT_TOOL::Init(), GROUP_TOOL::Init(), and PCB_SELECTION_TOOL::Init().

◆ ShowContextMenu() [1/2]

void TOOL_MENU::ShowContextMenu ( )

Helper function to show a context menu without any selection for tools that can't make selections.

Definition at line 66 of file tool_menu.cpp.

67{
70}
void SetDirty()
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Assign a context menu and tells when it should be activated.
@ CMENU_NOW
Definition: tool_event.h:148

References CMENU_NOW, m_menu, m_tool, TOOL_INTERACTIVE::SetContextMenu(), and ACTION_MENU::SetDirty().

◆ ShowContextMenu() [2/2]

void TOOL_MENU::ShowContextMenu ( SELECTION aSelection)

Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.

You don't have to use this function, if the caller has a different way to show the menu, it can create one from the reference returned by TOOL_MENU::GetMenu(), but it will have to be managed externally to this class.

Definition at line 57 of file tool_menu.cpp.

58{
59 m_menu.Evaluate( aSelection );
63}
void ClearDirty()
Clear the dirty flag on the menu and all descendants.
void UpdateAll()
Run update handlers for the menu and its submenus.
void Evaluate(SELECTION &aSelection)
Update the contents of the menu based on the supplied conditions.

References ACTION_MENU::ClearDirty(), CMENU_NOW, CONDITIONAL_MENU::Evaluate(), m_menu, m_tool, TOOL_INTERACTIVE::SetContextMenu(), and ACTION_MENU::UpdateAll().

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDA_3D_CONTROLLER::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

Member Data Documentation

◆ m_menu

CONDITIONAL_MENU TOOL_MENU::m_menu
private

The conditional menu displayed by the tool.

Definition at line 105 of file tool_menu.h.

Referenced by GetMenu(), and ShowContextMenu().

◆ m_subMenus

std::vector<std::shared_ptr<ACTION_MENU> > TOOL_MENU::m_subMenus
private

Lifetime-managing container of submenus.

Definition at line 115 of file tool_menu.h.

Referenced by GetSubMenus(), and RegisterSubMenu().

◆ m_tool

TOOL_INTERACTIVE& TOOL_MENU::m_tool
private

The tool that owns this menu.

Definition at line 110 of file tool_menu.h.

Referenced by ShowContextMenu().


The documentation for this class was generated from the following files: