-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanvas.h
More file actions
68 lines (54 loc) · 1.67 KB
/
Copy pathcanvas.h
File metadata and controls
68 lines (54 loc) · 1.67 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef CANVAS_H
#define CANVAS_H
#include <QWidget>
#include <QImage>
#include <QColor>
#include <QVector>
#include <QPoint>
class QPainter;
class QMouseEvent;
class QPaintEvent;
class QResizeEvent;
class QSlider;
class QColorDialog;
class Canvas : public QWidget {
Q_OBJECT
public:
explicit Canvas(QWidget *parent = nullptr);
void setBrushTool();
void setEraserTool();
void setFillTool();
void setColorPickerTool();
void setBrushSize(int size);
void setBrushColor(const QColor &color);
QColor getBrushColor() const;
int getBrushSize() const; // Declare the getter for brush size
void addLayer();
void removeLayer(int index);
void setCurrentLayer(int index);
void setLayerVisibility(int index, bool visible);
int getLayerCount() const;
int getCurrentLayer() const;
void importImage(const QString &filePath);
void exportImage(const QString &filePath); // Remove const here
void resizeCanvas(int width, int height);
protected:
void paintEvent(QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
private:
void initializeCanvas();
void drawCheckeredBackground(QPainter &painter);
void fillArea(const QPoint &clickPoint); // Add the fillArea declaration
QVector<QImage> layers;
QVector<bool> layerVisibility;
int currentLayer;
int brushSize;
QColor brushColor;
bool drawing;
QPoint lastPoint;
enum Tool { Brush, Eraser, Fill, ColorPicker } currentTool;
};
#endif // CANVAS_H