-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpainter.h
45 lines (39 loc) · 1.1 KB
/
painter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef PAINTER_H
#define PAINTER_H
#include <QWidget>
#include <QMouseEvent>
#include <QPen>
#include <tool.h>
#include "animationframe.h"
class Painter : public QWidget
{
Q_OBJECT
public:
explicit Painter(QWidget *parent = nullptr);
void setSize(int width, int height);
void setPenWidth(int width);
int getPenWidth();
void setPenColor(QColor &color);
QColor getPenColor();
double aspectRatio = 480 / 640; // height / width
void setFrame(AnimationFrame *f);
Tool tool = Tool::pen;
public slots:
void clearImage();
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private:
void drawLineTo(const QPoint &point);
void resizeImage(QImage *image, const QSize &newSize);
QPen pen;
bool modified = false;
bool drawing = false;
AnimationFrame *frame = nullptr;
QPoint lastPoint;
QColor penColor;
};
#endif // PAINTER_H