MouseEvent.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 _GAZEBO_MOUSEEVENT_HH_
18 #define _GAZEBO_MOUSEEVENT_HH_
19 
20 #include <ignition/math/Vector2.hh>
21 #include "gazebo/util/system.hh"
22 
23 namespace gazebo
24 {
25  namespace common
26  {
28  class MouseEventPrivate;
29 
32 
35  class GZ_COMMON_VISIBLE MouseEvent
36  {
38  public: enum MouseButton
39  {
41  NO_BUTTON = 0x0,
42 
44  LEFT = 0x1,
45 
47  MIDDLE = 0x2,
48 
50  RIGHT = 0x4
51  };
52 
54  public: enum EventType
55  {
58 
61 
64 
67 
69  SCROLL
70  };
71 
73  public: MouseEvent();
74 
77  public: MouseEvent(const MouseEvent &_other);
78 
80  public: virtual ~MouseEvent();
81 
84  public: ignition::math::Vector2i Pos() const;
85 
88  public: void SetPos(const ignition::math::Vector2i &_pos);
89 
93  public: void SetPos(const int _x, const int _y);
94 
97  public: ignition::math::Vector2i PrevPos() const;
98 
101  public: void SetPrevPos(const ignition::math::Vector2i &_pos);
102 
106  public: void SetPrevPos(const int _x, const int _y);
107 
110  public: ignition::math::Vector2i PressPos() const;
111 
114  public: void SetPressPos(const ignition::math::Vector2i &_pos);
115 
119  public: void SetPressPos(const int _x, const int _y);
120 
123  public: ignition::math::Vector2i Scroll() const;
124 
127  public: void SetScroll(const ignition::math::Vector2i &_scroll);
128 
132  public: void SetScroll(const int _x, const int _y);
133 
136  public: float MoveScale() const;
137 
140  public: void SetMoveScale(const float _scale);
141 
145  public: bool Dragging() const;
146 
149  public: void SetDragging(const bool _dragging);
150 
153  public: EventType Type() const;
154 
157  public: void SetType(const EventType _type) const;
158 
162 
165  public: void SetButton(const MouseEvent::MouseButton _button) const;
166 
170  public: unsigned int Buttons() const;
171 
175  public: void SetButtons(const unsigned int &_buttons);
176 
179  public: bool Shift() const;
180 
183  public: void SetShift(const bool _shift) const;
184 
187  public: bool Alt() const;
188 
191  public: void SetAlt(const bool _alt);
192 
195  public: bool Control() const;
196 
199  public: void SetControl(const bool _control) const;
200 
204  public: MouseEvent &operator=(const MouseEvent &_other);
205 
208  private: MouseEventPrivate *dataPtr;
209  };
211  }
212 }
213 #endif
@ MIDDLE
Middle button.
Definition: MouseEvent.hh:47
MouseEvent & operator=(const MouseEvent &_other)
Assignment operator.
@ RIGHT
Right button.
Definition: MouseEvent.hh:50
void SetPos(const int _x, const int _y)
Set mouse pointer position on the screen.
ignition::math::Vector2i PrevPos() const
Get the previous position.
MouseButton
Standard mouse buttons enumeration.
Definition: MouseEvent.hh:39
Forward declarations for the common classes.
Definition: Animation.hh:27
EventType Type() const
Get the event type.
ignition::math::Vector2i Scroll() const
Get the scroll position.
void SetControl(const bool _control) const
Set the control key press flag.
@ SCROLL
Scroll event.
Definition: MouseEvent.hh:69
@ NO_EVENT
No event.
Definition: MouseEvent.hh:57
common
Definition: FuelModelDatabase.hh:37
@ NO_BUTTON
No button.
Definition: MouseEvent.hh:41
ignition::math::Vector2i Pos() const
Get mouse pointer position on the screen.
void SetButton(const MouseEvent::MouseButton _button) const
Set the button which caused the event.
void SetScroll(const ignition::math::Vector2i &_scroll)
Set the scroll position.
void SetButtons(const unsigned int &_buttons)
Set the state of the buttons when the event was generated.
@ LEFT
Left button.
Definition: MouseEvent.hh:44
@ RELEASE
Release event.
Definition: MouseEvent.hh:66
@ PRESS
Press event.
Definition: MouseEvent.hh:63
MouseEvent::MouseButton Button() const
Get the button which caused this event.
void SetPrevPos(const int _x, const int _y)
Set the previous position.
void SetMoveScale(const float _scale)
Set the scaling factor.
bool Control() const
Get the control key press flag.
void SetAlt(const bool _alt)
Set the alt key press flag.
void SetPressPos(const int _x, const int _y)
Set the position of button press.
void SetPressPos(const ignition::math::Vector2i &_pos)
Set the position of button press.
bool Alt() const
Get the alt key press flag.
void SetType(const EventType _type) const
Set the event type.
unsigned int Buttons() const
Get the state of the buttons when the event was generated.
float MoveScale() const
Get the scaling factor.
MouseEvent()
Constructor.
void SetDragging(const bool _dragging)
Set the flag for mouse drag motion.
void SetPos(const ignition::math::Vector2i &_pos)
Set mouse pointer position on the screen.
EventType
Mouse event types enumeration.
Definition: MouseEvent.hh:55
virtual ~MouseEvent()
Destructor.
@ MOVE
Move event.
Definition: MouseEvent.hh:60
MouseEvent(const MouseEvent &_other)
Copy constructor.
bool Shift() const
Get the shift key press flag.
void SetShift(const bool _shift) const
Set the shift key press flag.
void SetScroll(const int _x, const int _y)
Set the scroll position.
Generic description of a mouse event.
Definition: MouseEvent.hh:36
void SetPrevPos(const ignition::math::Vector2i &_pos)
Set the previous position.
ignition::math::Vector2i PressPos() const
Get the position of button press.
bool Dragging() const
Get the flag for mouse drag motion.