-
Notifications
You must be signed in to change notification settings - Fork 0
/
operator_pixmap.hpp
57 lines (47 loc) · 1.37 KB
/
operator_pixmap.hpp
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
// SPDX-License-Identifier: GPL-2.0
#ifndef OPERATOR_PIXMAP_HPP
#define OPERATOR_PIXMAP_HPP
#include "operator.hpp"
#include <QImage>
#include <QString>
#include <QPoint>
#include <QPainter>
class OperatorPixmapState final : public Operator::StateTemplate<OperatorPixmapState> {
QJsonObject to_json() const override;
void from_json(const QJsonObject &) override;
size_t n; // Set once at initialization
public:
void init(size_t n);
QImage image;
QString directory;
int brush_size = 1;
bool antialiasing = false;
};
class OperatorPixmap : public OperatorTemplate<OperatorId::Pixmap, OperatorPixmapState, 0, 1>
{
void load_file();
void clear();
void invert();
void update_buffers();
void init() override;
void placed() override;
void state_reset() override;
bool handle_click(QGraphicsSceneMouseEvent *event) override;
void drag_handle(const QPointF &p, Qt::KeyboardModifiers) override;
void restore_handles() override; // Tells us that we exited from drag mode
QPainter painter;
QPen pen;
QPoint pos;
bool dont_accumulate_undo;
// Switch between pens
MenuButton *brush_menu;
void switch_brush(int size, bool antialiasing);
public:
inline static constexpr const char *icon = ":/icons/pixmap.svg";
inline static constexpr const char *tooltip = "Add Pixmap";
OperatorPixmap(MainWindow &w);
private:
friend class Operator;
template<size_t N> void calculate();
};
#endif