18 #include <QParallelAnimationGroup>
19 #include <QPropertyAnimation>
36 explicit Joystick(QWidget* parent =
nullptr);
42 float x()
const {
return _x; }
48 float y()
const {
return _y; }
73 void setX(
const float& value);
79 void setY(
const float& value);
118 void movePos(
const QPoint& coordinates);
130 float checkValue(
const float& value,
const float& min,
const float& max)
const;
145 virtual void paintEvent(QPaintEvent* event)
override;
The class to visualize analog joystick swing on a widget.
const float _midPoint
Middle value of the raw analog joystick coordinates.
float checkValue(const float &value, const float &min, const float &max) const
Check if the coordinate value is in proper range.
void addYAnimation()
Add an animation for the joystick to return to the y-axis zero position.
void yChange(float value)
Signal emitted when the y coordinate value changed.
Qt::Alignment _alignment
Widget alignment.
QPropertyAnimation * _xAnimation
Animation on the the x axis.
void removeYAnimation()
Remove an animation for the joystick to return to the y-axis zero position.
float x() const
Get a coordinate value on the x axis.
QPropertyAnimation * _yAnimation
Animation on the the y axis.
void movePos(const QPoint &coordinates)
Change the knop coordinates.
QRectF _knopBounds
Knop bounds.
void setX(const float &value)
Set the value of the x coordinate.
void setY(const float &value)
Set the value of the y coordinate.
float _y
Value of the the y coordinate.
float _x
Value of the the x coordinate.
float y() const
Get a coordinate value on the y axis.
void removeXAnimation()
Remove an animation for the joystick to return to the x-axis zero position.
virtual void paintEvent(QPaintEvent *event) override
Draw an analog joystick with its' background.
QParallelAnimationGroup * _animation
Animation group for two axis.
void addXAnimation()
Add an animation for the joystick to return to the x-axis zero position.
~Joystick()=default
Destroy the Joystick object.
void setAlignment(Qt::Alignment align)
Set the widget alignment.
void resizeEvent(QResizeEvent *event) override
Event handler to change size of widget.
Joystick(QWidget *parent=nullptr)
Construct a new Joystick object.
void xChange(float value)
Signal emitted when the x coordinate value changed.
QRectF _bounds
Background bounds.