FabGL2 2.0.0
Graphics, audio, GUI and retro-computing library for the ESP32 (ESP-IDF)
Loading...
Searching...
No Matches
uitheme.cpp
1/*
2 Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3 Copyright (c) 2019-2026 Fabrizio Di Vittorio.
4 All rights reserved.
5
6
7* Please contact fdivitto2013@gmail.com if you need a commercial license.
8
9
10* This library and related software is available under GPL v3.
11
12 FabGL is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
16
17 FabGL is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with FabGL. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26
27#include "uitheme.h"
28
29
30namespace fabgl {
31
32
33
34// The ESP32 VGA output has 2 bits per channel (64 colors): each component is one of 0, 85, 170, 255
35// (RGB888toPackedRGB222() keeps the 2 high bits), so the theme colors are defined on that grid.
36
37// neutral colors (the accent dependent slots are taken from Accents)
38static const RGB888 ThemeColors[16] = {
39 RGB888( 0, 0, 0), // Black
40 RGB888( 0, 0, 0), // Desktop (accent)
41 RGB888( 0, 170, 85), // Green
42 RGB888( 0, 0, 0), // Bloom1 (accent)
43 RGB888( 0, 0, 0), // AccentDark (accent)
44 RGB888( 0, 0, 0), // Bloom2 (accent)
45 RGB888( 0, 0, 0), // Card
46 RGB888( 85, 85, 85), // Border
47 RGB888(170, 170, 170), // TextDim
48 RGB888(255, 0, 0), // Red
49 RGB888( 85, 85, 85), // Hover
50 RGB888(255, 255, 0), // Amber
51 RGB888( 0, 0, 0), // Accent (accent)
52 RGB888( 0, 0, 0), // Window
53 RGB888(255, 255, 255), // Text
54 RGB888(255, 255, 255), // White
55};
56
57
58struct AccentShades {
59 RGB888 accent, accentDark, bloom2, bloom1, desktop;
60};
61
62
63// indexed by uiThemeAccent
64static const AccentShades Accents[] = {
65 // accent accentDark bloom2 bloom1 desktop
66 { RGB888(255, 170, 0), RGB888(170, 85, 0), RGB888(85, 0, 0), RGB888(0, 0, 0), RGB888(0, 0, 0) }, // Orange
67 { RGB888( 0, 170, 255), RGB888( 0, 85, 170), RGB888( 0, 85, 85), RGB888(0, 0, 0), RGB888(0, 0, 0) }, // Cyan
68 { RGB888(170, 85, 255), RGB888( 85, 0, 170), RGB888(85, 0, 85), RGB888(0, 0, 0), RGB888(0, 0, 0) }, // Violet
69 { RGB888( 85, 255, 85), RGB888( 0, 170, 85), RGB888( 0, 85, 0), RGB888(0, 0, 0), RGB888(0, 0, 0) }, // Green
70};
71
72
74 : m_accent(accent),
75 m_paletted(false),
76 m_paletteSize(0)
77{
78 applyToUnstyled = true;
79}
80
81
82// 4 color palette: slot of each uiThemeInk (0 = black, 1 = gray, 2 = accent, 3 = white)
83static const uint8_t Ink4Slot[16] = {
84 0, // Black
85 0, // Desktop
86 2, // Green
87 0, // Bloom1
88 2, // AccentDark
89 1, // Bloom2
90 0, // Card
91 1, // Border
92 3, // TextDim
93 2, // Red
94 1, // Hover
95 2, // Amber
96 2, // Accent
97 0, // Window
98 3, // Text
99 3, // White
100};
101
102
103// default palette of VGA4Controller: the display maps a color to the slot that had the nearest default color
104static const RGB888 Default4Palette[4] = { RGB888(0, 0, 0), RGB888(0, 0, 255), RGB888(0, 255, 0), RGB888(255, 255, 255) };
105
106
107// prepares the colors returned by ink() for a palette of "colors" entries, returns the number of slots to program
108int uiDarkTheme::preparePalette(int colors)
109{
110 m_paletteSize = colors >= 16 ? 16 : 4;
111 for (int i = 0; i < 16; ++i)
112 m_ink[i] = m_paletteSize == 16 ? RGB888((Color) i) : Default4Palette[Ink4Slot[i]];
113 m_paletted = true;
114 return m_paletteSize;
115}
116
117
118RGB888 uiDarkTheme::paletteColor(int slot)
119{
120 if (m_paletteSize == 16)
121 return color((uiThemeInk) slot);
122 switch (slot) {
123 case 1: return color(uiThemeInk::Border);
124 case 2: return color(uiThemeInk::Accent);
125 case 3: return color(uiThemeInk::White);
126 default: return color(uiThemeInk::Black);
127 }
128}
129
130
132{
133 auto const & a = Accents[(int) m_accent];
134 switch (value) {
135 case uiThemeInk::Accent: return a.accent;
136 case uiThemeInk::AccentDark: return a.accentDark;
137 case uiThemeInk::Bloom2: return a.bloom2;
138 case uiThemeInk::Bloom1: return a.bloom1;
139 case uiThemeInk::Desktop: return a.desktop;
140 default: return ThemeColors[(int) value];
141 }
142}
143
144
146{
147 app->setStyle(this);
148
149 auto & dlg = app->appProps().dialogStyleClasses;
151 dlg.label = uiThemeStyle::Label;
152 dlg.button = uiThemeStyle::Button;
153 dlg.textEdit = uiThemeStyle::Edit;
154 dlg.panel = uiThemeStyle::DialogFooter;
155
156 // the root window exists before the style is set
158}
159
160
162{
163 auto const & t = object->objectType();
164 if (t.uiFrame) {
165 auto title = ((uiFrame *) object)->title();
166 return title && title[0] ? uiThemeStyle::Frame : uiThemeStyle::Popup;
167 }
168 if (t.uiPanel)
169 return uiThemeStyle::Card;
170 if (t.uiLabel || t.uiStaticLabel)
171 return uiThemeStyle::Label;
172 if (t.uiSplitButton)
174 if (t.uiCustomComboBox)
176 if (t.uiButton)
178 if (t.uiTextEdit)
179 return uiThemeStyle::Edit;
180 if (t.uiCustomListBox)
182 if (t.uiCheckBox)
184 if (t.uiSlider)
186 if (t.uiProgressBar)
188 if (t.uiPaintBox)
190 if (t.uiKnob)
191 return uiThemeStyle::Knob;
192 if (t.uiToggleSwitch)
194 if (t.uiLevelBar)
196 if (t.uiLedBar)
198 if (t.uiStepper)
200 if (t.uiTileSelector)
202 if (t.uiGraph)
203 return uiThemeStyle::Graph;
204 if (t.uiPianoKeyboard)
206 if (t.uiFader)
207 return uiThemeStyle::Fader;
208 if (t.uiPad)
209 return uiThemeStyle::Pad;
210 if (t.uiSegmentDisplay)
212 if (t.uiStepGrid)
214 return 0;
215}
216
217
218void uiDarkTheme::setBorder(uiWindow * window, int size, RGB888 color, RGB888 focusedColor, int cornerRadius)
219{
220 auto & s = window->windowStyle();
221 s.borderSize = size;
222 s.focusedBorderSize = size;
223 s.borderColor = color;
224 s.activeBorderColor = color;
225 s.focusedBorderColor = focusedColor;
226 s.cornerRadius = cornerRadius;
227}
228
229
230void uiDarkTheme::setScrollBars(uiScrollableControl * control)
231{
232 auto & s = control->scrollableControlStyle();
233 s.scrollBarBackgroundColor = ink(uiThemeInk::Card);
234 s.scrollBarForegroundColor = ink(uiThemeInk::Border);
235 s.mouseOverScrollBarForegroundColor = ink(uiThemeInk::TextDim);
236 s.scrollBarSize = 10;
237}
238
239
240// controls are "outlined": background of the container, thin gray border, accent border when focused
241void uiDarkTheme::setListBox(uiCustomListBox * listBox)
242{
243 RGB888 background = listBox->parentBackgroundColor();
244 setBorder(listBox, 1, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
245 setScrollBars(listBox);
246 auto & s = listBox->listBoxStyle();
247 s.backgroundColor = background;
248 s.focusedBackgroundColor = background;
249 s.selectedBackgroundColor = ink(uiThemeInk::Hover);
250 s.focusedSelectedBackgroundColor = ink(uiThemeInk::Accent);
251 s.itemHeight = 20;
252 s.textFont = normalFont();
253 s.textColor = ink(uiThemeInk::Text);
254 s.selectedTextColor = ink(uiThemeInk::White);
255}
256
257
258void uiDarkTheme::setEdit(uiTextEdit * edit)
259{
260 RGB888 background = edit->parentBackgroundColor();
261 setBorder(edit, 1, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
262 auto & s = edit->textEditStyle();
263 s.backgroundColor = background;
264 s.mouseOverBackgroundColor = background;
265 s.focusedBackgroundColor = background;
266 s.textColor = ink(uiThemeInk::Text);
267 s.textFont = normalFont();
268}
269
270
271void uiDarkTheme::setButton(uiButton * button, uint32_t styleClassID)
272{
273 auto & s = button->buttonStyle();
274 s.textFont = normalFont();
275 switch (styleClassID) {
277 setBorder(button, 1, ink(uiThemeInk::Accent), ink(uiThemeInk::White));
278 s.backgroundColor = ink(uiThemeInk::Accent);
279 s.mouseOverBackgroundColor = ink(uiThemeInk::AccentDark);
280 s.mouseDownBackgroundColor = ink(uiThemeInk::AccentDark);
281 s.downBackgroundColor = ink(uiThemeInk::AccentDark);
282 s.textColor = ink(uiThemeInk::White);
283 s.mouseOverTextColor = ink(uiThemeInk::White);
284 s.downTextColor = ink(uiThemeInk::White);
285 break;
287 {
288 RGB888 background = button->parentBackgroundColor();
289 setBorder(button, 1, background, ink(uiThemeInk::Accent));
290 s.backgroundColor = background;
291 s.mouseOverBackgroundColor = ink(uiThemeInk::Hover);
292 s.mouseDownBackgroundColor = ink(uiThemeInk::AccentDark);
293 s.downBackgroundColor = ink(uiThemeInk::AccentDark);
294 s.textColor = ink(uiThemeInk::Text);
295 s.mouseOverTextColor = ink(uiThemeInk::White);
296 s.downTextColor = ink(uiThemeInk::White);
297 break;
298 }
299 default:
300 // outlined. When down (switch buttons) it takes the accent color
301 setBorder(button, 1, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
302 s.backgroundColor = button->parentBackgroundColor();
303 s.mouseOverBackgroundColor = ink(uiThemeInk::Hover);
304 s.mouseDownBackgroundColor = ink(uiThemeInk::AccentDark);
305 s.downBackgroundColor = ink(uiThemeInk::Accent);
306 s.textColor = ink(uiThemeInk::Text);
307 s.mouseOverTextColor = ink(uiThemeInk::White);
308 s.downTextColor = ink(uiThemeInk::White);
309 break;
310 }
311}
312
313
314// windows with title: 3 pixels border (accent when active, it is also the resize area), accent title bar with a line
315// below, size grip. Popups: 1 pixel border. keepBorderSize: frames created without style class keep their border
316void uiDarkTheme::setFrame(uiFrame * frame, uint32_t styleClassID, bool keepBorderSize)
317{
318 bool hasTitle = styleClassID == uiThemeStyle::Frame || styleClassID == uiThemeStyle::Dialog;
319 int bSize = keepBorderSize ? frame->windowStyle().borderSize : (hasTitle ? 3 : 1);
320 setBorder(frame, bSize, ink(uiThemeInk::Border), ink(uiThemeInk::Border));
321 if (hasTitle) {
324 }
325 frame->frameProps().hasSizeGrip = hasTitle;
326 auto & s = frame->frameStyle();
328 s.titleBackgroundColor = ink(uiThemeInk::Card);
329 s.activeTitleBackgroundColor = ink(uiThemeInk::AccentDark);
330 s.titleSeparatorSize = 1;
331 s.titleSeparatorColor = ink(uiThemeInk::Border);
332 s.activeTitleSeparatorColor = ink(uiThemeInk::Accent);
333 s.sizeGripColor = ink(uiThemeInk::TextDim);
334 s.titleColor = ink(uiThemeInk::TextDim);
335 s.activeTitleColor = ink(uiThemeInk::White);
336 s.titleFont = normalFont();
337 s.buttonColor = ink(uiThemeInk::TextDim);
338 s.activeButtonColor = ink(uiThemeInk::White);
339 s.mouseOverBackgroundButtonColor = ink(uiThemeInk::Accent);
340 s.mouseOverButtonColor = ink(uiThemeInk::White);
341}
342
343
344void uiDarkTheme::setLabel(uiObject * object, uint32_t styleClassID)
345{
346 FontInfo const * font = styleClassID == uiThemeStyle::LabelDim ? smallFont() :
347 styleClassID == uiThemeStyle::LabelTitle ? titleFont() :
348 styleClassID == uiThemeStyle::LabelBig ? bigFont() : normalFont();
349 bool accented = styleClassID == uiThemeStyle::LabelValue || styleClassID == uiThemeStyle::LabelTitle || styleClassID == uiThemeStyle::LabelBig;
350 RGB888 color = styleClassID == uiThemeStyle::LabelDim ? ink(uiThemeInk::TextDim) :
351 styleClassID == uiThemeStyle::LabelDesktop ? ink(uiThemeInk::White) :
352 accented ? ink(uiThemeInk::Accent) : ink(uiThemeInk::Text);
353 RGB888 background = styleClassID == uiThemeStyle::LabelDesktop ? ink(uiThemeInk::Desktop) : ((uiWindow *) object)->parentBackgroundColor();
354 if (object->objectType().uiStaticLabel) {
355 auto & s = ((uiStaticLabel *) object)->labelStyle();
356 s.textFont = font;
357 s.textColor = color;
358 s.backgroundColor = background;
359 } else if (object->objectType().uiLabel) {
360 auto & s = ((uiLabel *) object)->labelStyle();
361 s.textFont = font;
362 s.textColor = color;
363 s.backgroundColor = background;
364 s.textAlign = styleClassID == uiThemeStyle::LabelValue ? uiHAlign::Right : uiHAlign::Left;
365 }
366}
367
368
369void uiDarkTheme::setComboBox(uiCustomComboBox * comboBox)
370{
371 auto & s = comboBox->comboBoxStyle();
372 s.buttonBackgroundColor = comboBox->parentBackgroundColor();
373 s.buttonColor = ink(uiThemeInk::TextDim);
374 auto listBox = comboBox->listBoxControl();
375 setListBox(listBox);
376 // the drop down list is over other windows: raised surface
379 auto edit = comboBox->editControl();
380 if (edit->objectType().uiTextEdit)
381 setEdit((uiTextEdit *) edit);
382 else if (edit->objectType().uiButton)
383 setButton((uiButton *) edit, uiThemeStyle::Button);
384 setBorder(comboBox, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Border));
385}
386
387
388void uiDarkTheme::setStyle(uiObject * object, uint32_t styleClassID)
389{
390 bool byType = styleClassID == 0;
391 if (byType)
392 styleClassID = defaultStyleClass(object);
393
394 auto const & type = object->objectType();
395
396 switch (styleClassID) {
397
401 if (type.uiFrame)
402 setFrame((uiFrame *) object, styleClassID, byType);
403 break;
404
406 if (type.uiFrame) {
407 auto frame = (uiFrame *) object;
408 setFrame(frame, uiThemeStyle::Popup, false);
410 frame->windowStyle().borderSize = 0;
411 frame->frameProps().moveable = false;
412 frame->frameProps().resizeable = false;
413 }
414 break;
415
418 if (type.uiPanel) {
419 auto panel = (uiPanel *) object;
420 setBorder(panel, 1, ink(uiThemeInk::Border), ink(uiThemeInk::Border));
421 panel->panelStyle().backgroundColor = styleClassID == uiThemeStyle::Card ? ink(uiThemeInk::Card) : ink(uiThemeInk::Window);
422 }
423 break;
424
431 setLabel(object, styleClassID);
432 break;
433
437 if (type.uiButton)
438 setButton((uiButton *) object, styleClassID);
439 break;
440
442 if (type.uiTextEdit)
443 setEdit((uiTextEdit *) object);
444 break;
445
447 if (type.uiCustomListBox)
448 setListBox((uiCustomListBox *) object);
449 break;
450
453 // the last constructor (uiComboBox, uiSplitButton...) has created the edit control and the list
454 if (type.uiComboBox || type.uiSplitButton || type.uiColorComboBox)
455 setComboBox((uiCustomComboBox *) object);
456 break;
457
459 if (type.uiCheckBox) {
460 // outlined box with an accent mark, round radio buttons (corner radius = half size) with an accent dot
461 auto checkBox = (uiCheckBox *) object;
462 bool radio = checkBox->kind() == uiCheckBoxKind::RadioButton;
463 int size = imin(checkBox->size().width, checkBox->size().height);
464 RGB888 background = checkBox->parentBackgroundColor();
465 setBorder(checkBox, 1, ink(uiThemeInk::TextDim), ink(uiThemeInk::Accent), radio ? size / 2 : 0);
466 auto & s = checkBox->checkBoxStyle();
467 s.boldMark = true;
468 s.backgroundColor = background;
469 s.checkedBackgroundColor = background;
470 s.mouseOverBackgroundColor = ink(uiThemeInk::Hover);
471 s.foregroundColor = ink(uiThemeInk::Accent);
472 s.mouseOverForegroundColor = ink(uiThemeInk::Accent);
473 }
474 break;
475
477 if (type.uiSlider) {
478 auto slider = (uiSlider *) object;
479 setBorder(slider, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
480 slider->windowStyle().focusedBorderSize = 1;
481 auto & s = slider->sliderStyle();
482 s.backgroundColor = slider->parentBackgroundColor();
483 s.slideColor = ink(uiThemeInk::Border);
484 s.rangeColor = ink(uiThemeInk::Accent);
485 s.gripColor = ink(uiThemeInk::TextDim);
486 s.mouseOverGripColor = ink(uiThemeInk::Text);
487 s.ticksColor = ink(uiThemeInk::Border);
488 }
489 break;
490
492 if (type.uiProgressBar) {
493 auto bar = (uiProgressBar *) object;
494 setBorder(bar, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Border));
495 auto & s = bar->progressBarStyle();
496 s.backgroundColor = ink(uiThemeInk::Border);
497 s.foregroundColor = ink(uiThemeInk::Accent);
498 s.textFont = smallFont();
499 s.textColor = ink(uiThemeInk::White);
500 }
501 break;
502
504 if (type.uiPaintBox) {
505 auto paintBox = (uiPaintBox *) object;
506 setBorder(paintBox, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Border));
507 setScrollBars(paintBox);
508 paintBox->paintBoxStyle().backgroundColor = ink(uiThemeInk::Black);
509 }
510 break;
511
513 if (type.uiKnob) {
514 auto knob = (uiKnob *) object;
515 setBorder(knob, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
516 knob->windowStyle().focusedBorderSize = 1;
517 auto & s = knob->knobStyle();
518 s.backgroundColor = knob->parentBackgroundColor();
519 s.labelFont = smallFont();
520 s.labelColor = ink(uiThemeInk::TextDim);
521 s.valueFont = smallFont();
522 s.valueColor = ink(uiThemeInk::Text);
523 s.activeValueColor = ink(uiThemeInk::Accent);
524 s.ringColor = ink(uiThemeInk::Accent);
525 s.ringBackgroundColor = ink(uiThemeInk::Hover);
526 s.bodyColor = ink(uiThemeInk::Border);
527 s.capColor = ink(uiThemeInk::Window);
528 s.pointerColor = ink(uiThemeInk::Accent);
529 }
530 break;
531
533 if (type.uiToggleSwitch) {
534 auto sw = (uiToggleSwitch *) object;
535 setBorder(sw, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
536 sw->windowStyle().focusedBorderSize = 1;
537 auto & s = sw->toggleSwitchStyle();
538 s.backgroundColor = sw->parentBackgroundColor();
539 s.onColor = ink(uiThemeInk::Accent);
540 s.offColor = ink(uiThemeInk::Border);
541 s.thumbColor = ink(uiThemeInk::Text);
542 s.textFont = normalFont();
543 s.onTextColor = ink(uiThemeInk::Text);
544 s.offTextColor = ink(uiThemeInk::TextDim);
545 }
546 break;
547
549 if (type.uiLevelBar) {
550 auto bar = (uiLevelBar *) object;
551 setBorder(bar, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
552 bar->windowStyle().focusedBorderSize = 1;
553 bar->levelBarProps().segmentGap = 1;
554 auto & s = bar->levelBarStyle();
555 s.backgroundColor = bar->parentBackgroundColor();
556 s.lowColor = ink(uiThemeInk::Accent);
557 s.lowOffColor = ink(uiThemeInk::Hover);
558 s.highColor = ink(uiThemeInk::Red);
559 s.highOffColor = ink(uiThemeInk::Hover);
560 s.textFont = normalFont();
561 s.textColor = ink(uiThemeInk::Text);
562 }
563 break;
564
566 if (type.uiLedBar) {
567 auto & s = ((uiLedBar *) object)->ledBarStyle();
568 s.backgroundColor = ((uiWindow *) object)->parentBackgroundColor();
569 s.ledColors[0] = ink(uiThemeInk::Hover);
570 s.ledColors[1] = ink(uiThemeInk::Green);
571 s.ledColors[2] = ink(uiThemeInk::Amber);
572 s.ledColors[3] = ink(uiThemeInk::Red);
573 }
574 break;
575
577 if (type.uiStepper) {
578 auto stepper = (uiStepper *) object;
579 RGB888 background = stepper->parentBackgroundColor();
580 setBorder(stepper, 1, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
581 auto & s = stepper->stepperStyle();
582 s.backgroundColor = background;
583 s.buttonBackgroundColor = background;
584 s.mouseDownButtonBackgroundColor = ink(uiThemeInk::Accent);
585 s.buttonBorderColor = ink(uiThemeInk::Border);
586 s.arrowColor = ink(uiThemeInk::TextDim);
587 s.mouseDownArrowColor = ink(uiThemeInk::White);
588 s.textFont = normalFont();
589 s.textColor = ink(uiThemeInk::Text);
590 }
591 break;
592
594 if (type.uiTileSelector) {
595 auto tiles = (uiTileSelector *) object;
596 setBorder(tiles, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
597 tiles->windowStyle().focusedBorderSize = 1;
598 auto & s = tiles->tileSelectorStyle();
599 s.backgroundColor = tiles->parentBackgroundColor();
600 s.tileBackgroundColor = ink(uiThemeInk::Window);
601 s.tileBorderColor = ink(uiThemeInk::Border);
602 s.selectedTileBorderColor = ink(uiThemeInk::Accent);
603 s.textFont = smallFont();
604 s.textColor = ink(uiThemeInk::TextDim);
605 s.selectedTextColor = ink(uiThemeInk::Accent);
606 }
607 break;
608
610 if (type.uiGraph) {
611 auto graph = (uiGraph *) object;
612 setBorder(graph, 1, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
613 auto & s = graph->graphStyle();
614 s.backgroundColor = ink(uiThemeInk::Black);
615 s.gridColor = ink(uiThemeInk::Hover);
616 s.lineColor = ink(uiThemeInk::Accent);
617 s.fillColor = ink(uiThemeInk::Bloom2);
618 }
619 break;
620
622 if (type.uiPianoKeyboard) {
623 auto piano = (uiPianoKeyboard *) object;
624 setBorder(piano, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
625 piano->windowStyle().focusedBorderSize = 1;
626 auto & s = piano->pianoKeyboardStyle();
627 s.backgroundColor = ink(uiThemeInk::Black);
628 s.topLineColor = ink(uiThemeInk::Accent);
629 s.whiteKeyColor = ink(uiThemeInk::Text);
630 s.whiteKeyFrontColor = ink(uiThemeInk::TextDim);
631 s.blackKeyColor = ink(uiThemeInk::Black);
632 s.blackKeyBevelColor = ink(uiThemeInk::Hover);
633 s.pressedKeyColor = ink(uiThemeInk::Accent);
634 s.pressedKeyFrontColor = ink(uiThemeInk::AccentDark);
635 s.textFont = smallFont();
636 s.labelColor = ink(uiThemeInk::TextDim);
637 s.blackLabelColor = ink(uiThemeInk::TextDim);
638 s.noteNameColor = ink(uiThemeInk::TextDim);
639 s.cNoteNameColor = ink(uiThemeInk::AccentDark);
640 s.pressedTextColor = ink(uiThemeInk::White);
641 }
642 break;
643
645 if (type.uiFader) {
646 auto fader = (uiFader *) object;
647 setBorder(fader, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
648 auto & s = fader->faderStyle();
649 s.backgroundColor = fader->parentBackgroundColor();
650 s.slotColor = ink(uiThemeInk::Black);
651 s.levelColor = ink(uiThemeInk::Accent);
652 s.tickColor = ink(uiThemeInk::Border);
653 s.capColor = ink(uiThemeInk::Hover);
654 s.capEdgeColor = ink(uiThemeInk::TextDim);
655 s.capLineColor = ink(uiThemeInk::Text);
656 s.activeCapLineColor = ink(uiThemeInk::Accent);
657 }
658 break;
659
661 if (type.uiPad) {
662 auto pad = (uiPad *) object;
663 setBorder(pad, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
664 auto & s = pad->padStyle();
665 s.backgroundColor = pad->parentBackgroundColor();
666 s.padColor = ink(uiThemeInk::Card);
667 s.padBevelColor = ink(uiThemeInk::Border);
668 s.padShadowColor = ink(uiThemeInk::Border);
669 s.mouseOverPadColor = ink(uiThemeInk::Hover);
670 s.pressedPadColor = ink(uiThemeInk::Accent);
671 s.litPadColor = ink(uiThemeInk::AccentDark);
672 s.textFont = smallFont();
673 s.textColor = ink(uiThemeInk::Text);
674 s.pressedTextColor = ink(uiThemeInk::White);
675 s.ledOnColor = ink(uiThemeInk::Accent);
676 s.ledOffColor = ink(uiThemeInk::Hover);
677 s.keyLabelColor = ink(uiThemeInk::TextDim);
678 }
679 break;
680
682 if (type.uiSegmentDisplay) {
683 auto & s = ((uiSegmentDisplay *) object)->segmentDisplayStyle();
684 s.backgroundColor = ink(uiThemeInk::Black);
685 s.segmentColor = ink(uiThemeInk::Red);
686 s.offSegmentColor = ink(uiThemeInk::Hover);
687 ((uiSegmentDisplay *) object)->segmentDisplayProps().showOffSegments = false;
688 }
689 break;
690
692 if (type.uiStepGrid) {
693 auto grid = (uiStepGrid *) object;
694 setBorder(grid, 0, ink(uiThemeInk::Border), ink(uiThemeInk::Accent));
695 auto & s = grid->stepGridStyle();
696 s.backgroundColor = grid->parentBackgroundColor();
697 s.cellColors[0] = ink(uiThemeInk::Hover);
698 s.cellColors[1] = ink(uiThemeInk::AccentDark);
699 s.cellColors[2] = ink(uiThemeInk::Accent);
700 s.cellColors[3] = ink(uiThemeInk::White);
701 s.groupCellColor = ink(uiThemeInk::Border);
702 s.disabledCellColor = ink(uiThemeInk::Card);
703 s.playheadColor = ink(uiThemeInk::Text);
704 s.playheadCellColor = ink(uiThemeInk::TextDim);
705 s.labelFont = smallFont();
706 s.labelBackgroundColor = ink(uiThemeInk::Card);
707 s.labelColor = ink(uiThemeInk::Text);
708 s.mutedLabelColor = ink(uiThemeInk::TextDim);
709 s.mutedMarkColor = ink(uiThemeInk::Red);
710 s.selectedLabelBackgroundColor = ink(uiThemeInk::AccentDark);
711 s.selectedLabelColor = ink(uiThemeInk::White);
712 s.activeLabelColor = ink(uiThemeInk::Accent);
713 s.headerColor = ink(uiThemeInk::TextDim);
714 s.beatHeaderColor = ink(uiThemeInk::Text);
715 s.cursorColor = ink(uiThemeInk::Accent);
716 }
717 break;
718
719 default:
720 break;
721 }
722}
723
724
725
726} // end of namespace
uiAppProps & appProps()
Sets or gets application properties.
Definition fabui.h:5488
uiFrame * rootWindow()
Gets a pointer to the root window.
Definition fabui.h:5250
void setStyle(uiStyle *value)
Sets the style of the application controls.
Definition fabui.h:5568
Represents the whole application base class.
Definition fabui.h:5167
uiButtonStyle & buttonStyle()
Sets or gets button style.
Definition fabui.h:1376
Represents a button control. A button can have text and optionally a bitmap.
Definition fabui.h:1334
Represents a checkbox or a radiobutton.
Definition fabui.h:2784
This is a combination of a listbox and another component, base of all combobox components.
Definition fabui.h:2479
uiListBoxStyle & listBoxStyle()
Sets or gets listbox style.
Definition fabui.h:2132
Base class for list controls that display a list of selectable items.
Definition fabui.h:2108
uiDarkTheme(uiThemeAccent accent=uiThemeAccent::Orange)
Creates the theme.
Definition uitheme.cpp:73
RGB888 color(uiThemeInk value)
Gets the actual RGB value of a theme color.
Definition uitheme.cpp:131
static FontInfo const * normalFont()
Definition uitheme.h:241
static FontInfo const * bigFont()
Definition uitheme.h:243
uint32_t defaultStyleClass(uiObject *object)
Gets the style class used for an element created without style class.
Definition uitheme.cpp:161
void apply(uiApp *app)
Applies the theme to an application.
Definition uitheme.cpp:145
uiThemeAccent accent()
Determines the accent color.
Definition uitheme.h:174
static FontInfo const * smallFont()
Definition uitheme.h:240
void setStyle(uiObject *object, uint32_t styleClassID)
Configures a UI element (called by the library).
Definition uitheme.cpp:388
RGB888 ink(uiThemeInk value)
Gets the color to use with the Canvas and the styles to obtain a theme color.
Definition uitheme.h:195
static FontInfo const * titleFont()
Definition uitheme.h:242
A linear fader, like the level controls of a mixing console.
Definition fabui.h:4240
uiFrameProps & frameProps()
Sets or gets frame properties.
Definition fabui.h:946
uiFrameStyle & frameStyle()
Sets or gets frame style.
Definition fabui.h:939
A frame is a window with a title bar, maximize/minimize/close buttons and that is resizable or movabl...
Definition fabui.h:889
Plots a sequence of values as a curve (waveforms, envelopes, frequency responses.....
Definition fabui.h:3881
A rotary knob. The value changes dragging the mouse up and down, with the mouse wheel or with the key...
Definition fabui.h:3156
A row of leds. Each led has a state (0 = off, 1..3 = on with different colors).
Definition fabui.h:3528
A horizontal segmented bar, like a led level meter. It can show a level or let the user set it.
Definition fabui.h:3415
uiObjectType & objectType()
Determines the object type.
Definition fabui.h:328
Base class of all UI elements like windows and controls.
Definition fabui.h:315
A momentary button that reacts when pressed, like the pads and the buttons of the drum machines.
Definition fabui.h:4417
A paintbox control allows applications to perform custom drawings providing uiPaintBox....
Definition fabui.h:1963
A panel is used to contain and to group some controls.
Definition fabui.h:1906
An on-screen piano keyboard, played with the mouse (dragging slides between notes) or by the applicat...
Definition fabui.h:4051
A progress bar shows a completion percentage using a colored bar.
Definition fabui.h:3047
A seven segment led display, like the ones of the vintage instruments.
Definition fabui.h:4570
A slider or track bar is a graphical control element with which a user may set a value by moving an i...
Definition fabui.h:2918
A grid of cells for step sequencers: one row for each instrument (or note), one column for each step.
Definition fabui.h:4739
A text between "previous" and "next" arrow buttons, to step through values (for example an octave).
Definition fabui.h:3633
uiTextEditStyle & textEditStyle()
Sets or gets text edit style.
Definition fabui.h:1520
Represents a text edit control.
Definition fabui.h:1495
A row of selectable tiles. The content of each tile is painted by the application (onPaintTile).
Definition fabui.h:3735
An on/off switch: a track with a sliding thumb, and an optional text on its left.
Definition fabui.h:3307
uiWindowStyle & windowStyle()
Sets or gets window style.
Definition fabui.h:597
RGB888 parentBackgroundColor()
Determines the background color behind this window.
Definition fabui.cpp:1804
Base class for all visible UI elements (Frames and Controls).
Definition fabui.h:452
uiThemeInk
Colors of uiDarkTheme. Each one is a slot of the 16 color palette (see uiDarkTheme::setupPalette()).
Definition uitheme.h:47
uiThemeAccent
Accent colors of uiDarkTheme.
Definition uitheme.h:70
Color
Named colors.
Represents a 24-bit RGB color.
Represents a 24-bit RGB color.
uiDialogStyleClasses dialogStyleClasses
Definition fabui.h:5112
FontInfo const * textFont
Definition fabui.h:1296
uint8_t moveable
Definition fabui.h:836
uint8_t resizeable
Definition fabui.h:835
uint8_t hasSizeGrip
Definition fabui.h:841
RGB888 backgroundColor
Definition fabui.h:796
RGB888 focusedBackgroundColor
Definition fabui.h:2070
bool applyToUnstyled
When true setStyle() is called also for the UI elements created without a style class (styleClassID =...
Definition fabui.h:5076
uint8_t borderSize
Definition fabui.h:415
RGB888 activeBorderColor
Definition fabui.h:413
This file contains uiDarkTheme, a ready to use dark theme for the GUI (fabui.h).