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, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef __TOOL_EVENT_H
24#define __TOOL_EVENT_H
25
26#include <cstdio>
27#include <deque>
28#include <iterator>
29
30#include <ki_any.h>
31
32#include <math/vector2d.h>
33#include <optional>
34#include <atomic>
35
36#include <tool/tool_action.h>
37#include <wx/debug.h>
38
39class COMMIT;
40class TOOL_ACTION;
41class TOOL_MANAGER;
42class TOOL_BASE;
43class TOOLS_HOLDER;
44
48enum TOOL_EVENT_CATEGORY : unsigned int
49{
50 TC_NONE = 0x00,
51 TC_MOUSE = 0x01,
53 TC_COMMAND = 0x04,
54 TC_MESSAGE = 0x08,
55 TC_VIEW = 0x10,
56 TC_ANY = 0xffffffff
57};
58
59enum TOOL_ACTIONS : unsigned int
60{
61 // UI input events
62 TA_NONE = 0x0000,
65 TA_MOUSE_UP = 0x0004,
66 TA_MOUSE_DOWN = 0x0008,
67 TA_MOUSE_DRAG = 0x0010,
70 TA_MOUSE = 0x007f,
71
74
75 // View related events
77 TA_VIEW_ZOOM = 0x0200,
78 TA_VIEW_PAN = 0x0400,
79 TA_VIEW_DIRTY = 0x0800,
80 TA_VIEW = 0x0f00,
81
83
87
91
95
98
100
103
106
108 TA_ACTION = 0x80000,
109
111 TA_ACTIVATE = 0x100000,
112
114 TA_REACTIVATE = 0x200000,
115
117 TA_MODEL_CHANGE = 0x400000,
118
120 TA_PRIME = 0x800001,
121
122 TA_ANY = 0xffffffff
123};
124
136
137enum TOOL_MODIFIERS : unsigned int
138{
139 MD_SHIFT = 0x1000,
140 MD_CTRL = 0x2000,
141 MD_ALT = 0x4000,
142 MD_SUPER = 0x8000,
143 MD_META = 0x10000,
144 MD_ALTGR = 0x20000,
146};
147
155
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
269 bool IsReactivate() const { return m_reactivate; }
270 void SetReactivate( bool aReactivate = true ) { m_reactivate = aReactivate; }
271
272 void SetSynchronous( std::atomic<SYNCRONOUS_TOOL_STATE>* aState )
273 {
274 m_synchronousState = aState;
275 }
276 std::atomic<SYNCRONOUS_TOOL_STATE>* SynchronousState() const { return m_synchronousState; }
277
278 void SetCommit( COMMIT* aCommit ) { m_commit = aCommit; }
279 COMMIT* Commit() const { return m_commit; }
280
283 const VECTOR2D Delta() const
284 {
286 }
287
289 const VECTOR2D Position() const
290 {
292 }
293
295 const VECTOR2D DragOrigin() const
296 {
298 }
299
301 int Buttons() const
302 {
303 assert( m_category == TC_MOUSE ); // this should be used only with mouse events
304 return m_mouseButtons;
305 }
306
307 bool IsClick( int aButtonMask = BUT_ANY ) const;
308
309 bool IsDblClick( int aButtonMask = BUT_ANY ) const;
310
311 bool IsDrag( int aButtonMask = BUT_ANY ) const
312 {
313 return m_actions == TA_MOUSE_DRAG && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
314 }
315
316 bool IsMouseDown( int aButtonMask = BUT_ANY ) const
317 {
318 return m_actions == TA_MOUSE_DOWN && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
319 }
320
321 bool IsMouseUp( int aButtonMask = BUT_ANY ) const
322 {
323 return m_actions == TA_MOUSE_UP && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
324 }
325
326 bool IsMotion() const
327 {
328 return m_actions == TA_MOUSE_MOTION;
329 }
330
331 bool IsMouseAction() const
332 {
333 return ( m_actions & TA_MOUSE );
334 }
335
336 bool IsCancel() const
337 {
338 return m_actions == TA_CANCEL_TOOL;
339 }
340
341 bool IsActivate() const
342 {
343 return m_actions == TA_ACTIVATE;
344 }
345
346 bool IsUndoRedo() const
347 {
349 }
350
351 bool IsChoiceMenu() const
352 {
353 return m_actions & TA_CHOICE_MENU;
354 }
355
356 bool IsPrime() const
357 {
358 return m_actions == TA_PRIME;
359 }
360
362 int Modifier( int aMask = MD_MODIFIER_MASK ) const
363 {
364 return m_modifiers & aMask;
365 }
366
368 {
369 return Modifier( MD_CTRL );
370 }
371
372 int KeyCode() const
373 {
374 return m_keyCode;
375 }
376
377 bool IsKeyPressed() const
378 {
379 return m_actions == TA_KEY_PRESSED;
380 }
381
388 bool Matches( const TOOL_EVENT& aEvent ) const
389 {
390 if( !( m_category & aEvent.m_category ) )
391 return false;
392
394 {
395 if( !m_commandStr.empty() && !aEvent.getCommandStr().empty() )
396 return m_commandStr == aEvent.m_commandStr;
397
398 if( (bool) m_commandId && (bool) aEvent.m_commandId )
399 return *m_commandId == *aEvent.m_commandId;
400 }
401
402 // BUGFIX: TA_ANY should match EVERYTHING, even TA_NONE (for TC_MESSAGE)
403 if( m_actions == TA_ANY && aEvent.m_actions == TA_NONE && aEvent.m_category == TC_MESSAGE )
404 return true;
405
406 // BUGFIX: This check must happen after the TC_COMMAND check because otherwise events of
407 // the form { TC_COMMAND, TA_NONE } will be incorrectly skipped
408 if( !( m_actions & aEvent.m_actions ) )
409 return false;
410
411 return true;
412 }
413
420 bool IsAction( const TOOL_ACTION* aAction ) const;
421
426 bool IsCancelInteractive() const;
427
431 bool IsSelectionEvent() const;
432
439 bool IsPointEditor() const;
440
446 bool IsMoveTool() const;
447
453 bool IsEditorTool() const;
454
458 bool IsSimulator() const;
459
460 bool HasParameter() const
461 {
462 return m_param.has_value();
463 }
464
468 template<typename T, std::enable_if_t<!std::is_pointer<T>::value>* = nullptr >
469 T Parameter() const
470 {
471 T param;
472
473 wxCHECK_MSG( m_param.has_value(), T(), "Attempted to get a parameter from an event with "
474 "no parameter." );
475
476 try
477 {
478 param = ki::any_cast<T>( m_param );
479 }
480 catch( const ki::bad_any_cast& )
481 {
482 wxCHECK_MSG( false, T(), wxString::Format( "Requested parameter type %s from event "
483 "with parameter type %s.",
484 typeid(T).name(),
485 m_param.type().name() ) );
486 }
487
488 return param;
489 }
490
494 template<typename T, std::enable_if_t<std::is_pointer<T>::value>* = nullptr>
495 T Parameter() const
496 {
497 T param = nullptr;
498
499 wxCHECK_MSG( m_param.has_value(), param, "Attempted to get a parameter from an event with "
500 "no parameter." );
501
502 try
503 {
504 param = ki::any_cast<T>( m_param );
505 }
506 catch( const ki::bad_any_cast& )
507 {
508 wxCHECK_MSG( false, param, wxString::Format( "Requested parameter type %s from event "
509 "with parameter type %s.",
510 typeid(T).name(),
511 m_param.type().name() ) );
512 }
513
514 return param;
515 }
516
523 template<typename T>
524 void SetParameter(T aParam)
525 {
526 m_param = aParam;
527 }
528
529 std::optional<int> GetCommandId() const
530 {
531 return m_commandId;
532 }
533
534 void SetMousePosition( const VECTOR2D& aP )
535 {
536 m_mousePos = aP;
537 }
538
539 void SetActionGroup( const TOOL_ACTION_GROUP& aGroup )
540 {
541 m_actionGroup = aGroup;
542 }
543
544 bool IsActionInGroup( const TOOL_ACTION_GROUP& aGroup ) const;
545
546private:
547 friend class TOOL_EVENT_LIST;
548 friend class TOOL_DISPATCHER;
549 friend class TOOL_MANAGER;
550 friend class TOOLS_HOLDER;
551
552 void init();
553
554 const std::string& getCommandStr() const { return m_commandStr; }
555
556 void setMouseDragOrigin( const VECTOR2D& aP )
557 {
559 }
560
561 void setMouseDelta( const VECTOR2D& aP )
562 {
563 m_mouseDelta = aP;
564 }
565
566 void setMouseButtons( int aButtons )
567 {
568 assert( ( aButtons & ~BUT_BUTTON_MASK ) == 0 );
569 m_mouseButtons = aButtons;
570 }
571
572 void setModifiers( int aMods )
573 {
574 assert( ( aMods & ~MD_MODIFIER_MASK ) == 0 );
575 m_modifiers = aMods;
576 }
577
588 VECTOR2D returnCheckedPosition( const VECTOR2D& aPos ) const;
589
596
597
599 std::optional<TOOL_ACTION_GROUP> m_actionGroup;
600
603
606
609
612
615
618
621
622 std::atomic<SYNCRONOUS_TOOL_STATE>* m_synchronousState;
623
626
629
632
633 std::optional<int> m_commandId;
634 std::string m_commandStr;
635};
636
637typedef std::optional<TOOL_EVENT> OPT_TOOL_EVENT;
638
644{
645public:
647 typedef std::deque<TOOL_EVENT>::iterator iterator;
648 typedef std::deque<TOOL_EVENT>::const_iterator const_iterator;
649
653
655 TOOL_EVENT_LIST( const TOOL_EVENT& aSingleEvent )
656 {
657 m_events.push_back( aSingleEvent );
658 }
659
661 TOOL_EVENT_LIST( const TOOL_EVENT_LIST& aEventList )
662 {
663 m_events.clear();
664
665 for( const TOOL_EVENT& event : aEventList.m_events )
666 m_events.push_back( event );
667 }
668
674 const std::string Format() const;
675
681 const std::string Names() const;
682
683 OPT_TOOL_EVENT Matches( const TOOL_EVENT& aEvent ) const
684 {
685 for( const TOOL_EVENT& event : m_events )
686 {
687 if( event.Matches( aEvent ) )
688 return event;
689 }
690
691 return OPT_TOOL_EVENT();
692 }
693
699 void Add( const TOOL_EVENT& aEvent )
700 {
701 m_events.push_back( aEvent );
702 }
703
705 {
706 return m_events.begin();
707 }
708
710 {
711 return m_events.end();
712 }
713
715 {
716 return m_events.begin();
717 }
718
720 {
721 return m_events.end();
722 }
723
724 int size() const
725 {
726 return m_events.size();
727 }
728
729 void clear()
730 {
731 m_events.clear();
732 }
733
735 {
736 m_events.clear();
737
738 for( const TOOL_EVENT& event : aEventList.m_events )
739 m_events.push_back( event );
740
741 return *this;
742 }
743
745 {
746 m_events.clear();
747 m_events.push_back( aEvent );
748 return *this;
749 }
750
752 {
753 Add( aEvent );
754 return *this;
755 }
756
758 {
759 std::copy( aEvent.m_events.begin(), aEvent.m_events.end(), std::back_inserter( m_events ) );
760 return *this;
761 }
762
763private:
764 std::deque<TOOL_EVENT> m_events;
765};
766
767
768inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEventA, const TOOL_EVENT& aEventB )
769{
771
772 l.Add( aEventA );
773 l.Add( aEventB );
774
775 return l;
776}
777
778
779inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEvent,
780 const TOOL_EVENT_LIST& aEventList )
781{
782 TOOL_EVENT_LIST l( aEventList );
783
784 l.Add( aEvent );
785 return l;
786}
787
788
789#endif
const char * name
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition commit.h:68
Define a group that can be used to group actions (and their events) of similar operations.
Definition tool_action.h:75
Represent a single user action.
Base abstract interface for all kinds of tools.
Definition tool_base.h:62
A list of TOOL_EVENTs, with overloaded || operators allowing for concatenating TOOL_EVENTs with littl...
Definition tool_event.h:644
iterator begin()
Definition tool_event.h:704
const std::string Format() const
Return information about event in form of a human-readable string.
int size() const
Definition tool_event.h:724
TOOL_EVENT value_type
Definition tool_event.h:646
std::deque< TOOL_EVENT > m_events
Definition tool_event.h:764
std::deque< TOOL_EVENT >::const_iterator const_iterator
Definition tool_event.h:648
const std::string Names() const
Return a string containing the names of all the events in this list.
iterator end()
Definition tool_event.h:709
TOOL_EVENT_LIST & operator=(const TOOL_EVENT &aEvent)
Definition tool_event.h:744
std::deque< TOOL_EVENT >::iterator iterator
Definition tool_event.h:647
TOOL_EVENT_LIST(const TOOL_EVENT &aSingleEvent)
Constructor for a list containing only one TOOL_EVENT.
Definition tool_event.h:655
TOOL_EVENT_LIST()
Default constructor. Creates an empty list.
Definition tool_event.h:651
void Add(const TOOL_EVENT &aEvent)
Add a tool event to the list.
Definition tool_event.h:699
TOOL_EVENT_LIST & operator=(const TOOL_EVENT_LIST &aEventList)
Definition tool_event.h:734
const_iterator cbegin() const
Definition tool_event.h:714
TOOL_EVENT_LIST(const TOOL_EVENT_LIST &aEventList)
Copy an existing TOOL_EVENT_LIST.
Definition tool_event.h:661
TOOL_EVENT_LIST & operator||(const TOOL_EVENT_LIST &aEvent)
Definition tool_event.h:757
OPT_TOOL_EVENT Matches(const TOOL_EVENT &aEvent) const
Definition tool_event.h:683
const_iterator cend() const
Definition tool_event.h:719
TOOL_EVENT_LIST & operator||(const TOOL_EVENT &aEvent)
Definition tool_event.h:751
Generic, UI-independent tool event.
Definition tool_event.h:167
int Buttons() const
Return information about mouse buttons state.
Definition tool_event.h:301
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:256
bool DisableGridSnapping() const
Definition tool_event.h:367
bool HasParameter() const
Definition tool_event.h:460
friend class TOOL_EVENT_LIST
Definition tool_event.h:547
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:594
void SetCommit(COMMIT *aCommit)
Definition tool_event.h:278
std::optional< int > m_commandId
Definition tool_event.h:633
void setMouseDragOrigin(const VECTOR2D &aP)
Definition tool_event.h:556
int m_keyCode
Stores code of pressed/released key.
Definition tool_event.h:617
void SetActionGroup(const TOOL_ACTION_GROUP &aGroup)
Definition tool_event.h:539
TOOL_ACTION_SCOPE m_scope
Definition tool_event.h:592
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:251
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition tool_event.h:246
void SetMousePosition(const VECTOR2D &aP)
Definition tool_event.h:534
int m_modifiers
State of key modifiers (Ctrl/Alt/etc.).
Definition tool_event.h:620
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:372
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition tool_event.h:388
TOOL_BASE * FirstResponder() const
Definition tool_event.h:264
ki::any m_param
Generic parameter used for passing non-standard data.
Definition tool_event.h:628
void setMouseDelta(const VECTOR2D &aP)
Definition tool_event.h:561
bool IsActivate() const
Definition tool_event.h:341
void SetFirstResponder(TOOL_BASE *aTool)
Definition tool_event.h:265
friend class TOOL_DISPATCHER
Definition tool_event.h:548
VECTOR2D m_mousePos
Current mouse cursor position.
Definition tool_event.h:608
bool IsPrime() const
Definition tool_event.h:356
std::string m_commandStr
Definition tool_event.h:634
bool IsSimulator() const
Indicate if the event is from the simulator.
COMMIT * Commit() const
Definition tool_event.h:279
const VECTOR2D Position() const
Return mouse cursor position in world coordinates.
Definition tool_event.h:289
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:524
bool ForceImmediate() const
Returns if the action associated with this event should be treated as immediate regardless of the cur...
Definition tool_event.h:261
bool IsReactivate() const
Control whether the tool is first being pushed to the stack or being reactivated after a pause.
Definition tool_event.h:269
friend class TOOL_MANAGER
Definition tool_event.h:549
bool IsKeyPressed() const
Definition tool_event.h:377
bool IsClick(int aButtonMask=BUT_ANY) const
void SetForceImmediate(bool aForceImmediate=true)
Definition tool_event.h:262
TOOL_EVENT_CATEGORY Category() const
Return the category (eg. mouse/keyboard/action) of an event.
Definition tool_event.h:243
std::atomic< SYNCRONOUS_TOOL_STATE > * m_synchronousState
Definition tool_event.h:622
bool m_passEvent
Definition tool_event.h:593
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:270
void init()
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition tool_event.h:311
int Modifier(int aMask=MD_MODIFIER_MASK) const
Return information about key modifiers state (Ctrl, Alt, etc.).
Definition tool_event.h:362
COMMIT * m_commit
Commit the tool handling the event should add to.
Definition tool_event.h:625
bool IsMoveTool() const
Indicate if the event is from one of the move tools.
TOOL_ACTIONS m_actions
Definition tool_event.h:591
std::optional< TOOL_ACTION_GROUP > m_actionGroup
Optional group that the parent action for the event belongs to.
Definition tool_event.h:599
bool m_forceImmediate
Definition tool_event.h:595
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:295
void SetHasPosition(bool aHasPosition)
Definition tool_event.h:257
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:602
bool IsCancel() const
Definition tool_event.h:336
void setMouseButtons(int aButtons)
Definition tool_event.h:566
TOOL_BASE * m_firstResponder
The first tool to receive the event.
Definition tool_event.h:631
friend class TOOLS_HOLDER
Definition tool_event.h:550
T Parameter() const
Return a parameter assigned to the event.
Definition tool_event.h:469
bool IsMouseDown(int aButtonMask=BUT_ANY) const
Definition tool_event.h:316
bool IsDblClick(int aButtonMask=BUT_ANY) const
const std::string & getCommandStr() const
Definition tool_event.h:554
TOOL_EVENT_CATEGORY m_category
Definition tool_event.h:590
void SetSynchronous(std::atomic< SYNCRONOUS_TOOL_STATE > *aState)
Definition tool_event.h:272
bool IsUndoRedo() const
Definition tool_event.h:346
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:614
std::atomic< SYNCRONOUS_TOOL_STATE > * SynchronousState() const
Definition tool_event.h:276
VECTOR2D m_mouseDelta
Difference between mouse cursor position and the point where dragging event has started.
Definition tool_event.h:605
TOOL_EVENT(TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, const std::string &aExtraParam, TOOL_ACTION_SCOPE aScope=AS_GLOBAL)
Definition tool_event.h:224
std::optional< int > GetCommandId() const
Definition tool_event.h:529
void setModifiers(int aMods)
Definition tool_event.h:572
void SetPassEvent(bool aPass=true)
Definition tool_event.h:252
bool IsChoiceMenu() const
Definition tool_event.h:351
VECTOR2D m_mouseDragOrigin
Point where dragging has started.
Definition tool_event.h:611
bool IsMouseAction() const
Definition tool_event.h:331
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition tool_event.h:321
bool IsMotion() const
Definition tool_event.h:326
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:283
Master controller class:
A type-safe container of any type.
Definition ki_any.h:92
Exception class thrown by a failed any_cast.
Definition ki_any.h:80
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:445
TOOL_ACTION_SCOPE
Scope of tool actions.
Definition tool_action.h:42
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition tool_action.h:45
const TOOL_EVENT_LIST operator||(const TOOL_EVENT &aEventA, const TOOL_EVENT &aEventB)
Definition tool_event.h:768
TOOL_ACTIONS
Definition tool_event.h:60
@ TA_MODEL_CHANGE
Model has changed (partial update).
Definition tool_event.h:117
@ TA_ANY
Definition tool_event.h:122
@ TA_CHOICE_MENU_CHOICE
Context menu choice.
Definition tool_event.h:94
@ TA_UNDO_REDO_PRE
This event is sent before undo/redo command is performed.
Definition tool_event.h:102
@ TA_MOUSE_CLICK
Definition tool_event.h:63
@ TA_CHOICE_MENU_UPDATE
Context menu update.
Definition tool_event.h:90
@ TA_MOUSE
Definition tool_event.h:70
@ TA_ACTIVATE
Tool activation event.
Definition tool_event.h:111
@ TA_CHOICE_MENU_CLOSED
Context menu is closed, no matter whether anything has been chosen or not.
Definition tool_event.h:97
@ TA_PRIME
Tool priming event (a special mouse click).
Definition tool_event.h:120
@ TA_MOUSE_MOTION
Definition tool_event.h:68
@ TA_MOUSE_UP
Definition tool_event.h:65
@ TA_KEYBOARD
Definition tool_event.h:73
@ TA_VIEW_REFRESH
Definition tool_event.h:76
@ TA_CHOICE_MENU
Definition tool_event.h:99
@ TA_MOUSE_DRAG
Definition tool_event.h:67
@ TA_CHANGE_LAYER
Definition tool_event.h:82
@ TA_MOUSE_DOWN
Definition tool_event.h:66
@ TA_VIEW
Definition tool_event.h:80
@ TA_UNDO_REDO_POST
This event is sent after undo/redo command is performed.
Definition tool_event.h:105
@ TA_KEY_PRESSED
Definition tool_event.h:72
@ TA_MOUSE_DBLCLICK
Definition tool_event.h:64
@ TA_MOUSE_WHEEL
Definition tool_event.h:69
@ TA_ACTION
Tool action (allows one to control tools).
Definition tool_event.h:108
@ TA_VIEW_PAN
Definition tool_event.h:78
@ TA_NONE
Definition tool_event.h:62
@ TA_CANCEL_TOOL
Tool cancel event.
Definition tool_event.h:86
@ TA_VIEW_DIRTY
Definition tool_event.h:79
@ TA_REACTIVATE
Tool re-activation event for tools already on the stack.
Definition tool_event.h:114
@ TA_VIEW_ZOOM
Definition tool_event.h:77
CONTEXT_MENU_TRIGGER
Defines when a context menu is opened.
Definition tool_event.h:150
@ CMENU_NOW
Right now (after TOOL_INTERACTIVE::SetContextMenu).
Definition tool_event.h:152
@ CMENU_OFF
Never.
Definition tool_event.h:153
@ CMENU_BUTTON
On the right button.
Definition tool_event.h:151
std::optional< TOOL_EVENT > OPT_TOOL_EVENT
Definition tool_event.h:637
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_MODIFIERS
Definition tool_event.h:138
@ MD_MODIFIER_MASK
Definition tool_event.h:145
@ MD_META
Definition tool_event.h:143
@ MD_ALT
Definition tool_event.h:141
@ MD_CTRL
Definition tool_event.h:140
@ MD_SUPER
Definition tool_event.h:142
@ MD_ALTGR
Definition tool_event.h:144
@ MD_SHIFT
Definition tool_event.h:139
TOOL_EVENT_CATEGORY
Internal (GUI-independent) event definitions.
Definition tool_event.h:49
@ TC_NONE
Definition tool_event.h:50
@ TC_ANY
Definition tool_event.h:56
@ TC_COMMAND
Definition tool_event.h:53
@ TC_MOUSE
Definition tool_event.h:51
@ TC_MESSAGE
Definition tool_event.h:54
@ TC_KEYBOARD
Definition tool_event.h:52
@ TC_VIEW
Definition tool_event.h:55
TOOL_MOUSE_BUTTONS
Definition tool_event.h:126
@ BUT_AUX1
Definition tool_event.h:131
@ BUT_MIDDLE
Definition tool_event.h:130
@ BUT_LEFT
Definition tool_event.h:128
@ BUT_RIGHT
Definition tool_event.h:129
@ BUT_AUX2
Definition tool_event.h:132
@ BUT_BUTTON_MASK
Definition tool_event.h:133
@ BUT_NONE
Definition tool_event.h:127
@ BUT_ANY
Definition tool_event.h:134
VECTOR2< double > VECTOR2D
Definition vector2d.h:682