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
128
130{
131 BUT_NONE = 0x0,
132 BUT_LEFT = 0x1,
135 BUT_AUX1 = 0x8,
136 BUT_AUX2 = 0x10,
138 BUT_ANY = 0xffffffff
140
142{
143 MD_SHIFT = 0x1000,
144 MD_CTRL = 0x2000,
145 MD_ALT = 0x4000,
147};
148
151{
154 CMENU_OFF
156
158{
163
168{
169public:
175 const std::string Format() const;
176
178 TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) :
179 m_category( aCategory ),
180 m_actions( aAction ),
181 m_scope( aScope ),
182 m_mouseButtons( 0 ),
183 m_keyCode( 0 ),
184 m_modifiers( 0 ),
185 m_synchronousState( nullptr ),
186 m_commit( nullptr ),
187 m_firstResponder( nullptr )
188 {
189 init();
190 }
191
192 TOOL_EVENT( TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam,
193 TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) :
194 m_category( aCategory ),
195 m_actions( aAction ),
196 m_scope( aScope ),
197 m_mouseButtons( 0 ),
198 m_keyCode( 0 ),
199 m_modifiers( 0 ),
200 m_synchronousState( nullptr ),
201 m_commit( nullptr ),
202 m_firstResponder( nullptr )
203 {
204 if( aCategory == TC_MOUSE )
205 {
206 setMouseButtons( aExtraParam & BUT_BUTTON_MASK );
207 }
208 else if( aCategory == TC_KEYBOARD )
209 {
210 m_keyCode = aExtraParam & ~MD_MODIFIER_MASK; // Filter out modifiers
211 }
212 else if( aCategory == TC_COMMAND )
213 {
214 m_commandId = aExtraParam;
215 }
216
217 if( aCategory & ( TC_MOUSE | TC_KEYBOARD ) )
218 {
219 m_modifiers = aExtraParam & MD_MODIFIER_MASK;
220 }
221
222 init();
223 }
224
226 const std::string& aExtraParam, TOOL_ACTION_SCOPE aScope = AS_GLOBAL ) :
227 m_category( aCategory ),
228 m_actions( aAction ),
229 m_scope( aScope ),
230 m_mouseButtons( 0 ),
231 m_keyCode( 0 ),
232 m_modifiers( 0 ),
233 m_synchronousState( nullptr ),
234 m_commit( nullptr ),
235 m_firstResponder( nullptr )
236 {
237 if( aCategory == TC_COMMAND || aCategory == TC_MESSAGE )
238 m_commandStr = aExtraParam;
239
240 init();
241 }
242
245
247 TOOL_ACTIONS Action() const { return m_actions; }
248
252 bool PassEvent() const { return m_passEvent; }
253 void SetPassEvent( bool aPass = true ) { m_passEvent = aPass; }
254
257 bool HasPosition() const { return m_hasPosition; }
258 void SetHasPosition( bool aHasPosition ) { m_hasPosition = aHasPosition; }
259
262 bool ForceImmediate() const { return m_forceImmediate; }
263 void SetForceImmediate( bool aForceImmediate = true ) { m_forceImmediate = aForceImmediate; }
264
266 void SetFirstResponder( TOOL_BASE* aTool ) { m_firstResponder = aTool; }
267
270 bool IsReactivate() const { return m_reactivate; }
271 void SetReactivate( bool aReactivate = true ) { m_reactivate = aReactivate; }
272
273 void SetSynchronous( std::atomic<SYNCRONOUS_TOOL_STATE>* aState )
274 {
275 m_synchronousState = aState;
276 }
277 std::atomic<SYNCRONOUS_TOOL_STATE>* SynchronousState() const { return m_synchronousState; }
278
279 void SetCommit( COMMIT* aCommit ) { m_commit = aCommit; }
280 COMMIT* Commit() const { return m_commit; }
281
284 const VECTOR2D Delta() const
285 {
287 }
288
290 const VECTOR2D Position() const
291 {
293 }
294
296 const VECTOR2D DragOrigin() const
297 {
299 }
300
302 int Buttons() const
303 {
304 assert( m_category == TC_MOUSE ); // this should be used only with mouse events
305 return m_mouseButtons;
306 }
307
308 bool IsClick( int aButtonMask = BUT_ANY ) const;
309
310 bool IsDblClick( int aButtonMask = BUT_ANY ) const;
311
312 bool IsDrag( int aButtonMask = BUT_ANY ) const
313 {
314 return m_actions == TA_MOUSE_DRAG && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
315 }
316
317 bool IsMouseDown( int aButtonMask = BUT_ANY ) const
318 {
319 return m_actions == TA_MOUSE_DOWN && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
320 }
321
322 bool IsMouseUp( int aButtonMask = BUT_ANY ) const
323 {
324 return m_actions == TA_MOUSE_UP && ( m_mouseButtons & aButtonMask ) == m_mouseButtons;
325 }
326
327 bool IsMotion() const
328 {
329 return m_actions == TA_MOUSE_MOTION;
330 }
331
332 bool IsMouseAction() const
333 {
334 return ( m_actions & TA_MOUSE );
335 }
336
337 bool IsCancel() const
338 {
339 return m_actions == TA_CANCEL_TOOL;
340 }
341
342 bool IsActivate() const
343 {
344 return m_actions == TA_ACTIVATE;
345 }
346
347 bool IsUndoRedo() const
348 {
350 }
351
352 bool IsChoiceMenu() const
353 {
354 return m_actions & TA_CHOICE_MENU;
355 }
356
357 bool IsPrime() const
358 {
359 return m_actions == TA_PRIME;
360 }
361
363 int Modifier( int aMask = MD_MODIFIER_MASK ) const
364 {
365 return m_modifiers & aMask;
366 }
367
369 {
370 return Modifier( MD_CTRL );
371 }
372
373 int KeyCode() const
374 {
375 return m_keyCode;
376 }
377
378 bool IsKeyPressed() const
379 {
380 return m_actions == TA_KEY_PRESSED;
381 }
382
389 bool Matches( const TOOL_EVENT& aEvent ) const
390 {
391 if( !( m_category & aEvent.m_category ) )
392 return false;
393
395 {
396 if( !m_commandStr.empty() && !aEvent.getCommandStr().empty() )
397 return m_commandStr == aEvent.m_commandStr;
398
399 if( (bool) m_commandId && (bool) aEvent.m_commandId )
400 return *m_commandId == *aEvent.m_commandId;
401 }
402
403 // BUGFIX: TA_ANY should match EVERYTHING, even TA_NONE (for TC_MESSAGE)
404 if( m_actions == TA_ANY && aEvent.m_actions == TA_NONE && aEvent.m_category == TC_MESSAGE )
405 return true;
406
407 // BUGFIX: This check must happen after the TC_COMMAND check because otherwise events of
408 // the form { TC_COMMAND, TA_NONE } will be incorrectly skipped
409 if( !( m_actions & aEvent.m_actions ) )
410 return false;
411
412 return true;
413 }
414
421 bool IsAction( const TOOL_ACTION* aAction ) const;
422
427 bool IsCancelInteractive() const;
428
432 bool IsSelectionEvent() const;
433
440 bool IsPointEditor() const;
441
447 bool IsMoveTool() const;
448
454 bool IsEditorTool() const;
455
459 bool IsSimulator() const;
460
464 template<typename T, std::enable_if_t<!std::is_pointer<T>::value>* = nullptr >
465 T Parameter() const
466 {
467 T param;
468
469 wxCHECK_MSG( m_param.has_value(), T(), "Attempted to get a parameter from an event with "
470 "no parameter." );
471
472 try
473 {
474 param = ki::any_cast<T>( m_param );
475 }
476 catch( const ki::bad_any_cast& )
477 {
478 wxCHECK_MSG( false, T(), wxString::Format( "Requested parameter type %s from event "
479 "with parameter type %s.",
480 typeid(T).name(),
481 m_param.type().name() ) );
482 }
483
484 return param;
485 }
486
490 template<typename T, std::enable_if_t<std::is_pointer<T>::value>* = nullptr>
491 T Parameter() const
492 {
493 T param = nullptr;
494
495 wxCHECK_MSG( m_param.has_value(), param, "Attempted to get a parameter from an event with "
496 "no parameter." );
497
498 try
499 {
500 param = ki::any_cast<T>( m_param );
501 }
502 catch( const ki::bad_any_cast& )
503 {
504 wxCHECK_MSG( false, param, wxString::Format( "Requested parameter type %s from event "
505 "with parameter type %s.",
506 typeid(T).name(),
507 m_param.type().name() ) );
508 }
509
510 return param;
511 }
512
519 template<typename T>
520 void SetParameter(T aParam)
521 {
522 m_param = aParam;
523 }
524
525 std::optional<int> GetCommandId() const
526 {
527 return m_commandId;
528 }
529
530 void SetMousePosition( const VECTOR2D& aP )
531 {
532 m_mousePos = aP;
533 }
534
535 void SetActionGroup( const TOOL_ACTION_GROUP& aGroup )
536 {
537 m_actionGroup = aGroup;
538 }
539
540 bool IsActionInGroup( const TOOL_ACTION_GROUP& aGroup ) const;
541
542private:
543 friend class TOOL_EVENT_LIST;
544 friend class TOOL_DISPATCHER;
545 friend class TOOL_MANAGER;
546 friend class TOOLS_HOLDER;
547
548 void init();
549
550 const std::string& getCommandStr() const { return m_commandStr; }
551
552 void setMouseDragOrigin( const VECTOR2D& aP )
553 {
555 }
556
557 void setMouseDelta( const VECTOR2D& aP )
558 {
559 m_mouseDelta = aP;
560 }
561
562 void setMouseButtons( int aButtons )
563 {
564 assert( ( aButtons & ~BUT_BUTTON_MASK ) == 0 );
565 m_mouseButtons = aButtons;
566 }
567
568 void setModifiers( int aMods )
569 {
570 assert( ( aMods & ~MD_MODIFIER_MASK ) == 0 );
571 m_modifiers = aMods;
572 }
573
584 VECTOR2D returnCheckedPosition( const VECTOR2D& aPos ) const;
585
592
593
595 std::optional<TOOL_ACTION_GROUP> m_actionGroup;
596
599
602
605
608
611
614
617
618 std::atomic<SYNCRONOUS_TOOL_STATE>* m_synchronousState;
619
622
625
628
629 std::optional<int> m_commandId;
630 std::string m_commandStr;
631};
632
633typedef std::optional<TOOL_EVENT> OPT_TOOL_EVENT;
634
640{
641public:
643 typedef std::deque<TOOL_EVENT>::iterator iterator;
644 typedef std::deque<TOOL_EVENT>::const_iterator const_iterator;
645
648 {}
649
651 TOOL_EVENT_LIST( const TOOL_EVENT& aSingleEvent )
652 {
653 m_events.push_back( aSingleEvent );
654 }
655
657 TOOL_EVENT_LIST( const TOOL_EVENT_LIST& aEventList )
658 {
659 m_events.clear();
660
661 for( const TOOL_EVENT& event : aEventList.m_events )
662 m_events.push_back( event );
663 }
664
670 const std::string Format() const;
671
677 const std::string Names() const;
678
679 OPT_TOOL_EVENT Matches( const TOOL_EVENT& aEvent ) const
680 {
681 for( const TOOL_EVENT& event : m_events )
682 {
683 if( event.Matches( aEvent ) )
684 return event;
685 }
686
687 return OPT_TOOL_EVENT();
688 }
689
695 void Add( const TOOL_EVENT& aEvent )
696 {
697 m_events.push_back( aEvent );
698 }
699
701 {
702 return m_events.begin();
703 }
704
706 {
707 return m_events.end();
708 }
709
711 {
712 return m_events.begin();
713 }
714
716 {
717 return m_events.end();
718 }
719
720 int size() const
721 {
722 return m_events.size();
723 }
724
725 void clear()
726 {
727 m_events.clear();
728 }
729
731 {
732 m_events.clear();
733
734 for( const TOOL_EVENT& event : aEventList.m_events )
735 m_events.push_back( event );
736
737 return *this;
738 }
739
741 {
742 m_events.clear();
743 m_events.push_back( aEvent );
744 return *this;
745 }
746
748 {
749 Add( aEvent );
750 return *this;
751 }
752
754 {
755 std::copy( aEvent.m_events.begin(), aEvent.m_events.end(), std::back_inserter( m_events ) );
756 return *this;
757 }
758
759private:
760 std::deque<TOOL_EVENT> m_events;
761};
762
763
764inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEventA, const TOOL_EVENT& aEventB )
765{
767
768 l.Add( aEventA );
769 l.Add( aEventB );
770
771 return l;
772}
773
774
775inline const TOOL_EVENT_LIST operator||( const TOOL_EVENT& aEvent,
776 const TOOL_EVENT_LIST& aEventList )
777{
778 TOOL_EVENT_LIST l( aEventList );
779
780 l.Add( aEvent );
781 return l;
782}
783
784
785#endif
const char * name
Definition: DXF_plotter.cpp:59
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:640
iterator begin()
Definition: tool_event.h:700
const std::string Format() const
Return information about event in form of a human-readable string.
Definition: tool_event.cpp:187
int size() const
Definition: tool_event.h:720
TOOL_EVENT value_type
Definition: tool_event.h:642
std::deque< TOOL_EVENT > m_events
Definition: tool_event.h:760
std::deque< TOOL_EVENT >::const_iterator const_iterator
Definition: tool_event.h:644
const std::string Names() const
Return a string containing the names of all the events in this list.
Definition: tool_event.cpp:198
iterator end()
Definition: tool_event.h:705
TOOL_EVENT_LIST & operator=(const TOOL_EVENT &aEvent)
Definition: tool_event.h:740
std::deque< TOOL_EVENT >::iterator iterator
Definition: tool_event.h:643
TOOL_EVENT_LIST(const TOOL_EVENT &aSingleEvent)
Constructor for a list containing only one TOOL_EVENT.
Definition: tool_event.h:651
TOOL_EVENT_LIST()
Default constructor. Creates an empty list.
Definition: tool_event.h:647
void Add(const TOOL_EVENT &aEvent)
Add a tool event to the list.
Definition: tool_event.h:695
TOOL_EVENT_LIST & operator=(const TOOL_EVENT_LIST &aEventList)
Definition: tool_event.h:730
const_iterator cbegin() const
Definition: tool_event.h:710
TOOL_EVENT_LIST(const TOOL_EVENT_LIST &aEventList)
Copy an existing TOOL_EVENT_LIST.
Definition: tool_event.h:657
TOOL_EVENT_LIST & operator||(const TOOL_EVENT_LIST &aEvent)
Definition: tool_event.h:753
OPT_TOOL_EVENT Matches(const TOOL_EVENT &aEvent) const
Definition: tool_event.h:679
const_iterator cend() const
Definition: tool_event.h:715
TOOL_EVENT_LIST & operator||(const TOOL_EVENT &aEvent)
Definition: tool_event.h:747
Generic, UI-independent tool event.
Definition: tool_event.h:168
int Buttons() const
Return information about mouse buttons state.
Definition: tool_event.h:302
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:257
bool DisableGridSnapping() const
Definition: tool_event.h:368
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:590
void SetCommit(COMMIT *aCommit)
Definition: tool_event.h:279
std::optional< int > m_commandId
Definition: tool_event.h:629
void setMouseDragOrigin(const VECTOR2D &aP)
Definition: tool_event.h:552
int m_keyCode
Stores code of pressed/released key.
Definition: tool_event.h:613
void SetActionGroup(const TOOL_ACTION_GROUP &aGroup)
Definition: tool_event.h:535
TOOL_ACTION_SCOPE m_scope
Definition: tool_event.h:588
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:252
TOOL_ACTIONS Action() const
Returns more specific information about the type of an event.
Definition: tool_event.h:247
void SetMousePosition(const VECTOR2D &aP)
Definition: tool_event.h:530
int m_modifiers
State of key modifiers (Ctrl/Alt/etc.).
Definition: tool_event.h:616
TOOL_EVENT(TOOL_EVENT_CATEGORY aCategory=TC_NONE, TOOL_ACTIONS aAction=TA_NONE, TOOL_ACTION_SCOPE aScope=AS_GLOBAL)
Definition: tool_event.h:177
int KeyCode() const
Definition: tool_event.h:373
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:389
TOOL_BASE * FirstResponder() const
Definition: tool_event.h:265
ki::any m_param
Generic parameter used for passing non-standard data.
Definition: tool_event.h:624
void setMouseDelta(const VECTOR2D &aP)
Definition: tool_event.h:557
bool IsActivate() const
Definition: tool_event.h:342
void SetFirstResponder(TOOL_BASE *aTool)
Definition: tool_event.h:266
VECTOR2D m_mousePos
Current mouse cursor position.
Definition: tool_event.h:604
bool IsPrime() const
Definition: tool_event.h:357
std::string m_commandStr
Definition: tool_event.h:630
bool IsSimulator() const
Indicate if the event is from the simulator.
Definition: tool_event.cpp:257
COMMIT * Commit() const
Definition: tool_event.h:280
const VECTOR2D Position() const
Return mouse cursor position in world coordinates.
Definition: tool_event.h:290
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:520
bool ForceImmediate() const
Returns if the action associated with this event should be treated as immediate regardless of the cur...
Definition: tool_event.h:262
bool IsReactivate() const
Control whether the tool is first being pushed to the stack or being reactivated after a pause.
Definition: tool_event.h:270
bool IsKeyPressed() const
Definition: tool_event.h:378
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:209
void SetForceImmediate(bool aForceImmediate=true)
Definition: tool_event.h:263
TOOL_EVENT_CATEGORY Category() const
Return the category (eg. mouse/keyboard/action) of an event.
Definition: tool_event.h:244
std::atomic< SYNCRONOUS_TOOL_STATE > * m_synchronousState
Definition: tool_event.h:618
bool m_passEvent
Definition: tool_event.h:589
TOOL_EVENT(TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam, TOOL_ACTION_SCOPE aScope=AS_GLOBAL)
Definition: tool_event.h:192
void SetReactivate(bool aReactivate=true)
Definition: tool_event.h:271
void init()
Definition: tool_event.cpp:58
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:312
int Modifier(int aMask=MD_MODIFIER_MASK) const
Return information about key modifiers state (Ctrl, Alt, etc.).
Definition: tool_event.h:363
COMMIT * m_commit
Commit the tool handling the event should add to.
Definition: tool_event.h:621
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:587
std::optional< TOOL_ACTION_GROUP > m_actionGroup
Optional group that the parent action for the event belongs to.
Definition: tool_event.h:595
bool m_forceImmediate
Definition: tool_event.h:591
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
Return the point where dragging has started.
Definition: tool_event.h:296
void SetHasPosition(bool aHasPosition)
Definition: tool_event.h:258
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
True when the tool is being re-activated from the stack.
Definition: tool_event.h:598
bool IsCancel() const
Definition: tool_event.h:337
void setMouseButtons(int aButtons)
Definition: tool_event.h:562
TOOL_BASE * m_firstResponder
The first tool to receive the event.
Definition: tool_event.h:627
T Parameter() const
Return a parameter assigned to the event.
Definition: tool_event.h:465
bool IsMouseDown(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:317
bool IsDblClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:215
const std::string & getCommandStr() const
Definition: tool_event.h:550
TOOL_EVENT_CATEGORY m_category
Definition: tool_event.h:586
void SetSynchronous(std::atomic< SYNCRONOUS_TOOL_STATE > *aState)
Definition: tool_event.h:273
bool IsUndoRedo() const
Definition: tool_event.h:347
bool IsPointEditor() const
Indicate if the event is from one of the point editors.
Definition: tool_event.cpp:238
int m_mouseButtons
State of mouse buttons.
Definition: tool_event.h:610
std::atomic< SYNCRONOUS_TOOL_STATE > * SynchronousState() const
Definition: tool_event.h:277
VECTOR2D m_mouseDelta
Difference between mouse cursor position and the point where dragging event has started.
Definition: tool_event.h:601
TOOL_EVENT(TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, const std::string &aExtraParam, TOOL_ACTION_SCOPE aScope=AS_GLOBAL)
Definition: tool_event.h:225
std::optional< int > GetCommandId() const
Definition: tool_event.h:525
void setModifiers(int aMods)
Definition: tool_event.h:568
void SetPassEvent(bool aPass=true)
Definition: tool_event.h:253
bool IsChoiceMenu() const
Definition: tool_event.h:352
VECTOR2D m_mouseDragOrigin
Point where dragging has started.
Definition: tool_event.h:607
bool IsMouseAction() const
Definition: tool_event.h:332
bool IsMouseUp(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:322
bool IsMotion() const
Definition: tool_event.h:327
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
Return information about difference between current mouse cursor position and the place where draggin...
Definition: tool_event.h:284
Master controller class:
Definition: tool_manager.h:62
A type-safe container of any type.
Definition: ki_any.h:93
bool has_value() const noexcept
Report whether there is a contained object or not.
Definition: ki_any.h:312
const std::type_info & type() const noexcept
The typeid of the contained object, or typeid(void) if empty.
Definition: ki_any.h:316
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.
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:764
CONTEXT_MENU_TRIGGER
Defines when a context menu is opened.
Definition: tool_event.h:151
@ CMENU_NOW
Right now (after TOOL_INTERACTIVE::SetContextMenu).
Definition: tool_event.h:153
@ CMENU_OFF
Never.
Definition: tool_event.h:154
@ CMENU_BUTTON
On the right button.
Definition: tool_event.h:152
std::optional< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:633
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:146
@ MD_ALT
Definition: tool_event.h:145
@ MD_CTRL
Definition: tool_event.h:144
@ MD_SHIFT
Definition: tool_event.h:143
SYNCRONOUS_TOOL_STATE
Definition: tool_event.h:158
@ STS_CANCELLED
Definition: tool_event.h:161
@ STS_FINISHED
Definition: tool_event.h:160
@ STS_RUNNING
Definition: tool_event.h:159
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