1 Star 0 Fork 15

adewei/LVGLBuilder

forked from zhangheyang/LVGLBuilder 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
LVGLSimulator.h 2.64 KB
一键复制 编辑 原始数据 按行查看 历史
#ifndef LVGLSIMULATOR_H
#define LVGLSIMULATOR_H
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QTextStream>
#include "lvgl/lvgl.h"
class LVGLObject;
class LVGLItem;
class LVGLObjectModel;
class LVGLPropertyModel;
class LVGLScene : public QGraphicsScene {
Q_OBJECT
public:
LVGLScene(QObject *parent = nullptr);
LVGLObject *selected() const;
LVGLObject *hoverObject() const;
void setHoverObject(LVGLObject *hoverObject);
public slots:
void setSelected(LVGLObject *selected);
protected:
virtual void drawBackground(QPainter *painter, const QRectF &rect) override;
private:
LVGLObject *m_selected;
LVGLObject *m_hoverObject;
};
class LVGLSimulator : public QGraphicsView {
Q_OBJECT
public:
explicit LVGLSimulator(QWidget *parent = nullptr);
~LVGLSimulator() override;
LVGLObject *selectedObject() const;
LVGLItem *item() const;
void moveObject(LVGLObject *obj, int dx, int dy);
void addObject(LVGLObject *obj);
void removeObject(LVGLObject *obj);
void setObjectModel(LVGLObjectModel *objectModel);
void setPropertyModel(LVGLPropertyModel *propertyModel);
void setobjParent(lv_obj_t *parent);
public slots:
void setSelectedObject(LVGLObject *obj);
void setZoomLevel(int level);
void clear();
void setMouseEnable(bool enable);
void changeResolution(QSize size);
signals:
void objectSelected(LVGLObject *obj);
void objectPositionChanged();
void objectAdded(LVGLObject *obj);
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void dropEvent(QDropEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
private slots:
void update();
private:
LVGLObject *selectObject(QList<LVGLObject *> objs, bool doubleClick) const;
QList<LVGLObject *> objectsUnderCoords(QPoint pos, bool includeLocked) const;
void generateCodeObject(QTextStream &stream, LVGLObject *o);
// void parseJson(QJsonObject object, LVGLObject *parent = nullptr);
LVGLScene *m_scene;
LVGLObject *m_selectedObject;
bool m_mouseEnabled;
LVGLItem *m_item;
LVGLObjectModel *m_objectModel;
lv_obj_t *m_parent;
LVGLPropertyModel *m_propertyModel;
};
class LVGLKeyPressEventFilter : public QObject {
Q_OBJECT
public:
explicit LVGLKeyPressEventFilter(LVGLSimulator *sim,
QObject *parent = nullptr);
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
private:
LVGLSimulator *m_sim;
};
#endif // LVGLSIMULATOR_H
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/adewei/LVGLBuilder.git
git@gitee.com:adewei/LVGLBuilder.git
adewei
LVGLBuilder
LVGLBuilder
master

搜索帮助