KiCad PCB EDA Suite
tool_event.h File Reference
#include <cstdio>
#include <deque>
#include <iterator>
#include <math/vector2d.h>
#include <optional>
#include <tool/tool_action.h>

Go to the source code of this file.

Classes

class  TOOL_EVENT
 Generic, UI-independent tool event. More...
 
class  TOOL_EVENT_LIST
 A list of TOOL_EVENTs, with overloaded || operators allowing for concatenating TOOL_EVENTs with little code. More...
 

Typedefs

typedef std::optional< TOOL_EVENTOPT_TOOL_EVENT
 

Enumerations

enum  TOOL_EVENT_CATEGORY {
  TC_NONE = 0x00 , TC_MOUSE = 0x01 , TC_KEYBOARD = 0x02 , TC_COMMAND = 0x04 ,
  TC_MESSAGE = 0x08 , TC_VIEW = 0x10 , TC_ANY = 0xffffffff
}
 Internal (GUI-independent) event definitions. More...
 
enum  TOOL_ACTIONS {
  TA_NONE = 0x0000 , TA_MOUSE_CLICK = 0x0001 , TA_MOUSE_DBLCLICK = 0x0002 , TA_MOUSE_UP = 0x0004 ,
  TA_MOUSE_DOWN = 0x0008 , TA_MOUSE_DRAG = 0x0010 , TA_MOUSE_MOTION = 0x0020 , TA_MOUSE_WHEEL = 0x0040 ,
  TA_MOUSE = 0x007f , TA_KEY_PRESSED = 0x0080 , TA_KEYBOARD = TA_KEY_PRESSED , TA_VIEW_REFRESH = 0x0100 ,
  TA_VIEW_ZOOM = 0x0200 , TA_VIEW_PAN = 0x0400 , TA_VIEW_DIRTY = 0x0800 , TA_VIEW = 0x0f00 ,
  TA_CHANGE_LAYER = 0x1000 , TA_CANCEL_TOOL = 0x2000 , TA_CHOICE_MENU_UPDATE = 0x4000 , TA_CHOICE_MENU_CHOICE = 0x8000 ,
  TA_CHOICE_MENU_CLOSED = 0x10000 , TA_CHOICE_MENU = TA_CHOICE_MENU_UPDATE | TA_CHOICE_MENU_CHOICE | TA_CHOICE_MENU_CLOSED , TA_UNDO_REDO_PRE = 0x20000 , TA_UNDO_REDO_POST = 0x40000 ,
  TA_ACTION = 0x80000 , TA_ACTIVATE = 0x100000 , TA_REACTIVATE = 0x200000 , TA_MODEL_CHANGE = 0x400000 ,
  TA_PRIME = 0x800001 , TA_ANY = 0xffffffff
}
 
enum  TOOL_MOUSE_BUTTONS {
  BUT_NONE = 0x0 , BUT_LEFT = 0x1 , BUT_RIGHT = 0x2 , BUT_MIDDLE = 0x4 ,
  BUT_AUX1 = 0x8 , BUT_AUX2 = 0x10 , BUT_BUTTON_MASK = BUT_LEFT | BUT_RIGHT | BUT_MIDDLE | BUT_AUX1 | BUT_AUX2 , BUT_ANY = 0xffffffff
}
 
enum  TOOL_MODIFIERS { MD_SHIFT = 0x1000 , MD_CTRL = 0x2000 , MD_ALT = 0x4000 , MD_MODIFIER_MASK = MD_SHIFT | MD_CTRL | MD_ALT }
 
enum  CONTEXT_MENU_TRIGGER { CMENU_BUTTON = 0 , CMENU_NOW , CMENU_OFF }
 Defines when a context menu is opened. More...
 

Functions

const TOOL_EVENT_LIST operator|| (const TOOL_EVENT &aEventA, const TOOL_EVENT &aEventB)
 
const TOOL_EVENT_LIST operator|| (const TOOL_EVENT &aEvent, const TOOL_EVENT_LIST &aEventList)
 

Typedef Documentation

◆ OPT_TOOL_EVENT

typedef std::optional<TOOL_EVENT> OPT_TOOL_EVENT

Definition at line 557 of file tool_event.h.

Enumeration Type Documentation

◆ CONTEXT_MENU_TRIGGER

Defines when a context menu is opened.

Enumerator
CMENU_BUTTON 
CMENU_NOW 
CMENU_OFF 

Definition at line 145 of file tool_event.h.

146{
147 CMENU_BUTTON = 0, // On the right button
148 CMENU_NOW, // Right now (after TOOL_INTERACTIVE::SetContextMenu)
149 CMENU_OFF // Never
150};
@ CMENU_NOW
Definition: tool_event.h:148
@ CMENU_OFF
Definition: tool_event.h:149
@ CMENU_BUTTON
Definition: tool_event.h:147

◆ TOOL_ACTIONS

Enumerator
TA_NONE 
TA_MOUSE_CLICK 
TA_MOUSE_DBLCLICK 
TA_MOUSE_UP 
TA_MOUSE_DOWN 
TA_MOUSE_DRAG 
TA_MOUSE_MOTION 
TA_MOUSE_WHEEL 
TA_MOUSE 
TA_KEY_PRESSED 
TA_KEYBOARD 
TA_VIEW_REFRESH 
TA_VIEW_ZOOM 
TA_VIEW_PAN 
TA_VIEW_DIRTY 
TA_VIEW 
TA_CHANGE_LAYER 
TA_CANCEL_TOOL 
TA_CHOICE_MENU_UPDATE 
TA_CHOICE_MENU_CHOICE 
TA_CHOICE_MENU_CLOSED 
TA_CHOICE_MENU 
TA_UNDO_REDO_PRE 
TA_UNDO_REDO_POST 
TA_ACTION 
TA_ACTIVATE 
TA_REACTIVATE 
TA_MODEL_CHANGE 
TA_PRIME 
TA_ANY 

Definition at line 58 of file tool_event.h.

59{
60 // UI input events
61 TA_NONE = 0x0000,
62 TA_MOUSE_CLICK = 0x0001,
63 TA_MOUSE_DBLCLICK = 0x0002,
64 TA_MOUSE_UP = 0x0004,
65 TA_MOUSE_DOWN = 0x0008,
66 TA_MOUSE_DRAG = 0x0010,
67 TA_MOUSE_MOTION = 0x0020,
68 TA_MOUSE_WHEEL = 0x0040,
69 TA_MOUSE = 0x007f,
70
71 TA_KEY_PRESSED = 0x0080,
73
74 // View related events
75 TA_VIEW_REFRESH = 0x0100,
76 TA_VIEW_ZOOM = 0x0200,
77 TA_VIEW_PAN = 0x0400,
78 TA_VIEW_DIRTY = 0x0800,
79 TA_VIEW = 0x0f00,
80
81 TA_CHANGE_LAYER = 0x1000,
82
83 // Tool cancel event. Issued automagically when the user hits escape or selects End Tool from
84 // the context menu.
85 TA_CANCEL_TOOL = 0x2000,
86
87 // Context menu update. Issued whenever context menu is open and the user hovers the mouse
88 // over one of choices. Used in dynamic highlighting in disambiguation menu
89 TA_CHOICE_MENU_UPDATE = 0x4000,
90
91 // Context menu choice. Sent if the user picked something from the context menu or
92 // closed it without selecting anything.
93 TA_CHOICE_MENU_CHOICE = 0x8000,
94
95 // Context menu is closed, no matter whether anything has been chosen or not.
96 TA_CHOICE_MENU_CLOSED = 0x10000,
97
99
100 // This event is sent *before* undo/redo command is performed.
101 TA_UNDO_REDO_PRE = 0x20000,
102
103 // This event is sent *after* undo/redo command is performed.
104 TA_UNDO_REDO_POST = 0x40000,
105
106 // Tool action (allows one to control tools).
107 TA_ACTION = 0x80000,
108
109 // Tool activation event.
110 TA_ACTIVATE = 0x100000,
111
112 // Tool re-activation event for tools already on the stack
113 TA_REACTIVATE = 0x200000,
114
115 // Model has changed (partial update).
116 TA_MODEL_CHANGE = 0x400000,
117
118 // Tool priming event (a special mouse click)
119 TA_PRIME = 0x800001,
120
121 TA_ANY = 0xffffffff
122};
@ TA_MODEL_CHANGE
Definition: tool_event.h:116
@ TA_ANY
Definition: tool_event.h:121
@ TA_CHOICE_MENU_CHOICE
Definition: tool_event.h:93
@ TA_UNDO_REDO_PRE
Definition: tool_event.h:101
@ TA_MOUSE_CLICK
Definition: tool_event.h:62
@ TA_CHOICE_MENU_UPDATE
Definition: tool_event.h:89
@ TA_MOUSE
Definition: tool_event.h:69
@ TA_ACTIVATE
Definition: tool_event.h:110
@ TA_CHOICE_MENU_CLOSED
Definition: tool_event.h:96
@ TA_PRIME
Definition: tool_event.h:119
@ TA_MOUSE_MOTION
Definition: tool_event.h:67
@ TA_MOUSE_UP
Definition: tool_event.h:64
@ TA_KEYBOARD
Definition: tool_event.h:72
@ TA_VIEW_REFRESH
Definition: tool_event.h:75
@ TA_CHOICE_MENU
Definition: tool_event.h:98
@ TA_MOUSE_DRAG
Definition: tool_event.h:66
@ TA_CHANGE_LAYER
Definition: tool_event.h:81
@ TA_MOUSE_DOWN
Definition: tool_event.h:65
@ TA_VIEW
Definition: tool_event.h:79
@ TA_UNDO_REDO_POST
Definition: tool_event.h:104
@ TA_KEY_PRESSED
Definition: tool_event.h:71
@ TA_MOUSE_DBLCLICK
Definition: tool_event.h:63
@ TA_MOUSE_WHEEL
Definition: tool_event.h:68
@ TA_ACTION
Definition: tool_event.h:107
@ TA_VIEW_PAN
Definition: tool_event.h:77
@ TA_NONE
Definition: tool_event.h:61
@ TA_CANCEL_TOOL
Definition: tool_event.h:85
@ TA_VIEW_DIRTY
Definition: tool_event.h:78
@ TA_REACTIVATE
Definition: tool_event.h:113
@ TA_VIEW_ZOOM
Definition: tool_event.h:76

◆ TOOL_EVENT_CATEGORY

Internal (GUI-independent) event definitions.

Enumerator
TC_NONE 
TC_MOUSE 
TC_KEYBOARD 
TC_COMMAND 
TC_MESSAGE 
TC_VIEW 
TC_ANY 

Definition at line 47 of file tool_event.h.

48{
49 TC_NONE = 0x00,
50 TC_MOUSE = 0x01,
51 TC_KEYBOARD = 0x02,
52 TC_COMMAND = 0x04,
53 TC_MESSAGE = 0x08,
54 TC_VIEW = 0x10,
55 TC_ANY = 0xffffffff
56};
@ TC_NONE
Definition: tool_event.h:49
@ TC_ANY
Definition: tool_event.h:55
@ TC_COMMAND
Definition: tool_event.h:52
@ TC_MOUSE
Definition: tool_event.h:50
@ TC_MESSAGE
Definition: tool_event.h:53
@ TC_KEYBOARD
Definition: tool_event.h:51
@ TC_VIEW
Definition: tool_event.h:54

◆ TOOL_MODIFIERS

Enumerator
MD_SHIFT 
MD_CTRL 
MD_ALT 
MD_MODIFIER_MASK 

Definition at line 136 of file tool_event.h.

137{
138 MD_SHIFT = 0x1000,
139 MD_CTRL = 0x2000,
140 MD_ALT = 0x4000,
142};
@ MD_MODIFIER_MASK
Definition: tool_event.h:141
@ MD_ALT
Definition: tool_event.h:140
@ MD_CTRL
Definition: tool_event.h:139
@ MD_SHIFT
Definition: tool_event.h:138

◆ TOOL_MOUSE_BUTTONS

Enumerator
BUT_NONE 
BUT_LEFT 
BUT_RIGHT 
BUT_MIDDLE 
BUT_AUX1 
BUT_AUX2 
BUT_BUTTON_MASK 
BUT_ANY 

Definition at line 124 of file tool_event.h.

125{
126 BUT_NONE = 0x0,
127 BUT_LEFT = 0x1,
128 BUT_RIGHT = 0x2,
129 BUT_MIDDLE = 0x4,
130 BUT_AUX1 = 0x8,
131 BUT_AUX2 = 0x10,
133 BUT_ANY = 0xffffffff
134};
@ BUT_AUX1
Definition: tool_event.h:130
@ BUT_MIDDLE
Definition: tool_event.h:129
@ BUT_LEFT
Definition: tool_event.h:127
@ BUT_RIGHT
Definition: tool_event.h:128
@ BUT_AUX2
Definition: tool_event.h:131
@ BUT_BUTTON_MASK
Definition: tool_event.h:132
@ BUT_NONE
Definition: tool_event.h:126
@ BUT_ANY
Definition: tool_event.h:133

Function Documentation

◆ operator||() [1/2]

const TOOL_EVENT_LIST operator|| ( const TOOL_EVENT aEvent,
const TOOL_EVENT_LIST aEventList 
)
inline

Definition at line 693 of file tool_event.h.

695{
696 TOOL_EVENT_LIST l( aEventList );
697
698 l.Add( aEvent );
699 return l;
700}
A list of TOOL_EVENTs, with overloaded || operators allowing for concatenating TOOL_EVENTs with littl...
Definition: tool_event.h:564

References TOOL_EVENT_LIST::Add().

◆ operator||() [2/2]

const TOOL_EVENT_LIST operator|| ( const TOOL_EVENT aEventA,
const TOOL_EVENT aEventB 
)
inline

Definition at line 682 of file tool_event.h.

683{
685
686 l.Add( aEventA );
687 l.Add( aEventB );
688
689 return l;
690}
void Add(const TOOL_EVENT &aEvent)
Add a tool event to the list.
Definition: tool_event.h:613

References TOOL_EVENT_LIST::Add().