1 /*
2     This file is part of Magnum.
3 
4     Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
5               Vladimír Vondruš <mosra@centrum.cz>
6 
7     Permission is hereby granted, free of charge, to any person obtaining a
8     copy of this software and associated documentation files (the "Software"),
9     to deal in the Software without restriction, including without limitation
10     the rights to use, copy, modify, merge, publish, distribute, sublicense,
11     and/or sell copies of the Software, and to permit persons to whom the
12     Software is furnished to do so, subject to the following conditions:
13 
14     The above copyright notice and this permission notice shall be included
15     in all copies or substantial portions of the Software.
16 
17     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23     DEALINGS IN THE SOFTWARE.
24 */
25 
26 #include "Style.h"
27 
28 #include <Corrade/Containers/Reference.h>
29 #include <Corrade/Utility/Resource.h>
30 #include <Magnum/GL/Buffer.h>
31 #include <Magnum/GL/Shader.h>
32 #include <Magnum/GL/Texture.h>
33 #include <Magnum/GL/Version.h>
34 
35 #include "Magnum/Ui/Widget.h"
36 
37 #ifdef MAGNUM_BUILD_STATIC
importShaderResources()38 static void importShaderResources() {
39     CORRADE_RESOURCE_INITIALIZE(MagnumUi_RESOURCES)
40 }
41 #endif
42 
43 namespace Magnum { namespace Ui {
44 
45 namespace Implementation {
46 
backgroundColorIndex(const Type type,const Style style,const State state)47 UnsignedByte backgroundColorIndex(const Type type, const Style style, const State state) {
48     enum: UnsignedByte {
49         Hidden = 0,
50 
51         ModalDefaultDefault,
52         ModalDefaultDisabled,
53         ModalPrimaryDefault,
54         ModalPrimaryDisabled,
55         ModalSuccessDefault,
56         ModalSuccessDisabled,
57         ModalInfoDefault,
58         ModalInfoDisabled,
59         ModalWarningDefault,
60         ModalWarningDisabled,
61         ModalDangerDefault,
62         ModalDangerDisabled,
63         ModalDimDefault,
64 
65         BackgroundColorCount
66     };
67 
68     static_assert(UnsignedByte(BackgroundColorCount) <= UnsignedByte(Implementation::BackgroundColorCount), "");
69 
70     if(state == State::Hidden)
71         return Hidden;
72 
73     const UnsignedInt encoded = (UnsignedInt(type) << 16) |
74                                 (UnsignedInt(style) << 8) |
75                                  UnsignedInt(state);
76 
77     switch(encoded) {
78         #define _c(type, style, state)                                      \
79             case (UnsignedInt(Type::type) << 16) |                          \
80                  (UnsignedInt(Style::style) << 8) |                         \
81                   UnsignedInt(State::state):                                \
82                 return type ## style ## state;
83         _c(Modal, Default, Default)
84         _c(Modal, Default, Disabled)
85         _c(Modal, Primary, Default)
86         _c(Modal, Primary, Disabled)
87         _c(Modal, Success, Default)
88         _c(Modal, Success, Disabled)
89         _c(Modal, Info, Default)
90         _c(Modal, Info, Disabled)
91         _c(Modal, Warning, Default)
92         _c(Modal, Warning, Disabled)
93         _c(Modal, Danger, Default)
94         _c(Modal, Danger, Disabled)
95         _c(Modal, Dim, Default)
96         #undef _c
97     }
98 
99     /* LCOV_EXCL_START */
100     CORRADE_ASSERT(false, "Ui::StyleConfiguration: unsupported background color index" << type << style << state, 0);
101     std::abort();
102     /* LCOV_EXCL_STOP */
103 }
104 
foregroundColorIndex(const Type type,const Style style,const State state)105 UnsignedByte foregroundColorIndex(const Type type, const Style style, const State state) {
106     enum: UnsignedByte {
107         Hidden = 0,
108 
109         ButtonDefaultDefault,
110         ButtonDefaultHover,
111         ButtonDefaultPressed,
112         ButtonDefaultDisabled,
113         ButtonPrimaryDefault,
114         ButtonPrimaryHover,
115         ButtonPrimaryPressed,
116         ButtonPrimaryDisabled,
117         ButtonSuccessDefault,
118         ButtonSuccessHover,
119         ButtonSuccessPressed,
120         ButtonSuccessDisabled,
121         ButtonInfoDefault,
122         ButtonInfoHover,
123         ButtonInfoPressed,
124         ButtonInfoDisabled,
125         ButtonWarningDefault,
126         ButtonWarningHover,
127         ButtonWarningPressed,
128         ButtonWarningDisabled,
129         ButtonDangerDefault,
130         ButtonDangerHover,
131         ButtonDangerPressed,
132         ButtonDangerDisabled,
133         ButtonDimDefault,
134         ButtonDimHover,
135         ButtonDimPressed,
136         ButtonDimDisabled,
137 
138         InputDefaultDefault,
139         InputDefaultHover,
140         InputDefaultPressed,
141         InputDefaultActive,
142         InputDefaultDisabled,
143         InputPrimaryDefault,
144         InputPrimaryHover,
145         InputPrimaryPressed,
146         InputPrimaryActive,
147         InputPrimaryDisabled,
148         InputSuccessDefault,
149         InputSuccessHover,
150         InputSuccessPressed,
151         InputSuccessActive,
152         InputSuccessDisabled,
153         InputInfoDefault,
154         InputInfoHover,
155         InputInfoPressed,
156         InputInfoActive,
157         InputInfoDisabled,
158         InputWarningDefault,
159         InputWarningHover,
160         InputWarningPressed,
161         InputWarningActive,
162         InputWarningDisabled,
163         InputDangerDefault,
164         InputDangerHover,
165         InputDangerPressed,
166         InputDangerActive,
167         InputDangerDisabled,
168         InputDimDefault,
169         InputDimHover,
170         InputDimPressed,
171         InputDimActive,
172         InputDimDisabled,
173 
174         ForegroundColorCount
175     };
176 
177     static_assert(UnsignedByte(ForegroundColorCount) <= UnsignedByte(Implementation::ForegroundColorCount), "");
178 
179     if(state == State::Hidden)
180         return Hidden;
181 
182     const UnsignedInt encoded = (UnsignedInt(type) << 16) |
183                                 (UnsignedInt(style) << 8) |
184                                  UnsignedInt(state);
185 
186     switch(encoded) {
187         #define _c(type, style, state)                                      \
188             case (UnsignedInt(Type::type) << 16) |                          \
189                  (UnsignedInt(Style::style) << 8) |                         \
190                   UnsignedInt(State::state):                                \
191                 return type ## style ## state;
192         _c(Button, Default, Default)
193         _c(Button, Default, Hover)
194         _c(Button, Default, Pressed)
195         _c(Button, Default, Disabled)
196         _c(Button, Primary, Default)
197         _c(Button, Primary, Hover)
198         _c(Button, Primary, Pressed)
199         _c(Button, Primary, Disabled)
200         _c(Button, Success, Default)
201         _c(Button, Success, Hover)
202         _c(Button, Success, Pressed)
203         _c(Button, Success, Disabled)
204         _c(Button, Info, Default)
205         _c(Button, Info, Hover)
206         _c(Button, Info, Pressed)
207         _c(Button, Info, Disabled)
208         _c(Button, Warning, Default)
209         _c(Button, Warning, Hover)
210         _c(Button, Warning, Pressed)
211         _c(Button, Warning, Disabled)
212         _c(Button, Danger, Default)
213         _c(Button, Danger, Hover)
214         _c(Button, Danger, Pressed)
215         _c(Button, Danger, Disabled)
216         _c(Button, Dim, Default)
217         _c(Button, Dim, Hover)
218         _c(Button, Dim, Pressed)
219         _c(Button, Dim, Disabled)
220 
221         _c(Input, Default, Default)
222         _c(Input, Default, Hover)
223         _c(Input, Default, Pressed)
224         _c(Input, Default, Active)
225         _c(Input, Default, Disabled)
226         _c(Input, Primary, Default)
227         _c(Input, Primary, Hover)
228         _c(Input, Primary, Pressed)
229         _c(Input, Primary, Active)
230         _c(Input, Primary, Disabled)
231         _c(Input, Success, Default)
232         _c(Input, Success, Hover)
233         _c(Input, Success, Pressed)
234         _c(Input, Success, Active)
235         _c(Input, Success, Disabled)
236         _c(Input, Info, Default)
237         _c(Input, Info, Hover)
238         _c(Input, Info, Pressed)
239         _c(Input, Info, Active)
240         _c(Input, Info, Disabled)
241         _c(Input, Warning, Default)
242         _c(Input, Warning, Hover)
243         _c(Input, Warning, Pressed)
244         _c(Input, Warning, Active)
245         _c(Input, Warning, Disabled)
246         _c(Input, Danger, Default)
247         _c(Input, Danger, Hover)
248         _c(Input, Danger, Pressed)
249         _c(Input, Danger, Active)
250         _c(Input, Danger, Disabled)
251         _c(Input, Dim, Default)
252         _c(Input, Dim, Hover)
253         _c(Input, Dim, Pressed)
254         _c(Input, Dim, Active)
255         _c(Input, Dim, Disabled)
256         #undef _c
257     }
258 
259     /* LCOV_EXCL_START */
260     CORRADE_ASSERT(false, "Ui::StyleConfiguration: unsupported foreground color index" << type << style << state, 0);
261     std::abort();
262     /* LCOV_EXCL_STOP */
263 }
264 
textColorIndex(const Type type,const Style style,const State state)265 UnsignedByte textColorIndex(const Type type, const Style style, const State state) {
266     enum: UnsignedByte {
267         Hidden = 0,
268 
269         ButtonDefaultDefault,
270         ButtonDefaultHover,
271         ButtonDefaultPressed,
272         ButtonDefaultDisabled,
273         ButtonPrimaryDefault,
274         ButtonPrimaryHover,
275         ButtonPrimaryPressed,
276         ButtonPrimaryDisabled,
277         ButtonSuccessDefault,
278         ButtonSuccessHover,
279         ButtonSuccessPressed,
280         ButtonSuccessDisabled,
281         ButtonInfoDefault,
282         ButtonInfoHover,
283         ButtonInfoPressed,
284         ButtonInfoDisabled,
285         ButtonWarningDefault,
286         ButtonWarningHover,
287         ButtonWarningPressed,
288         ButtonWarningDisabled,
289         ButtonDangerDefault,
290         ButtonDangerHover,
291         ButtonDangerPressed,
292         ButtonDangerDisabled,
293         ButtonDimDefault,
294         ButtonDimHover,
295         ButtonDimPressed,
296         ButtonDimDisabled,
297         ButtonFlatDefault,
298         ButtonFlatHover,
299         ButtonFlatPressed,
300         ButtonFlatDisabled,
301 
302         LabelDefaultDefault,
303         LabelDefaultDisabled,
304         LabelPrimaryDefault,
305         LabelPrimaryDisabled,
306         LabelSuccessDefault,
307         LabelSuccessDisabled,
308         LabelInfoDefault,
309         LabelInfoDisabled,
310         LabelWarningDefault,
311         LabelWarningDisabled,
312         LabelDangerDefault,
313         LabelDangerDisabled,
314         LabelDimDefault,
315         LabelDimDisabled,
316 
317         InputDefaultDefault,
318         InputDefaultHover,
319         InputDefaultPressed,
320         InputDefaultActive,
321         InputDefaultDisabled,
322         InputPrimaryDefault,
323         InputPrimaryHover,
324         InputPrimaryPressed,
325         InputPrimaryActive,
326         InputPrimaryDisabled,
327         InputSuccessDefault,
328         InputSuccessHover,
329         InputSuccessPressed,
330         InputSuccessActive,
331         InputSuccessDisabled,
332         InputInfoDefault,
333         InputInfoHover,
334         InputInfoPressed,
335         InputInfoActive,
336         InputInfoDisabled,
337         InputWarningDefault,
338         InputWarningHover,
339         InputWarningPressed,
340         InputWarningActive,
341         InputWarningDisabled,
342         InputDangerDefault,
343         InputDangerHover,
344         InputDangerPressed,
345         InputDangerActive,
346         InputDangerDisabled,
347         InputDimDefault,
348         InputDimHover,
349         InputDimPressed,
350         InputDimActive,
351         InputDimDisabled,
352         InputFlatDefault,
353         InputFlatHover,
354         InputFlatPressed,
355         InputFlatActive,
356         InputFlatDisabled,
357 
358         TextColorCount
359     };
360 
361     static_assert(UnsignedByte(TextColorCount) <= UnsignedByte(Implementation::TextColorCount), "");
362 
363     if(state == State::Hidden)
364         return Hidden;
365 
366     const UnsignedInt encoded = (UnsignedInt(type) << 16) |
367                                 (UnsignedInt(style) << 8) |
368                                  UnsignedInt(state);
369 
370     switch(encoded) {
371         #define _c(type, style, state)                                      \
372             case (UnsignedInt(Type::type) << 16) |                          \
373                  (UnsignedInt(Style::style) << 8) |                         \
374                   UnsignedInt(State::state):                                \
375                 return type ## style ## state;
376         _c(Button, Default, Default)
377         _c(Button, Default, Hover)
378         _c(Button, Default, Pressed)
379         _c(Button, Default, Disabled)
380         _c(Button, Primary, Default)
381         _c(Button, Primary, Hover)
382         _c(Button, Primary, Pressed)
383         _c(Button, Primary, Disabled)
384         _c(Button, Success, Default)
385         _c(Button, Success, Hover)
386         _c(Button, Success, Pressed)
387         _c(Button, Success, Disabled)
388         _c(Button, Info, Default)
389         _c(Button, Info, Hover)
390         _c(Button, Info, Pressed)
391         _c(Button, Info, Disabled)
392         _c(Button, Warning, Default)
393         _c(Button, Warning, Hover)
394         _c(Button, Warning, Pressed)
395         _c(Button, Warning, Disabled)
396         _c(Button, Danger, Default)
397         _c(Button, Danger, Hover)
398         _c(Button, Danger, Pressed)
399         _c(Button, Danger, Disabled)
400         _c(Button, Dim, Default)
401         _c(Button, Dim, Hover)
402         _c(Button, Dim, Pressed)
403         _c(Button, Dim, Disabled)
404         _c(Button, Flat, Default)
405         _c(Button, Flat, Hover)
406         _c(Button, Flat, Pressed)
407         _c(Button, Flat, Disabled)
408 
409         _c(Label, Default, Default)
410         _c(Label, Default, Disabled)
411         _c(Label, Primary, Default)
412         _c(Label, Primary, Disabled)
413         _c(Label, Success, Default)
414         _c(Label, Success, Disabled)
415         _c(Label, Info, Default)
416         _c(Label, Info, Disabled)
417         _c(Label, Warning, Default)
418         _c(Label, Warning, Disabled)
419         _c(Label, Danger, Default)
420         _c(Label, Danger, Disabled)
421         _c(Label, Dim, Default)
422         _c(Label, Dim, Disabled)
423 
424         _c(Input, Default, Default)
425         _c(Input, Default, Hover)
426         _c(Input, Default, Pressed)
427         _c(Input, Default, Active)
428         _c(Input, Default, Disabled)
429         _c(Input, Primary, Default)
430         _c(Input, Primary, Hover)
431         _c(Input, Primary, Pressed)
432         _c(Input, Primary, Active)
433         _c(Input, Primary, Disabled)
434         _c(Input, Success, Default)
435         _c(Input, Success, Hover)
436         _c(Input, Success, Pressed)
437         _c(Input, Success, Active)
438         _c(Input, Success, Disabled)
439         _c(Input, Info, Default)
440         _c(Input, Info, Hover)
441         _c(Input, Info, Pressed)
442         _c(Input, Info, Active)
443         _c(Input, Info, Disabled)
444         _c(Input, Warning, Default)
445         _c(Input, Warning, Hover)
446         _c(Input, Warning, Pressed)
447         _c(Input, Warning, Active)
448         _c(Input, Warning, Disabled)
449         _c(Input, Danger, Default)
450         _c(Input, Danger, Hover)
451         _c(Input, Danger, Pressed)
452         _c(Input, Danger, Active)
453         _c(Input, Danger, Disabled)
454         _c(Input, Dim, Default)
455         _c(Input, Dim, Hover)
456         _c(Input, Dim, Pressed)
457         _c(Input, Dim, Active)
458         _c(Input, Dim, Disabled)
459         _c(Input, Flat, Default)
460         _c(Input, Flat, Hover)
461         _c(Input, Flat, Pressed)
462         _c(Input, Flat, Active)
463         _c(Input, Flat, Disabled)
464         #undef _c
465     }
466 
467     /* LCOV_EXCL_START */
468     CORRADE_ASSERT(false, "Ui::StyleConfiguration: unsupported text color index" << type << style << state, 0);
469     std::abort();
470     /* LCOV_EXCL_STOP */
471 }
472 
473 namespace {
474 
stateForFlags(WidgetFlags flags)475 State stateForFlags(WidgetFlags flags) {
476     if(flags & WidgetFlag::Hidden) return State::Hidden;
477     if(flags & WidgetFlag::Disabled) return State::Disabled;
478     if(flags & WidgetFlag::Pressed) return State::Pressed;
479     if(flags & WidgetFlag::Active) return State::Active;
480     if(flags & WidgetFlag::Hovered) return State::Hover;
481     return State::Default;
482 }
483 
484 }
485 
backgroundColorIndex(const Type type,const Style style,const WidgetFlags flags)486 UnsignedByte backgroundColorIndex(const Type type, const Style style, const WidgetFlags flags) {
487     return backgroundColorIndex(type, style, stateForFlags(flags));
488 }
489 
foregroundColorIndex(const Type type,const Style style,const WidgetFlags flags)490 UnsignedByte foregroundColorIndex(const Type type, const Style style, const WidgetFlags flags) {
491     return foregroundColorIndex(type, style, stateForFlags(flags));
492 }
493 
textColorIndex(const Type type,const Style style,const WidgetFlags flags)494 UnsignedByte textColorIndex(const Type type, const Style style, const WidgetFlags flags) {
495     return textColorIndex(type, style, stateForFlags(flags));
496 }
497 
498 }
499 
operator <<(Debug & debug,const Type value)500 Debug& operator<<(Debug& debug, const Type value) {
501     switch(value) {
502         /* LCOV_EXCL_START */
503         #define _c(value) case Type::value: return debug << "Ui::Type::" #value;
504         _c(Button)
505         _c(Input)
506         _c(Label)
507         _c(Modal)
508         #undef _c
509         /* LCOV_EXCL_STOP */
510     }
511 
512     return debug << "Ui::Type(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
513 }
514 
operator <<(Debug & debug,const State value)515 Debug& operator<<(Debug& debug, const State value) {
516     switch(value) {
517         /* LCOV_EXCL_START */
518         #define _c(value) case State::value: return debug << "Ui::State::" #value;
519         _c(Default)
520         _c(Hover)
521         _c(Pressed)
522         _c(Active)
523         _c(Disabled)
524         _c(Hidden)
525         #undef _c
526         /* LCOV_EXCL_STOP */
527     }
528 
529     return debug << "Ui::State(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
530 }
531 
operator <<(Debug & debug,const Style value)532 Debug& operator<<(Debug& debug, const Style value) {
533     switch(value) {
534         /* LCOV_EXCL_START */
535         #define _c(value) case Style::value: return debug << "Ui::Style::" #value;
536         _c(Default)
537         _c(Primary)
538         _c(Success)
539         _c(Info)
540         _c(Warning)
541         _c(Danger)
542         _c(Dim)
543         _c(Flat)
544         #undef _c
545         /* LCOV_EXCL_STOP */
546     }
547 
548     return debug << "Ui::Style(" << Debug::nospace << reinterpret_cast<void*>(UnsignedInt(value)) << Debug::nospace << ")";
549 }
550 
StyleConfiguration()551 StyleConfiguration::StyleConfiguration() {
552     /* Don't forget to update the shader code also */
553     static_assert(sizeof(Background) == 4*4 + 4*4*Implementation::BackgroundColorCount, "Improper size of Background uniform structure");
554     static_assert(sizeof(Foreground) == 4*4 + 4*4*Implementation::ForegroundColorCount*3, "Improper size of Foreground uniform structure");
555     static_assert(sizeof(Text) == 4*4*Implementation::TextColorCount, "Improper size of Text uniform structure");
556     static_assert(sizeof(Implementation::QuadVertex) == 6*4, "Improper size of QuadVertex vertex structure");
557     static_assert(sizeof(Implementation::QuadInstance) == 4*4 + 4, "Improper size of QuadInstance vertex structure");
558     static_assert(sizeof(Implementation::TextVertex) == 4*4 + 4, "Improper size of TextVertex vertex structure");
559 }
560 
561 namespace {
562 
premult(const Color4 & color)563 inline Color4 premult(const Color4& color) {
564     return {color.rgb()*color.a(), color.a()};
565 }
566 
567 }
568 
defaultStyleConfiguration()569 StyleConfiguration defaultStyleConfiguration() {
570     using namespace Math::Literals;
571 
572     return Ui::StyleConfiguration{}
573         .setFontSize(16.0f)
574         .setMargin({10.0f, 7.0f})
575         .setPadding({13.0f, 10.0f})
576         .setCornerRadius(4.0f)
577         .setCornerSmoothnessOut(0.125f)
578 
579         .setTopFillColor(   Ui::Type::Button, Ui::Style::Default, Ui::State::Hover,    0xf9f9f9_rgbf)
580         .setBottomFillColor(Ui::Type::Button, Ui::Style::Default, Ui::State::Hover,    0xd9d9d9_rgbf)
581         .setTextColor(      Ui::Type::Button, Ui::Style::Default, Ui::State::Hover,    0x9e9e9e_rgbf)
582         .setTopFillColor(   Ui::Type::Button, Ui::Style::Default, Ui::State::Default,  0xe9e9e9_rgbf)
583         .setBottomFillColor(Ui::Type::Button, Ui::Style::Default, Ui::State::Default,  0xbfbfbf_rgbf)
584         .setTextColor(      Ui::Type::Button, Ui::Style::Default, Ui::State::Default,  0x1c1c1c_rgbf)
585         .setTopFillColor(   Ui::Type::Button, Ui::Style::Default, Ui::State::Pressed,  0x717171_rgbf)
586         .setBottomFillColor(Ui::Type::Button, Ui::Style::Default, Ui::State::Pressed,  0x8e8e8e_rgbf)
587         .setTextColor(      Ui::Type::Button, Ui::Style::Default, Ui::State::Pressed,  0x313131_rgbf)
588         .setTopFillColor(   Ui::Type::Button, Ui::Style::Default, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
589         .setBottomFillColor(Ui::Type::Button, Ui::Style::Default, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
590         .setTextColor(      Ui::Type::Button, Ui::Style::Default, Ui::State::Disabled, premult(0xafafaf4d_rgbaf))
591 
592         .setTopFillColor(   Ui::Type::Button, Ui::Style::Primary, Ui::State::Hover,    0x7891e6_rgbf)
593         .setBottomFillColor(Ui::Type::Button, Ui::Style::Primary, Ui::State::Hover,    0x4165dc_rgbf)
594         .setTextColor(      Ui::Type::Button, Ui::Style::Primary, Ui::State::Hover,    0xf0f3fc_rgbf)
595         .setTopFillColor(   Ui::Type::Button, Ui::Style::Primary, Ui::State::Default,  0x284fd6_rgbf)
596         .setBottomFillColor(Ui::Type::Button, Ui::Style::Primary, Ui::State::Default,  0x2040ac_rgbf)
597         .setTextColor(      Ui::Type::Button, Ui::Style::Primary, Ui::State::Default,  0xd7dff8_rgbf)
598         .setTopFillColor(   Ui::Type::Button, Ui::Style::Primary, Ui::State::Pressed,  0x132566_rgbf)
599         .setBottomFillColor(Ui::Type::Button, Ui::Style::Primary, Ui::State::Pressed,  0x1a3085_rgbf)
600         .setTextColor(      Ui::Type::Button, Ui::Style::Primary, Ui::State::Pressed,  0x4f72e0_rgbf)
601         .setTopFillColor(   Ui::Type::Button, Ui::Style::Primary, Ui::State::Disabled, premult(0x7171714d_rgbaf))
602         .setBottomFillColor(Ui::Type::Button, Ui::Style::Primary, Ui::State::Disabled, premult(0x7171714d_rgbaf))
603         .setTextColor(      Ui::Type::Button, Ui::Style::Primary, Ui::State::Disabled, premult(0xf6f6f64d_rgbaf))
604 
605         .setTopFillColor(   Ui::Type::Button, Ui::Style::Danger, Ui::State::Hover,    0xe5685f_rgbf)
606         .setBottomFillColor(Ui::Type::Button, Ui::Style::Danger, Ui::State::Hover,    0xdc3427_rgbf)
607         .setTextColor(      Ui::Type::Button, Ui::Style::Danger, Ui::State::Hover,    0xfae3e1_rgbf)
608         .setTopFillColor(   Ui::Type::Button, Ui::Style::Danger, Ui::State::Default,  0xbd2a1f_rgbf)
609         .setBottomFillColor(Ui::Type::Button, Ui::Style::Danger, Ui::State::Default,  0x9a2219_rgbf)
610         .setTextColor(      Ui::Type::Button, Ui::Style::Danger, Ui::State::Default,  0xf5c7c4_rgbf)
611         .setTopFillColor(   Ui::Type::Button, Ui::Style::Danger, Ui::State::Pressed,  0x57130e_rgbf)
612         .setBottomFillColor(Ui::Type::Button, Ui::Style::Danger, Ui::State::Pressed,  0x7e1d15_rgbf)
613         .setTextColor(      Ui::Type::Button, Ui::Style::Danger, Ui::State::Pressed,  0xd93124_rgbf)
614         .setTopFillColor(   Ui::Type::Button, Ui::Style::Danger, Ui::State::Disabled, premult(0x7171714d_rgbaf))
615         .setBottomFillColor(Ui::Type::Button, Ui::Style::Danger, Ui::State::Disabled, premult(0x7171714d_rgbaf))
616         .setTextColor(      Ui::Type::Button, Ui::Style::Danger, Ui::State::Disabled, premult(0xf6f6f64d_rgbaf))
617 
618         .setTopFillColor(   Ui::Type::Button, Ui::Style::Success, Ui::State::Hover,    0x36d134_rgbf)
619         .setBottomFillColor(Ui::Type::Button, Ui::Style::Success, Ui::State::Hover,    0x27a425_rgbf)
620         .setTextColor(      Ui::Type::Button, Ui::Style::Success, Ui::State::Hover,    0xd5f4d5_rgbf)
621         .setTopFillColor(   Ui::Type::Button, Ui::Style::Success, Ui::State::Default,  0x1d791b_rgbf)
622         .setBottomFillColor(Ui::Type::Button, Ui::Style::Success, Ui::State::Default,  0x186014_rgbf)
623         .setTextColor(      Ui::Type::Button, Ui::Style::Success, Ui::State::Default,  0xc1eebf_rgbf)
624         .setTopFillColor(   Ui::Type::Button, Ui::Style::Success, Ui::State::Pressed,  0x0f390b_rgbf)
625         .setBottomFillColor(Ui::Type::Button, Ui::Style::Success, Ui::State::Pressed,  0x165914_rgbf)
626         .setTextColor(      Ui::Type::Button, Ui::Style::Success, Ui::State::Pressed,  0x2a9327_rgbf)
627         .setTopFillColor(   Ui::Type::Button, Ui::Style::Success, Ui::State::Disabled, premult(0x7171714d_rgbaf))
628         .setBottomFillColor(Ui::Type::Button, Ui::Style::Success, Ui::State::Disabled, premult(0x7171714d_rgbaf))
629         .setTextColor(      Ui::Type::Button, Ui::Style::Success, Ui::State::Disabled, premult(0xf6f6f64d_rgbaf))
630 
631         .setTopFillColor(   Ui::Type::Button, Ui::Style::Warning, Ui::State::Hover,    0xf3f098_rgbf)
632         .setBottomFillColor(Ui::Type::Button, Ui::Style::Warning, Ui::State::Hover,    0xe7e243_rgbf)
633         .setTextColor(      Ui::Type::Button, Ui::Style::Warning, Ui::State::Hover,    0xa1a117_rgbf)
634         .setTopFillColor(   Ui::Type::Button, Ui::Style::Warning, Ui::State::Default,  0xdbd61b_rgbf)
635         .setBottomFillColor(Ui::Type::Button, Ui::Style::Warning, Ui::State::Default,  0xb7b217_rgbf)
636         .setTextColor(      Ui::Type::Button, Ui::Style::Warning, Ui::State::Default,  0x363608_rgbf)
637         .setTopFillColor(   Ui::Type::Button, Ui::Style::Warning, Ui::State::Pressed,  0x56540b_rgbf)
638         .setBottomFillColor(Ui::Type::Button, Ui::Style::Warning, Ui::State::Pressed,  0x7f7d0f_rgbf)
639         .setTextColor(      Ui::Type::Button, Ui::Style::Warning, Ui::State::Pressed,  0x313107_rgbf)
640         .setTopFillColor(   Ui::Type::Button, Ui::Style::Warning, Ui::State::Disabled, premult(0x7171714d_rgbaf))
641         .setBottomFillColor(Ui::Type::Button, Ui::Style::Warning, Ui::State::Disabled, premult(0x7171714d_rgbaf))
642         .setTextColor(      Ui::Type::Button, Ui::Style::Warning, Ui::State::Disabled, premult(0xf6f6f64d_rgbaf))
643 
644         .setTextColor(Ui::Type::Button, Ui::Style::Flat, Ui::State::Hover,    0xd0d9f7_rgbf)
645         .setTextColor(Ui::Type::Button, Ui::Style::Flat, Ui::State::Default,  0x8fa5ec_rgbf)
646         .setTextColor(Ui::Type::Button, Ui::Style::Flat, Ui::State::Pressed,  0x224ccd_rgbf)
647         .setTextColor(Ui::Type::Button, Ui::Style::Flat, Ui::State::Disabled, premult(0xa6a6a64d_rgbaf))
648 
649         .setTextColor(Ui::Type::Label, Ui::Style::Primary, Ui::State::Default,  0x284fd6_rgbf)
650         .setTextColor(Ui::Type::Label, Ui::Style::Primary, Ui::State::Disabled, premult(0xb0b0b04d_rgbaf))
651 
652         .setTextColor(Ui::Type::Label, Ui::Style::Danger,  Ui::State::Default,  0xbd2a1f_rgbf)
653         .setTextColor(Ui::Type::Label, Ui::Style::Danger,  Ui::State::Disabled, premult(0xb0b0b04d_rgbaf))
654 
655         .setTextColor(Ui::Type::Label, Ui::Style::Success, Ui::State::Default,  0x1d791b_rgbf)
656         .setTextColor(Ui::Type::Label, Ui::Style::Success, Ui::State::Disabled, premult(0xb0b0b04d_rgbaf))
657 
658         .setTextColor(Ui::Type::Label, Ui::Style::Warning, Ui::State::Default,  0xdbd61b_rgbf)
659         .setTextColor(Ui::Type::Label, Ui::Style::Warning, Ui::State::Disabled, premult(0xb0b0b04d_rgbaf))
660 
661         .setTextColor(Ui::Type::Label, Ui::Style::Info,    Ui::State::Default,  0x7c94e7_rgbf)
662         .setTextColor(Ui::Type::Label, Ui::Style::Info,    Ui::State::Disabled, premult(0xb0b0b04d_rgbaf))
663 
664         .setTextColor(Ui::Type::Label, Ui::Style::Default, Ui::State::Default,  0xe7e7e7_rgbf)
665         .setTextColor(Ui::Type::Label, Ui::Style::Default, Ui::State::Disabled, premult(0x6363634d_rgbaf))
666 
667         .setTextColor(Ui::Type::Label, Ui::Style::Dim,     Ui::State::Default,  0x939393_rgbf)
668         .setTextColor(Ui::Type::Label, Ui::Style::Dim,     Ui::State::Disabled, premult(0x4242424d_rgbaf))
669 
670         .setTopFillColor(   Ui::Type::Input, Ui::Style::Default, Ui::State::Hover,    0xd9d9d9_rgbf)
671         .setBottomFillColor(Ui::Type::Input, Ui::Style::Default, Ui::State::Hover,    0xf9f9f9_rgbf)
672         .setTextColor(      Ui::Type::Input, Ui::Style::Default, Ui::State::Hover,    0x777777_rgbf)
673         .setTopFillColor(   Ui::Type::Input, Ui::Style::Default, Ui::State::Default,  0xbfbfbf_rgbf)
674         .setBottomFillColor(Ui::Type::Input, Ui::Style::Default, Ui::State::Default,  0xe9e9e9_rgbf)
675         .setTextColor(      Ui::Type::Input, Ui::Style::Default, Ui::State::Default,  0x1c1c1c_rgbf)
676         .setTopFillColor(   Ui::Type::Input, Ui::Style::Default, Ui::State::Pressed,  0x717171_rgbf)
677         .setBottomFillColor(Ui::Type::Input, Ui::Style::Default, Ui::State::Pressed,  0x8e8e8e_rgbf)
678         .setTextColor(      Ui::Type::Input, Ui::Style::Default, Ui::State::Pressed,  0x313131_rgbf)
679         .setTopFillColor(   Ui::Type::Input, Ui::Style::Default, Ui::State::Active,   0x909090_rgbf)
680         .setBottomFillColor(Ui::Type::Input, Ui::Style::Default, Ui::State::Active,   0xbdbdbd_rgbf)
681         .setTextColor(      Ui::Type::Input, Ui::Style::Default, Ui::State::Active,   0x242424_rgbf)
682         .setTopFillColor(   Ui::Type::Input, Ui::Style::Default, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
683         .setBottomFillColor(Ui::Type::Input, Ui::Style::Default, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
684         .setTextColor(      Ui::Type::Input, Ui::Style::Default, Ui::State::Disabled, premult(0xafafaf4d_rgbaf))
685 
686         .setTopFillColor(   Ui::Type::Input, Ui::Style::Danger, Ui::State::Hover,    0xd9d9d9_rgbf)
687         .setBottomFillColor(Ui::Type::Input, Ui::Style::Danger, Ui::State::Hover,    0xf9f9f9_rgbf)
688         .setTextColor(      Ui::Type::Input, Ui::Style::Danger, Ui::State::Hover,    0xe87f75_rgbf)
689         .setTopFillColor(   Ui::Type::Input, Ui::Style::Danger, Ui::State::Default,  0xbfbfbf_rgbf)
690         .setBottomFillColor(Ui::Type::Input, Ui::Style::Danger, Ui::State::Default,  0xe9e9e9_rgbf)
691         .setTextColor(      Ui::Type::Input, Ui::Style::Danger, Ui::State::Default,  0xa4261b_rgbf)
692         .setTopFillColor(   Ui::Type::Input, Ui::Style::Danger, Ui::State::Pressed,  0x717171_rgbf)
693         .setBottomFillColor(Ui::Type::Input, Ui::Style::Danger, Ui::State::Pressed,  0x8e8e8e_rgbf)
694         .setTextColor(      Ui::Type::Input, Ui::Style::Danger, Ui::State::Pressed,  0xf4c2be_rgbf)
695         .setTopFillColor(   Ui::Type::Input, Ui::Style::Danger, Ui::State::Active,   0xea8884_rgbf)
696         .setBottomFillColor(Ui::Type::Input, Ui::Style::Danger, Ui::State::Active,   0xf2bab6_rgbf)
697         .setTextColor(      Ui::Type::Input, Ui::Style::Danger, Ui::State::Active,   0x7e1d15_rgbf)
698         .setTopFillColor(   Ui::Type::Input, Ui::Style::Danger, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
699         .setBottomFillColor(Ui::Type::Input, Ui::Style::Danger, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
700         .setTextColor(      Ui::Type::Input, Ui::Style::Danger, Ui::State::Disabled, premult(0xafafaf4d_rgbaf))
701 
702         .setTopFillColor(   Ui::Type::Input, Ui::Style::Success, Ui::State::Hover,    0xd9d9d9_rgbf)
703         .setBottomFillColor(Ui::Type::Input, Ui::Style::Success, Ui::State::Hover,    0xf9f9f9_rgbf)
704         .setTextColor(      Ui::Type::Input, Ui::Style::Success, Ui::State::Hover,    0x61db5d_rgbf)
705         .setTopFillColor(   Ui::Type::Input, Ui::Style::Success, Ui::State::Default,  0xbfbfbf_rgbf)
706         .setBottomFillColor(Ui::Type::Input, Ui::Style::Success, Ui::State::Default,  0xe9e9e9_rgbf)
707         .setTextColor(      Ui::Type::Input, Ui::Style::Success, Ui::State::Default,  0x21871e_rgbf)
708         .setTopFillColor(   Ui::Type::Input, Ui::Style::Success, Ui::State::Pressed,  0x717171_rgbf)
709         .setBottomFillColor(Ui::Type::Input, Ui::Style::Success, Ui::State::Pressed,  0x8e8e8e_rgbf)
710         .setTextColor(      Ui::Type::Input, Ui::Style::Success, Ui::State::Pressed,  0x77e074_rgbf)
711         .setTopFillColor(   Ui::Type::Input, Ui::Style::Success, Ui::State::Active,   0x8ae781_rgbf)
712         .setBottomFillColor(Ui::Type::Input, Ui::Style::Success, Ui::State::Active,   0xc7f2c6_rgbf)
713         .setTextColor(      Ui::Type::Input, Ui::Style::Success, Ui::State::Active,   0x165914_rgbf)
714         .setTopFillColor(   Ui::Type::Input, Ui::Style::Success, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
715         .setBottomFillColor(Ui::Type::Input, Ui::Style::Success, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
716         .setTextColor(      Ui::Type::Input, Ui::Style::Success, Ui::State::Disabled, premult(0xafafaf4d_rgbaf))
717 
718         .setTopFillColor(   Ui::Type::Input, Ui::Style::Warning, Ui::State::Hover,    0xd9d9d9_rgbf)
719         .setBottomFillColor(Ui::Type::Input, Ui::Style::Warning, Ui::State::Hover,    0xf9f9f9_rgbf)
720         .setTextColor(      Ui::Type::Input, Ui::Style::Warning, Ui::State::Hover,    0xcec818_rgbf)
721         .setTopFillColor(   Ui::Type::Input, Ui::Style::Warning, Ui::State::Default,  0xbfbfbf_rgbf)
722         .setBottomFillColor(Ui::Type::Input, Ui::Style::Warning, Ui::State::Default,  0xe9e9e9_rgbf)
723         .setTextColor(      Ui::Type::Input, Ui::Style::Warning, Ui::State::Default,  0x827e0f_rgbf)
724         .setTopFillColor(   Ui::Type::Input, Ui::Style::Warning, Ui::State::Pressed,  0x717171_rgbf)
725         .setBottomFillColor(Ui::Type::Input, Ui::Style::Warning, Ui::State::Pressed,  0x8e8e8e_rgbf)
726         .setTextColor(      Ui::Type::Input, Ui::Style::Warning, Ui::State::Pressed,  0xd1cd19_rgbf)
727         .setTopFillColor(   Ui::Type::Input, Ui::Style::Warning, Ui::State::Active,   0xf0ec88_rgbf)
728         .setBottomFillColor(Ui::Type::Input, Ui::Style::Warning, Ui::State::Active,   0xfaf9d2_rgbf)
729         .setTextColor(      Ui::Type::Input, Ui::Style::Warning, Ui::State::Active,   0x7f7d0f_rgbf)
730         .setTopFillColor(   Ui::Type::Input, Ui::Style::Warning, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
731         .setBottomFillColor(Ui::Type::Input, Ui::Style::Warning, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
732         .setTextColor(      Ui::Type::Input, Ui::Style::Warning, Ui::State::Disabled, premult(0xafafaf4d_rgbaf))
733 
734         .setTextColor(Ui::Type::Input, Ui::Style::Flat, Ui::State::Hover,    0xd0d9f7_rgbf)
735         .setTextColor(Ui::Type::Input, Ui::Style::Flat, Ui::State::Default,  0x8fa5ec_rgbf)
736         .setTextColor(Ui::Type::Input, Ui::Style::Flat, Ui::State::Pressed,  0x224ccd_rgbf)
737         .setTextColor(Ui::Type::Input, Ui::Style::Flat, Ui::State::Active,   0x456ce0_rgbf)
738         .setTextColor(Ui::Type::Input, Ui::Style::Flat, Ui::State::Disabled, premult(0xa6a6a64d_rgbaf))
739 
740         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Dim, Ui::State::Default, premult(0x00000099_rgbaf))
741         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Default, Ui::State::Default, premult(0x1f1f1fe5_rgbaf))
742         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Danger, Ui::State::Default, premult(0x411713e5_rgbaf))
743         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Success, Ui::State::Default, premult(0x102c10e5_rgbaf))
744         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Warning, Ui::State::Default, premult(0x323112e5_rgbaf))
745         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Info, Ui::State::Default, premult(0x10172fe5_rgbaf));
746 }
747 
mcssDarkStyleConfiguration()748 StyleConfiguration mcssDarkStyleConfiguration() {
749     using namespace Math::Literals;
750 
751     return Ui::StyleConfiguration{}
752         /* Base font size is 1rem = 16px, margin between components is 1rem,
753            padding inside also, but reduce the vertical margin to half here.
754            Corner radius is 0.2rem. */
755         .setFontSize(16.0f)
756         .setMargin({12.0f, 10.0f})
757         .setPadding({16.0f, 12.0f})
758         .setCornerRadius(3.2f)
759         .setCornerSmoothnessOut(0.0125f)
760 
761         /* Buttons: using --*-color for default color, --*-button-active-color
762            for hover/pressed color. Text color is always --header-background-color.
763            Everything has 80% opacity except the text, the disabled state is
764            default but with 30% opacity. Disabled text color is --background-color
765            with 80% opacity. */
766         .setTopFillColor(   Ui::Type::Button, Ui::Style::Default, Ui::State::Default,  0xdcdcdc_rgbf)
767         .setBottomFillColor(Ui::Type::Button, Ui::Style::Default, Ui::State::Default,  0xdcdcdc_rgbf)
768         .setTextColor(      Ui::Type::Button, Ui::Style::Default, Ui::State::Default,  0x22272e_rgbf)
769         .setTextColor(      Ui::Type::Button, Ui::Style::Default, Ui::State::Hover,    0x22272e_rgbf)
770         .setTopFillColor(   Ui::Type::Button, Ui::Style::Default, Ui::State::Hover,    0xa5c9ea_rgbf)
771         .setBottomFillColor(Ui::Type::Button, Ui::Style::Default, Ui::State::Hover,    0xa5c9ea_rgbf)
772         .setTopFillColor(   Ui::Type::Button, Ui::Style::Default, Ui::State::Pressed,  0xa5c9ea_rgbf)
773         .setBottomFillColor(Ui::Type::Button, Ui::Style::Default, Ui::State::Pressed,  0xa5c9ea_rgbf)
774         .setTextColor(      Ui::Type::Button, Ui::Style::Default, Ui::State::Pressed,  0x22272e_rgbf)
775         .setTopFillColor(   Ui::Type::Button, Ui::Style::Default, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
776         .setBottomFillColor(Ui::Type::Button, Ui::Style::Default, Ui::State::Disabled, premult(0x4a4a4a4d_rgbaf))
777         .setTextColor(      Ui::Type::Button, Ui::Style::Default, Ui::State::Disabled, premult(0xafafaf4d_rgbaf))
778 
779         .setTopFillColor(   Ui::Type::Button, Ui::Style::Primary, Ui::State::Default,  0xa5c9eaff_rgbaf*0.8f)
780         .setBottomFillColor(Ui::Type::Button, Ui::Style::Primary, Ui::State::Default,  0xa5c9eaff_rgbaf*0.8f)
781         .setTextColor(      Ui::Type::Button, Ui::Style::Primary, Ui::State::Default,  0x22272eff_rgbaf)
782         .setTopFillColor(   Ui::Type::Button, Ui::Style::Primary, Ui::State::Hover,    0xdcdcdcff_rgbaf*0.8f)
783         .setBottomFillColor(Ui::Type::Button, Ui::Style::Primary, Ui::State::Hover,    0xdcdcdcff_rgbaf*0.8f)
784         .setTextColor(      Ui::Type::Button, Ui::Style::Primary, Ui::State::Hover,    0x22272eff_rgbaf)
785         .setTopFillColor(   Ui::Type::Button, Ui::Style::Primary, Ui::State::Pressed,  0xdcdcdcff_rgbaf*0.8f)
786         .setBottomFillColor(Ui::Type::Button, Ui::Style::Primary, Ui::State::Pressed,  0xdcdcdcff_rgbaf*0.8f)
787         .setTextColor(      Ui::Type::Button, Ui::Style::Primary, Ui::State::Pressed,  0x22272eff_rgbaf)
788         .setTopFillColor(   Ui::Type::Button, Ui::Style::Primary, Ui::State::Disabled, 0xa5c9eaff_rgbaf*0.3f)
789         .setBottomFillColor(Ui::Type::Button, Ui::Style::Primary, Ui::State::Disabled, 0xa5c9eaff_rgbaf*0.3f)
790         .setTextColor(      Ui::Type::Button, Ui::Style::Primary, Ui::State::Disabled, 0x2f363fff_rgbaf*0.8f)
791 
792         .setTopFillColor(   Ui::Type::Button, Ui::Style::Success, Ui::State::Default,  0x3bd267ff_rgbaf*0.8f)
793         .setBottomFillColor(Ui::Type::Button, Ui::Style::Success, Ui::State::Default,  0x3bd267ff_rgbaf*0.8f)
794         .setTextColor(      Ui::Type::Button, Ui::Style::Success, Ui::State::Default,  0x22272eff_rgbaf)
795         .setTopFillColor(   Ui::Type::Button, Ui::Style::Success, Ui::State::Hover,    0xacecbeff_rgbaf*0.8f)
796         .setBottomFillColor(Ui::Type::Button, Ui::Style::Success, Ui::State::Hover,    0xacecbeff_rgbaf*0.8f)
797         .setTextColor(      Ui::Type::Button, Ui::Style::Success, Ui::State::Hover,    0x22272eff_rgbaf)
798         .setTopFillColor(   Ui::Type::Button, Ui::Style::Success, Ui::State::Pressed,  0xacecbeff_rgbaf*0.8f)
799         .setBottomFillColor(Ui::Type::Button, Ui::Style::Success, Ui::State::Pressed,  0xacecbeff_rgbaf*0.8f)
800         .setTextColor(      Ui::Type::Button, Ui::Style::Success, Ui::State::Pressed,  0x22272eff_rgbaf)
801         .setTopFillColor(   Ui::Type::Button, Ui::Style::Success, Ui::State::Disabled, 0x3bd267ff_rgbaf*0.3f)
802         .setBottomFillColor(Ui::Type::Button, Ui::Style::Success, Ui::State::Disabled, 0x3bd267ff_rgbaf*0.3f)
803         .setTextColor(      Ui::Type::Button, Ui::Style::Success, Ui::State::Disabled, 0x2f363fff_rgbaf*0.8f)
804 
805         .setTopFillColor(   Ui::Type::Button, Ui::Style::Warning, Ui::State::Default,  0xc7cf2fff_rgbaf*0.8f)
806         .setBottomFillColor(Ui::Type::Button, Ui::Style::Warning, Ui::State::Default,  0xc7cf2fff_rgbaf*0.8f)
807         .setTextColor(      Ui::Type::Button, Ui::Style::Warning, Ui::State::Default,  0x22272eff_rgbaf)
808         .setTopFillColor(   Ui::Type::Button, Ui::Style::Warning, Ui::State::Hover,    0xe9ecaeff_rgbaf*0.8f)
809         .setBottomFillColor(Ui::Type::Button, Ui::Style::Warning, Ui::State::Hover,    0xe9ecaeff_rgbaf*0.8f)
810         .setTextColor(      Ui::Type::Button, Ui::Style::Warning, Ui::State::Hover,    0x22272eff_rgbaf)
811         .setTopFillColor(   Ui::Type::Button, Ui::Style::Warning, Ui::State::Pressed,  0xe9ecaeff_rgbaf*0.8f)
812         .setBottomFillColor(Ui::Type::Button, Ui::Style::Warning, Ui::State::Pressed,  0xe9ecaeff_rgbaf*0.8f)
813         .setTextColor(      Ui::Type::Button, Ui::Style::Warning, Ui::State::Pressed,  0x22272eff_rgbaf)
814         .setTopFillColor(   Ui::Type::Button, Ui::Style::Warning, Ui::State::Disabled, 0xc7cf2fff_rgbaf*0.3f)
815         .setBottomFillColor(Ui::Type::Button, Ui::Style::Warning, Ui::State::Disabled, 0xc7cf2fff_rgbaf*0.3f)
816         .setTextColor(      Ui::Type::Button, Ui::Style::Warning, Ui::State::Disabled, 0x2f363fff_rgbaf*0.8f)
817 
818         .setTopFillColor(   Ui::Type::Button, Ui::Style::Danger, Ui::State::Default,  0xcd3431ff_rgbaf*0.8f)
819         .setBottomFillColor(Ui::Type::Button, Ui::Style::Danger, Ui::State::Default,  0xcd3431ff_rgbaf*0.8f)
820         .setTextColor(      Ui::Type::Button, Ui::Style::Danger, Ui::State::Default,  0x22272eff_rgbaf)
821         .setTopFillColor(   Ui::Type::Button, Ui::Style::Danger, Ui::State::Hover,    0xff9391ff_rgbaf*0.8f)
822         .setBottomFillColor(Ui::Type::Button, Ui::Style::Danger, Ui::State::Hover,    0xff9391ff_rgbaf*0.8f)
823         .setTextColor(      Ui::Type::Button, Ui::Style::Danger, Ui::State::Hover,    0x22272eff_rgbaf)
824         .setTopFillColor(   Ui::Type::Button, Ui::Style::Danger, Ui::State::Pressed,  0xff9391ff_rgbaf*0.8f)
825         .setBottomFillColor(Ui::Type::Button, Ui::Style::Danger, Ui::State::Pressed,  0xff9391ff_rgbaf*0.8f)
826         .setTextColor(      Ui::Type::Button, Ui::Style::Danger, Ui::State::Pressed,  0x22272eff_rgbaf)
827         .setTopFillColor(   Ui::Type::Button, Ui::Style::Danger, Ui::State::Disabled, 0xcd3431ff_rgbaf*0.3f)
828         .setBottomFillColor(Ui::Type::Button, Ui::Style::Danger, Ui::State::Disabled, 0xcd3431ff_rgbaf*0.3f)
829         .setTextColor(      Ui::Type::Button, Ui::Style::Danger, Ui::State::Disabled, 0x2f363fff_rgbaf*0.8f)
830 
831         /* Flat button is styled the same as links (--link-color,
832            --link-active-color). Disabled state is --dim-link-color with 80%
833            opacity. */
834         .setTextColor(Ui::Type::Button, Ui::Style::Flat, Ui::State::Hover,    0xa5c9eaff_rgbaf)
835         .setTextColor(Ui::Type::Button, Ui::Style::Flat, Ui::State::Default,  0x5b9dd9ff_rgbaf)
836         .setTextColor(Ui::Type::Button, Ui::Style::Flat, Ui::State::Pressed,  0xa5c9eaff_rgbaf)
837         .setTextColor(Ui::Type::Button, Ui::Style::Flat, Ui::State::Disabled, 0xacacacff_rgbaf*0.8f)
838 
839         /* Labels the same as in m.css (--*-color), disabled state is 30%
840            opacity, same as with button color. */
841         .setTextColor(Ui::Type::Label, Ui::Style::Default, Ui::State::Default,  0xdcdcdcff_rgbaf)
842         .setTextColor(Ui::Type::Label, Ui::Style::Default, Ui::State::Disabled, 0xdcdcdcff_rgbaf*0.3f)
843 
844         .setTextColor(Ui::Type::Label, Ui::Style::Primary, Ui::State::Default,  0xa5c9eaff_rgbaf)
845         .setTextColor(Ui::Type::Label, Ui::Style::Primary, Ui::State::Disabled, 0xa5c9eaff_rgbaf*0.3f)
846 
847         .setTextColor(Ui::Type::Label, Ui::Style::Success, Ui::State::Default,  0x3bd267ff_rgbaf)
848         .setTextColor(Ui::Type::Label, Ui::Style::Success, Ui::State::Disabled, 0x3bd267ff_rgbaf*0.3f)
849 
850         .setTextColor(Ui::Type::Label, Ui::Style::Warning, Ui::State::Default,  0xc7cf2fff_rgbaf)
851         .setTextColor(Ui::Type::Label, Ui::Style::Warning, Ui::State::Disabled, 0xc7cf2fff_rgbaf*0.3f)
852 
853         .setTextColor(Ui::Type::Label, Ui::Style::Danger,  Ui::State::Default,  0xcd3431ff_rgbaf)
854         .setTextColor(Ui::Type::Label, Ui::Style::Danger,  Ui::State::Disabled, 0xcd3431ff_rgbaf*0.3f)
855 
856         .setTextColor(Ui::Type::Label, Ui::Style::Info,    Ui::State::Default,  0x2f83ccff_rgbaf)
857         .setTextColor(Ui::Type::Label, Ui::Style::Info,    Ui::State::Disabled, 0x2f83ccff_rgbaf*0.3f)
858 
859         .setTextColor(Ui::Type::Label, Ui::Style::Dim,     Ui::State::Default,  0x747474ff_rgbaf)
860         .setTextColor(Ui::Type::Label, Ui::Style::Dim,     Ui::State::Disabled, 0x747474ff_rgbaf*0.3f)
861 
862         /* Input is --*-filled-background-color for background in all cases,
863            --*-filled-color for text color in default state,
864            --*-filled-link-active-color for hover and --*-filled-link-color for
865            active/pressed, because it's more distinctive than
866            --*-filled-link-active-color. */
867         .setTopFillColor(   Ui::Type::Input, Ui::Style::Default, Ui::State::Default,  0x34424dff_rgbaf*0.8f)
868         .setBottomFillColor(Ui::Type::Input, Ui::Style::Default, Ui::State::Default,  0x34424dff_rgbaf*0.8f)
869         .setTextColor(      Ui::Type::Input, Ui::Style::Default, Ui::State::Default,  0xdcdcdcff_rgbaf)
870         .setTopFillColor(   Ui::Type::Input, Ui::Style::Default, Ui::State::Hover,    0x34424dff_rgbaf*0.8f)
871         .setBottomFillColor(Ui::Type::Input, Ui::Style::Default, Ui::State::Hover,    0x34424dff_rgbaf*0.8f)
872         .setTextColor(      Ui::Type::Input, Ui::Style::Default, Ui::State::Hover,    0x5b9dd9ff_rgbaf)
873         .setTopFillColor(   Ui::Type::Input, Ui::Style::Default, Ui::State::Pressed,  0x34424dff_rgbaf*0.8f)
874         .setBottomFillColor(Ui::Type::Input, Ui::Style::Default, Ui::State::Pressed,  0x34424dff_rgbaf*0.8f)
875         .setTextColor(      Ui::Type::Input, Ui::Style::Default, Ui::State::Pressed,  0xa5c9eaff_rgbaf)
876         .setTopFillColor(   Ui::Type::Input, Ui::Style::Default, Ui::State::Active,   0x34424dff_rgbaf*0.8f)
877         .setBottomFillColor(Ui::Type::Input, Ui::Style::Default, Ui::State::Active,   0x34424dff_rgbaf*0.8f)
878         .setTextColor(      Ui::Type::Input, Ui::Style::Default, Ui::State::Active,   0x5b9dd9ff_rgbaf)
879         .setTopFillColor(   Ui::Type::Input, Ui::Style::Default, Ui::State::Disabled, 0x34424dff_rgbaf*0.3f)
880         .setBottomFillColor(Ui::Type::Input, Ui::Style::Default, Ui::State::Disabled, 0x34424dff_rgbaf*0.3f)
881         .setTextColor(      Ui::Type::Input, Ui::Style::Default, Ui::State::Disabled, 0xdcdcdcff_rgbaf*0.3f)
882 
883         .setTopFillColor(   Ui::Type::Input, Ui::Style::Warning, Ui::State::Default,  0x6d702aff_rgbaf*0.8f)
884         .setBottomFillColor(Ui::Type::Input, Ui::Style::Warning, Ui::State::Default,  0x6d702aff_rgbaf*0.8f)
885         .setTextColor(      Ui::Type::Input, Ui::Style::Warning, Ui::State::Default,  0xe9ecaeff_rgbaf)
886         .setTopFillColor(   Ui::Type::Input, Ui::Style::Warning, Ui::State::Hover,    0x6d702aff_rgbaf*0.8f)
887         .setBottomFillColor(Ui::Type::Input, Ui::Style::Warning, Ui::State::Hover,    0x6d702aff_rgbaf*0.8f)
888         .setTextColor(      Ui::Type::Input, Ui::Style::Warning, Ui::State::Hover,    0xb8bf2bff_rgbaf)
889         .setTopFillColor(   Ui::Type::Input, Ui::Style::Warning, Ui::State::Pressed,  0x6d702aff_rgbaf*0.8f)
890         .setBottomFillColor(Ui::Type::Input, Ui::Style::Warning, Ui::State::Pressed,  0x6d702aff_rgbaf*0.8f)
891         .setTextColor(      Ui::Type::Input, Ui::Style::Warning, Ui::State::Pressed,  0xe9ecaeff_rgbaf)
892         .setTopFillColor(   Ui::Type::Input, Ui::Style::Warning, Ui::State::Active,   0x6d702aff_rgbaf*0.8f)
893         .setBottomFillColor(Ui::Type::Input, Ui::Style::Warning, Ui::State::Active,   0x6d702aff_rgbaf*0.8f)
894         .setTextColor(      Ui::Type::Input, Ui::Style::Warning, Ui::State::Active,   0xb8bf2bff_rgbaf)
895         .setTopFillColor(   Ui::Type::Input, Ui::Style::Warning, Ui::State::Disabled, 0x6d702aff_rgbaf*0.3f)
896         .setBottomFillColor(Ui::Type::Input, Ui::Style::Warning, Ui::State::Disabled, 0x6d702aff_rgbaf*0.3f)
897         .setTextColor(      Ui::Type::Input, Ui::Style::Warning, Ui::State::Disabled, 0xe9ecaeff_rgbaf*0.3f)
898 
899         .setTopFillColor(   Ui::Type::Input, Ui::Style::Success, Ui::State::Default,  0x2a703fff_rgbaf*0.8f)
900         .setBottomFillColor(Ui::Type::Input, Ui::Style::Success, Ui::State::Default,  0x2a703fff_rgbaf*0.8f)
901         .setTextColor(      Ui::Type::Input, Ui::Style::Success, Ui::State::Default,  0xacecbeff_rgbaf)
902         .setTopFillColor(   Ui::Type::Input, Ui::Style::Success, Ui::State::Hover,    0x2a703fff_rgbaf*0.8f)
903         .setBottomFillColor(Ui::Type::Input, Ui::Style::Success, Ui::State::Hover,    0x2a703fff_rgbaf*0.8f)
904         .setTextColor(      Ui::Type::Input, Ui::Style::Success, Ui::State::Hover,    0x3bd267ff_rgbaf)
905         .setTopFillColor(   Ui::Type::Input, Ui::Style::Success, Ui::State::Pressed,  0x2a703fff_rgbaf*0.8f)
906         .setBottomFillColor(Ui::Type::Input, Ui::Style::Success, Ui::State::Pressed,  0x2a703fff_rgbaf*0.8f)
907         .setTextColor(      Ui::Type::Input, Ui::Style::Success, Ui::State::Pressed,  0xacecbeff_rgbaf)
908         .setTopFillColor(   Ui::Type::Input, Ui::Style::Success, Ui::State::Active,   0x2a703fff_rgbaf*0.8f)
909         .setBottomFillColor(Ui::Type::Input, Ui::Style::Success, Ui::State::Active,   0x2a703fff_rgbaf*0.8f)
910         .setTextColor(      Ui::Type::Input, Ui::Style::Success, Ui::State::Active,   0x3bd267ff_rgbaf)
911         .setTopFillColor(   Ui::Type::Input, Ui::Style::Success, Ui::State::Disabled, 0x2a703fff_rgbaf*0.3f)
912         .setBottomFillColor(Ui::Type::Input, Ui::Style::Success, Ui::State::Disabled, 0x2a703fff_rgbaf*0.3f)
913         .setTextColor(      Ui::Type::Input, Ui::Style::Success, Ui::State::Disabled, 0xacecbeff_rgbaf*0.3f)
914 
915         .setTopFillColor(   Ui::Type::Input, Ui::Style::Danger, Ui::State::Default,  0x702b2aff_rgbaf*0.8f)
916         .setBottomFillColor(Ui::Type::Input, Ui::Style::Danger, Ui::State::Default,  0x702b2aff_rgbaf*0.8f)
917         .setTextColor(      Ui::Type::Input, Ui::Style::Danger, Ui::State::Default,  0xff9391ff_rgbaf)
918         .setTopFillColor(   Ui::Type::Input, Ui::Style::Danger, Ui::State::Hover,    0x702b2aff_rgbaf*0.8f)
919         .setBottomFillColor(Ui::Type::Input, Ui::Style::Danger, Ui::State::Hover,    0x702b2aff_rgbaf*0.8f)
920         .setTextColor(      Ui::Type::Input, Ui::Style::Danger, Ui::State::Hover,    0xd85c59ff_rgbaf)
921         .setTopFillColor(   Ui::Type::Input, Ui::Style::Danger, Ui::State::Pressed,  0x702b2aff_rgbaf*0.8f)
922         .setBottomFillColor(Ui::Type::Input, Ui::Style::Danger, Ui::State::Pressed,  0x702b2aff_rgbaf*0.8f)
923         .setTextColor(      Ui::Type::Input, Ui::Style::Danger, Ui::State::Pressed,  0xff9391ff_rgbaf)
924         .setTopFillColor(   Ui::Type::Input, Ui::Style::Danger, Ui::State::Active,   0x702b2aff_rgbaf*0.8f)
925         .setBottomFillColor(Ui::Type::Input, Ui::Style::Danger, Ui::State::Active,   0x702b2aff_rgbaf*0.8f)
926         .setTextColor(      Ui::Type::Input, Ui::Style::Danger, Ui::State::Active,   0xd85c59ff_rgbaf)
927         .setTopFillColor(   Ui::Type::Input, Ui::Style::Danger, Ui::State::Disabled, 0x702b2aff_rgbaf*0.3f)
928         .setBottomFillColor(Ui::Type::Input, Ui::Style::Danger, Ui::State::Disabled, 0x702b2aff_rgbaf*0.3f)
929         .setTextColor(      Ui::Type::Input, Ui::Style::Danger, Ui::State::Disabled, 0xff9391ff_rgbaf*0.3f)
930 
931         /* Flat input is styled like inverse links (--link-active-color as
932            default/pressed, --link-color as active/hover) to distinguish it
933            from button. Disabled is --dim-filled-link-active-color with 80%
934            opacity. */
935         .setTextColor(Ui::Type::Input, Ui::Style::Flat, Ui::State::Default,  0xa5c9eaff_rgbaf)
936         .setTextColor(Ui::Type::Input, Ui::Style::Flat, Ui::State::Hover,    0x5b9dd9ff_rgbaf)
937         .setTextColor(Ui::Type::Input, Ui::Style::Flat, Ui::State::Pressed,  0xa5c9eaff_rgbaf)
938         .setTextColor(Ui::Type::Input, Ui::Style::Flat, Ui::State::Active,   0x5b9dd9ff_rgbaf)
939         .setTextColor(Ui::Type::Input, Ui::Style::Flat, Ui::State::Disabled, 0x747474ff_rgbaf*0.8f)
940 
941         /* Modal background is --*-filled-background-color with 30% opacity. */
942         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Dim, Ui::State::Default, 0x00000099_rgbaf)
943         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Default, Ui::State::Default, 0x34424dff_rgbaf*0.8f)
944         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Success, Ui::State::Default, 0x2a703fff_rgbaf*0.8f)
945         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Warning, Ui::State::Default, 0x6d702aff_rgbaf*0.8f)
946         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Danger, Ui::State::Default, 0x702b2aff_rgbaf*0.8f)
947         .setBackgroundColor(Ui::Type::Modal, Ui::Style::Info, Ui::State::Default, 0x2a4f70ff_rgbaf*0.8f);
948 }
949 
pack(GL::Buffer & backgroundUniforms,GL::Buffer & foregroundUniforms,GL::Buffer & textUniforms) const950 void StyleConfiguration::pack(GL::Buffer& backgroundUniforms, GL::Buffer& foregroundUniforms, GL::Buffer& textUniforms) const {
951     backgroundUniforms.setData({&_background, 1}, GL::BufferUsage::StaticDraw);
952     foregroundUniforms.setData({&_foreground, 1}, GL::BufferUsage::StaticDraw);
953     textUniforms.setData({&_text, 1}, GL::BufferUsage::StaticDraw);
954 }
955 
956 namespace Implementation {
957 
bindCornerTexture(GL::Texture2D & texture)958 AbstractQuadShader& AbstractQuadShader::bindCornerTexture(GL::Texture2D& texture) {
959     texture.bind(0);
960     return *this;
961 }
962 
BackgroundShader()963 BackgroundShader::BackgroundShader() {
964     #ifdef MAGNUM_BUILD_STATIC
965     if(!Utility::Resource::hasGroup("MagnumUi"))
966         importShaderResources();
967     #endif
968 
969     Utility::Resource rs{"MagnumUi"};
970 
971     GL::Shader vert{
972         #ifndef MAGNUM_TARGET_GLES
973         GL::Version::GL330,
974         #else
975         GL::Version::GLES300,
976         #endif
977         GL::Shader::Type::Vertex};
978     GL::Shader frag{
979         #ifndef MAGNUM_TARGET_GLES
980         GL::Version::GL330,
981         #else
982         GL::Version::GLES300,
983         #endif
984         GL::Shader::Type::Fragment};
985     vert.addSource("#define BACKGROUND_COLOR_COUNT " + std::to_string(Implementation::BackgroundColorCount) + "\n");
986     frag.addSource("#define BACKGROUND_COLOR_COUNT " + std::to_string(Implementation::BackgroundColorCount) + "\n");
987     vert.addSource(rs.get("BackgroundShader.vert"));
988     frag.addSource(rs.get("BackgroundShader.frag"));
989 
990     CORRADE_INTERNAL_ASSERT(GL::Shader::compile({vert, frag}));
991     attachShaders({vert, frag});
992 
993     CORRADE_INTERNAL_ASSERT(link());
994 
995     setUniform(uniformLocation("cornerTextureData"), 0);
996     setUniformBlockBinding(uniformBlockIndex("Style"), 0);
997     _transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
998 }
999 
bindStyleBuffer(GL::Buffer & buffer)1000 BackgroundShader& BackgroundShader::bindStyleBuffer(GL::Buffer& buffer) {
1001     buffer.bind(GL::Buffer::Target::Uniform, 0);
1002     return *this;
1003 }
1004 
ForegroundShader()1005 ForegroundShader::ForegroundShader() {
1006     #ifdef MAGNUM_BUILD_STATIC
1007     if(!Utility::Resource::hasGroup("MagnumUi"))
1008         importShaderResources();
1009     #endif
1010 
1011     Utility::Resource rs{"MagnumUi"};
1012 
1013     GL::Shader vert{
1014         #ifndef MAGNUM_TARGET_GLES
1015         GL::Version::GL330,
1016         #else
1017         GL::Version::GLES300,
1018         #endif
1019         GL::Shader::Type::Vertex};
1020     GL::Shader frag{
1021         #ifndef MAGNUM_TARGET_GLES
1022         GL::Version::GL330,
1023         #else
1024         GL::Version::GLES300,
1025         #endif
1026         GL::Shader::Type::Fragment};
1027     vert.addSource("#define FOREGROUND_COLOR_COUNT " + std::to_string(Implementation::ForegroundColorCount) + "\n");
1028     frag.addSource("#define FOREGROUND_COLOR_COUNT " + std::to_string(Implementation::ForegroundColorCount) + "\n");
1029     vert.addSource(rs.get("ForegroundShader.vert"));
1030     frag.addSource(rs.get("ForegroundShader.frag"));
1031 
1032     CORRADE_INTERNAL_ASSERT(GL::Shader::compile({vert, frag}));
1033     attachShaders({vert, frag});
1034 
1035     CORRADE_INTERNAL_ASSERT(link());
1036 
1037     setUniform(uniformLocation("cornerTextureData"), 0);
1038     setUniformBlockBinding(uniformBlockIndex("Style"), 1);
1039     _transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
1040 }
1041 
bindStyleBuffer(GL::Buffer & buffer)1042 ForegroundShader& ForegroundShader::bindStyleBuffer(GL::Buffer& buffer) {
1043     buffer.bind(GL::Buffer::Target::Uniform, 1);
1044     return *this;
1045 }
1046 
TextShader()1047 TextShader::TextShader() {
1048     #ifdef MAGNUM_BUILD_STATIC
1049     if(!Utility::Resource::hasGroup("MagnumUi"))
1050         importShaderResources();
1051     #endif
1052 
1053     Utility::Resource rs{"MagnumUi"};
1054 
1055     GL::Shader vert{
1056         #ifndef MAGNUM_TARGET_GLES
1057         GL::Version::GL330,
1058         #else
1059         GL::Version::GLES300,
1060         #endif
1061         GL::Shader::Type::Vertex};
1062     GL::Shader frag{
1063         #ifndef MAGNUM_TARGET_GLES
1064         GL::Version::GL330,
1065         #else
1066         GL::Version::GLES300,
1067         #endif
1068         GL::Shader::Type::Fragment};
1069     vert.addSource(rs.get("TextShader.vert"));
1070     frag.addSource("#define TEXT_COLOR_COUNT " + std::to_string(Implementation::TextColorCount) + "\n");
1071     frag.addSource(rs.get("TextShader.frag"));
1072 
1073     CORRADE_INTERNAL_ASSERT(GL::Shader::compile({vert, frag}));
1074     attachShaders({vert, frag});
1075 
1076     CORRADE_INTERNAL_ASSERT(link());
1077 
1078     setUniformBlockBinding(uniformBlockIndex("Style"), 2);
1079     _transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix");
1080     setUniform(uniformLocation("textureData"), 1);
1081 }
1082 
bindGlyphCacheTexture(GL::Texture2D & texture)1083 TextShader& TextShader::bindGlyphCacheTexture(GL::Texture2D& texture) {
1084     texture.bind(1);
1085     return *this;
1086 }
1087 
bindStyleBuffer(GL::Buffer & buffer)1088 TextShader& TextShader::bindStyleBuffer(GL::Buffer& buffer) {
1089     buffer.bind(GL::Buffer::Target::Uniform, 2);
1090     return *this;
1091 }
1092 
1093 }}}
1094