Loading...
Searching...
No Matches
ml::Theme Struct Reference

Universal design token set applied across all Themeable components. More...

#include <Malena/Manifests/Theme.h>

Inheritance diagram for ml::Theme:
[legend]

Public Member Functions

virtual ~Theme ()=default

Public Attributes

sf::Color background = sf::Color(20, 20, 20)
sf::Color border = sf::Color(100, 100, 100)
sf::Color borderFocus = sf::Color(100, 60, 200)
float borderThickness = 1.5f
sf::Color disabled = sf::Color(60, 60, 60)
sf::Color error = sf::Color(220, 70, 70)
const sf::Fontfont = nullptr
unsigned int fontSize = 14
unsigned int fontSizeLarge = 18
unsigned int fontSizeSmall = 11
sf::Color muted = sf::Color(120, 120, 120)
sf::Color onBackground = sf::Color(220, 220, 220)
sf::Color onDisabled = sf::Color(120, 120, 120)
sf::Color onPrimary = sf::Color::White
sf::Color onSurface = sf::Color::White
sf::Color primary = sf::Color(100, 60, 200)
float radius = 8.f
sf::Color secondary = sf::Color(70, 130, 230)
float spacing = 8.f
sf::Color success = sf::Color(70, 200, 100)
sf::Color surface = sf::Color(40, 40, 40)

Detailed Description

Universal design token set applied across all Themeable components.

A Theme is a plain struct of visual tokens — colors, typography, and spacing — that form the visual identity of a UI. Components that inherit Themeable automatically re-style themselves when the active theme changes via ThemeManager::apply().

Malena ships two built-in themes (DarkTheme and LightTheme). Custom themes are created by inheriting Theme and overriding tokens:

struct NeonTheme : ml::Theme
{
NeonTheme()
{
primary = sf::Color(0, 255, 180);
surface = sf::Color(10, 10, 20);
background = sf::Color(5, 5, 15);
onSurface = sf::Color(220, 255, 245);
border = sf::Color(0, 180, 130);
radius = 4.f;
}
};
Universal design token set applied across all Themeable components.
Definition Theme.h:70
sf::Color border
Definition Theme.h:98
sf::Color primary
Definition Theme.h:74
sf::Color onSurface
Definition Theme.h:86
float radius
Definition Theme.h:132
sf::Color background
Definition Theme.h:83
sf::Color surface
Definition Theme.h:80

Registering in a Manifest

class GameManifest : public ml::Manifest
{
public:
enum class Themes { Home, GameOver, Menu };
inline static const auto _ = [](){
set(Themes::Home, ml::DarkTheme());
set(Themes::GameOver, NeonTheme());
set(Themes::Menu, ml::LightTheme());
return 0;
}();
};
Base class for all Malena manifests.
Definition Manifest.h:51
static void set(EnumType key, const char *filepath)
Register an asset file path.
Malena default dark theme.
Definition Theme.h:155
Light theme with clean white surfaces and purple accents.
Definition Theme.h:184

Applying at runtime

ml::ThemeManager::apply<GameManifest>(GameManifest::Themes::Home);
static void apply(typename MANIFEST::Themes themeKey)
Apply a theme stored in a Manifest enum.
See also
ThemeManager, Themeable, DarkTheme, LightTheme

Definition at line 69 of file Theme.h.

Constructor & Destructor Documentation

◆ ~Theme()

virtual ml::Theme::~Theme ( )
virtualdefault

Member Data Documentation

◆ background

sf::Color ml::Theme::background = sf::Color(20, 20, 20)

Page/scene background color.

Definition at line 83 of file Theme.h.

◆ border

sf::Color ml::Theme::border = sf::Color(100, 100, 100)

Border/outline color for inactive components.

Definition at line 98 of file Theme.h.

◆ borderFocus

sf::Color ml::Theme::borderFocus = sf::Color(100, 60, 200)

Border/outline color for focused components.

Definition at line 101 of file Theme.h.

◆ borderThickness

float ml::Theme::borderThickness = 1.5f

Default border/outline thickness.

Definition at line 138 of file Theme.h.

◆ disabled

sf::Color ml::Theme::disabled = sf::Color(60, 60, 60)

Disabled component color.

Definition at line 110 of file Theme.h.

◆ error

sf::Color ml::Theme::error = sf::Color(220, 70, 70)

Error/invalid state color.

Definition at line 104 of file Theme.h.

◆ font

const sf::Font* ml::Theme::font = nullptr

Default font used by all text-bearing components.

Definition at line 118 of file Theme.h.

◆ fontSize

unsigned int ml::Theme::fontSize = 14

Base font size in points.

Definition at line 121 of file Theme.h.

◆ fontSizeLarge

unsigned int ml::Theme::fontSizeLarge = 18

Large font size — headings, titles.

Definition at line 127 of file Theme.h.

◆ fontSizeSmall

unsigned int ml::Theme::fontSizeSmall = 11

Small font size — descriptions, captions.

Definition at line 124 of file Theme.h.

◆ muted

sf::Color ml::Theme::muted = sf::Color(120, 120, 120)

Muted text — placeholders, disabled labels, descriptions.

Definition at line 95 of file Theme.h.

◆ onBackground

sf::Color ml::Theme::onBackground = sf::Color(220, 220, 220)

Text/icon color on top of background.

Definition at line 92 of file Theme.h.

◆ onDisabled

sf::Color ml::Theme::onDisabled = sf::Color(120, 120, 120)

Disabled text/icon color.

Definition at line 113 of file Theme.h.

◆ onPrimary

sf::Color ml::Theme::onPrimary = sf::Color::White

Text/icon color on top of primary.

Definition at line 89 of file Theme.h.

◆ onSurface

sf::Color ml::Theme::onSurface = sf::Color::White

Text/icon color on top of surface.

Definition at line 86 of file Theme.h.

◆ primary

sf::Color ml::Theme::primary = sf::Color(100, 60, 200)

Primary brand color — buttons, active states, highlights.

Definition at line 74 of file Theme.h.

◆ radius

float ml::Theme::radius = 8.f

Default corner radius for rounded rectangles and buttons.

Definition at line 132 of file Theme.h.

◆ secondary

sf::Color ml::Theme::secondary = sf::Color(70, 130, 230)

Secondary accent color — hover states, secondary actions.

Definition at line 77 of file Theme.h.

◆ spacing

float ml::Theme::spacing = 8.f

Base spacing unit — padding, gaps between elements.

Definition at line 135 of file Theme.h.

◆ success

sf::Color ml::Theme::success = sf::Color(70, 200, 100)

Success/confirm state color.

Definition at line 107 of file Theme.h.

◆ surface

sf::Color ml::Theme::surface = sf::Color(40, 40, 40)

Surface color — card backgrounds, input backgrounds.

Definition at line 80 of file Theme.h.


The documentation for this struct was generated from the following file: