Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
design_update.hpp
Go to the documentation of this file.
1#pragma once
2#include <cstddef>
4#include <span>
5#include <string>
6#include <string_view>
7#include <vector>
8
9namespace pulp::view {
11
12// A materialized node can contain a static visual region plus one or more
13// typed, host-driven slots. This classification is intentionally narrower
14// than a widget kind: it tells an update consumer which value setter can be
15// used without rebuilding the Skia/Dawn-backed visual record.
24
25struct DesignSlot {
27 std::string route_id;
28 // Canonical binding key (for a vector this is a length-prefixed x/y pair;
29 // static slots are empty). Keeping the key in the classification makes
30 // re-key updates observable and prevents a caller from accidentally
31 // treating two controls with different host routes as the same slot.
32 std::string key;
33
34 friend bool operator==(const DesignSlot&, const DesignSlot&) = default;
35};
36
37// Return a deterministic typed slot inventory for `node` and its descendants.
38// Static nodes produce one static_visual entry; dynamic entries are sorted by
39// route, kind, and key so unordered IR attributes cannot perturb update plans.
40std::vector<DesignSlot> classify_design_slots(const IRNode& node);
41
42// A keyed node is retained or moved only while its materialization shape is
43// compatible. If the same stable anchor changes node type, render lane, widget
44// kind, or binding topology, the planner emits a removed/inserted pair so a
45// caller cannot reuse a stale native view or binding. Binding names themselves
46// remain mutable values and do not force recreation.
47
48// Updates apply in emission order to a mutable child vector that starts as
49// the old children. `removed` erases `old_index`. `inserted` inserts at
50// `new_index`. `moved` erases `old_index` and then inserts at `new_index`.
51// Both are positions in the vector at the moment the update applies, so a
52// materializer can apply them directly; after the last update the vector
53// equals the new children. `retained` changes nothing and records the
54// child's index in the old and new child lists.
57 std::string key;
58 std::size_t old_index = 0;
59 std::size_t new_index = 0;
60};
61
63 // No child on this side carries a stable anchor; one entry per side.
65 // The anchor repeats an earlier sibling's anchor; one entry per repeat.
67 // This child has no anchor while some siblings on the same side do.
69};
70
71// Why a sibling set could not be planned by key. Present only when the plan
72// falls back to a wholesale replace, so an author can find the child to fix.
75 std::string key;
76 std::size_t index = 0;
77 bool old_side = false;
78
79 friend bool operator==(const DesignKeyDiagnostic&, const DesignKeyDiagnostic&) = default;
80};
81
84 std::size_t first = 0;
85 std::size_t count = 0;
86};
88 std::size_t retained = 0;
89 std::size_t moved = 0;
90 std::size_t inserted = 0;
91 std::size_t removed = 0;
92
93 std::size_t total() const noexcept {
94 return retained + moved + inserted + removed;
95 }
96
98 const DesignUpdateWorkCounters&) = default;
99};
100
102 std::vector<DesignChildUpdate> updates;
103 std::vector<DesignUpdateBlock> blocks;
104 // Deterministic work census for import/runtime observability. These counts
105 // are derived from updates in emission order and are independent of the
106 // unordered IR attribute storage used by the compatibility checks.
107 // `moved` is minimal: survivors that keep their relative order (a longest
108 // increasing subsequence of old positions, after trimming the common
109 // prefix and suffix) stay in place and only the rest move.
111 // Ordered old side first, then by index; empty for a keyed plan.
112 std::vector<DesignKeyDiagnostic> key_diagnostics;
113 bool keyed = false;
114 bool ambiguous_keys = false;
115};
116
117std::string_view to_string(DesignKeyDiagnosticReason reason) noexcept;
118DesignChildUpdatePlan plan_design_child_updates(std::span<const IRNode> old_children,
119 std::span<const IRNode> new_children);
120} // namespace pulp::view
Normalized intermediate representation (IR) for imported designs: the IR value model (style,...
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
DesignUpdateKind
Definition design_update.hpp:10
@ moved
Definition design_update.hpp:10
@ retained
Definition design_update.hpp:10
@ inserted
Definition design_update.hpp:10
@ removed
Definition design_update.hpp:10
const char * to_string(AppearanceDefectKind kind)
DesignKeyDiagnosticReason
Definition design_update.hpp:62
@ duplicate
Definition design_update.hpp:66
@ missing
Definition design_update.hpp:64
DesignSlotKind
Definition design_update.hpp:16
@ dynamic_action
Definition design_update.hpp:22
@ dynamic_meter
Definition design_update.hpp:20
@ dynamic_scalar
Definition design_update.hpp:18
@ dynamic_vector
Definition design_update.hpp:19
@ dynamic_text
Definition design_update.hpp:21
@ static_visual
Definition design_update.hpp:17
std::vector< DesignSlot > classify_design_slots(const IRNode &node)
DesignChildUpdatePlan plan_design_child_updates(std::span< const IRNode > old_children, std::span< const IRNode > new_children)
@ mixed
Definition accessibility.hpp:132
Definition design_update.hpp:101
bool keyed
Definition design_update.hpp:113
std::vector< DesignChildUpdate > updates
Definition design_update.hpp:102
DesignUpdateWorkCounters work
Definition design_update.hpp:110
std::vector< DesignUpdateBlock > blocks
Definition design_update.hpp:103
bool ambiguous_keys
Definition design_update.hpp:114
std::vector< DesignKeyDiagnostic > key_diagnostics
Definition design_update.hpp:112
Definition design_update.hpp:55
std::string key
Definition design_update.hpp:57
std::size_t old_index
Definition design_update.hpp:58
std::size_t new_index
Definition design_update.hpp:59
DesignUpdateKind kind
Definition design_update.hpp:56
Definition design_update.hpp:73
bool old_side
Definition design_update.hpp:77
std::string key
Definition design_update.hpp:75
DesignKeyDiagnosticReason reason
Definition design_update.hpp:74
friend bool operator==(const DesignKeyDiagnostic &, const DesignKeyDiagnostic &)=default
std::size_t index
Definition design_update.hpp:76
Definition design_update.hpp:25
DesignSlotKind kind
Definition design_update.hpp:26
std::string key
Definition design_update.hpp:32
std::string route_id
Definition design_update.hpp:27
friend bool operator==(const DesignSlot &, const DesignSlot &)=default
Definition design_update.hpp:82
std::size_t count
Definition design_update.hpp:85
DesignUpdateKind kind
Definition design_update.hpp:83
std::size_t first
Definition design_update.hpp:84
Definition design_update.hpp:87
friend bool operator==(const DesignUpdateWorkCounters &, const DesignUpdateWorkCounters &)=default
std::size_t total() const noexcept
Definition design_update.hpp:93
std::size_t removed
Definition design_update.hpp:91
std::size_t inserted
Definition design_update.hpp:90
std::size_t retained
Definition design_update.hpp:88
std::size_t moved
Definition design_update.hpp:89
Definition design_ir.hpp:614