-
Notifications
You must be signed in to change notification settings - Fork 0
/
operator_view.hpp
63 lines (48 loc) · 1.4 KB
/
operator_view.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
58
59
60
61
62
63
// SPDX-License-Identifier: GPL-2.0
#ifndef OPERATOR_VIEW_HPP
#define OPERATOR_VIEW_HPP
#include "operator.hpp"
#include "aligned_buf.hpp"
#include "color.hpp"
#include <QImage>
class OperatorViewState final : public Operator::StateTemplate<OperatorViewState> {
QJsonObject to_json() const override;
void from_json(const QJsonObject &) override;
public:
OperatorViewState();
ColorMode mode = ColorMode::LINEAR;
double scale = 1.0;
ColorType color_type = ColorType::RW;
QString directory;
};
class OperatorView : public OperatorTemplate<OperatorId::View, OperatorViewState, 1, 0>
{
AlignedBuf<uint32_t> imagebuf;
QString get_scale_text() const;
void show_empty();
void execute() override;
void init() override;
void state_reset() override;
void restore_handles() override;
void set_scale(double scale);
// Save as png file
void save_file();
// Display zoom level
QGraphicsTextItem *text;
// Switch between color modes
MenuButton *color_menu;
MenuButton *mode_menu;
void switch_color(ColorType type);
void switch_mode(ColorMode mode);
Scroller *scroller;
bool dont_accumulate_undo;
template<size_t N, typename T> void calculate_doit();
public:
inline static constexpr const char *icon = ":/icons/view.svg";
inline static constexpr const char *tooltip = "Add View";
using OperatorTemplate::OperatorTemplate;
private:
friend class Operator;
template<size_t N> void calculate();
};
#endif