Loading...
Searching...
No Matches
Skin.hpp
1#pragma once
2#include <QBrush>
3#include <QCursor>
4#include <QFont>
5#include <QObject>
6#include <QPair>
7#include <QPen>
8#include <QVector>
9
10#include <score_lib_base_export.h>
11
12#include <verdigris>
13class QJsonObject;
14namespace score
15{
16struct Brush;
17class Skin;
18struct SCORE_LIB_BASE_EXPORT BrushSet
19{
20 QBrush brush;
21 QPen pen_cosmetic;
22 QPen pen0;
23 QPen pen0_solid_round;
24 QPen pen1;
25 QPen pen1_dotted;
26 QPen pen1_solid_flat_miter;
27 QPen pen1_5;
28 QPen pen2;
29 QPen pen2_solid_round_round;
30 QPen pen2_solid_flat_miter;
31 QPen pen2_dashdot_square_miter;
32 QPen pen2_dotted_square_miter;
33 QPen pen3;
34 QPen pen3_solid_flat_miter;
35 QPen pen3_solid_round_round;
36 QPen pen3_dashed_flat_miter;
37
38 void setupPens();
39
40private:
41 BrushSet() noexcept;
42 BrushSet(const BrushSet&) noexcept;
43 BrushSet(BrushSet&&) noexcept;
44 BrushSet& operator=(const BrushSet&) noexcept;
45 BrushSet& operator=(BrushSet&&) noexcept;
46 ~BrushSet();
47
48 explicit BrushSet(const QBrush& b) noexcept;
49
50 BrushSet& operator=(const QBrush& b) noexcept;
51 friend struct Brush;
52 friend class Skin;
53};
54
55struct SCORE_LIB_BASE_EXPORT Brush
56{
57 operator const QBrush&() const noexcept { return main.brush; }
58 QColor color() const noexcept { return main.brush.color(); }
59
60 BrushSet main;
61 BrushSet darker;
62 BrushSet darker300;
63 BrushSet lighter;
64 BrushSet lighter180;
65
66 void reload(QColor color) noexcept;
67
68 struct Pair;
69
70private:
71 Brush() noexcept;
72 Brush(const Brush&) noexcept;
73 Brush(Brush&&) noexcept;
74 Brush& operator=(const Brush&) noexcept;
75 Brush& operator=(Brush&&) noexcept;
76 ~Brush();
77
78 explicit Brush(const QBrush& b) noexcept;
79 Brush& operator=(const QBrush& b) noexcept;
80
81 friend class Skin;
82};
84{
85 Pair(QString&& str, QColor&& c)
86 : first{std::move(str)}
87 , second{std::move(c)}
88 {
89 }
90 QString first;
91 Brush second;
92};
93class SCORE_LIB_BASE_EXPORT Skin : public QObject
94{
95 W_OBJECT(Skin)
96public:
97 static Skin& instance() noexcept;
98 ~Skin() override;
99
100 void load(const QJsonObject& style);
101
102 QFont SansFont;
103 QFont MonoFont;
104 QFont MonoFontSmall;
105 QFont SansFontSmall;
106
107 QFont Bold10Pt;
108 QFont Bold12Pt;
109 QFont Medium7Pt;
110 QFont Medium8Pt;
111 QFont Medium10Pt;
112 QFont Medium12Pt;
113
114 QFont TitleFont;
115
116 Brush Dark;
117 Brush HalfDark;
118 Brush DarkGray;
119 Brush Gray;
120 Brush LightGray;
121 Brush HalfLight;
122 Brush Light;
123
124 Brush Emphasis1;
125 Brush Emphasis2;
126 Brush Emphasis3;
127 Brush Emphasis4;
128 Brush Emphasis5;
129
130 Brush Base1;
131 Brush Base2;
132 Brush Base3;
133 Brush Base4;
134 Brush Base5;
135
136 Brush Warn1;
137 Brush Warn2;
138 Brush Warn3;
139
140 Brush Background1;
141 Brush Background2;
142
143 Brush Transparent1;
144 Brush Transparent2;
145 Brush Transparent3;
146
147 Brush Smooth1;
148 Brush Smooth2;
149 Brush Smooth3;
150
151 Brush Tender1;
152 Brush Tender2;
153 Brush Tender3;
154
155 Brush Cable1;
156 Brush Cable2;
157 Brush Cable3;
158
159 Brush SelectedCable1;
160 Brush SelectedCable2;
161 Brush SelectedCable3;
162
163 Brush Port1;
164 Brush Port2;
165 Brush Port3;
166
167 Brush Pulse1;
168 Brush Pulse2;
169
170 const QPen TransparentPen;
171 const QBrush TransparentBrush;
172 const QPen NoPen;
173 const QBrush NoBrush;
174 QBrush TextBrush;
175
176 QPen TextItemPen;
177
178 QBrush SliderBrush;
179 QPen SliderPen;
180 QBrush SliderInteriorBrush;
181 QPen SliderLine;
182 QPen SliderTextPen;
183 QFont SliderFont;
184
185 QCursor CursorPointer;
186 QCursor CursorOpenHand;
187 QCursor CursorClosedHand;
188 QCursor CursorPointingHand;
189 QCursor CursorMagnifier;
190 QCursor CursorMove;
191 QCursor CursorScaleH;
192 QCursor CursorScaleV;
193 QCursor CursorScaleFDiag;
194 QCursor CursorSpin;
195
196 QCursor CursorPlayFromHere;
197 QCursor CursorCreationMode;
198
199 const Brush* fromString(const QString& s) const;
200 Brush* fromString(const QString& s);
201 QString toString(const Brush*) const;
202
203 QVector<QPair<QColor, QString>> getColors() const;
204 QVector<QPair<QColor, QString>> getDefaultPaletteColors() const;
205
206 // In [0; 25[
207 int PulseIndex{};
208
209 int LoadIndex{};
210
211public:
212 void changed() E_SIGNAL(SCORE_LIB_BASE_EXPORT, changed)
213
214private:
215 void timerEvent(QTimerEvent* event) override;
216 Skin() noexcept;
217
218 struct NoGUI
219 {
220 };
221 explicit Skin(NoGUI);
222
223 struct color_map;
224 color_map* initColorMap() noexcept;
225 color_map* m_colorMap{};
226 std::vector<Brush::Pair> m_defaultPalette;
227
228 bool m_pulseDirection{false};
229};
230}
Definition Skin.hpp:94
Base toolkit upon which the software is built.
Definition Application.cpp:97
Definition Skin.hpp:84
Definition Skin.hpp:56
Definition Skin.hpp:19
Definition Skin.cpp:35