FabGL2 2.0.0
Graphics, audio, GUI and retro-computing library for the ESP32 (ESP-IDF)
Loading...
Searching...
No Matches
uitheme.h
Go to the documentation of this file.
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#pragma once
28
29
35
36
37#include "fabui.h"
38
39
40namespace fabgl {
41
42
43
65
66
70enum class uiThemeAccent : uint8_t {
75};
76
77
125
126
158class uiDarkTheme : public uiStyle {
159
160public:
161
168
174 uiThemeAccent accent() { return m_accent; }
175
183 RGB888 color(uiThemeInk value);
184
195 RGB888 ink(uiThemeInk value) { return m_paletted ? m_ink[(int) value] : color(value); }
196
206 template <typename DisplayController>
207 void setupPalette(DisplayController * displayController) {
208 int colors = preparePalette(displayController->colorsCount());
209 for (int i = 0; i < colors; ++i)
210 displayController->setPaletteItem(i, paletteColor(i));
211 }
212
221 void apply(uiApp * app);
222
229 void setStyle(uiObject * object, uint32_t styleClassID);
230
238 uint32_t defaultStyleClass(uiObject * object);
239
240 static FontInfo const * smallFont() { return &FONT_std_12; }
241 static FontInfo const * normalFont() { return &FONT_std_14; }
242 static FontInfo const * titleFont() { return &FONT_std_17; }
243 static FontInfo const * bigFont() { return &FONT_std_24; }
244
245
246protected:
247
248 void setBorder(uiWindow * window, int size, RGB888 color, RGB888 focusedColor, int cornerRadius = 0);
249 void setScrollBars(uiScrollableControl * control);
250 void setListBox(uiCustomListBox * listBox);
251 void setEdit(uiTextEdit * edit);
252 void setButton(uiButton * button, uint32_t styleClassID);
253 void setFrame(uiFrame * frame, uint32_t styleClassID, bool keepBorderSize);
254 void setLabel(uiObject * object, uint32_t styleClassID);
255 void setComboBox(uiCustomComboBox * comboBox);
256
257 int preparePalette(int colors);
258 RGB888 paletteColor(int slot);
259
260
261private:
262
263 uiThemeAccent m_accent;
264 bool m_paletted;
265 int m_paletteSize;
266 RGB888 m_ink[16]; // color to use for each uiThemeInk with the reprogrammed palette
267
268};
269
270
271
272} // end of namespace
Represents the whole application base class.
Definition fabui.h:5167
Represents a button control. A button can have text and optionally a bitmap.
Definition fabui.h:1334
This is a combination of a listbox and another component, base of all combobox components.
Definition fabui.h:2479
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
void setupPalette(DisplayController *displayController)
Reprograms the palette of the display with the theme colors.
Definition uitheme.h:207
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 frame is a window with a title bar, maximize/minimize/close buttons and that is resizable or movabl...
Definition fabui.h:889
Base class of all UI elements like windows and controls.
Definition fabui.h:315
A scrollable control is a control with optionally vertical and/or horizontal scrollbars.
Definition fabui.h:1130
Represents a text edit control.
Definition fabui.h:1495
Base class for all visible UI elements (Frames and Controls).
Definition fabui.h:452
This file contains all classes related to FabGL Graphical User Interface.
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
Describes a bitmapped font.
Definition fabutils.h:363
Represents a 24-bit RGB color.
Base class for application styles.
Definition fabui.h:5060
Style classes of uiDarkTheme.
Definition uitheme.h:84