Snake/back-end/guiobject.h

52 lines
1.0 KiB
C
Raw Normal View History

#ifndef GUIOBJECT_H
#define GUIOBJECT_H
2018-10-08 21:10:07 +03:00
#include "baseclass.h"
#include "QObject"
2018-10-11 18:09:35 +03:00
#include <QRectF>
2018-10-08 21:10:07 +03:00
class GuiObject:public QObject, public BaseClass
{
2018-10-08 21:10:07 +03:00
Q_OBJECT
2018-10-11 18:09:35 +03:00
Q_PROPERTY(double angle READ angle NOTIFY angleChanged)
Q_PROPERTY(QString texture READ texture NOTIFY textureChanged)
Q_PROPERTY(QRectF rect READ rect WRITE setRect NOTIFY rectChanged)
2018-10-11 18:09:35 +03:00
Q_PROPERTY(int guiId READ guiId NOTIFY guiIdChanged)
2018-10-11 00:04:52 +03:00
private:
void generateId();
2018-10-11 18:09:35 +03:00
2018-10-08 21:10:07 +03:00
protected:
2018-10-11 18:09:35 +03:00
int m_guiId;
double m_angle;
QString m_texture;
QRectF m_rect;
2018-10-11 00:04:52 +03:00
void setTexture(const QString &texture);
void setRect(QRectF rect);
public:
2018-10-08 21:10:07 +03:00
GuiObject(QObject *ptr = nullptr);
2018-10-11 18:09:35 +03:00
double angle() const;
QString texture() const;
2018-10-08 21:10:07 +03:00
2018-10-11 18:09:35 +03:00
void render();
2018-10-08 21:10:07 +03:00
2018-10-11 18:09:35 +03:00
QRectF rect() const;
QRectF &getRect();
void setAngle(double angle);
int guiId() const;
2018-10-11 00:04:52 +03:00
2018-10-11 18:09:35 +03:00
signals:
void angleChanged(double angle);
void textureChanged(QString texture);
void rectChanged(QRectF rect);
void guiIdChanged(int guiId);
};
2018-10-08 21:10:07 +03:00
#endif // GUIOBJECT_H