|
Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
|
UI-owned style transaction coordinator; tree must outlive this nonmovable object. Bindings own metadata and only observe Node handles. Stale bindings are pruned on the next successful operation. Destruction leaves already computed widget values intact. One engine may own a widget's style at a time; overlapping engines are unsupported. No notifications, I/O, workers or hot reload. All mutations reject active frames and wrong-thread calls before work. More...
#include <style.hpp>
Public Member Functions | |
| StyleEngine (WidgetTree &tree, std::size_t maxBindings=4096, StyleRoleLimits roleLimits={}) | |
| StyleEngine (const StyleEngine &)=delete | |
| StyleEngine & | operator= (const StyleEngine &)=delete |
| std::expected< Invalidation, StyleError > | bind (Node< Widget > node, StyleTarget target) |
| Register/update metadata and atomically recompute every bound widget. | |
| std::expected< Invalidation, StyleError > | bindBatch (std::span< const StyleRegistration > registrations) |
| Update metadata in one transaction, then recompute every bound widget once. Duplicate input nodes return INVALID_ARGUMENT. Stale bindings are pruned before admission. Empty input performs the same refresh as refresh(). With index allocation available, identity lookup takes O((B + R) log(R + 2)) work and O(R) temporary space for B existing bindings and R input registrations. Metadata copies and style resolution are additional costs; existing callback order is preserved. If index allocation fails, an allocation-free O(R^2) validation preserves argument-error priority before returning NO_MEMORY for an otherwise valid batch. | |
| std::expected< StyleRoleRegistration, StyleError > | registerRoles (Node< Widget > node, std::span< const std::string_view > names) |
| Register an existing bound node for a bounded semantic projection. | |
| std::expected< StyleRoleRegistration, StyleError > | registerRoles (Node< Widget > node, std::initializer_list< std::string_view > names) |
| std::expected< StyleRoleRegistration, StyleError > | replaceRoles (const StyleRoleRegistration ®istration, std::span< const std::string_view > names) |
| Atomically replace the bounded names of a live semantic registration. | |
| std::expected< StyleRoleRegistration, StyleError > | replaceRoles (const StyleRoleRegistration ®istration, std::initializer_list< std::string_view > names) |
| std::expected< Invalidation, StyleError > | unregisterRoles (const StyleRoleRegistration ®istration) |
| std::expected< Invalidation, StyleError > | replace (StyleSheet sheet) |
| Install a complete typed stylesheet atomically between frames. | |
| std::expected< Invalidation, StyleError > | replacePss (std::string_view source) |
| Parse and install without ever exposing a partial stylesheet. | |
| std::expected< Invalidation, StyleError > | refresh () |
| Recompute against current manual widget options, between frames. | |
| std::uint64_t | revision () const noexcept |
| Inspect on UI; no allocation or tree access. | |
| std::expected< Invalidation, StyleError > | enableLayers (StyleLayerOptions options={}) |
| Enable owning tiers atomically; equal configuration is a no-op. | |
| std::expected< StyleLayerHandle, StyleError > | addLayer (StyleTier tier, std::string_view name, const StyleSheet &sheet) |
| Install an owning APPLICATION or USER layer with a unique tier name. | |
| std::expected< Invalidation, StyleError > | replaceLayer (StyleLayerHandle handle, const StyleSheet &sheet) |
| Replace a non-base layer while retaining its installation order. | |
| std::expected< Invalidation, StyleError > | removeLayer (StyleLayerHandle handle) |
| Remove declarations; base slots remain and revoke their owner. | |
| std::expected< Invalidation, StyleError > | updateLayers (std::span< const StyleLayerUpdate > updates) |
| Atomically update existing unique handles. Empty input is a no-op. | |
| std::expected< StyleLayerHandle, StyleError > | baseLayer (StyleTier tier) const |
| Observe one permanent base slot on its UI thread. | |
| std::expected< Invalidation, StyleError > | defaults (const StyleSheet &sheet) |
| Replace the DEFAULTS slot beneath all other layers. | |
| std::expected< Invalidation, StyleError > | theme (const StyleSheet &sheet) |
| Replace THEME and hand authority to the caller, including equal values. | |
Friends | |
| class | ManagedScene |
| struct | StyleLayerTestAccess |
UI-owned style transaction coordinator; tree must outlive this nonmovable object. Bindings own metadata and only observe Node handles. Stale bindings are pruned on the next successful operation. Destruction leaves already computed widget values intact. One engine may own a widget's style at a time; overlapping engines are unsupported. No notifications, I/O, workers or hot reload. All mutations reject active frames and wrong-thread calls before work.
|
explicit |
| tree | Borrowed UI owner, required to outlive the engine. |
| maxBindings | Positive registry budget; default matches the tree's default capacity. |
| roleLimits | Explicit opt-in counts; coherence is checked before role registration. |
| std::expected< StyleLayerHandle, StyleError > portals::StyleEngine::addLayer | ( | StyleTier | tier, |
| std::string_view | name, | ||
| const StyleSheet & | sheet ) |
Install an owning APPLICATION or USER layer with a unique tier name.
| tier | APPLICATION or USER priority. |
| name | Nonempty tier-unique name, normalized into ownership after budget admission. |
| sheet | Borrowed declarations, copied after admission; input remains caller-owned. |
| std::expected< StyleLayerHandle, StyleError > portals::StyleEngine::baseLayer | ( | StyleTier | tier | ) | const |
Observe one permanent base slot on its UI thread.
| tier | DEFAULTS or THEME priority. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::bind | ( | Node< Widget > | node, |
| StyleTarget | target ) |
Register/update metadata and atomically recompute every bound widget.
| node | Checked target; no ownership transfer. |
| target | Owned matching metadata, copied during staging. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::bindBatch | ( | std::span< const StyleRegistration > | registrations | ) |
Update metadata in one transaction, then recompute every bound widget once. Duplicate input nodes return INVALID_ARGUMENT. Stale bindings are pruned before admission. Empty input performs the same refresh as refresh(). With index allocation available, identity lookup takes O((B + R) log(R + 2)) work and O(R) temporary space for B existing bindings and R input registrations. Metadata copies and style resolution are additional costs; existing callback order is preserved. If index allocation fails, an allocation-free O(R^2) validation preserves argument-error priority before returning NO_MEMORY for an otherwise valid batch.
| registrations | Borrowed live targets and metadata, copied during staging. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::defaults | ( | const StyleSheet & | sheet | ) |
Replace the DEFAULTS slot beneath all other layers.
| sheet | Borrowed replacement declarations, copied only after budget admission. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::enableLayers | ( | StyleLayerOptions | options = {} | ) |
Enable owning tiers atomically; equal configuration is a no-op.
| options | Nonzero aggregate limits, including at least two layer slots. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::refresh | ( | ) |
Recompute against current manual widget options, between frames.
|
inline |
| node | Checked live binding. |
| names | Borrowed names copied during this call. |
| std::expected< StyleRoleRegistration, StyleError > portals::StyleEngine::registerRoles | ( | Node< Widget > | node, |
| std::span< const std::string_view > | names ) |
Register an existing bound node for a bounded semantic projection.
| node | Checked live binding. |
| names | Unique lower-kebab names copied before publication. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::removeLayer | ( | StyleLayerHandle | handle | ) |
Remove declarations; base slots remain and revoke their owner.
| handle | Live observer; removed non-base identities cannot be reused. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::replace | ( | StyleSheet | sheet | ) |
Install a complete typed stylesheet atomically between frames.
| sheet | Owned replacement rules; validation and staging precede commit. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::replaceLayer | ( | StyleLayerHandle | handle, |
| const StyleSheet & | sheet ) |
Replace a non-base layer while retaining its installation order.
| handle | Existing non-base observer, admitted on the engine UI thread. |
| sheet | Borrowed candidate; equal values allocate nothing and retain revision. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::replacePss | ( | std::string_view | source | ) |
Parse and install without ever exposing a partial stylesheet.
| source | Borrowed PSS; copied by parsing before the atomic commit. |
|
inline |
| registration | Live registration owned by this engine. |
| names | Borrowed names copied during this call. |
| std::expected< StyleRoleRegistration, StyleError > portals::StyleEngine::replaceRoles | ( | const StyleRoleRegistration & | registration, |
| std::span< const std::string_view > | names ) |
Atomically replace the bounded names of a live semantic registration.
| registration | Live registration owned by this engine; its participation must survive staging. |
| names | Unique nonempty lower-kebab names, copied before publication within the configured limits. |
|
noexcept |
Inspect on UI; no allocation or tree access.
| std::expected< Invalidation, StyleError > portals::StyleEngine::theme | ( | const StyleSheet & | sheet | ) |
Replace THEME and hand authority to the caller, including equal values.
| sheet | Borrowed replacement, installed as the whole sheet in legacy mode. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::unregisterRoles | ( | const StyleRoleRegistration & | registration | ) |
| registration | Live registration of this engine, retained by the caller. |
| std::expected< Invalidation, StyleError > portals::StyleEngine::updateLayers | ( | std::span< const StyleLayerUpdate > | updates | ) |
Atomically update existing unique handles. Empty input is a no-op.
| updates | Borrowed complete batch; duplicate handles and base replacements are rejected. |