Gazebo Common

API Reference

4.8.1
gz/common/MouseEvent.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GZ_COMMON_MOUSEEVENT_HH_
18 #define GZ_COMMON_MOUSEEVENT_HH_
19 
20 #include <memory>
21 #include <gz/math/Vector2.hh>
22 
23 #include <gz/common/config.hh>
24 #include <gz/common/events/Export.hh>
26 
27 namespace ignition
28 {
29  namespace common
30  {
32  class MouseEventPrivate;
33 
36  class IGNITION_COMMON_EVENTS_VISIBLE MouseEvent
37  {
39  public: enum MouseButton
40  {
42  NO_BUTTON = 0x0,
43 
45  LEFT = 0x1,
46 
48  MIDDLE = 0x2,
49 
51  RIGHT = 0x4
52  };
53 
55  public: enum EventType
56  {
59 
62 
65 
68 
70  SCROLL
71  };
72 
74  public: MouseEvent();
75 
78  public: MouseEvent(const MouseEvent &_other);
79 
81  public: virtual ~MouseEvent();
82 
85  public: math::Vector2i Pos() const;
86 
89  public: void SetPos(const math::Vector2i &_pos);
90 
94  public: void SetPos(const int _x, const int _y);
95 
98  public: math::Vector2i PrevPos() const;
99 
102  public: void SetPrevPos(const math::Vector2i &_pos);
103 
107  public: void SetPrevPos(const int _x, const int _y);
108 
111  public: math::Vector2i PressPos() const;
112 
115  public: void SetPressPos(const math::Vector2i &_pos);
116 
120  public: void SetPressPos(const int _x, const int _y);
121 
124  public: math::Vector2i Scroll() const;
125 
128  public: void SetScroll(const math::Vector2i &_scroll);
129 
133  public: void SetScroll(const int _x, const int _y);
134 
137  public: float MoveScale() const;
138 
141  public: void SetMoveScale(const float _scale);
142 
146  public: bool Dragging() const;
147 
150  public: void SetDragging(const bool _dragging);
151 
154  public: EventType Type() const;
155 
158  public: void SetType(const EventType _type) const;
159 
163 
166  public: void SetButton(const MouseEvent::MouseButton _button) const;
167 
171  public: unsigned int Buttons() const;
172 
176  public: void SetButtons(const unsigned int &_buttons);
177 
180  public: bool Shift() const;
181 
184  public: void SetShift(const bool _shift) const;
185 
188  public: bool Alt() const;
189 
192  public: void SetAlt(const bool _alt);
193 
196  public: bool Control() const;
197 
200  public: void SetControl(const bool _control) const;
201 
205  public: MouseEvent &operator=(const MouseEvent &_other);
206 
210  private: std::unique_ptr<MouseEventPrivate> dataPtr;
212  };
213  }
214 }
215 #endif
Generic description of a mouse event.
Definition: gz/common/MouseEvent.hh:37
void SetMoveScale(const float _scale)
Set the scaling factor.
void SetPrevPos(const math::Vector2i &_pos)
Set the previous position.
void SetPrevPos(const int _x, const int _y)
Set the previous position.
bool Shift() const
Get the shift key press flag.
EventType Type() const
Get the event type.
EventType
Mouse event types enumeration.
Definition: gz/common/MouseEvent.hh:56
@ NO_EVENT
No event.
Definition: gz/common/MouseEvent.hh:58
@ PRESS
Press event.
Definition: gz/common/MouseEvent.hh:64
@ RELEASE
Release event.
Definition: gz/common/MouseEvent.hh:67
@ MOVE
Move event.
Definition: gz/common/MouseEvent.hh:61
void SetShift(const bool _shift) const
Set the shift key press flag.
void SetPos(const math::Vector2i &_pos)
Set mouse pointer position on the screen.
void SetPressPos(const int _x, const int _y)
Set the position of button press.
void SetType(const EventType _type) const
Set the event type.
void SetButton(const MouseEvent::MouseButton _button) const
Set the button which caused the event.
void SetAlt(const bool _alt)
Set the alt key press flag.
bool Control() const
Get the control key press flag.
math::Vector2i Scroll() const
Get the scroll position.
void SetControl(const bool _control) const
Set the control key press flag.
math::Vector2i PressPos() const
Get the position of button press.
void SetPos(const int _x, const int _y)
Set mouse pointer position on the screen.
void SetPressPos(const math::Vector2i &_pos)
Set the position of button press.
MouseEvent & operator=(const MouseEvent &_other)
Assignment operator.
MouseEvent(const MouseEvent &_other)
Copy constructor.
void SetDragging(const bool _dragging)
Set the flag for mouse drag motion.
float MoveScale() const
Get the scaling factor.
unsigned int Buttons() const
Get the state of the buttons when the event was generated.
MouseButton
Standard mouse buttons enumeration.
Definition: gz/common/MouseEvent.hh:40
MouseEvent::MouseButton Button() const
Get the button which caused this event.
math::Vector2i Pos() const
Get mouse pointer position on the screen.
bool Dragging() const
Get the flag for mouse drag motion.
void SetButtons(const unsigned int &_buttons)
Set the state of the buttons when the event was generated.
virtual ~MouseEvent()
Destructor.
void SetScroll(const int _x, const int _y)
Set the scroll position.
void SetScroll(const math::Vector2i &_scroll)
Set the scroll position.
bool Alt() const
Get the alt key press flag.
math::Vector2i PrevPos() const
Get the previous position.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: gz/common/SuppressWarning.hh:65
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: gz/common/SuppressWarning.hh:68
Forward declarations for the common classes.