Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
style.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4
5#include <portals/style_types.hpp>
6#include <portals/widget.hpp>
7
8#include <initializer_list>
9#include <memory>
10#include <span>
11#include <string>
12#include <string_view>
13#include <thread>
14#include <vector>
15
16namespace portals {
17struct PssDocument;
18
19namespace detail {
20struct StyleThemeReceiver;
21struct StyleRoleState;
22struct StyleRoleTestAccess;
23} // namespace detail
24
35
37inline constexpr std::size_t MAX_STYLE_BASE_TYPES = 32;
38
44 ~StyleTarget() = default;
45
46 std::string type{""};
47 std::string id{""};
48 std::vector<std::string> classes =
49 std::vector<std::string>(0);
50 bool control{false};
51 std::vector<std::string> baseTypes = std::vector<std::string>(
52 0);
53};
54
60
66 ~StyleSelector() = default;
67
68 std::string type{""};
69 std::string id{""};
70 std::vector<std::string> classes = std::vector<std::string>(0);
72 bool readOnly{false};
73
77 bool operator==(const StyleSelector &other) const = default;
78};
79
82 std::optional<RgbColor> foreground;
83 std::optional<RgbColor> background;
84 std::optional<bool> bold;
85 std::optional<bool> italic;
86 std::optional<bool> underline;
87
89 bool operator==(const StylePaintDeclarations &other) const = default;
90};
91
93inline constexpr std::size_t MAX_STYLE_ROLE_NAME_BYTES = 63;
95inline constexpr std::size_t MAX_STYLE_ROLE_PATCHES = 4096;
96
97namespace detail {
98constexpr bool validStyleRoleName(std::string_view name) noexcept {
99 if (name.empty() || name.size() > MAX_STYLE_ROLE_NAME_BYTES || name.front() < 'a' || name.front() > 'z' ||
100 name.back() == '-') {
101 return false;
102 }
103 for (const char value : name) {
104 if (!((value >= 'a' && value <= 'z') || (value >= '0' && value <= '9') || value == '-')) {
105 return false;
106 }
107 }
108 return true;
109}
110} // namespace detail
111
114 ~StyleRolePatch() = default;
115 std::string name{""};
117 bool operator==(const StyleRolePatch &) const = default;
118};
119
122 std::size_t maxRegistrations{256};
123 std::size_t maxRolesPerRegistration{32};
124 std::size_t maxTotalRoles{4096};
125};
126
129 ~StyleRoleValue() = default;
130 std::string name{""};
131 std::array<CellStyle, 6> states{};
132 bool operator==(const StyleRoleValue &) const = default;
133};
134
137 ~StyleRolePalette() = default;
138 std::vector<StyleRoleValue> values = std::vector<StyleRoleValue>(0);
142 std::optional<CellStyle> find(std::string_view name, StyleState state = StyleState::NORMAL) const noexcept;
143 bool operator==(const StyleRolePalette &) const = default;
144};
145
152public:
157 std::shared_ptr<const StyleRolePalette> snapshot() const noexcept;
159 std::uint64_t revision() const noexcept;
160
161private:
162 friend class StyleEngine;
163 friend struct detail::StyleRoleTestAccess;
164 std::shared_ptr<detail::StyleRoleState> state_;
165 std::shared_ptr<const void> participation_;
166};
167
203
205struct StyleRule {
209 ~StyleRule() = default;
210
214 std::shared_ptr<const detail::ScrollbarGlyphRefs> scrollbarGlyphs;
216 std::shared_ptr<const StyleSizing> sizing;
217 std::shared_ptr<const std::vector<StyleRolePatch>> roles;
218
222 bool operator==(const StyleRule &other) const {
223 return selector == other.selector && declarations == other.declarations &&
224 ((!scrollbarGlyphs && !other.scrollbarGlyphs) ||
225 (scrollbarGlyphs && other.scrollbarGlyphs &&
226 detail::equalScrollbarGlyphs(*scrollbarGlyphs, *other.scrollbarGlyphs))) &&
227 (sizing == other.sizing || (sizing && other.sizing && *sizing == *other.sizing)) &&
228 (roles == other.roles || (roles && other.roles && *roles == *other.roles));
229 }
230};
231
237 ~StyleSheet() = default;
238
239 std::vector<StyleRule> rules =
240 std::vector<StyleRule>(0);
241 std::optional<NodeId>
243
247 bool operator==(const StyleSheet &other) const = default;
248};
249
257
260 std::size_t maxLayers{16};
261 std::size_t maxRules{1024};
262 std::size_t maxDeclarations{6144};
263 std::size_t maxOwnedBytes{1024 * 1024};
264
268 bool operator==(const StyleLayerOptions &other) const = default;
269};
270
273public:
275 StyleLayerHandle() = default;
276
277private:
278 friend class StyleEngine;
279 std::weak_ptr<const void> lifetime_;
280 std::thread::id owner_;
281 std::uint64_t epoch_{};
282 std::uint64_t id_{};
283};
284
288 std::optional<StyleSheet> sheet;
289};
290
291namespace detail {
294 bool layered{};
295 std::uint64_t epoch{};
296 std::uint64_t id{};
297 std::uint64_t owner{};
298};
299} // namespace detail
300
302inline constexpr std::size_t MAX_STYLE_RULES = 1024;
304inline constexpr std::size_t MAX_PSS_BYTES = 1024 * 1024;
305
309 std::size_t line{1};
310 std::size_t column{1};
311 std::string_view message;
312 const char
313 *property{};
314 std::uint64_t layerId{};
315
317 std::string_view propertyName() const noexcept {
318 return property ? std::string_view(property) : std::string_view{};
319 }
320};
321
326std::expected<void, StyleError> validateStyleTarget(const StyleTarget &target) noexcept;
327
332std::expected<StyleSheet, StyleError> parsePss(std::string_view source);
333
343ComputedStyle resolveStyle(const StyleSheet &sheet, const StyleTarget &target, ComputedStyle defaults = {},
344 bool readOnly = false) noexcept;
345
355
364
367
370
373
376
384public:
389 explicit StyleEngine(WidgetTree &tree, std::size_t maxBindings = 4096, StyleRoleLimits roleLimits = {});
390 StyleEngine(const StyleEngine &) = delete;
391 StyleEngine &operator=(const StyleEngine &) = delete;
392
398 std::expected<Invalidation, StyleError> bind(Node<Widget> node, StyleTarget target);
399
411 std::expected<Invalidation, StyleError> bindBatch(std::span<const StyleRegistration> registrations);
416 std::expected<StyleRoleRegistration, StyleError> registerRoles(Node<Widget> node,
417 std::span<const std::string_view> names);
418
422 std::expected<StyleRoleRegistration, StyleError> registerRoles(Node<Widget> node,
423 std::initializer_list<std::string_view> names) {
424 return registerRoles(node, std::span<const std::string_view>(names.begin(), names.size()));
425 }
426
436 std::expected<StyleRoleRegistration, StyleError> replaceRoles(const StyleRoleRegistration &registration,
437 std::span<const std::string_view> names);
438
443 std::expected<StyleRoleRegistration, StyleError> replaceRoles(const StyleRoleRegistration &registration,
444 std::initializer_list<std::string_view> names) {
445 return replaceRoles(registration, std::span<const std::string_view>(names.begin(), names.size()));
446 }
447
451 std::expected<Invalidation, StyleError> unregisterRoles(const StyleRoleRegistration &registration);
456 std::expected<Invalidation, StyleError> replace(StyleSheet sheet);
461 std::expected<Invalidation, StyleError> replacePss(std::string_view source);
465 std::expected<Invalidation, StyleError> refresh();
469 std::uint64_t revision() const noexcept;
470
482 std::expected<StyleLayerHandle, StyleError> addLayer(StyleTier tier, std::string_view name, const StyleSheet &sheet);
488 std::expected<Invalidation, StyleError> replaceLayer(StyleLayerHandle handle, const StyleSheet &sheet);
493 std::expected<Invalidation, StyleError> removeLayer(StyleLayerHandle handle);
498 std::expected<Invalidation, StyleError> updateLayers(std::span<const StyleLayerUpdate> updates);
503 std::expected<StyleLayerHandle, StyleError> baseLayer(StyleTier tier) const;
508 std::expected<Invalidation, StyleError> defaults(const StyleSheet &sheet);
513 std::expected<Invalidation, StyleError> theme(const StyleSheet &sheet);
514
515private:
516 friend class ManagedScene;
517 friend struct StyleLayerTestAccess;
518
519 struct Layer {
520 Layer(std::uint64_t identity = 0, std::uint64_t installationOrder = 0, StyleTier priority = StyleTier::DEFAULTS)
521 : id(identity), order(installationOrder), tier(priority), name("") {
522 }
523
524 // Checked MSVC string/container moves can allocate; transfer records by copy or swap.
525 ~Layer() = default;
526 std::uint64_t id;
527 std::uint64_t order;
528 StyleTier tier;
529 std::string name;
530 StyleSheet sheet;
531 std::shared_ptr<const PssDocument> document;
532 };
533
534 struct LayerState {
535 std::vector<Layer> layers = std::vector<Layer>(0);
536 StyleLayerOptions options;
537 std::uint64_t epoch{};
538 std::uint64_t nextId{1};
539 std::uint64_t nextOrder{1};
540 std::uint64_t owner{};
541 std::uint64_t themeBase{};
542 std::uint64_t preview{};
543 bool enabled{};
544 };
545 enum class Mutation {
546 ENABLE,
547 ADD,
548 UPDATE,
549 DEFAULTS,
550 THEME,
551 OWNED_THEME,
552 ADMIT,
553 PREVIEW,
554 PREVIEW_COMMIT,
555 PREVIEW_CANCEL
556 };
557
558 struct PreviewCapture {
559 std::uint64_t revision{};
560 detail::StyleThemeLease lease;
561 std::weak_ptr<const void> lifetime;
562 };
563
564 using RoleRegistry = std::vector<std::weak_ptr<detail::StyleRoleState>>;
565
566 struct Binding {
567 Node<Widget> node;
568 StyleTarget target;
569 };
570
571 std::expected<Invalidation, StyleError>
572 install(StyleSheet sheet, std::vector<Binding> &&bindings, LayerState *candidate = nullptr, bool wholeReplace = false,
573 const detail::StyleThemeLease *lease = nullptr, const PreviewCapture *previewCapture = nullptr,
574 bool notifyTheme = false, std::shared_ptr<const RoleRegistry> *roleCandidate = nullptr,
575 detail::StyleRoleState *replacedRole = nullptr);
576 std::expected<Invalidation, StyleError> replaceOwnedTheme(const StyleSheet &sheet, detail::StyleThemeLease lease);
577 std::expected<void, StyleError> mergeBindings(std::span<const StyleRegistration> registrations,
578 std::optional<std::vector<Binding>> &destination);
579 std::expected<Invalidation, StyleError>
580 mutate(Mutation mutation, StyleLayerOptions options, StyleTier tier, std::string_view name, const StyleSheet *sheet,
581 std::span<const StyleLayerUpdate> updates, std::span<const StyleRegistration> registrations,
582 StyleLayerHandle *added = nullptr, const detail::StyleThemeLease *lease = nullptr,
583 const PssDocument *document = nullptr, std::optional<StyleLayerOptions> admissionOptions = std::nullopt,
584 const PreviewCapture *previewCapture = nullptr);
585 PreviewCapture capturePreview() const noexcept;
586 std::expected<void, StyleError> validatePreviewCapture(const PreviewCapture &capture) const;
587 bool ownsPreview(const StyleLayerHandle &handle) const noexcept;
588 std::expected<void, StyleError> validateHandle(const StyleLayerHandle &handle) const;
589 std::expected<void, StyleError> validateLease(detail::StyleThemeLease lease) const;
590 detail::StyleThemeLease themeLease() const noexcept;
591 StyleLayerHandle handle(std::uint64_t id, std::uint64_t epoch) const noexcept;
592 ComputedStyle resolve(const StyleSheet &sheet, const LayerState &state, const StyleTarget &target,
593 ComputedStyle defaults, NodeId node = {}, bool readOnly = false) const noexcept;
594 std::expected<void, StyleError> checkBoundary(bool completing = false) const;
595 WidgetTree &tree_;
596 std::weak_ptr<detail::StyleThemeReceiver> themeReceiver_;
597 std::size_t maxBindings_;
598 StyleSheet sheet_;
599 std::vector<Binding> bindings_ = std::vector<Binding>(0);
600 StyleRoleLimits roleLimits_;
601 std::shared_ptr<const RoleRegistry> roleRegistrations_;
602 std::uint64_t revision_{};
603 std::shared_ptr<const void> lifetime_ = std::make_shared<const char>(char{});
604 const std::thread::id owner_ = std::this_thread::get_id();
605 LayerState layerState_;
606 bool stagingLayers_{};
607};
608} // namespace portals
Copyable typed observer; never owns or exposes an unchecked widget pointer.
Definition widget.hpp:92
UI-owned style transaction coordinator; tree must outlive this nonmovable object. Bindings own metada...
Definition style.hpp:383
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::uint64_t revision() const noexcept
Inspect on UI; no allocation or tree access.
std::expected< Invalidation, StyleError > refresh()
Recompute against current manual widget options, between frames.
std::expected< Invalidation, StyleError > bindBatch(std::span< const StyleRegistration > registrations)
Update metadata in one transaction, then recompute every bound widget once. Duplicate input nodes ret...
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 > replacePss(std::string_view source)
Parse and install without ever exposing a partial stylesheet.
std::expected< Invalidation, StyleError > updateLayers(std::span< const StyleLayerUpdate > updates)
Atomically update existing unique handles. Empty input is a no-op.
std::expected< Invalidation, StyleError > replace(StyleSheet sheet)
Install a complete typed stylesheet atomically between frames.
std::expected< Invalidation, StyleError > bind(Node< Widget > node, StyleTarget target)
Register/update metadata and atomically recompute every bound widget.
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 > enableLayers(StyleLayerOptions options={})
Enable owning tiers atomically; equal configuration is a no-op.
std::expected< StyleRoleRegistration, StyleError > replaceRoles(const StyleRoleRegistration &registration, std::span< const std::string_view > names)
Atomically replace the bounded names of a live semantic registration.
std::expected< StyleRoleRegistration, StyleError > registerRoles(Node< Widget > node, std::initializer_list< std::string_view > names)
Definition style.hpp:422
std::expected< Invalidation, StyleError > theme(const StyleSheet &sheet)
Replace THEME and hand authority to the caller, including equal values.
std::expected< Invalidation, StyleError > unregisterRoles(const StyleRoleRegistration &registration)
StyleEngine(WidgetTree &tree, std::size_t maxBindings=4096, StyleRoleLimits roleLimits={})
std::expected< StyleRoleRegistration, StyleError > replaceRoles(const StyleRoleRegistration &registration, std::initializer_list< std::string_view > names)
Definition style.hpp:443
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.
Weak UI-affine observer; destruction does not remove its layer.
Definition style.hpp:272
StyleLayerHandle()=default
Construct an empty observer; layer mutations reject it as INVALID_ARGUMENT.
UI-thread scoped registration; the engine retains only a weak observer. Copies share participation....
Definition style.hpp:151
StyleRoleRegistration()=default
Empty allocation-free handle.
std::uint64_t revision() const noexcept
std::shared_ptr< const StyleRolePalette > snapshot() const noexcept
Exclusive parent/child ownership on Scheduler's UI thread. Scheduler must outlive this object....
Definition widget.hpp:179
constexpr auto PREVIEW
Local work only.
Definition document_highlight_types.hpp:47
Public Portals API.
Definition action.hpp:8
StyleSheet gruvboxTheme()
StyleSheet modernTheme()
StyleSheet nordTheme()
constexpr std::size_t MAX_STYLE_BASE_TYPES
Maximum owned ancestor names per style target, excluding its immediate type.
Definition style.hpp:37
StyleSheet themeFromTokens(ThemeTokens tokens)
constexpr std::size_t MAX_STYLE_ROLE_PATCHES
Maximum aggregate typed semantic patches in one admitted stylesheet.
Definition style.hpp:95
@ DISABLED
Recording is stopped; retained evidence remains available.
Definition diagnostics.hpp:72
ComputedStyle resolveStyle(const StyleSheet &sheet, const StyleTarget &target, ComputedStyle defaults={}, bool readOnly=false) noexcept
Resolve one subject through the same engine used by typed and PSS installation.
std::expected< StyleSheet, StyleError > parsePss(std::string_view source)
Parse strict PSS v0 without I/O or mutation, on any thread.
constexpr std::size_t MAX_STYLE_ROLE_NAME_BYTES
Maximum ASCII bytes in a registered lower-kebab semantic role name.
Definition style.hpp:93
StyleSheet tokyoNightTheme()
StyleSheet turboTheme()
StyleSheet catppuccinLatteTheme()
StyleState
Presentation states; ANY matches every state without changing behavior.
Definition style.hpp:26
@ NORMAL
Ordinary content.
Definition style.hpp:28
@ FOCUSED
Synchronized control focus.
Definition style.hpp:29
@ CARET
Editor software caret.
Definition style.hpp:33
@ ANY
Match all presentation variants.
Definition style.hpp:27
@ SELECTED
Selected row or editor range.
Definition style.hpp:31
constexpr std::size_t MAX_STYLE_RULES
Finite typed/PSS rule budget.
Definition style.hpp:302
StyleTier
Independent cascade priority, before selector specificity.
Definition style.hpp:251
@ APPLICATION
Application overrides, above THEME.
Definition style.hpp:254
@ USER
User overrides, above APPLICATION.
Definition style.hpp:255
@ DEFAULTS
Declarations above widget defaults and below all other tiers.
Definition style.hpp:252
@ THEME
Reserved theme declarations controlled by one authority lease.
Definition style.hpp:253
std::expected< void, StyleError > validateStyleTarget(const StyleTarget &target) noexcept
Validate bounded ancestor metadata without allocation or retaining input.
constexpr std::size_t MAX_PSS_BYTES
Finite parser input byte budget.
Definition style.hpp:304
Invalidation
Accumulated work; layout always includes painting.
Definition widget_types.hpp:41
@ HEADER
Independent heading rows sharing the horizontal tracks.
Definition grid.hpp:24
TreeError
Checked tree failures; rejected operations never start the requested callback.
Definition widget_types.hpp:26
@ INVALID_ARGUMENT
An option, enum value or operation argument is invalid.
Definition widget_types.hpp:27
@ NORMAL
Unclassified source and whitespace.
Definition document_highlight_types.hpp:53
Owning resolved presentation; no actions or model state are encoded.
Definition style_types.hpp:169
Owning parsed declarations and provenance; input bytes need not survive the call. Metadata is not aut...
Definition pss_data.hpp:259
Owning RGB color; terminal encoding belongs to the output adapter.
Definition cell_buffer.hpp:20
Typed declarations; absent values preserve less-specific rules or widget defaults.
Definition style.hpp:169
StylePaintDeclarations scrollbarThumbStart
Thumb start overrides, inheriting the common thumb.
Definition style.hpp:188
std::optional< ScrollbarThumbPattern > scrollbarThumbPattern
Independent scrollbar source.
Definition style.hpp:185
StylePaintDeclarations scrollbarThumbBody
Thumb body overrides, inheriting the common thumb.
Definition style.hpp:189
StylePaintDeclarations scrollbarEnds
Scrollbar ends overrides.
Definition style.hpp:181
StylePaintDeclarations scrollbarThumbEnd
Thumb end overrides, inheriting the common thumb.
Definition style.hpp:190
StylePaintDeclarations scrollbarThumbSingle
Thumb single overrides, inheriting the common thumb.
Definition style.hpp:191
StylePaintDeclarations scrollbarCorner
Scrollbar corner overrides.
Definition style.hpp:182
std::optional< RgbColor > foreground
RGB text color.
Definition style.hpp:170
StylePaintDeclarations sliderThumb
Slider position indicator overrides.
Definition style.hpp:194
std::optional< std::int32_t > minWidth
Nonnegative cell minimum; allowed only on state-independent selectors.
Definition style.hpp:175
StylePaintDeclarations sliderTrack
Unfilled Slider rail overrides, inheriting the resolved state.
Definition style.hpp:192
std::optional< bool > bold
Explicit true/false bold request.
Definition style.hpp:172
std::optional< ScrollbarArrowPattern > scrollbarArrowPattern
Independent scrollbar source.
Definition style.hpp:186
std::optional< bool > italic
Explicit true/false italic request.
Definition style.hpp:173
StylePaintDeclarations frameLine
Frame perimeter overrides, inheriting the common resolved state.
Definition style.hpp:176
std::optional< ScrollbarPattern > scrollbarTrackPattern
Independent scrollbar source.
Definition style.hpp:184
std::optional< GlyphFallback > glyphFallback
Explicit portable one-cell admission fallback.
Definition style.hpp:196
bool operator==(const StyleDeclarations &other) const =default
StylePaintDeclarations scrollbarArrows
Functional arrow button overrides.
Definition style.hpp:183
std::optional< RgbColor > background
RGB fill color.
Definition style.hpp:171
StylePaintDeclarations frameTitle
Frame title text overrides.
Definition style.hpp:177
StylePaintDeclarations frameEnds
Frame title prefix/suffix overrides.
Definition style.hpp:178
StylePaintDeclarations sliderFill
Filled Slider rail overrides.
Definition style.hpp:193
StylePaintDeclarations scrollbarTrack
Scrollbar track overrides.
Definition style.hpp:179
std::optional< bool > underline
Explicit true/false underline request.
Definition style.hpp:174
StylePaintDeclarations scrollbarThumb
Scrollbar thumb overrides.
Definition style.hpp:180
std::optional< GlyphProfile > glyphProfile
Named base beneath independent patterns and literal sources.
Definition style.hpp:195
Allocation-free error; message borrows a static string literal.
Definition style.hpp:307
std::uint64_t layerId
Failing resident/candidate layer identity; zero for legacy or typed sources.
Definition style.hpp:314
std::string_view propertyName() const noexcept
Definition style.hpp:317
TreeError cause
Tree/validation/allocation failure category.
Definition style.hpp:308
std::size_t column
One-based byte column, or one for typed/tree errors.
Definition style.hpp:310
const char * property
Null or a library static null-terminated property identity for a failed literal preparation.
Definition style.hpp:313
std::string_view message
Static diagnostic; never borrows source input.
Definition style.hpp:311
std::size_t line
One-based PSS line, or one for typed/tree errors.
Definition style.hpp:309
Aggregate logical owning payload budgets; base slots count as layers.
Definition style.hpp:259
std::size_t maxOwnedBytes
Logical payload charge; not a whole-heap allocator cap.
Definition style.hpp:263
std::size_t maxRules
Rules summed across the complete resident table.
Definition style.hpp:261
bool operator==(const StyleLayerOptions &other) const =default
std::size_t maxLayers
Resident layer slots, including the two permanent bases.
Definition style.hpp:260
std::size_t maxDeclarations
Present optional fields, including explicit false values.
Definition style.hpp:262
Replace an existing layer, or remove it when sheet is absent.
Definition style.hpp:286
std::optional< StyleSheet > sheet
Owning replacement or nullopt for removal.
Definition style.hpp:288
StyleLayerHandle handle
Existing layer identity; duplicate identities reject the batch.
Definition style.hpp:287
Sparse paint attributes for an existing presentation part.
Definition style.hpp:81
std::optional< RgbColor > foreground
RGB text color.
Definition style.hpp:82
std::optional< bool > underline
Explicit underline request.
Definition style.hpp:86
bool operator==(const StylePaintDeclarations &other) const =default
std::optional< RgbColor > background
RGB fill color.
Definition style.hpp:83
std::optional< bool > italic
Explicit italic request.
Definition style.hpp:85
std::optional< bool > bold
Explicit bold request.
Definition style.hpp:84
Owned metadata for one checked target in an atomic binding batch.
Definition style.hpp:56
Node< Widget > node
Observing handle; the tree retains widget ownership.
Definition style.hpp:57
StyleTarget target
Matching metadata copied into the engine on success.
Definition style.hpp:58
Limits paid only by opt-in semantic registrations.
Definition style.hpp:121
std::size_t maxRolesPerRegistration
Positive maximum names in one registration.
Definition style.hpp:123
std::size_t maxTotalRoles
Positive aggregate count of live registered names.
Definition style.hpp:124
std::size_t maxRegistrations
Positive maximum live registrations, also bounded by maxBindings.
Definition style.hpp:122
Owning role projection; retain a const shared snapshot across node/engine retirement.
Definition style.hpp:136
~StyleRolePalette()=default
Keep checked vector transfers throwable.
std::optional< CellStyle > find(std::string_view name, StyleState state=StyleState::NORMAL) const noexcept
std::vector< StyleRoleValue > values
Bounded registered names only.
Definition style.hpp:138
bool operator==(const StyleRolePalette &) const =default
Cold sparse paint patch; names never encode focus or selection state.
Definition style.hpp:113
StylePaintDeclarations paint
Absent leaves inherit the resolved ordinary surface.
Definition style.hpp:116
std::string name
Lower-kebab name, copied by owning declarations.
Definition style.hpp:115
~StyleRolePatch()=default
Checked container copies may allocate; suppress implicit noexcept moves.
bool operator==(const StyleRolePatch &) const =default
One immutable-at-publication role in normal/focused/disabled/selected/header/caret order.
Definition style.hpp:128
bool operator==(const StyleRoleValue &) const =default
std::array< CellStyle, 6 > states
Actual paint values after the existing cascade.
Definition style.hpp:131
std::string name
Registered owned name.
Definition style.hpp:130
~StyleRoleValue()=default
Keep checked string transfers throwable.
One owned selector/declaration pair in source order.
Definition style.hpp:205
StyleDeclarations declarations
Definition style.hpp:212
std::shared_ptr< const std::vector< StyleRolePatch > > roles
Optional cold immutable semantic declarations.
Definition style.hpp:217
StyleSelector selector
Matching and specificity criteria.
Definition style.hpp:211
bool operator==(const StyleRule &other) const
Definition style.hpp:222
~StyleRule()=default
Destroy owned values. Deliberately suppress implicit noexcept moves: checked MSVC container moves can...
std::shared_ptr< const StyleSizing > sizing
Optional immutable runtime sizing; shared ownership, never a view.
Definition style.hpp:216
Conjunction of optional type, id, classes, one state and read-only; no hierarchy combinators.
Definition style.hpp:62
std::string type
Empty or * means any type.
Definition style.hpp:68
StyleState state
Optional presentation-state predicate.
Definition style.hpp:71
bool readOnly
True requires read-only; false adds no qualifier.
Definition style.hpp:72
~StyleSelector()=default
Destroy owned values. Deliberately suppress implicit noexcept moves: checked MSVC container moves can...
bool operator==(const StyleSelector &other) const =default
std::vector< std::string > classes
Every named class is required.
Definition style.hpp:70
Owned immutable-at-use rules; constructing typed values may allocate and throw.
Definition style.hpp:233
bool operator==(const StyleSheet &other) const =default
std::optional< NodeId > scope
Optional exact node restriction; preserves selector specificity and source metadata.
Definition style.hpp:242
std::vector< StyleRule > rules
Source-order rules, at most MAX_STYLE_RULES when installed.
Definition style.hpp:239
~StyleSheet()=default
Destroy owned values. Deliberately suppress implicit noexcept moves: checked MSVC container moves can...
Owned subject metadata, supplied explicitly for built-in or custom widget types.
Definition style.hpp:40
std::vector< std::string > baseTypes
Nearest-base-first owning names, at most MAX_STYLE_BASE_TYPES; no empty, wildcard,...
Definition style.hpp:51
~StyleTarget()=default
Destroy owned values. Deliberately suppress implicit noexcept moves: checked MSVC container moves can...
std::vector< std::string > classes
Case-sensitive class names; all selector classes must match.
Definition style.hpp:48
bool control
Also match Control selectors; explicit targets opt in independently of their type name.
Definition style.hpp:50
std::string type
Case-sensitive type name, for example Button or Table.
Definition style.hpp:46
Typed palette tokens for the built-in theme factories.
Definition style.hpp:347
RgbColor foreground
Normal foreground.
Definition style.hpp:348
RgbColor background
Normal background.
Definition style.hpp:349
RgbColor accent
Focus background, active frame foreground and contrasting caret foreground.
Definition style.hpp:350
RgbColor selection
Selected-row/range background.
Definition style.hpp:352
RgbColor heading
Heading foreground.
Definition style.hpp:353
RgbColor muted
Disabled foreground.
Definition style.hpp:351
Private captured theme authority, including legacy epoch admission.
Definition style.hpp:293
std::uint64_t epoch
Engine identity generation captured at attach.
Definition style.hpp:295
std::uint64_t owner
Reserved THEME authority generation.
Definition style.hpp:297
bool layered
Captured opt-in mode; controllers never silently adopt a new mode.
Definition style.hpp:294