KiCad PCB EDA Suite
Loading...
Searching...
No Matches
tool_event.h
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) 2013-2023 CERN
5 * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Tomasz Wlostowski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#ifndef __TOOL_EVENT_H
28#define __TOOL_EVENT_H
29
30#include <any>
31#include <cstdio>
32#include <deque>
33#include <iterator>
34
35#include <math/vector2d.h>
36#include <optional>
37#include <atomic>
38
39#include <tool/tool_action.h>
40#include <wx/debug.h>
41
42class COMMIT;
43class TOOL_ACTION;
44class TOOL_MANAGER;
45class TOOL_BASE;
46class TOOLS_HOLDER;
47
52{
53 TC_NONE = 0x00,
54 TC_MOUSE = 0x01,
56 TC_COMMAND = 0x04,
57 TC_MESSAGE = 0x08,
58 TC_VIEW = 0x10,
59 TC_ANY = 0xffffffff
60};
61
63{
64 // UI input events
65 TA_NONE = 0x0000,
68 TA_MOUSE_UP = 0x0004,
69 TA_MOUSE_DOWN = 0x0008,
70 TA_MOUSE_DRAG = 0x0010,
73 TA_MOUSE = 0x007f,
74
77
78 // View related events
80 TA_VIEW_ZOOM = 0x0200,
81 TA_VIEW_PAN = 0x0400,
82 TA_VIEW_DIRTY = 0x0800,
83 TA_VIEW = 0x0f00,
84
86
87 // Tool cancel event. Issued automagically when the user hits escape or selects End Tool from
88 // the context menu.
90
91 // Context menu update. Issued whenever context menu is open and the user hovers the mouse
92 // over one of choices. Used in dynamic highlighting in disambiguation menu
94
95 // Context menu choice. Sent if the user picked something from the context menu or
96 // closed it without selecting anything.
98
99 // Context menu is closed, no matter whether anything has been chosen or not.
101
103
104 // This event is sent *before* undo/redo command is performed.
106
107 // This event is sent *after* undo/redo command is performed.
109
110 // Tool action (allows one to control tools).
111 TA_ACTION = 0x80000,
112
113 // Tool activation event.
114 TA_ACTIVATE = 0x100000,
115
116 // Tool re-activation event for tools already on the stack
117 TA_REACTIVATE = 0x200000,
118
119 // Model has changed (partial update).
120 TA_MODEL_CHANGE = 0x400000,
121
122 // Tool priming event (a special mouse click)
123 TA_PRIME = 0x800001,
124
125 TA_ANY = 0xffffffff
127
129{
130 BUT_NONE = 0x0,
131 BUT_LEFT = 0x1,
134 BUT_AUX1 = 0x8,
135 BUT_AUX2 = 0x10,
137 BUT_ANY = 0xffffffff
139
141{
142 MD_SHIFT = 0x1000,
143 MD_CTRL = 0x2000,
144 MD_ALT = 0x4000,
146};
147
150{
151 CMENU_BUTTON = 0, // On the right button
152 CMENU_NOW, // Right now (after TOOL_INTERACTIVE::SetContextMenu)
153 CMENU_OFF // Never
155
157{
162
167{
168public:
174 const std::string Format() const;
175
177 TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) :
178 m_category( aCategory ),
179 m_actions( aAction ),
180 m_scope( aScope ),
181 m_mouseButtons( 0 ),
182 m_keyCode( 0 ),
183 m_modifiers( 0 ),
184 m_synchronousState( nullptr ),
185 m_commit( nullptr ),
186 m_firstResponder( nullptr )
187 {
188 init();
189 }
190
191 TOOL_EVENT( TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam,
192 TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) :
193 m_category( aCategory ),
194 m_actions( aAction ),
195 m_scope( aScope ),
196 m_mouseButtons( 0 ),
197 m_keyCode( 0 ),
198 m_modifiers( 0 ),
199 m_synchronousState( nullptr ),
200 m_commit( nullptr ),
201 m_firstResponder( nullptr )
202 {
203 if( aCategory == TC_MOUSE )
204 {
205 setMouseButtons( aExtraParam & BUT_BUTTON_MASK );
206 }
207 else if( aCategory == TC_KEYBOARD )
208 {
209 m_keyCode = aExtraParam & ~MD_MODIFIER_MASK; // Filter out modifiers
210 }
211 else if( aCategory == TC_COMMAND )
212 {
213 m_commandId = aExtraParam;
214 }
215
216 if( aCategory & ( TC_MOUSE | TC_KEYBOARD ) )
217 {
218 m_modifiers = aExtraParam & MD_MODIFIER_MASK;
219 }
220
221 init();
222 }
223
225 const std::string& aExtraParam, TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) :
226 m_category( aCategory ),
227 m_actions( aAction ),
228 m_scope( aScope ),
229 m_mouseButtons( 0 ),
230 m_keyCode( 0 ),
231 m_modifiers( 0 ),
232 m_synchronousState( nullptr ),
233 m_commit( nullptr ),
234 m_firstResponder( nullptr )
235 {
236 if( aCategory == TC_COMMAND || aCategory == TC_MESSAGE )
237 m_commandStr = aExtraParam;
238
239 init();
240 }
241
244
246 TOOL_ACTIONS Action() const { return m_actions; }
247
251 bool PassEvent() const { return m_passEvent; }
252 void SetPassEvent( bool aPass = true ) { m_passEvent = aPass; }
253
256 bool HasPosition() const { return m_hasPosition; }
257 void SetHasPosition( bool aHasPosition ) { m_hasPosition = aHasPosition; }
258
261 bool ForceImmediate() const { return m_forceImmediate; }
262 void SetForceImmediate( bool aForceImmediate = true ) { m_forceImmediate = aForceImmediate; }
263
265 void SetFirstResponder( TOOL_BASE* aTool ) { m_firstResponder = aTool; }
266
268 bool IsReactivate() const { return m_reactivate; }
269 void SetReactivate( bool aReactivate = true ) { m_reactivate = aReactivate; }
270
271 void SetSynchronous( std::atomic<SYNCRONOUS_TOOL_STATE>* aState ) { m_synchronousState = aState; }
272 std::atomic<SYNCRONOUS_TOOL_STATE>* SynchronousState() const { return m_synchronousState; }
273
274 void SetCommit( COMMIT* aCommit ) { m_commit = aCommit; }
275 COMMIT* Commit() const { return m_commit; }
276
279 const VECTOR2D Delta() const
280 {
282 }
283
285 const VECTOR2D Position() const
286 {
288 }
289
291 const VECTOR2D DragOrigin() const
292 {
294 }
295
297 int Buttons() const
298 {
299 assert( m_category == TC_MOUSE ); // this should be used only with mouse events
300 return m_mouseButtons;
301 }
302
303 bool IsClick( int aButtonMask = BUT_ANY ) const;
304
305 bool IsDblClick( int aButtonMask = BUT_ANY ) const;
306
307 bool IsDrag( int aButtonMask = BUT_ANY ) const
308 {
309 return m_actions == TA_MOUSE_DRAG && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
310 }
311
312 bool IsMouseDown( int aButtonMask = BUT_ANY ) const
313 {
314 return m_actions == TA_MOUSE_DOWN && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
315 }
316
317 bool IsMouseUp( int aButtonMask = BUT_ANY ) const
318 {
319 return m_actions == TA_MOUSE_UP && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
320 }
321
322 bool IsMotion() const
323 {
324 return m_actions == TA_MOUSE_MOTION;
325 }
326
327 bool IsMouseAction() const
328 {
329 return ( m_actions & TA_MOUSE );
330 }
331
332 bool IsCancel() const
333 {
334 return m_actions == TA_CANCEL_TOOL;
335 }
336
337 bool IsActivate() const
338 {
339 return m_actions == TA_ACTIVATE;
340 }
341
342 bool IsUndoRedo() const
343 {
345 }
346
347 bool IsChoiceMenu() const
348 {
349 return m_actions & TA_CHOICE_MENU;
350 }
351
352 bool IsPrime() const
353 {
354 return m_actions == TA_PRIME;
355 }
356
358 int Modifier( int aMask = MD_MODIFIER_MASK ) const
359 {
360 return m_modifiers & aMask;
361 }
362
364 {
365 return Modifier( MD_CTRL );
366 }
367
368 int KeyCode() const
369 {
370 return m_keyCode;
371 }
372
373 bool IsKeyPressed() const
374 {
375 return m_actions == TA_KEY_PRESSED;
376 }
377
384 bool Matches( const TOOL_EVENT& aEvent ) const
385 {
386 if( !( m_category & aEvent.m_category ) )
387 return false;
388
390 {
391 if( !m_commandStr.empty() && !aEvent.getCommandStr().empty() )
392 return m_commandStr == aEvent.m_commandStr;
393
394 if( (bool) m_commandId && (bool) aEvent.m_commandId )
395 return *m_commandId == *aEvent.m_commandId;
396 }
397
398 // BUGFIX: TA_ANY should match EVERYTHING, even TA_NONE (for TC_MESSAGE)
399 if( m_actions == TA_ANY && aEvent.m_actions == TA_NONE && aEvent.m_category == TC_MESSAGE )
400 return true;
401
402 // BUGFIX: This check must happen after the TC_COMMAND check because otherwise events of
403 // the form { TC_COMMAND, TA_NONE } will be incorrectly skipped
404 if( !( m_actions & aEvent.m_actions ) )
405 return false;
406
407 return true;
408 }
409
416 bool IsAction( const TOOL_ACTION* aAction ) const;
417
422 bool IsCancelInteractive() const;
423
427 bool IsSelectionEvent() const;
428
435 bool IsPointEditor() const;
436
442 bool IsMoveTool() const;
443
449 bool IsEditorTool() const;
450
454 bool IsSimulator() const;
455
459 template<typename T, std::enable_if_t<!std::is_pointer<T>::value>* = nullptr >
460 T Parameter() const
461 {
462 T param;
463
464 wxCHECK_MSG( m_param.has_value(), T(), "Attempted to get a parameter from an event with "
465 "no parameter." );
466
467 try
468 {
469 param = std::any_cast<T>( m_param );
470 }
471 catch( const std::bad_any_cast& )
472 {
473 wxCHECK_MSG( false, T(), wxString::Format( "Requested parameter type %s from event "
474 "with parameter type %s.",
475 typeid(T).name(),
476 m_param.type().name() ) );
477 }
478
479 return param;
480 }
481
485 template<typename T, std::enable_if_t<std::is_pointer<T>::value>* = nullptr>
486 T Parameter() const
487 {
488 T param = nullptr;
489
490 wxCHECK_MSG( m_param.has_value(), param, "Attempted to get a parameter from an event with "
491 "no parameter." );
492
493 try
494 {
495 param = std::any_cast<T>( m_param );
496 }
497 catch( const std::bad_any_cast& )
498 {
499 wxCHECK_MSG( false, param, wxString::Format( "Requested parameter type %s from event "
500 "with parameter type %s.",
501 typeid(T).name(),
502 m_param.type().name() ) );
503 }
504
505 return param;
506 }
507
514 template<typename T>
515 void SetParameter(T aParam)
516 {
517 m_param = aParam;
518 }
519
520 std::optional<int> GetCommandId() const
521 {
522 return m_commandId;
523 }
524
525 void SetMousePosition( const VECTOR2D& aP )
526 {
527 m_mousePos = aP;
528 }
529
530 void SetActionGroup( const TOOL_ACTION_GROUP& aGroup )
531 {
532 m_actionGroup = aGroup;
533 }
534
535 bool IsActionInGroup( const TOOL_ACTION_GROUP& aGroup ) const;
536
537private:
538 friend class TOOL_EVENT_LIST;
539 friend class TOOL_DISPATCHER;
540 friend class TOOL_MANAGER;
541 friend class TOOLS_HOLDER;
542
543 void init();
544
545 const std::string& getCommandStr() const { return m_commandStr; }
546
547 void setMouseDragOrigin( const VECTOR2D& aP )
548 {
550 }
551
552 void setMouseDelta( const VECTOR2D& aP )
553 {
554 m_mouseDelta = aP;
555 }
556
557 void setMouseButtons( int aButtons )
558 {
559 assert( ( aButtons & ~BUT_BUTTON_MASK ) == 0 );
560 m_mouseButtons = aButtons;
561 }
562
563 void setModifiers( int aMods )
564 {
565 assert( ( aMods & ~MD_MODIFIER_MASK ) == 0 );
566 m_modifiers = aMods;
567 }
568
579 VECTOR2D returnCheckedPosition( const VECTOR2D& aPos ) const;
580
587
588
590 std::optional<TOOL_ACTION_GROUP> m_actionGroup;
591
594
598
601
604
607
610
613
614 std::atomic<SYNCRONOUS_TOOL_STATE>* m_synchronousState;
615
618
620 std::any m_param;
621
624
625 std::optional<int> m_commandId;
626 std::string m_commandStr;
627};
628
629typedef std::optional<TOOL_EVENT> OPT_TOOL_EVENT;
630
636{
637public:
639 typedef std::deque<TOOL_EVENT>::iterator iterator;
640 typedef std::deque<TOOL_EVENT>::const_iterator const_iterator;
641
644 {}
645
647 TOOL_EVENT_LIST( const TOOL_EVENT& aSingleEvent )
648 {
649 m_events.push_back( aSingleEvent );
650 }
651
653 TOOL_EVENT_LIST( const TOOL_EVENT_LIST& aEventList )
654 {
655 m_events.clear();
656
657 for( const TOOL_EVENT& event : aEventList.m_events )
658 m_events.push_back( event );
659 }
660
667 const std::string Format() const;
668
674 const std::string Names() const;
675
676 OPT_TOOL_EVENT Matches( const TOOL_EVENT& aEvent ) const
677 {
678 for( const TOOL_EVENT& event : m_events )
679 {
680 if( event.Matches( aEvent ) )
681 return event;
682 }
683
684 return OPT_TOOL_EVENT();
685 }
686
692 void Add( const TOOL_EVENT& aEvent )
693 {
694 m_events.push_back( aEvent );
695 }
696
698 {
699 return m_events.begin();
700 }
701
703 {
704 return m_events.end();
705 }
706
708 {
709 return m_events.begin();
710 }
711
713 {
714 return m_events.end();
715 }
716
717 int size() const
718 {
719 return m_events.size();
720 }
721
722 void clear()
723 {
724 m_events.clear();
725 }
726
728 {
729 m_events.clear();
730
731 for( const TOOL_EVENT& event : aEventList.m_events )
732 m_events.push_back( event );
733
734 return *this;
735 }
736
738 {
739 m_events.clear();
740 m_events.push_back( aEvent );
741 return *this;
742 }
743
745 {
746 Add( aEvent );
747 return *this;
748 }
749
751 {
752 std::copy( aEvent.m_events.begin(), aEvent.m_events.end(), std::back_inserter( m_events ) );
753 return *this;
754 }
755
756private:
757 std::deque<TOOL_EVENT> m_events;
758};
759
760
761inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEventA, const TOOL_EVENT& aEventB )
762{
764
765 l.Add( aEventA );
766 l.Add( aEventB );
767
768 return l;
769}
770
771
772inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEvent,
773 const TOOL_EVENT_LIST& aEventList )
774{
775 TOOL_EVENT_LIST l( aEventList );
776
777 l.Add( aEvent );
778 return l;
779}
780
781
782#endif
const char * name
Definition: DXF_plotter.cpp:57
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition: commit.h:74
Define a group that can be used to group actions (and their events) of similar operations.
Definition: tool_action.h:63
Represent a single user action.
Definition: tool_action.h:269
Base abstract interface for all kinds of tools.
Definition: tool_base.h:66
A list of TOOL_EVENTs, with overloaded || operators allowing for concatenating TOOL_EVENTs with littl...
Definition: tool_event.h:636
iterator begin()
Definition: tool_event.h:697
const std::string Format() const
Function Format() Returns information about event in form of a human-readable string.
Definition: tool_event.cpp:187
int size() const
Definition: tool_event.h:717
TOOL_EVENT value_type
Definition: tool_event.h:638
std::deque< TOOL_EVENT > m_events
Definition: tool_event.h:757
std::deque< TOOL_EVENT >::const_iterator const_iterator
Default constructor. Creates an empty list.
Definition: tool_event.h:640
const std::string Names() const
Returns a string containing the names of all the events in this list.
Definition: tool_event.cpp:198
iterator end()
Definition: tool_event.h:702
TOOL_EVENT_LIST & operator=(const TOOL_EVENT &aEvent)
Definition: tool_event.h:737
std::deque< TOOL_EVENT >::iterator iterator
Definition: tool_event.h:639
TOOL_EVENT_LIST(const TOOL_EVENT &aSingleEvent)
Copy an existing TOOL_EVENT_LIST.
Definition: tool_event.h:647
TOOL_EVENT_LIST()
Constructor for a list containing only one TOOL_EVENT.
Definition: tool_event.h:643
void Add(const TOOL_EVENT &aEvent)
Add a tool event to the list.
Definition: tool_event.h:692
TOOL_EVENT_LIST & operator=(const TOOL_EVENT_LIST &aEventList)
Definition: tool_event.h:727
const_iterator cbegin() const
Definition: tool_event.h:707
TOOL_EVENT_LIST(const TOOL_EVENT_LIST &aEventList)
Definition: tool_event.h:653
TOOL_EVENT_LIST & operator||(const TOOL_EVENT_LIST &aEvent)
Definition: tool_event.h:750
OPT_TOOL_EVENT Matches(const TOOL_EVENT &aEvent) const
Definition: tool_event.h:676
const_iterator cend() const
Definition: tool_event.h:712
TOOL_EVENT_LIST & operator||(const TOOL_EVENT &aEvent)
Definition: tool_event.h:744
Generic, UI-independent tool event.
Definition: tool_event.h:167
int Buttons() const
Definition: tool_event.h:297
bool HasPosition() const
Definition: tool_event.h:256
bool DisableGridSnapping() const
Definition: tool_event.h:363
bool IsCancelInteractive() const
Indicate the event should restart/end an ongoing interactive tool's event loop (eg esc key,...
Definition: tool_event.cpp:221
bool m_hasPosition
Definition: tool_event.h:585
void SetCommit(COMMIT *aCommit)
Definition: tool_event.h:274
std::optional< int > m_commandId
Definition: tool_event.h:625
void setMouseDragOrigin(const VECTOR2D &aP)
Definition: tool_event.h:547
int m_keyCode
State of key modifiers (Ctrl/Alt/etc.)
Definition: tool_event.h:609
void SetActionGroup(const TOOL_ACTION_GROUP &aGroup)
Definition: tool_event.h:530
TOOL_ACTION_SCOPE m_scope
Definition: tool_event.h:583
bool PassEvent() const
Definition: tool_event.h:251
TOOL_ACTIONS Action() const
These give a tool a method of informing the TOOL_MANAGER that a particular event should be passed on ...
Definition: tool_event.h:246
void SetMousePosition(const VECTOR2D &aP)
Definition: tool_event.h:525
int m_modifiers
Definition: tool_event.h:612
TOOL_EVENT(TOOL_EVENT_CATEGORY aCategory=TC_NONE, TOOL_ACTIONS aAction=TA_NONE, TOOL_ACTION_SCOPE aScope=AS_GLOBAL)
Definition: tool_event.h:176
int KeyCode() const
Definition: tool_event.h:368
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:384
TOOL_BASE * FirstResponder() const
Definition: tool_event.h:264
void setMouseDelta(const VECTOR2D &aP)
Definition: tool_event.h:552
bool IsActivate() const
Definition: tool_event.h:337
std::any m_param
The first tool to receive the event.
Definition: tool_event.h:620
void SetFirstResponder(TOOL_BASE *aTool)
Controls whether the tool is first being pushed to the stack or being reactivated after a pause.
Definition: tool_event.h:265
VECTOR2D m_mousePos
Point where dragging has started.
Definition: tool_event.h:600
bool IsPrime() const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:352
std::string m_commandStr
Definition: tool_event.h:626
bool IsSimulator() const
Indicate if the event is from the simulator.
Definition: tool_event.cpp:257
COMMIT * Commit() const
Returns information about difference between current mouse cursor position and the place where draggi...
Definition: tool_event.h:275
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:285
bool IsSelectionEvent() const
Indicate an selection-changed notification event.
Definition: tool_event.cpp:229
void SetParameter(T aParam)
Set a non-standard parameter assigned to the event.
Definition: tool_event.h:515
bool ForceImmediate() const
Definition: tool_event.h:261
bool IsReactivate() const
Definition: tool_event.h:268
bool IsKeyPressed() const
Definition: tool_event.h:373
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:209
void SetForceImmediate(bool aForceImmediate=true)
Definition: tool_event.h:262
TOOL_EVENT_CATEGORY Category() const
Returns more specific information about the type of an event.
Definition: tool_event.h:243
std::atomic< SYNCRONOUS_TOOL_STATE > * m_synchronousState
Definition: tool_event.h:614
bool m_passEvent
Definition: tool_event.h:584
TOOL_EVENT(TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam, TOOL_ACTION_SCOPE aScope=AS_GLOBAL)
Definition: tool_event.h:191
void SetReactivate(bool aReactivate=true)
Definition: tool_event.h:269
void init()
Definition: tool_event.cpp:58
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:307
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:358
COMMIT * m_commit
Commit the tool handling the event should add to.
Definition: tool_event.h:617
bool IsMoveTool() const
Indicate if the event is from one of the move tools.
Definition: tool_event.cpp:245
TOOL_ACTIONS m_actions
Definition: tool_event.h:582
std::optional< TOOL_ACTION_GROUP > m_actionGroup
True when the tool is being re-activated from the stack.
Definition: tool_event.h:590
bool m_forceImmediate
Optional group that the parent action for the event belongs to.
Definition: tool_event.h:586
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:82
const VECTOR2D DragOrigin() const
Returns information about mouse buttons state.
Definition: tool_event.h:291
void SetHasPosition(bool aHasPosition)
Returns if the action associated with this event should be treated as immediate regardless of the cur...
Definition: tool_event.h:257
bool IsActionInGroup(const TOOL_ACTION_GROUP &aGroup) const
Definition: tool_event.cpp:88
VECTOR2D returnCheckedPosition(const VECTOR2D &aPos) const
Ensure that the event is a type that has a position before returning a position, otherwise return a n...
Definition: tool_event.cpp:74
bool IsEditorTool() const
Indicate if the event is asking for an editor tool.
Definition: tool_event.cpp:251
bool m_reactivate
Difference between mouse cursor position and the point where dragging event has started.
Definition: tool_event.h:593
bool IsCancel() const
Definition: tool_event.h:332
void setMouseButtons(int aButtons)
Definition: tool_event.h:557
TOOL_BASE * m_firstResponder
Definition: tool_event.h:623
T Parameter() const
Return a parameter assigned to the event.
Definition: tool_event.h:460
bool IsMouseDown(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:312
bool IsDblClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:215
const std::string & getCommandStr() const
Definition: tool_event.h:545
TOOL_EVENT_CATEGORY m_category
Definition: tool_event.h:581
void SetSynchronous(std::atomic< SYNCRONOUS_TOOL_STATE > *aState)
Definition: tool_event.h:271
bool IsUndoRedo() const
Definition: tool_event.h:342
bool IsPointEditor() const
Indicate if the event is from one of the point editors.
Definition: tool_event.cpp:238
int m_mouseButtons
Stores code of pressed/released key.
Definition: tool_event.h:606
std::atomic< SYNCRONOUS_TOOL_STATE > * SynchronousState() const
Definition: tool_event.h:272
VECTOR2D m_mouseDelta
Current mouse cursor position.
Definition: tool_event.h:597
TOOL_EVENT(TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, const std::string &aExtraParam, TOOL_ACTION_SCOPE aScope=AS_GLOBAL)
Returns the category (eg. mouse/keyboard/action) of an event..
Definition: tool_event.h:224
std::optional< int > GetCommandId() const
Definition: tool_event.h:520
void setModifiers(int aMods)
Definition: tool_event.h:563
void SetPassEvent(bool aPass=true)
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:252
bool IsChoiceMenu() const
Definition: tool_event.h:347
VECTOR2D m_mouseDragOrigin
State of mouse buttons.
Definition: tool_event.h:603
bool IsMouseAction() const
Definition: tool_event.h:327
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:317
bool IsMotion() const
Definition: tool_event.h:322
const std::string Format() const
Return information about event in form of a human-readable string.
Definition: tool_event.cpp:97
const VECTOR2D Delta() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:279
Master controller class:
Definition: tool_manager.h:57
TOOL_ACTION_SCOPE
Scope of tool actions.
Definition: tool_action.h:45
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition: tool_action.h:48
const TOOL_EVENT_LIST operator||(const TOOL_EVENT &aEventA, const TOOL_EVENT &aEventB)
Definition: tool_event.h:761
CONTEXT_MENU_TRIGGER
Defines when a context menu is opened.
Definition: tool_event.h:150
@ CMENU_NOW
Definition: tool_event.h:152
@ CMENU_OFF
Definition: tool_event.h:153
@ CMENU_BUTTON
Definition: tool_event.h:151
std::optional< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:629
TOOL_ACTIONS
Definition: tool_event.h:63
@ TA_MODEL_CHANGE
Definition: tool_event.h:120
@ TA_ANY
Definition: tool_event.h:125
@ TA_CHOICE_MENU_CHOICE
Definition: tool_event.h:97
@ TA_UNDO_REDO_PRE
Definition: tool_event.h:105
@ TA_MOUSE_CLICK
Definition: tool_event.h:66
@ TA_CHOICE_MENU_UPDATE
Definition: tool_event.h:93
@ TA_MOUSE
Definition: tool_event.h:73
@ TA_ACTIVATE
Definition: tool_event.h:114
@ TA_CHOICE_MENU_CLOSED
Definition: tool_event.h:100
@ TA_PRIME
Definition: tool_event.h:123
@ TA_MOUSE_MOTION
Definition: tool_event.h:71
@ TA_MOUSE_UP
Definition: tool_event.h:68
@ TA_KEYBOARD
Definition: tool_event.h:76
@ TA_VIEW_REFRESH
Definition: tool_event.h:79
@ TA_CHOICE_MENU
Definition: tool_event.h:102
@ TA_MOUSE_DRAG
Definition: tool_event.h:70
@ TA_CHANGE_LAYER
Definition: tool_event.h:85
@ TA_MOUSE_DOWN
Definition: tool_event.h:69
@ TA_VIEW
Definition: tool_event.h:83
@ TA_UNDO_REDO_POST
Definition: tool_event.h:108
@ TA_KEY_PRESSED
Definition: tool_event.h:75
@ TA_MOUSE_DBLCLICK
Definition: tool_event.h:67
@ TA_MOUSE_WHEEL
Definition: tool_event.h:72
@ TA_ACTION
Definition: tool_event.h:111
@ TA_VIEW_PAN
Definition: tool_event.h:81
@ TA_NONE
Definition: tool_event.h:65
@ TA_CANCEL_TOOL
Definition: tool_event.h:89
@ TA_VIEW_DIRTY
Definition: tool_event.h:82
@ TA_REACTIVATE
Definition: tool_event.h:117
@ TA_VIEW_ZOOM
Definition: tool_event.h:80
TOOL_EVENT_CATEGORY
Internal (GUI-independent) event definitions.
Definition: tool_event.h:52
@ TC_NONE
Definition: tool_event.h:53
@ TC_ANY
Definition: tool_event.h:59
@ TC_COMMAND
Definition: tool_event.h:56
@ TC_MOUSE
Definition: tool_event.h:54
@ TC_MESSAGE
Definition: tool_event.h:57
@ TC_KEYBOARD
Definition: tool_event.h:55
@ TC_VIEW
Definition: tool_event.h:58
TOOL_MODIFIERS
Definition: tool_event.h:141
@ MD_MODIFIER_MASK
Definition: tool_event.h:145
@ MD_ALT
Definition: tool_event.h:144
@ MD_CTRL
Definition: tool_event.h:143
@ MD_SHIFT
Definition: tool_event.h:142
SYNCRONOUS_TOOL_STATE
Definition: tool_event.h:157
@ STS_CANCELLED
Definition: tool_event.h:160
@ STS_FINISHED
Definition: tool_event.h:159
@ STS_RUNNING
Definition: tool_event.h:158
TOOL_MOUSE_BUTTONS
Definition: tool_event.h:129
@ BUT_AUX1
Definition: tool_event.h:134
@ BUT_MIDDLE
Definition: tool_event.h:133
@ BUT_LEFT
Definition: tool_event.h:131
@ BUT_RIGHT
Definition: tool_event.h:132
@ BUT_AUX2
Definition: tool_event.h:135
@ BUT_BUTTON_MASK
Definition: tool_event.h:136
@ BUT_NONE
Definition: tool_event.h:130
@ BUT_ANY
Definition: tool_event.h:137