rock_widget_collection  0.1
VirtualJoystick.h
Go to the documentation of this file.
1 #ifndef _VIRTUAL_JOYSTICK_WIDGET_H
2 #define _VIRTUAL_JOYSTICK_WIDGET_H
3 
4 #include <QtGui>
5 #include <cstring>
6 
7 class VirtualJoystick : public QWidget {
8 
9  Q_OBJECT
10 
11  public:
12 
13  VirtualJoystick(QWidget *parent, const std::string &name);
15 
16  signals:
17  // axis 1, axis 2
18  void axisChanged(double, double);
19 
20  private:
21  bool filled;
22 
23  void focus(bool in);
24 
25  QPointF calculateAxis(bool active);
26 
27  void mouseMoveEvent(QMouseEvent* event);
28  void mousePressEvent(QMouseEvent* event);
29  void mouseReleaseEvent(QMouseEvent* event);
30  void timerEvent(QTimerEvent* event);
31  void paintEvent(QPaintEvent* event);
32  void paintBase(QPainter &painter);
33  void paintStick(QPainter &painter);
34  void paintCross(QPainter &painter);
35 
36  void drawMouseRects(QPainter &painter);
37  void calculateCoordinates(void);
38 
39  double distance(QPointF A, QPointF B);
40  double angle(QPointF A, QPointF B);
41 
42  QPointF mousePosition;
43  double painterAngle;
44  QPointF painterCenter;
45  QPointF widgetCenter;
46  QPointF axisValues;
47 
48  QLinearGradient baseGrad;
49  QColor baseColor;
50  double height, maxHeight;
51  bool followMouse;
52  bool pressed;
53 
54  QLabel *title;
55  QLabel *axis1;
56  QLabel *axis2;
57  QLabel *str_title;
58 };
59 
60 #endif // _JOYSTICK_WIDGET_H
VirtualJoystick(QWidget *parent, const std::string &name)
void axisChanged(double, double)