KiCad PCB EDA Suite
|
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. | |
~TOOL_MENU () | |
Destruct any submenus created with TOOL_MENU::CreateSubMenu(). | |
CONDITIONAL_MENU & | GetMenu () |
void | RegisterSubMenu (std::shared_ptr< ACTION_MENU > aSubMenu) |
Store a submenu of this menu model. | |
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. | |
void | ShowContextMenu () |
Helper function to show a context menu without any selection for tools that can't make selections. | |
Private Attributes | |
CONDITIONAL_MENU | m_menu |
The conditional menu displayed by the tool. | |
TOOL_INTERACTIVE & | m_tool |
The tool that owns this menu. | |
std::vector< std::shared_ptr< ACTION_MENU > > | m_subMenus |
Lifetime-managing container of submenus. | |
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.
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.
TOOL_MENU::~TOOL_MENU | ( | ) |
Destruct any submenus created with TOOL_MENU::CreateSubMenu().
Definition at line 39 of file tool_menu.cpp.
CONDITIONAL_MENU & TOOL_MENU::GetMenu | ( | ) |
Definition at line 44 of file tool_menu.cpp.
References m_menu.
Referenced by EDA_DRAW_FRAME::AddStandardSubMenus(), EE_INSPECTION_TOOL::Init(), EE_POINT_EDITOR::Init(), SCH_EDIT_TABLE_TOOL::Init(), SCH_EDIT_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), SCH_MOVE_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), SYMBOL_EDITOR_MOVE_TOOL::Init(), SYMBOL_EDITOR_PIN_TOOL::Init(), PL_EDIT_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), BOARD_INSPECTION_TOOL::Init(), CONVERT_TOOL::Init(), EDIT_TOOL::Init(), GENERATOR_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), PCB_EDIT_TABLE_TOOL::Init(), PCB_POINT_EDITOR::Init(), and ALIGN_DISTRIBUTE_TOOL::Init().
|
inline |
Definition at line 80 of file tool_menu.h.
References m_subMenus.
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.
aSubMenu | a sub menu to add |
Definition at line 50 of file tool_menu.cpp.
References m_subMenus.
Referenced by EDA_DRAW_FRAME::AddStandardSubMenus(), SCH_LINE_WIRE_BUS_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), BOARD_INSPECTION_TOOL::Init(), EDIT_TOOL::Init(), and GROUP_TOOL::Init().
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.
References CMENU_NOW, m_menu, m_tool, TOOL_INTERACTIVE::SetContextMenu(), and ACTION_MENU::SetDirty().
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.
References ACTION_MENU::ClearDirty(), CMENU_NOW, CONDITIONAL_MENU::Evaluate(), m_menu, m_tool, TOOL_INTERACTIVE::SetContextMenu(), and ACTION_MENU::UpdateAll().
Referenced by EDIT_TOOL::doMoveSelection(), and POSITION_RELATIVE_TOOL::PositionRelativeInteractively().
|
private |
The conditional menu displayed by the tool.
Definition at line 105 of file tool_menu.h.
Referenced by GetMenu(), and ShowContextMenu().
|
private |
Lifetime-managing container of submenus.
Definition at line 115 of file tool_menu.h.
Referenced by GetSubMenus(), and RegisterSubMenu().
|
private |
The tool that owns this menu.
Definition at line 110 of file tool_menu.h.
Referenced by ShowContextMenu().