psychic-ui 0.0.0
Loading...
Searching...
No Matches
psychic_ui::Style Class Reference

#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

Detailed Description

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.

Constructor & Destructor Documentation

◆ Style() [1/3]

psychic_ui::Style::Style ( ChangedCallback onChanged,
void * owner )
inline

A style that notifies its owner when a setter changes it

◆ Style() [2/3]

psychic_ui::Style::Style ( const Style & other)
inline

Copies the values, not the owner

◆ Style() [3/3]

psychic_ui::Style::Style ( Style && other)
inlinenoexcept

Moving is copying: the values are plain data, and the owner stays where it is

Member Function Documentation

◆ clear()

Style & psychic_ui::Style::clear ( )

Unset every property

◆ defaults()

Style & psychic_ui::Style::defaults ( const Style & style)

Set the properties style sets and this one doesn't

◆ diff()

PropertyMask psychic_ui::Style::diff ( const Style & other) const
nodiscard

The properties whose value differs, or that are set in only one of the two styles

◆ has()

bool psychic_ui::Style::has ( Property property) const
inlinenodiscard

Whether the property is set

◆ operator=()

Style & psychic_ui::Style::operator= ( const Style & other)

Copies the values, keeps the owner (notified if anything changed)

◆ overlay()

Style & psychic_ui::Style::overlay ( const Style & style,
const PropertyMask & only = PropertyMask{}.set() )

Set every property style sets, or only those in only

◆ properties()

const PropertyMask & psychic_ui::Style::properties ( ) const
inlinenodiscard

The set properties

◆ trace()

void psychic_ui::Style::trace ( std::ostream & os) const

Print the set properties

◆ transition()

Style & psychic_ui::Style::transition ( Property property,
const Timing & timing )

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.

◆ unset()

Style & psychic_ui::Style::unset ( Property property)

Unset a property, its getter returns the default again


The documentation for this class was generated from the following files: