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 The 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 <cstdio>
31#include <deque>
32#include <iterator>
33
34#include <ki_any.h>
35
36#include <math/vector2d.h>
37#include <optional>
38#include <atomic>
39
40#include <tool/tool_action.h>
41#include <wx/debug.h>
42
43class COMMIT;
44class TOOL_ACTION;
45class TOOL_MANAGER;
46class TOOL_BASE;
47class TOOLS_HOLDER;
48
53{
54 TC_NONE = 0x00,
55 TC_MOUSE = 0x01,
57 TC_COMMAND = 0x04,
58 TC_MESSAGE = 0x08,
59 TC_VIEW = 0x10,
60 TC_ANY = 0xffffffff
61};
62
64{
65 // UI input events
66 TA_NONE = 0x0000,
69 TA_MOUSE_UP = 0x0004,
70 TA_MOUSE_DOWN = 0x0008,
71 TA_MOUSE_DRAG = 0x0010,
74 TA_MOUSE = 0x007f,
75
78
79 // View related events
81 TA_VIEW_ZOOM = 0x0200,
82 TA_VIEW_PAN = 0x0400,
83 TA_VIEW_DIRTY = 0x0800,
84 TA_VIEW = 0x0f00,
85
87
91
95
99
102
104
107
110
112 TA_ACTION = 0x80000,
113
115 TA_ACTIVATE = 0x100000,
116
118 TA_REACTIVATE = 0x200000,
119
121 TA_MODEL_CHANGE = 0x400000,
122
124 TA_PRIME = 0x800001,
125
126 TA_ANY = 0xffffffff
127};
128
140
142{
143 MD_SHIFT = 0x1000,
144 MD_CTRL = 0x2000,
145 MD_ALT = 0x4000,
146 MD_SUPER = 0x8000,
147 MD_META = 0x10000,
148 MD_ALTGR = 0x20000,
150};
151
159
166
171{
172public:
178 const std::string Format() const;
179
181 TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) :
182 m_category( aCategory ),
183 m_actions( aAction ),
184 m_scope( aScope ),
185 m_mouseButtons( 0 ),
186 m_keyCode( 0 ),
187 m_modifiers( 0 ),
188 m_synchronousState( nullptr ),
189 m_commit( nullptr ),
190 m_firstResponder( nullptr )
191 {
192 init();
193 }
194
195 TOOL_EVENT( TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam,
196 TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) :
197 m_category( aCategory ),
198 m_actions( aAction ),
199 m_scope( aScope ),
200 m_mouseButtons( 0 ),
201 m_keyCode( 0 ),
202 m_modifiers( 0 ),
203 m_synchronousState( nullptr ),
204 m_commit( nullptr ),
205 m_firstResponder( nullptr )
206 {
207 if( aCategory == TC_MOUSE )
208 {
209 setMouseButtons( aExtraParam & BUT_BUTTON_MASK );
210 }
211 else if( aCategory == TC_KEYBOARD )
212 {
213 m_keyCode = aExtraParam & ~MD_MODIFIER_MASK; // Filter out modifiers
214 }
215 else if( aCategory == TC_COMMAND )
216 {
217 m_commandId = aExtraParam;
218 }
219
220 if( aCategory & ( TC_MOUSE | TC_KEYBOARD ) )
221 {
222 m_modifiers = aExtraParam & MD_MODIFIER_MASK;
223 }
224
225 init();
226 }
227
229 const std::string& aExtraParam, TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) :
230 m_category( aCategory ),
231 m_actions( aAction ),
232 m_scope( aScope ),
233 m_mouseButtons( 0 ),
234 m_keyCode( 0 ),
235 m_modifiers( 0 ),
236 m_synchronousState( nullptr ),
237 m_commit( nullptr ),
238 m_firstResponder( nullptr )
239 {
240 if( aCategory == TC_COMMAND || aCategory == TC_MESSAGE )
241 m_commandStr = aExtraParam;
242
243 init();
244 }
245
248
250 TOOL_ACTIONS Action() const { return m_actions; }
251
255 bool PassEvent() const { return m_passEvent; }
256 void SetPassEvent( bool aPass = true ) { m_passEvent = aPass; }
257
260 bool HasPosition() const { return m_hasPosition; }
261 void SetHasPosition( bool aHasPosition ) { m_hasPosition = aHasPosition; }
262
265 bool ForceImmediate() const { return m_forceImmediate; }
266 void SetForceImmediate( bool aForceImmediate = true ) { m_forceImmediate = aForceImmediate; }
267
269 void SetFirstResponder( TOOL_BASE* aTool ) { m_firstResponder = aTool; }
270
273 bool IsReactivate() const { return m_reactivate; }
274 void SetReactivate( bool aReactivate = true ) { m_reactivate = aReactivate; }
275
276 void SetSynchronous( std::atomic<SYNCRONOUS_TOOL_STATE>* aState )
277 {
278 m_synchronousState = aState;
279 }
280 std::atomic<SYNCRONOUS_TOOL_STATE>* SynchronousState() const { return m_synchronousState; }
281
282 void SetCommit( COMMIT* aCommit ) { m_commit = aCommit; }
283 COMMIT* Commit() const { return m_commit; }
284
287 const VECTOR2D Delta() const
288 {
290 }
291
293 const VECTOR2D Position() const
294 {
296 }
297
299 const VECTOR2D DragOrigin() const
300 {
302 }
303
305 int Buttons() const
306 {
307 assert( m_category == TC_MOUSE ); // this should be used only with mouse events
308 return m_mouseButtons;
309 }
310
311 bool IsClick( int aButtonMask = BUT_ANY ) const;
312
313 bool IsDblClick( int aButtonMask = BUT_ANY ) const;
314
315 bool IsDrag( int aButtonMask = BUT_ANY ) const
316 {
317 return m_actions == TA_MOUSE_DRAG && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
318 }
319
320 bool IsMouseDown( int aButtonMask = BUT_ANY ) const
321 {
322 return m_actions == TA_MOUSE_DOWN && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
323 }
324
325 bool IsMouseUp( int aButtonMask = BUT_ANY ) const
326 {
327 return m_actions == TA_MOUSE_UP && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
328 }
329
330 bool IsMotion() const
331 {
332 return m_actions == TA_MOUSE_MOTION;
333 }
334
335 bool IsMouseAction() const
336 {
337 return ( m_actions & TA_MOUSE );
338 }
339
340 bool IsCancel() const
341 {
342 return m_actions == TA_CANCEL_TOOL;
343 }
344
345 bool IsActivate() const
346 {
347 return m_actions == TA_ACTIVATE;
348 }
349
350 bool IsUndoRedo() const
351 {
353 }
354
355 bool IsChoiceMenu() const
356 {
357 return m_actions & TA_CHOICE_MENU;
358 }
359
360 bool IsPrime() const
361 {
362 return m_actions == TA_PRIME;
363 }
364
366 int Modifier( int aMask = MD_MODIFIER_MASK ) const
367 {
368 return m_modifiers & aMask;
369 }
370
372 {
373 return Modifier( MD_CTRL );
374 }
375
376 int KeyCode() const
377 {
378 return m_keyCode;
379 }
380
381 bool IsKeyPressed() const
382 {
383 return m_actions == TA_KEY_PRESSED;
384 }
385
392 bool Matches( const TOOL_EVENT& aEvent ) const
393 {
394 if( !( m_category & aEvent.m_category ) )
395 return false;
396
398 {
399 if( !m_commandStr.empty() && !aEvent.getCommandStr().empty() )
400 return m_commandStr == aEvent.m_commandStr;
401
402 if( (bool) m_commandId && (bool) aEvent.m_commandId )
403 return *m_commandId == *aEvent.m_commandId;
404 }
405
406 // BUGFIX: TA_ANY should match EVERYTHING, even TA_NONE (for TC_MESSAGE)
407 if( m_actions == TA_ANY && aEvent.m_actions == TA_NONE && aEvent.m_category == TC_MESSAGE )
408 return true;
409
410 // BUGFIX: This check must happen after the TC_COMMAND check because otherwise events of
411 // the form { TC_COMMAND, TA_NONE } will be incorrectly skipped
412 if( !( m_actions & aEvent.m_actions ) )
413 return false;
414
415 return true;
416 }
417
424 bool IsAction( const TOOL_ACTION* aAction ) const;
425
430 bool IsCancelInteractive() const;
431
435 bool IsSelectionEvent() const;
436
443 bool IsPointEditor() const;
444
450 bool IsMoveTool() const;
451
457 bool IsEditorTool() const;
458
462 bool IsSimulator() const;
463
464 bool HasParameter() const
465 {
466 return m_param.has_value();
467 }
468
472 template<typename T, std::enable_if_t<!std::is_pointer<T>::value>* = nullptr >
473 T Parameter() const
474 {
475 T param;
476
477 wxCHECK_MSG( m_param.has_value(), T(), "Attempted to get a parameter from an event with "
478 "no parameter." );
479
480 try
481 {
482 param = ki::any_cast<T>( m_param );
483 }
484 catch( const ki::bad_any_cast& )
485 {
486 wxCHECK_MSG( false, T(), wxString::Format( "Requested parameter type %s from event "
487 "with parameter type %s.",
488 typeid(T).name(),
489 m_param.type().name() ) );
490 }
491
492 return param;
493 }
494
498 template<typename T, std::enable_if_t<std::is_pointer<T>::value>* = nullptr>
499 T Parameter() const
500 {
501 T param = nullptr;
502
503 wxCHECK_MSG( m_param.has_value(), param, "Attempted to get a parameter from an event with "
504 "no parameter." );
505
506 try
507 {
508 param = ki::any_cast<T>( m_param );
509 }
510 catch( const ki::bad_any_cast& )
511 {
512 wxCHECK_MSG( false, param, wxString::Format( "Requested parameter type %s from event "
513 "with parameter type %s.",
514 typeid(T).name(),
515 m_param.type().name() ) );
516 }
517
518 return param;
519 }
520
527 template<typename T>
528 void SetParameter(T aParam)
529 {
530 m_param = aParam;
531 }
532
533 std::optional<int> GetCommandId() const
534 {
535 return m_commandId;
536 }
537
538 void SetMousePosition( const VECTOR2D& aP )
539 {
540 m_mousePos = aP;
541 }
542
543 void SetActionGroup( const TOOL_ACTION_GROUP& aGroup )
544 {
545 m_actionGroup = aGroup;
546 }
547
548 bool IsActionInGroup( const TOOL_ACTION_GROUP& aGroup ) const;
549
550private:
551 friend class TOOL_EVENT_LIST;
552 friend class TOOL_DISPATCHER;
553 friend class TOOL_MANAGER;
554 friend class TOOLS_HOLDER;
555
556 void init();
557
558 const std::string& getCommandStr() const { return m_commandStr; }
559
560 void setMouseDragOrigin( const VECTOR2D& aP )
561 {
563 }
564
565 void setMouseDelta( const VECTOR2D& aP )
566 {
567 m_mouseDelta = aP;
568 }
569
570 void setMouseButtons( int aButtons )
571 {
572 assert( ( aButtons & ~BUT_BUTTON_MASK ) == 0 );
573 m_mouseButtons = aButtons;
574 }
575
576 void setModifiers( int aMods )
577 {
578 assert( ( aMods & ~MD_MODIFIER_MASK ) == 0 );
579 m_modifiers = aMods;
580 }
581
592 VECTOR2D returnCheckedPosition( const VECTOR2D& aPos ) const;
593
600
601
603 std::optional<TOOL_ACTION_GROUP> m_actionGroup;
604
607
610
613
616
619
622
625
626 std::atomic<SYNCRONOUS_TOOL_STATE>* m_synchronousState;
627
630
633
636
637 std::optional<int> m_commandId;
638 std::string m_commandStr;
639};
640
641typedef std::optional<TOOL_EVENT> OPT_TOOL_EVENT;
642
648{
649public:
651 typedef std::deque<TOOL_EVENT>::iterator iterator;
652 typedef std::deque<TOOL_EVENT>::const_iterator const_iterator;
653
657
659 TOOL_EVENT_LIST( const TOOL_EVENT& aSingleEvent )
660 {
661 m_events.push_back( aSingleEvent );
662 }
663
665 TOOL_EVENT_LIST( const TOOL_EVENT_LIST& aEventList )
666 {
667 m_events.clear();
668
669 for( const TOOL_EVENT& event : aEventList.m_events )
670 m_events.push_back( event );
671 }
672
678 const std::string Format() const;
679
685 const std::string Names() const;
686
687 OPT_TOOL_EVENT Matches( const TOOL_EVENT& aEvent ) const
688 {
689 for( const TOOL_EVENT& event : m_events )
690 {
691 if( event.Matches( aEvent ) )
692 return event;
693 }
694
695 return OPT_TOOL_EVENT();
696 }
697
703 void Add( const TOOL_EVENT& aEvent )
704 {
705 m_events.push_back( aEvent );
706 }
707
709 {
710 return m_events.begin();
711 }
712
714 {
715 return m_events.end();
716 }
717
719 {
720 return m_events.begin();
721 }
722
724 {
725 return m_events.end();
726 }
727
728 int size() const
729 {
730 return m_events.size();
731 }
732
733 void clear()
734 {
735 m_events.clear();
736 }
737
739 {
740 m_events.clear();
741
742 for( const TOOL_EVENT& event : aEventList.m_events )
743 m_events.push_back( event );
744
745 return *this;
746 }
747
749 {
750 m_events.clear();
751 m_events.push_back( aEvent );
752 return *this;
753 }
754
756 {
757 Add( aEvent );
758 return *this;
759 }
760
762 {
763 std::copy( aEvent.m_events.begin(), aEvent.m_events.end(), std::back_inserter( m_events ) );
764 return *this;
765 }
766
767private:
768 std::deque<TOOL_EVENT> m_events;
769};
770
771
772inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEventA, const TOOL_EVENT& aEventB )
773{
775
776 l.Add( aEventA );
777 l.Add( aEventB );
778
779 return l;
780}
781
782
783inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEvent,
784 const TOOL_EVENT_LIST& aEventList )
785{
786 TOOL_EVENT_LIST l( aEventList );
787
788 l.Add( aEvent );
789 return l;
790}
791
792
793#endif
const char * name
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition commit.h:72
Define a group that can be used to group actions (and their events) of similar operations.
Definition tool_action.h:79
Represent a single user action.
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:648
iterator begin()
Definition tool_event.h:708
const std::string Format() const
Return information about event in form of a human-readable string.
int size() const
Definition tool_event.h:728
TOOL_EVENT value_type
Definition tool_event.h:650
std::deque< TOOL_EVENT > m_events
Definition tool_event.h:768
std::deque< TOOL_EVENT >::const_iterator const_iterator
Definition tool_event.h:652
const std::string Names() const
Return a string containing the names of all the events in this list.
iterator end()
Definition tool_event.h:713
TOOL_EVENT_LIST & operator=(const TOOL_EVENT &aEvent)
Definition tool_event.h:748
std::deque< TOOL_EVENT >::iterator iterator
Definition tool_event.h:651
TOOL_EVENT_LIST(const TOOL_EVENT &aSingleEvent)
Constructor for a list containing only one TOOL_EVENT.
Definition tool_event.h:659
TOOL_EVENT_LIST()
Default constructor. Creates an empty list.
Definition tool_event.h:655
void Add(const TOOL_EVENT &aEvent)
Add a tool event to the list.
Definition tool_event.h:703
TOOL_EVENT_LIST & operator=(const TOOL_EVENT_LIST &aEventList)
Definition tool_event.h:738
const_iterator cbegin() const
Definition tool_event.h:718
TOOL_EVENT_LIST(const TOOL_EVENT_LIST &aEventList)
Copy an existing TOOL_EVENT_LIST.
Definition tool_event.h:665
TOOL_EVENT_LIST & operator||(const TOOL_EVENT_LIST &aEvent)
Definition tool_event.h:761
OPT_TOOL_EVENT Matches(const TOOL_EVENT &aEvent) const
Definition tool_event.h:687
const_iterator cend() const
Definition tool_event.h:723
TOOL_EVENT_LIST & operator||(const TOOL_EVENT &aEvent)
Definition tool_event.h:755
Generic, UI-independent tool event.
Definition tool_event.h:171
int Buttons() const
Return information about mouse buttons state.
Definition tool_event.h:305
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition tool_event.h:260
bool DisableGridSnapping() const
Definition tool_event.h:371
bool HasParameter() const
Definition tool_event.h:464
friend class TOOL_EVENT_LIST
Definition tool_event.h:551
bool IsCancelInteractive() const
Indicate the event should restart/end an ongoing interactive tool's event loop (eg esc key,...
bool m_hasPosition
Definition tool_event.h:598
void SetCommit(COMMIT *aCommit)
Definition tool_event.h:282
std::optional< int > m_commandId
Definition tool_event.h:637
void setMouseDragOrigin(const VECTOR2D &aP)
Definition tool_event.h:560
int m_keyCode
Stores code of pressed/released key.
Definition tool_event.h:621
void SetActionGroup(const TOOL_ACTION_GROUP &aGroup)
Definition tool_event.h:543
TOOL_ACTION_SCOPE m_scope
Definition tool_event.h:596
bool PassEvent() const
These give a tool a method of informing the TOOL_MANAGER that a particular event should be passed on ...
Definition tool_event.h:255
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition tool_event.h:250
void SetMousePosition(const VECTOR2D &aP)
Definition tool_event.h:538
int m_modifiers
State of key modifiers (Ctrl/Alt/etc.).
Definition tool_event.h:624
TOOL_EVENT(TOOL_EVENT_CATEGORY aCategory=TC_NONE, TOOL_ACTIONS aAction=TA_NONE, TOOL_ACTION_SCOPE aScope=AS_GLOBAL)
Definition tool_event.h:180
int KeyCode() const
Definition tool_event.h:376
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition tool_event.h:392
TOOL_BASE * FirstResponder() const
Definition tool_event.h:268
ki::any m_param
Generic parameter used for passing non-standard data.
Definition tool_event.h:632
void setMouseDelta(const VECTOR2D &aP)
Definition tool_event.h:565
bool IsActivate() const
Definition tool_event.h:345
void SetFirstResponder(TOOL_BASE *aTool)
Definition tool_event.h:269
friend class TOOL_DISPATCHER
Definition tool_event.h:552
VECTOR2D m_mousePos
Current mouse cursor position.
Definition tool_event.h:612
bool IsPrime() const
Definition tool_event.h:360
std::string m_commandStr
Definition tool_event.h:638
bool IsSimulator() const
Indicate if the event is from the simulator.
COMMIT * Commit() const
Definition tool_event.h:283
const VECTOR2D Position() const
Return mouse cursor position in world coordinates.
Definition tool_event.h:293
bool IsSelectionEvent() const
Indicate an selection-changed notification event.
void SetParameter(T aParam)
Set a non-standard parameter assigned to the event.
Definition tool_event.h:528
bool ForceImmediate() const
Returns if the action associated with this event should be treated as immediate regardless of the cur...
Definition tool_event.h:265
bool IsReactivate() const
Control whether the tool is first being pushed to the stack or being reactivated after a pause.
Definition tool_event.h:273
friend class TOOL_MANAGER
Definition tool_event.h:553
bool IsKeyPressed() const
Definition tool_event.h:381
bool IsClick(int aButtonMask=BUT_ANY) const
void SetForceImmediate(bool aForceImmediate=true)
Definition tool_event.h:266
TOOL_EVENT_CATEGORY Category() const
Return the category (eg. mouse/keyboard/action) of an event.
Definition tool_event.h:247
std::atomic< SYNCRONOUS_TOOL_STATE > * m_synchronousState
Definition tool_event.h:626
bool m_passEvent
Definition tool_event.h:597
TOOL_EVENT(TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam, TOOL_ACTION_SCOPE aScope=AS_GLOBAL)
Definition tool_event.h:195
void SetReactivate(bool aReactivate=true)
Definition tool_event.h:274
void init()
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition tool_event.h:315
int Modifier(int aMask=MD_MODIFIER_MASK) const
Return information about key modifiers state (Ctrl, Alt, etc.).
Definition tool_event.h:366
COMMIT * m_commit
Commit the tool handling the event should add to.
Definition tool_event.h:629
bool IsMoveTool() const
Indicate if the event is from one of the move tools.
TOOL_ACTIONS m_actions
Definition tool_event.h:595
std::optional< TOOL_ACTION_GROUP > m_actionGroup
Optional group that the parent action for the event belongs to.
Definition tool_event.h:603
bool m_forceImmediate
Definition tool_event.h:599
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
const VECTOR2D DragOrigin() const
Return the point where dragging has started.
Definition tool_event.h:299
void SetHasPosition(bool aHasPosition)
Definition tool_event.h:261
bool IsActionInGroup(const TOOL_ACTION_GROUP &aGroup) const
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...
bool IsEditorTool() const
Indicate if the event is asking for an editor tool.
bool m_reactivate
True when the tool is being re-activated from the stack.
Definition tool_event.h:606
bool IsCancel() const
Definition tool_event.h:340
void setMouseButtons(int aButtons)
Definition tool_event.h:570
TOOL_BASE * m_firstResponder
The first tool to receive the event.
Definition tool_event.h:635
friend class TOOLS_HOLDER
Definition tool_event.h:554
T Parameter() const
Return a parameter assigned to the event.
Definition tool_event.h:473
bool IsMouseDown(int aButtonMask=BUT_ANY) const
Definition tool_event.h:320
bool IsDblClick(int aButtonMask=BUT_ANY) const
const std::string & getCommandStr() const
Definition tool_event.h:558
TOOL_EVENT_CATEGORY m_category
Definition tool_event.h:594
void SetSynchronous(std::atomic< SYNCRONOUS_TOOL_STATE > *aState)
Definition tool_event.h:276
bool IsUndoRedo() const
Definition tool_event.h:350
bool IsPointEditor() const
Indicate if the event is from one of the point editors.
int m_mouseButtons
State of mouse buttons.
Definition tool_event.h:618
std::atomic< SYNCRONOUS_TOOL_STATE > * SynchronousState() const
Definition tool_event.h:280
VECTOR2D m_mouseDelta
Difference between mouse cursor position and the point where dragging event has started.
Definition tool_event.h:609
TOOL_EVENT(TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, const std::string &aExtraParam, TOOL_ACTION_SCOPE aScope=AS_GLOBAL)
Definition tool_event.h:228
std::optional< int > GetCommandId() const
Definition tool_event.h:533
void setModifiers(int aMods)
Definition tool_event.h:576
void SetPassEvent(bool aPass=true)
Definition tool_event.h:256
bool IsChoiceMenu() const
Definition tool_event.h:355
VECTOR2D m_mouseDragOrigin
Point where dragging has started.
Definition tool_event.h:615
bool IsMouseAction() const
Definition tool_event.h:335
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition tool_event.h:325
bool IsMotion() const
Definition tool_event.h:330
const std::string Format() const
Return information about event in form of a human-readable string.
const VECTOR2D Delta() const
Return information about difference between current mouse cursor position and the place where draggin...
Definition tool_event.h:287
Master controller class:
A type-safe container of any type.
Definition ki_any.h:93
Exception class thrown by a failed any_cast.
Definition ki_any.h:81
An implementation of std::any_cast, which uses type_info::hash_code to check validity of cast types.
ValueType any_cast(const any &any)
Access the contained object.
Definition ki_any.h:446
TOOL_ACTION_SCOPE
Scope of tool actions.
Definition tool_action.h:46
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition tool_action.h:49
const TOOL_EVENT_LIST operator||(const TOOL_EVENT &aEventA, const TOOL_EVENT &aEventB)
Definition tool_event.h:772
CONTEXT_MENU_TRIGGER
Defines when a context menu is opened.
Definition tool_event.h:154
@ CMENU_NOW
Right now (after TOOL_INTERACTIVE::SetContextMenu).
Definition tool_event.h:156
@ CMENU_OFF
Never.
Definition tool_event.h:157
@ CMENU_BUTTON
On the right button.
Definition tool_event.h:155
std::optional< TOOL_EVENT > OPT_TOOL_EVENT
Definition tool_event.h:641
TOOL_ACTIONS
Definition tool_event.h:64
@ TA_MODEL_CHANGE
Model has changed (partial update).
Definition tool_event.h:121
@ TA_ANY
Definition tool_event.h:126
@ TA_CHOICE_MENU_CHOICE
Context menu choice.
Definition tool_event.h:98
@ TA_UNDO_REDO_PRE
This event is sent before undo/redo command is performed.
Definition tool_event.h:106
@ TA_MOUSE_CLICK
Definition tool_event.h:67
@ TA_CHOICE_MENU_UPDATE
Context menu update.
Definition tool_event.h:94
@ TA_MOUSE
Definition tool_event.h:74
@ TA_ACTIVATE
Tool activation event.
Definition tool_event.h:115
@ TA_CHOICE_MENU_CLOSED
Context menu is closed, no matter whether anything has been chosen or not.
Definition tool_event.h:101
@ TA_PRIME
Tool priming event (a special mouse click).
Definition tool_event.h:124
@ TA_MOUSE_MOTION
Definition tool_event.h:72
@ TA_MOUSE_UP
Definition tool_event.h:69
@ TA_KEYBOARD
Definition tool_event.h:77
@ TA_VIEW_REFRESH
Definition tool_event.h:80
@ TA_CHOICE_MENU
Definition tool_event.h:103
@ TA_MOUSE_DRAG
Definition tool_event.h:71
@ TA_CHANGE_LAYER
Definition tool_event.h:86
@ TA_MOUSE_DOWN
Definition tool_event.h:70
@ TA_VIEW
Definition tool_event.h:84
@ TA_UNDO_REDO_POST
This event is sent after undo/redo command is performed.
Definition tool_event.h:109
@ TA_KEY_PRESSED
Definition tool_event.h:76
@ TA_MOUSE_DBLCLICK
Definition tool_event.h:68
@ TA_MOUSE_WHEEL
Definition tool_event.h:73
@ TA_ACTION
Tool action (allows one to control tools).
Definition tool_event.h:112
@ TA_VIEW_PAN
Definition tool_event.h:82
@ TA_NONE
Definition tool_event.h:66
@ TA_CANCEL_TOOL
Tool cancel event.
Definition tool_event.h:90
@ TA_VIEW_DIRTY
Definition tool_event.h:83
@ TA_REACTIVATE
Tool re-activation event for tools already on the stack.
Definition tool_event.h:118
@ TA_VIEW_ZOOM
Definition tool_event.h:81
TOOL_EVENT_CATEGORY
Internal (GUI-independent) event definitions.
Definition tool_event.h:53
@ TC_NONE
Definition tool_event.h:54
@ TC_ANY
Definition tool_event.h:60
@ TC_COMMAND
Definition tool_event.h:57
@ TC_MOUSE
Definition tool_event.h:55
@ TC_MESSAGE
Definition tool_event.h:58
@ TC_KEYBOARD
Definition tool_event.h:56
@ TC_VIEW
Definition tool_event.h:59
TOOL_MODIFIERS
Definition tool_event.h:142
@ MD_MODIFIER_MASK
Definition tool_event.h:149
@ MD_META
Definition tool_event.h:147
@ MD_ALT
Definition tool_event.h:145
@ MD_CTRL
Definition tool_event.h:144
@ MD_SUPER
Definition tool_event.h:146
@ MD_ALTGR
Definition tool_event.h:148
@ MD_SHIFT
Definition tool_event.h:143
SYNCRONOUS_TOOL_STATE
Definition tool_event.h:161
@ STS_CANCELLED
Definition tool_event.h:164
@ STS_FINISHED
Definition tool_event.h:163
@ STS_RUNNING
Definition tool_event.h:162
TOOL_MOUSE_BUTTONS
Definition tool_event.h:130
@ BUT_AUX1
Definition tool_event.h:135
@ BUT_MIDDLE
Definition tool_event.h:134
@ BUT_LEFT
Definition tool_event.h:132
@ BUT_RIGHT
Definition tool_event.h:133
@ BUT_AUX2
Definition tool_event.h:136
@ BUT_BUTTON_MASK
Definition tool_event.h:137
@ BUT_NONE
Definition tool_event.h:131
@ BUT_ANY
Definition tool_event.h:138
VECTOR2< double > VECTOR2D
Definition vector2d.h:694