Loading...
Searching...
No Matches
ControlTheme.h
Go to the documentation of this file.
1//
2// ControlTheme.h
3//
4
5#ifndef MALENA_CONTROLTHEME_H
6#define MALENA_CONTROLTHEME_H
7
8#pragma once
9
13
14namespace ml
15{
16 // ── ControlTheme ──────────────────────────────────────────────────────────
17
29 {
36 sf::Color mutedColor = sf::Color(120, 120, 120);
37 float padding = 8.f;
38
40 unsigned int fontSize = 14;
41 unsigned int fontSizeSmall = 11;
42
43 // ── applyFrom ─────────────────────────────────────────────────────────
44
45 ControlTheme& applyFrom(const Theme& t) override
46 {
50 errorColor = t.error;
54 mutedColor = t.muted;
55 padding = t.spacing;
56 // Only adopt the theme's font when it actually specifies one. Built-in
57 // themes leave font == nullptr ("no opinion"); overriding to the default
58 // font there would silently clobber a component's explicitly-set font
59 // (e.g. a Toolbar handed the icon font) → its glyphs render as "notdef"
60 // boxes once a theme is applied. Keep whatever the component already has.
61 if (t.font) font = t.font;
64 return *this;
65 }
66
67 // ── Assignment from parent ────────────────────────────────────────────
68
70 {
71 static_cast<GraphicTheme&>(*this) = g;
72 return *this;
73 }
74
75 // ── Getters / setters ─────────────────────────────────────────────────
76
77 [[nodiscard]] sf::Color getHoverColor() const { return hoverColor; }
78 [[nodiscard]] sf::Color getFocusColor() const { return focusColor; }
79 [[nodiscard]] sf::Color getErrorColor() const { return errorColor; }
80 [[nodiscard]] sf::Color getDisabledColor() const { return disabledColor; }
81 [[nodiscard]] sf::Color getDisabledTextColor() const { return disabledTextColor; }
82 [[nodiscard]] sf::Color getTextColor() const { return textColor; }
83 [[nodiscard]] sf::Color getMutedColor() const { return mutedColor; }
84 [[nodiscard]] float getPadding() const { return padding; }
85 [[nodiscard]] const sf::Font* getFont() const { return font; }
86 [[nodiscard]] unsigned int getFontSize() const { return fontSize; }
87 [[nodiscard]] unsigned int getFontSizeSmall() const { return fontSizeSmall; }
88
89 void setHoverColor(const sf::Color& c) { hoverColor = c; }
90 void setFocusColor(const sf::Color& c) { focusColor = c; }
91 void setErrorColor(const sf::Color& c) { errorColor = c; }
94 void setTextColor(const sf::Color& c) { textColor = c; }
95 void setMutedColor(const sf::Color& c) { mutedColor = c; }
96 void setPadding(float p) { padding = p; }
97 void setFont(const sf::Font& f) { font = &f; }
98 void setFont(const sf::Font&&) = delete;
99 void setFontSize(unsigned int s) { fontSize = s; }
100 void setFontSizeSmall(unsigned int s) { fontSizeSmall = s; }
101 };
102
103} // namespace ml
104
105#endif // MALENA_CONTROLTHEME_H
static const sf::Font & getDefault()
Return the built-in Arial font.
static const Color White
Definition Animate.h:25
Theme tokens for interactive UI controls.
unsigned int getFontSizeSmall() const
ControlTheme & operator=(const GraphicTheme &g)
unsigned int fontSize
void setTextColor(const sf::Color &c)
void setHoverColor(const sf::Color &c)
void setFocusColor(const sf::Color &c)
sf::Color disabledColor
sf::Color getDisabledColor() const
sf::Color hoverColor
sf::Color focusColor
sf::Color getHoverColor() const
unsigned int fontSizeSmall
sf::Color getFocusColor() const
void setFont(const sf::Font &f)
sf::Color getErrorColor() const
sf::Color mutedColor
sf::Color getDisabledTextColor() const
sf::Color errorColor
void setFontSize(unsigned int s)
sf::Color getMutedColor() const
const sf::Font * getFont() const
void setDisabledTextColor(const sf::Color &c)
void setFont(const sf::Font &&)=delete
void setPadding(float p)
float getPadding() const
void setDisabledColor(const sf::Color &c)
sf::Color getTextColor() const
ControlTheme & applyFrom(const Theme &t) override
Populate all fields from the global Theme token set.
void setMutedColor(const sf::Color &c)
const sf::Font * font
void setFontSizeSmall(unsigned int s)
sf::Color textColor
unsigned int getFontSize() const
sf::Color disabledTextColor
void setErrorColor(const sf::Color &c)
Theme tokens for all visual components.
virtual GraphicTheme & applyFrom(const Theme &t)
Populate all fields from the global Theme token set.
Universal design token set applied across all Themeable components.
Definition Theme.h:70
float spacing
Definition Theme.h:135
unsigned int fontSize
Definition Theme.h:121
sf::Color error
Definition Theme.h:104
const sf::Font * font
Definition Theme.h:118
unsigned int fontSizeSmall
Definition Theme.h:124
sf::Color onSurface
Definition Theme.h:86
sf::Color disabled
Definition Theme.h:110
sf::Color muted
Definition Theme.h:95
sf::Color onDisabled
Definition Theme.h:113
sf::Color borderFocus
Definition Theme.h:101
sf::Color secondary
Definition Theme.h:77