C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 9s
JS/TS / lint (pull_request) Successful in 25s
Python / static (pull_request) Successful in 34s
Rust / build (pull_request) Successful in 51s
Python / verify (pull_request) Failing after 1m25s
Rust / fmt (pull_request) Successful in 39s
Rust / clippy (pull_request) Successful in 59s
73 lines
1.6 KiB
C++
73 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <qcolor.h>
|
|
#include <qlist.h>
|
|
#include <qobject.h>
|
|
#include <qqmlengine.h>
|
|
#include <qtimer.h>
|
|
|
|
class BlobShape;
|
|
class BlobInvertedRect;
|
|
|
|
class BlobGroup : public QObject {
|
|
Q_OBJECT
|
|
QML_ELEMENT
|
|
Q_PROPERTY(
|
|
qreal smoothing READ smoothing WRITE setSmoothing NOTIFY
|
|
smoothingChanged)
|
|
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
|
|
Q_PROPERTY(
|
|
bool cornerFill READ cornerFill WRITE setCornerFill NOTIFY
|
|
cornerFillChanged)
|
|
|
|
public:
|
|
explicit BlobGroup(QObject* parent = nullptr);
|
|
~BlobGroup() override;
|
|
|
|
[[nodiscard]] qreal smoothing() const { return m_smoothing; }
|
|
|
|
void setSmoothing(qreal s);
|
|
|
|
[[nodiscard]] QColor color() const { return m_color; }
|
|
|
|
void setColor(const QColor& c);
|
|
|
|
[[nodiscard]] bool cornerFill() const { return m_cornerFill; }
|
|
|
|
void setCornerFill(bool e);
|
|
|
|
void addShape(BlobShape* shape);
|
|
void removeShape(BlobShape* shape);
|
|
|
|
void setInvertedRect(BlobInvertedRect* rect);
|
|
void clearInvertedRect(BlobInvertedRect* rect);
|
|
|
|
[[nodiscard]] const QList<BlobShape*>& shapes() const { return m_shapes; }
|
|
|
|
[[nodiscard]] BlobInvertedRect* invertedRect() const {
|
|
return m_invertedRect;
|
|
}
|
|
|
|
void markDirty();
|
|
void markShapeDirty(BlobShape* source);
|
|
void ensurePhysicsUpdated();
|
|
|
|
void requestPhysics();
|
|
|
|
signals:
|
|
void smoothingChanged();
|
|
void colorChanged();
|
|
void cornerFillChanged();
|
|
|
|
private:
|
|
void pumpPhysics();
|
|
|
|
qreal m_smoothing = 32.0;
|
|
QColor m_color{0x44, 0x88, 0xff};
|
|
bool m_cornerFill = true;
|
|
QList<BlobShape*> m_shapes;
|
|
BlobInvertedRect* m_invertedRect = nullptr;
|
|
bool m_physicsUpdated = false;
|
|
QTimer m_physicsPump;
|
|
};
|