17 #include <QParallelAnimationGroup>
18 #include <QPropertyAnimation>
35 explicit Joystick(QWidget* parent =
nullptr);
41 float x()
const {
return _x; }
47 float y()
const {
return _y; }
73 void setX(
const float& value);
79 void setY(
const float& value);
114 void movePos(
const QPoint& coordinates);
126 float checkValue(
const float& value,
const float& min,
const float& max)
const;
139 virtual void paintEvent(QPaintEvent* event)
override;
const float _midPoint
Middle value of raw analog joystick coordinates.
float checkValue(const float &value, const float &min, const float &max) const
Check if coordinate value is in proper range.
void addYAnimation()
Add animation for y axis to return knop to home position.
void yChange(float value)
Signal emitted in order to realize value change of y coordinate.
Qt::Alignment _alignment
Alignment used in resizeEvent.
~Joystick()
Delete Joystick object.
QPropertyAnimation * _xAnimation
Animation on x axis when knop is returning home position.
void removeYAnimation()
Remove animation for y axis to return knop to home position.
float x() const
Get x coordinate value.
QPropertyAnimation * _yAnimation
Animation on y axis when knop is returning home position.
void movePos(const QPoint &coordinates)
Change knop coordinates.
QRectF _knopBounds
Bounds of knop.
void setX(const float &value)
Set value of x coordinate.
void setY(const float &value)
Set value of y coordinate.
float _y
Value of y coordinate.
float _x
Value of x coordinate.
float y() const
Get y coordinate value.
void removeXAnimation()
Remove animation for x axis to return knop to home position.
virtual void paintEvent(QPaintEvent *event) override
Draw analog joystick with it's background.
QParallelAnimationGroup * _animation
Animation group used to animate knop returning to home position.
void addXAnimation()
Add animation for x axis to return knop to home position.
void setAlignment(Qt::Alignment align)
Set alignment needed for resizeEvent to work.
void resizeEvent(QResizeEvent *event) override
Event handler to change size of widget.
Joystick(QWidget *parent=nullptr)
Construct new Joystick object.
void xChange(float value)
Signal emitted in order to realize value change of x coordinate.
QRectF _bounds
Bounds of background.