|
psychic-ui 0.0.0
|
#include <Style.hpp>
Public Types | |
| using | ChangedCallback = void (*)(void *owner) |
Public Member Functions | |
| Style (ChangedCallback onChanged, void *owner) | |
| Style (const Style &other) | |
| Style & | operator= (const Style &other) |
| Style (Style &&other) noexcept | |
| Style & | operator= (Style &&other) noexcept |
| Style & | transition (Property property, const Timing &timing) |
| Style & | transition (std::initializer_list< Property > properties, const Timing &timing) |
| bool | has (Property property) const |
| const PropertyMask & | properties () const |
| Style & | unset (Property property) |
| Style & | clear () |
| Style & | overlay (const Style &style, const PropertyMask &only=PropertyMask{}.set()) |
| Style & | defaults (const Style &style) |
| PropertyMask | diff (const Style &other) const |
| bool | operator== (const Style &other) const |
| void | trace (std::ostream &os) const |
| void | trace () const |
A set of style values: a stylesheet rule, a Div's inline or default style, or a computed style.
Each property has a typed getter and a chainable setter, generated from PSYCHIC_UI_STYLE_PROPERTIES:
manager->style("Button").padding(12).color(rgb(0x9DA5B5)).cursor(Cursor::Hand);
float size = div->computedStyle().fontSize();
A property is either set or not; the getter returns the default (see the table) when it isn't. Storage is flat (one field per property plus a bit mask), so copying, overlaying and comparing styles never allocate.
|
inline |
A style that notifies its owner when a setter changes it
|
inline |
Copies the values, not the owner
|
inlinenoexcept |
Moving is copying: the values are plain data, and the owner stays where it is
| Style & psychic_ui::Style::clear | ( | ) |
Unset every property
| Style & psychic_ui::Style::defaults | ( | const Style & | style | ) |
Set the properties style sets and this one doesn't
|
nodiscard |
The properties whose value differs, or that are set in only one of the two styles
|
inlinenodiscard |
Whether the property is set
| Style & psychic_ui::Style::operator= | ( | const Style & | other | ) |
Copies the values, keeps the owner (notified if anything changed)
| Style & psychic_ui::Style::overlay | ( | const Style & | style, |
| const PropertyMask & | only = PropertyMask{}.set() ) |
Set every property style sets, or only those in only
|
inlinenodiscard |
The set properties
| void psychic_ui::Style::trace | ( | std::ostream & | os | ) | const |
Print the set properties
Add to the transition: these properties blend to their new values with this timing (see Transition). In a rule, the transition only applies when that rule's transition wins the cascade.
| Style & psychic_ui::Style::unset | ( | Property | property | ) |
Unset a property, its getter returns the default again