KiCad PCB EDA Suite
Loading...
Searching...
No Matches
tool_menu.cpp
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright (C) 2017-2022 KiCad Developers, see CHANGELOG.txt for contributors.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, you may find one here:
18
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19
* or you may search the http://www.gnu.org website for the version 2 license,
20
* or you may write to the Free Software Foundation, Inc.,
21
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
*/
23
24
#include <
eda_draw_frame.h
>
25
#include <
tool/tool_menu.h
>
26
#include <
tool/tool_interactive.h
>
27
#include <
tool/action_menu.h
>
28
#include <
tool/actions.h
>
29
#include <
tool/selection.h
>
30
31
32
TOOL_MENU::TOOL_MENU
(
TOOL_INTERACTIVE
& aTool ) :
33
m_menu( &aTool ),
34
m_tool( aTool )
35
{
36
}
37
38
39
TOOL_MENU::~TOOL_MENU
()
40
{
41
}
42
43
44
CONDITIONAL_MENU
&
TOOL_MENU::GetMenu
()
45
{
46
return
m_menu
;
47
}
48
49
50
void
TOOL_MENU::RegisterSubMenu
( std::shared_ptr<ACTION_MENU> aSubMenu )
51
{
52
// store a copy of the menu (keeps a reference)
53
m_subMenus
.push_back( std::move( aSubMenu ) );
54
}
55
56
57
void
TOOL_MENU::ShowContextMenu
(
SELECTION
& aSelection )
58
{
59
m_menu
.
Evaluate
( aSelection );
60
m_menu
.
UpdateAll
();
61
m_menu
.
ClearDirty
();
62
m_tool
.
SetContextMenu
( &
m_menu
,
CMENU_NOW
);
63
}
64
65
66
void
TOOL_MENU::ShowContextMenu
()
67
{
68
m_menu
.
SetDirty
();
69
m_tool
.
SetContextMenu
( &
m_menu
,
CMENU_NOW
);
70
}
71
72
action_menu.h
actions.h
ACTION_MENU::SetDirty
void SetDirty()
Definition:
action_menu.cpp:304
ACTION_MENU::ClearDirty
void ClearDirty()
Clear the dirty flag on the menu and all descendants.
Definition:
action_menu.cpp:297
ACTION_MENU::UpdateAll
void UpdateAll()
Run update handlers for the menu and its submenus.
Definition:
action_menu.cpp:280
CONDITIONAL_MENU
Definition:
conditional_menu.h:42
CONDITIONAL_MENU::Evaluate
void Evaluate(const SELECTION &aSelection)
Update the contents of the menu based on the supplied conditions.
Definition:
conditional_menu.cpp:128
SELECTION
Definition:
selection.h:39
TOOL_INTERACTIVE
Definition:
tool_interactive.h:57
TOOL_INTERACTIVE::SetContextMenu
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Assign a context menu and tells when it should be activated.
Definition:
tool_interactive.cpp:93
TOOL_MENU::GetMenu
CONDITIONAL_MENU & GetMenu()
Definition:
tool_menu.cpp:44
TOOL_MENU::m_tool
TOOL_INTERACTIVE & m_tool
The tool that owns this menu.
Definition:
tool_menu.h:110
TOOL_MENU::RegisterSubMenu
void RegisterSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition:
tool_menu.cpp:50
TOOL_MENU::ShowContextMenu
void ShowContextMenu()
Helper function to show a context menu without any selection for tools that can't make selections.
Definition:
tool_menu.cpp:66
TOOL_MENU::~TOOL_MENU
~TOOL_MENU()
Destruct any submenus created with TOOL_MENU::CreateSubMenu().
Definition:
tool_menu.cpp:39
TOOL_MENU::TOOL_MENU
TOOL_MENU(TOOL_INTERACTIVE &aTool)
Construct a new TOOL_MENU for a specific tool.
Definition:
tool_menu.cpp:32
TOOL_MENU::m_subMenus
std::vector< std::shared_ptr< ACTION_MENU > > m_subMenus
Lifetime-managing container of submenus.
Definition:
tool_menu.h:115
TOOL_MENU::m_menu
CONDITIONAL_MENU m_menu
The conditional menu displayed by the tool.
Definition:
tool_menu.h:105
eda_draw_frame.h
selection.h
CMENU_NOW
@ CMENU_NOW
Definition:
tool_event.h:152
tool_interactive.h
tool_menu.h
src
common
tool
tool_menu.cpp
Generated on Mon Oct 7 2024 00:04:59 for KiCad PCB EDA Suite by
1.9.6