|
psychic-ui 0.0.0
|
Public Member Functions | |
| StyleManager (const StyleManager &)=delete | |
| StyleManager & | operator= (const StyleManager &)=delete |
| StyleManager (StyleManager &&)=delete | |
| StyleManager & | operator= (StyleManager &&)=delete |
| void | reset () |
| template<typename T> | |
| void | loadStyleSheet (bool reset=false) |
| template<class S> | |
| StyleManager & | skinSet () |
| StyleManager & | skinSet (std::unique_ptr< SkinSet > skinSet, ColorScheme scheme=ColorScheme::Unknown) |
| StyleManager & | skinSet (std::unique_ptr< SkinSet > skinSet, Theme theme) |
| const SkinSet * | skinSet () const |
| template<class SkinT> | |
| std::shared_ptr< SkinT > | skin (std::string_view variant="") const |
| std::size_t | skinsGeneration () const |
| std::size_t | rulesGeneration () const |
| const Theme & | theme () const |
| StyleManager & | theme (const Theme &theme) |
| Density | density () const |
| bool | density (Density density) |
| const Sizes & | sizes () const |
| bool | valid () const |
| void | setValid () |
| void | invalidate () |
| StyleManager & | loadFont (const std::string &name, const std::string &path) |
| StyleManager & | resourceRoot (std::filesystem::path root) |
| const std::filesystem::path & | resourceRoot () const |
| sk_sp< SkTypeface > | font (const std::string &name) const |
| sk_sp< skia::textlayout::FontCollection > | fontCollection () |
| Style & | style (std::string selector) |
| Style | computeStyle (const Div *component) |
| std::vector< std::string > | matchedSelectors (const Div *component) |
Static Public Member Functions | |
| static std::shared_ptr< StyleManager > | getInstance () |
| static sk_sp< SkFontMgr > | fontManager () |
Protected Member Functions | |
| void | loadStyleSheet (std::type_index type, const std::function< std::unique_ptr< StyleSheet >()> &make) |
| void | clearRules () |
| void | reloadRules () |
| void | installSkinSet (std::unique_ptr< SkinSet > skinSet) |
| void | match (const Div *component) |
| void | matchCandidates (const std::vector< std::size_t > &candidates, const Div *component) |
| void | matchCandidates (const std::unordered_map< std::string, std::vector< std::size_t > > &index, const std::string &key, const Div *component) |
Protected Attributes | |
| std::unordered_map< std::string, std::unique_ptr< StyleDeclaration > > | _declarations {} |
| std::vector< StyleDeclaration * > | _rules {} |
| StyleDeclaration * | _universal {nullptr} |
| std::unordered_map< std::string, std::vector< std::size_t > > | _rulesById {} |
| std::unordered_map< std::string, std::vector< std::size_t > > | _rulesByClass {} |
| std::unordered_map< std::string, std::vector< std::size_t > > | _rulesByTag {} |
| std::vector< std::size_t > | _otherRules {} |
| std::vector< std::pair< int, std::size_t > > | _matches {} |
| std::filesystem::path | _resourceRoot {executableDirectory()} |
| std::unordered_map< std::string, sk_sp< SkTypeface > > | _fonts {} |
| sk_sp< skia::textlayout::FontCollection > | _fontCollection {nullptr} |
| std::vector< std::unique_ptr< SkinSet > > | _skinSets {} |
| SkinRegistry | _skins {} |
| std::size_t | _skinsGeneration {0} |
| std::size_t | _rulesGeneration {0} |
| bool | _valid {false} |
| Theme | _theme {themes::pivotalDark} |
| Density | _density {Density::Pointer} |
| std::vector< std::pair< std::type_index, std::unique_ptr< StyleSheet > > > | _styleSheets {} |
|
protected |
Drop every rule, keeping the fonts, the skins and the stylesheets
The style a Div gets, from (lowest priority first) the * rule, what it inherits from its parent's computed style, the rules matching it, its inline style, and its default style for what is still unset
|
inline |
The density the stylesheets size controls for: Pointer until a window goes to touch mode
| bool psychic_ui::StyleManager::density | ( | Density | density | ) |
| sk_sp< SkTypeface > psychic_ui::StyleManager::font | ( | const std::string & | name | ) | const |
The font loaded under that name, otherwise the system font of that family, otherwise the system default
| sk_sp< skia::textlayout::FontCollection > psychic_ui::StyleManager::fontCollection | ( | ) |
What text layout finds fonts in: the loaded fonts by name, then the system's fonts, which also fill in the characters a font lacks. Remade after a font is loaded.
|
static |
The platform's font manager (Fontconfig on Linux, CoreText on macOS), shared by every style manager: it loads font files and finds the system's fonts
|
static |
The style manager windows use unless given another one
|
protected |
Replace the skin set chain and the skins, bumping the generation; the rules are reloaded by the caller
|
inline |
Recompute every div's style on the next style pass, without touching the rules
| StyleManager & psychic_ui::StyleManager::loadFont | ( | const std::string & | name, |
| const std::string & | path ) |
Loads a font file under a name, which fontFamily styles use. A relative path is resolved against resourceRoot(), an absolute one is used as it is
|
inline |
Load a stylesheet: its rules apply after (and over, on equal weight) those loaded before it. The style manager keeps it, to load it again when the theme changes; loading a stylesheet type that is already loaded runs it again in its place.
|
protected |
Fill _matches with the rules matching a Div, in the order they apply
|
protected |
Add the candidates of one index bucket that match the Div to _matches
| std::vector< std::string > psychic_ui::StyleManager::matchedSelectors | ( | const Div * | component | ) |
The selectors of the rules matching a Div, in the order they apply. For debugging.
|
protected |
Clear the rules, then load the skin sets' rules and the stylesheets', in order
| void psychic_ui::StyleManager::reset | ( | ) |
| StyleManager & psychic_ui::StyleManager::resourceRoot | ( | std::filesystem::path | root | ) |
The directory relative resource paths (fonts) resolve against: the executable's directory by default, where psychic_ui_copy_resources copies res/. Set it before installing a skin set: a font is loaded once
|
inline |
Bumped every time every style is to be computed again: a rule set or changed, a stylesheet or a font loaded, the rules loaded again (a theme, a density or a skin set). Styles computed in such a pass change at once, without transitions: those follow a div's own state (classes, pseudo-classes, its inline style).
|
inline |
The theme's sizes for the current density
|
inline |
A new skin implementing SkinT from the skin set: the variant (from the set, else its fallback sets), else SkinT's default. nullptr only without a skin set, or when no set in the chain implements SkinT.
|
inline |
Use a skin set, with its default theme: its skins (and its fallback sets') replace the current set's, its rules load first, under the other stylesheets, and every component hatches a new skin on the next style pass. Loading a skin set with loadStyleSheet does the same.
|
inline |
The skin set in use, nullptr before one is set
| StyleManager & psychic_ui::StyleManager::skinSet | ( | std::unique_ptr< SkinSet > | skinSet, |
| Theme | theme ) |
Use a skin set with that theme rather than its own
|
inline |
Bumped every time the skin set changes: components hatch a new skin when it does
| Style & psychic_ui::StyleManager::style | ( | std::string | selector | ) |
Get the rule for a selector, declaring it if needed. Selectors are case insensitive. Rules apply like CSS: by specificity (weight), and on equal specificity the rule declared last wins.
manager->style("Button:hover").backgroundColor(rgb(0x3C414F));
| std::invalid_argument | when the selector can't be parsed |
|
inline |
The theme stylesheets read (manager->theme().palette.accent), Pivotal Dark until another is set
| StyleManager & psychic_ui::StyleManager::theme | ( | const Theme & | theme | ) |
Switch themes: the rules are cleared and the loaded stylesheets load again, in the same order, with the new values. Fonts and skins stay; the next style pass recomputes every div.
|
protected |
Every rule ever declared, by lowercase selector. Never shrinks, so that a Style & handed out stays valid.
|
protected |
Weight and index in _rules of the rules matching the Div being computed, kept to reuse its memory
|
protected |
The rules in effect, in declaration order: on equal weight, a later rule wins
|
protected |
The rules (indices in _rules) by what their rightmost part requires: an id, else its first class, else its tag. A Div only needs testing against the rules indexed under its id, classes and tags, plus those that require none of them (pseudo-classes only).
|
protected |
The skin set in use, last, after the sets it falls back on
|
protected |
The loaded stylesheets, in load order, with their type so that each type is loaded once
|
protected |
The * rule, if declared