62 lines
1.1 KiB
C++
62 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
|
|
#include <QPointF>
|
|
#include <QObject>
|
|
#include <QPixmap>
|
|
|
|
class QSvgRenderer;
|
|
class QTimer;
|
|
|
|
struct _XDisplay;
|
|
using Display = _XDisplay;
|
|
using Window = unsigned long;
|
|
|
|
class Rotator : public QObject {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit Rotator(QObject* parent = nullptr);
|
|
virtual ~Rotator();
|
|
|
|
void forAllWindows(std::function<void(Window)> func);
|
|
|
|
signals:
|
|
void angleUpdated(double newAngle);
|
|
void newImage(QPixmap map);
|
|
void force(QPointF force);
|
|
|
|
public slots:
|
|
void reset();
|
|
|
|
private slots:
|
|
void loop();
|
|
|
|
private:
|
|
void recalculateCursor(QPointF newPos);
|
|
void rerender();
|
|
void setCursor(const QPixmap& px, const QPointF& hostspot);
|
|
|
|
void forAllWindows(std::function<void(Window)> func, Window root);
|
|
|
|
Display* disp;
|
|
QSvgRenderer* renderer;
|
|
QTimer* loopTimer;
|
|
|
|
quint64 lastTimePoint;
|
|
|
|
QPointF lastPosition;
|
|
double angle; // deg
|
|
double angleVelocity; // deg / s
|
|
|
|
// TODO: make them changeable
|
|
double gravityStrength = 1.0;
|
|
double mouseForceStrength = 1.0;
|
|
double impulseStrength = 1.0;
|
|
|
|
static constexpr double length = 10.0;
|
|
|
|
static const QPointF Gravity;
|
|
};
|