Mouse detection
This commit is contained in:
parent
e24837649c
commit
bcd01a95b3
5 changed files with 163 additions and 16 deletions
|
|
@ -3,25 +3,46 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <iostream>
|
||||
#include "line.h"
|
||||
|
||||
class GridPreview : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GridPreview(QWidget *parent = nullptr);
|
||||
void setSize(int newWidth, int newHeight);
|
||||
void addLine(Line &line);
|
||||
void removeLine(int index);
|
||||
QString toLuaTable();
|
||||
void paintEvent(QPaintEvent* event);
|
||||
QColor colorFromString(QString color);
|
||||
private:
|
||||
int width = 5, height = 5;
|
||||
QVector<Line> lines {};
|
||||
QMap<QString, QColor> colorMap;
|
||||
const QString tableTemplate = "return {\n width = %1,\n height = %2,\n lines = {\n%3\n }\n}";
|
||||
|
||||
bool mouseCaptured = false;
|
||||
public:
|
||||
explicit GridPreview(QWidget *parent = nullptr);
|
||||
void setSize(int newWidth, int newHeight);
|
||||
|
||||
void addLine(Line &line);
|
||||
void removeLine(int index);
|
||||
|
||||
void setLineColor(int index, QString color);
|
||||
void setLineStartPoint(int index, int x, int y);
|
||||
void setLineEndPoint(int index, int x, int y);
|
||||
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
const Line& getLine(int index);
|
||||
|
||||
const QString toLuaTable();
|
||||
void paintEvent(QPaintEvent* event);
|
||||
const QColor colorFromString(const QString color);
|
||||
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
const QPoint localMousePosition(QMouseEvent* event);
|
||||
const QPoint snapToGrid(int x, int y);
|
||||
signals:
|
||||
void updatedContents();
|
||||
};
|
||||
|
||||
#endif // GRIDPREVIEW_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue