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