载入中...
搜索中...
未找到
PropertyView.cpp
浏览该文件的文档.
1#include "ui/PropertyView.h"
2
3#include <algorithm>
4#include <cerrno>
5#include <charconv>
6#include <cstdint>
7#include <cstdlib>
8#include <string_view>
9#include <utility>
10#include <vector>
11
12namespace eve::ui {
13namespace {
14
15using eve::Value;
16using property_access::PropertyDescriptor;
19
21void applyWrite(property_access::IPropertyAccess &model, const std::string &path, Value value) {
22 model.write(path, std::move(value))
23 .ignore("PropertyView UI writes are best-effort until the shell can present Result diagnostics");
24}
25
26std::string sanitize(std::string value) {
27 for (char &character : value)
28 if (character == ' ' || character == '.' || character == '[' || character == ']' ||
29 character == '/')
30 character = '_';
31 return value;
32}
33
34std::string displayName(const PropertyDescriptor &property) {
35 if (!property.displayName.empty()) return property.displayName;
36 const std::size_t separator = property.path.find_last_of("./");
37 return separator == std::string::npos ? property.path : property.path.substr(separator + 1);
38}
39
40std::string valueText(const Value &value) {
41 if (const auto *text = value.getIf<std::string>()) return *text;
42 if (const auto *boolean = value.getIf<bool>()) return *boolean ? "true" : "false";
43 if (const auto *integer = value.getIf<std::int64_t>()) return std::to_string(*integer);
44 if (const auto *number = value.getIf<double>()) return std::to_string(*number);
45 if (const auto *array = value.getIf<Value::Array>())
46 return std::to_string(array->size()) + " items";
47 if (const auto *object = value.getIf<Value::Object>())
48 return std::to_string(object->size()) + " fields";
49 return "null";
50}
51
52double numericValue(const Value &value) {
53 if (const auto *number = value.getIf<double>()) return *number;
54 if (const auto *integer = value.getIf<std::int64_t>()) return static_cast<double>(*integer);
55 return 0.0;
56}
57
58bool parseNumber(const std::string &text, bool integer, Value &out) {
59 if (integer) {
60 std::int64_t parsed = 0;
61 const auto converted = std::from_chars(text.data(), text.data() + text.size(), parsed);
62 if (converted.ec != std::errc() || converted.ptr != text.data() + text.size()) return false;
63 out = Value(parsed);
64 return true;
65 }
66 char *end = nullptr;
67 errno = 0;
68 const double parsed = std::strtod(text.c_str(), &end);
69 if (text.empty() || errno == ERANGE || end != text.c_str() + text.size()) return false;
70 out = Value(parsed);
71 return true;
72}
73
74Value::Array componentArray(const Value &value, std::size_t count) {
76 if (const auto *items = value.getIf<Value::Array>()) {
77 for (std::size_t index = 0; index < count && index < items->size(); ++index)
78 result[index] = Value(numericValue((*items)[index]));
79 }
80 return result;
81}
82
83AccessibilityRole accessibilityRole(PropertyKind kind, bool readOnly) {
85 switch (kind) {
86 case PropertyKind::Bool: return AccessibilityRole::Checkbox;
87 case PropertyKind::Integer:
88 case PropertyKind::Number: return AccessibilityRole::Slider;
89 case PropertyKind::Action: return AccessibilityRole::Button;
90 case PropertyKind::Enum: return AccessibilityRole::List;
91 case PropertyKind::Color: return AccessibilityRole::Slider;
92 case PropertyKind::String:
93 case PropertyKind::AssetRef:
94 case PropertyKind::ObjectRef:
95 case PropertyKind::Auto: return AccessibilityRole::TextInput;
96 default: return AccessibilityRole::Region;
97 }
98}
99
100WidgetDesc scalarElementEditor(const std::string &elementId, const std::string &elementLabel,
101 const Value &element, std::function<void(Value)> writeElement) {
102 if (const auto *boolean = element.getIf<bool>()) {
103 return checkbox(elementLabel, *boolean, elementId,
104 [writeElement = std::move(writeElement)](bool next) { writeElement(Value(next)); });
105 }
106 if (element.getIf<std::int64_t>() || element.getIf<double>()) {
107 return inputText(elementLabel, valueText(element), elementId,
108 [writeElement = std::move(writeElement),
109 integer = element.getIf<std::int64_t>() != nullptr](const std::string &next) {
110 Value parsed;
111 if (parseNumber(next, integer, parsed)) writeElement(std::move(parsed));
112 });
113 }
114 if (element.getIf<std::string>() || element.isNull()) {
115 return inputText(elementLabel, valueText(element), elementId,
116 [writeElement = std::move(writeElement)](const std::string &next) {
117 writeElement(Value(next));
118 });
119 }
120 return text(elementLabel + " = " + valueText(element), elementId);
121}
122
123WidgetDesc makeCompositeEditor(property_access::IPropertyAccess &model, const PropertyViewOptions &options,
124 const PropertyDescriptor &property, const Value &value,
125 const std::vector<std::string> &labels) {
126 const std::string id = propertyWidgetId(options, property.path);
127 Value::Array items = componentArray(value, labels.size());
128 std::vector<WidgetDesc> children;
129 children.push_back(text(displayName(property), id + "_label"));
130 for (std::size_t index = 0; index < labels.size(); ++index) {
131 const std::string componentId = id + "_" + labels[index];
132 const std::string path = property.path;
133 const std::size_t component = index;
134 const bool useSlider = property.numeric.minimum && property.numeric.maximum;
135 if (useSlider) {
136 children.push_back(slider(
137 labels[index], static_cast<float>(numericValue(items[index])),
138 static_cast<float>(*property.numeric.minimum), static_cast<float>(*property.numeric.maximum),
139 componentId, [&model, path, component, count = labels.size()](float next) {
140 const std::optional<Value> current = model.read(path);
141 Value::Array updated =
142 componentArray(current ? *current : Value(Value::Array{}), count);
143 updated[component] = Value(static_cast<double>(next));
144 applyWrite(model, path, Value(std::move(updated)));
145 }));
146 } else {
147 children.push_back(inputText(
148 labels[index], valueText(items[index]), componentId,
149 [&model, path, component, count = labels.size()](const std::string &next) {
150 Value parsed;
151 if (!parseNumber(next, false, parsed)) return;
152 const std::optional<Value> current = model.read(path);
154 componentArray(current ? *current : Value(Value::Array{}), count);
155 updated[component] = std::move(parsed);
156 applyWrite(model, path, Value(std::move(updated)));
157 }));
158 }
159 }
160 return row(std::move(children), id);
161}
162
163WidgetDesc makeArrayEditor(property_access::IPropertyAccess &model, const PropertyViewOptions &options,
164 const PropertyDescriptor &property, const Value &value) {
165 const std::string id = propertyWidgetId(options, property.path);
166 Value::Array items;
167 if (const auto *array = value.getIf<Value::Array>()) items = *array;
168 std::vector<WidgetDesc> rows;
169 for (std::size_t index = 0; index < items.size(); ++index) {
170 const std::string elementId = id + "_" + std::to_string(index);
171 const std::string elementLabel = displayName(property) + "[" + std::to_string(index) + "]";
172 const std::string path = property.path;
173 const std::size_t elementIndex = index;
174 WidgetDesc cell = scalarElementEditor(
175 elementId, elementLabel, items[index],
176 [&model, path, elementIndex](Value next) {
177 const std::optional<Value> current = model.read(path);
179 if (const auto *array = current ? current->getIf<Value::Array>() : nullptr)
180 updated = *array;
181 if (elementIndex >= updated.size()) updated.resize(elementIndex + 1);
182 updated[elementIndex] = std::move(next);
183 applyWrite(model, path, Value(std::move(updated)));
184 });
185 const auto onStructure = options.onStructureChange;
186 rows.push_back(row(
187 {std::move(cell),
188 button("x##" + elementId + "_del", elementId + "_del",
189 [&model, path, elementIndex, onStructure]() {
190 const std::optional<Value> current = model.read(path);
192 if (const auto *array = current ? current->getIf<Value::Array>() : nullptr)
193 updated = *array;
194 if (elementIndex < updated.size())
195 updated.erase(updated.begin() + static_cast<std::ptrdiff_t>(elementIndex));
196 applyWrite(model, path, Value(std::move(updated)));
197 if (onStructure) onStructure();
198 })},
199 elementId + "_row"));
200 }
201 const std::string path = property.path;
202 const auto onStructure = options.onStructureChange;
203 rows.push_back(row(
204 {button("+##" + id + "_add", id + "_add",
205 [&model, path, onStructure]() {
206 const std::optional<Value> current = model.read(path);
208 if (const auto *array = current ? current->getIf<Value::Array>() : nullptr)
209 updated = *array;
210 updated.emplace_back(std::string{});
211 applyWrite(model, path, Value(std::move(updated)));
212 if (onStructure) onStructure();
213 })},
214 id + "_addrow"));
215 return collapsingHeader(displayName(property) + " (array[" + std::to_string(items.size()) + "])##" + id,
216 std::move(rows), id, false);
217}
218
219WidgetDesc makeMapEditor(property_access::IPropertyAccess &model, const PropertyViewOptions &options,
220 const PropertyDescriptor &property, const Value &value, bool allowMutate) {
221 const std::string id = propertyWidgetId(options, property.path);
223 if (const auto *object = value.getIf<Value::Object>()) fields = *object;
224 std::vector<WidgetDesc> rows;
225 for (const auto &[key, entry] : fields) {
226 const std::string elementId = id + "_" + sanitize(key);
227 const std::string path = property.path;
228 const std::string fieldKey = key;
229 WidgetDesc cell = scalarElementEditor(
230 elementId, key, entry, [&model, path, fieldKey](Value next) {
231 const std::optional<Value> current = model.read(path);
233 if (const auto *object = current ? current->getIf<Value::Object>() : nullptr)
234 updated = *object;
235 updated[fieldKey] = std::move(next);
236 applyWrite(model, path, Value(std::move(updated)));
237 });
238 if (allowMutate) {
239 const auto onStructure = options.onStructureChange;
240 rows.push_back(row(
241 {std::move(cell),
242 button("x##" + elementId + "_del", elementId + "_del",
243 [&model, path, fieldKey, onStructure]() {
244 const std::optional<Value> current = model.read(path);
246 if (const auto *object = current ? current->getIf<Value::Object>() : nullptr)
247 updated = *object;
248 updated.erase(fieldKey);
249 applyWrite(model, path, Value(std::move(updated)));
250 if (onStructure) onStructure();
251 })},
252 elementId + "_row"));
253 } else {
254 rows.push_back(std::move(cell));
255 }
256 }
257 if (allowMutate) {
258 const std::string path = property.path;
259 const auto onStructure = options.onStructureChange;
260 rows.push_back(row(
261 {button("+##" + id + "_add", id + "_add",
262 [&model, path, onStructure]() {
263 const std::optional<Value> current = model.read(path);
265 if (const auto *object = current ? current->getIf<Value::Object>() : nullptr)
266 updated = *object;
267 std::string key = "key" + std::to_string(updated.size());
268 std::size_t suffix = 0;
269 while (updated.contains(key))
270 key = "key" + std::to_string(updated.size() + (++suffix));
271 updated.emplace(key, Value(std::string{}));
272 applyWrite(model, path, Value(std::move(updated)));
273 if (onStructure) onStructure();
274 })},
275 id + "_addrow"));
276 }
277 const std::string kindLabel = property.kind == PropertyKind::Struct ? "struct" : "map";
278 return collapsingHeader(displayName(property) + " (" + kindLabel + ")##" + id, std::move(rows), id, false);
279}
280
281WidgetDesc makePropertyField(property_access::IPropertyAccess &model, const PropertyViewOptions &options,
282 const PropertyDescriptor &property, const Value &value) {
283 const std::string id = propertyWidgetId(options, property.path);
284 const std::string label = displayName(property);
285 const bool readOnly =
286 property_access::hasFlag(property.flags, PropertyFlag::ReadOnly) || property.kind == PropertyKind::ReadOnlyText;
287 WidgetDesc result;
288
289 if (readOnly) {
290 if (property.kind == PropertyKind::Array || property.kind == PropertyKind::Map ||
291 property.kind == PropertyKind::Struct)
292 result = collapsingHeader(label + ": " + valueText(value) + "##" + id,
293 {text(valueText(value), id + "_summary")}, id, false);
294 else
295 result = text(label + ": " + valueText(value), id);
296 } else {
297 switch (property.kind) {
298 case PropertyKind::Bool: {
299 const bool current = value.getIf<bool>() ? *value.getIf<bool>() : false;
300 const std::string path = property.path;
301 result = checkbox(label, current, id, [&model, path](bool next) {
302 applyWrite(model, path, Value(next));
303 });
304 break;
305 }
306 case PropertyKind::Integer:
307 case PropertyKind::Number: {
308 const bool integer = property.kind == PropertyKind::Integer;
309 const std::string path = property.path;
310 if (property.numeric.minimum && property.numeric.maximum) {
311 result = slider(label, static_cast<float>(numericValue(value)),
312 static_cast<float>(*property.numeric.minimum),
313 static_cast<float>(*property.numeric.maximum), id,
314 [&model, path, integer](float next) {
315 if (integer)
316 applyWrite(model, path, Value(static_cast<std::int64_t>(next)));
317 else
318 applyWrite(model, path, Value(static_cast<double>(next)));
319 });
320 } else {
321 result = inputText(label, valueText(value), id,
322 [&model, path, integer](const std::string &next) {
323 Value parsed;
324 if (parseNumber(next, integer, parsed))
325 applyWrite(model, path, std::move(parsed));
326 });
327 }
328 break;
329 }
330 case PropertyKind::Enum: {
331 const std::string selected = valueText(value);
332 int selectedIndex = 0;
333 for (std::size_t index = 0; index < property.choices.size(); ++index)
334 if (property.choices[index] == selected) selectedIndex = static_cast<int>(index);
335 const std::string path = property.path;
336 const std::vector<std::string> choices = property.choices;
337 result = combo(label, choices, selectedIndex, id,
338 [&model, path, choices](float next) {
339 const int index = static_cast<int>(next);
340 if (index >= 0 && static_cast<std::size_t>(index) < choices.size())
341 applyWrite(model, path, Value(choices[static_cast<std::size_t>(index)]));
342 });
343 break;
344 }
345 case PropertyKind::Action: {
346 const std::string path = property.path;
347 result = button(label, id, [&model, path]() { applyWrite(model, path, Value(true)); });
348 break;
349 }
350 case PropertyKind::String:
351 case PropertyKind::AssetRef:
352 case PropertyKind::ObjectRef:
353 case PropertyKind::Auto: {
354 const std::string path = property.path;
355 result = inputText(label, valueText(value), id,
356 [&model, path](const std::string &next) {
357 applyWrite(model, path, Value(next));
358 });
359 break;
360 }
361 case PropertyKind::Color:
362 result = makeCompositeEditor(model, options, property, value, {"r", "g", "b", "a"});
363 break;
364 case PropertyKind::Vec2:
365 result = makeCompositeEditor(model, options, property, value, {"x", "y"});
366 break;
367 case PropertyKind::Vec3:
368 result = makeCompositeEditor(model, options, property, value, {"x", "y", "z"});
369 break;
370 case PropertyKind::Vec4:
371 result = makeCompositeEditor(model, options, property, value, {"x", "y", "z", "w"});
372 break;
373 case PropertyKind::Array:
374 result = makeArrayEditor(model, options, property, value);
375 break;
376 case PropertyKind::Map:
377 result = makeMapEditor(model, options, property, value, true);
378 break;
379 case PropertyKind::Struct:
380 result = makeMapEditor(model, options, property, value, true);
381 break;
382 case PropertyKind::ReadOnlyText:
383 result = text(label + ": " + valueText(value), id);
384 break;
385 }
386 }
387 result.tooltip = property.description;
388 result.accessibilityRole = accessibilityRole(property.kind, readOnly);
389 result.accessibilityName = label;
390 result.accessibilityDescription = property.description;
391 if (readOnly) {
392 result.focusMode = FocusMode::None;
393 result.mouseFilter = MouseFilter::Ignore;
394 }
395 return result;
396}
397
398bool visible(const PropertyDescriptor &property, const PropertyViewOptions &options) {
399 if (!options.showAdvanced && property_access::hasFlag(property.flags, PropertyFlag::Advanced)) return false;
400 if (!options.showEditorOnly && property_access::hasFlag(property.flags, PropertyFlag::EditorOnly)) return false;
401 if (!options.showReadOnly && (property_access::hasFlag(property.flags, PropertyFlag::ReadOnly) ||
402 property.kind == PropertyKind::ReadOnlyText))
403 return false;
404 return true;
405}
406
407void syncComposite(UIHost &host, const std::string &id, const Value &value,
408 const std::vector<std::string> &labels, const PropertyDescriptor &property) {
409 Value::Array items = componentArray(value, labels.size());
410 for (std::size_t index = 0; index < labels.size(); ++index) {
411 const std::string componentId = id + "_" + labels[index];
412 if (property.numeric.minimum && property.numeric.maximum)
413 host.setValueById(componentId, static_cast<float>(numericValue(items[index])));
414 else
415 host.setValueTextById(componentId, valueText(items[index]));
416 }
417}
418
419} // namespace
420
421std::string propertyWidgetId(const PropertyViewOptions &options, const std::string &path) {
422 return options.idPrefix + sanitize(path);
423}
424
427 auto property = model.schema().find(path);
428 const std::optional<Value> value = model.read(path);
429 if (!property || !value)
430 return text(path + ": unavailable", propertyWidgetId(options, path))
431 .withFocusMode(FocusMode::None)
432 .withMouseFilter(MouseFilter::Ignore)
433 .withAccessibility(AccessibilityRole::Text, path, "Property is unavailable");
434 return makePropertyField(model, options, property->get(), *value);
435}
436
438 std::vector<WidgetDesc> children;
439 if (!options.title.empty()) children.push_back(sectionHeader(options.title, options.idPrefix + "title"));
440
441 std::string category;
442 for (const PropertyDescriptor &property : model.schema().properties) {
443 if (!visible(property, options)) continue;
444 const std::optional<Value> value = model.read(property.path);
445 if (!value) continue;
446 if (options.groupCategories && !property.category.empty() && property.category != category) {
447 category = property.category;
448 children.push_back(sectionHeader(category, options.idPrefix + "category/" + sanitize(category)));
449 }
450 children.push_back(makePropertyField(model, options, property, *value));
451 }
452 return column(std::move(children), options.idPrefix + "root");
453}
454
456 for (const PropertyDescriptor &property : model.schema().properties) {
457 const std::optional<Value> value = model.read(property.path);
458 if (!value) continue;
459 const std::string id = propertyWidgetId(options, property.path);
460 const bool readOnly = property_access::hasFlag(property.flags, PropertyFlag::ReadOnly) ||
461 property.kind == PropertyKind::ReadOnlyText;
462 if (readOnly) {
463 host.setTextById(id, displayName(property) + ": " + valueText(*value));
464 continue;
465 }
466 switch (property.kind) {
467 case PropertyKind::Bool:
468 if (const auto *boolean = value->getIf<bool>()) host.setCheckedById(id, *boolean);
469 break;
470 case PropertyKind::Enum: {
471 const std::string selected = valueText(*value);
472 const auto found = std::find(property.choices.begin(), property.choices.end(), selected);
473 host.setValueById(id, found == property.choices.end()
474 ? 0.f
475 : static_cast<float>(found - property.choices.begin()));
476 break;
477 }
478 case PropertyKind::Integer:
479 case PropertyKind::Number:
480 if (property.numeric.minimum && property.numeric.maximum)
481 host.setValueById(id, static_cast<float>(numericValue(*value)));
482 else
483 host.setValueTextById(id, valueText(*value));
484 break;
485 case PropertyKind::Color:
486 syncComposite(host, id, *value, {"r", "g", "b", "a"}, property);
487 break;
488 case PropertyKind::Vec2:
489 syncComposite(host, id, *value, {"x", "y"}, property);
490 break;
491 case PropertyKind::Vec3:
492 syncComposite(host, id, *value, {"x", "y", "z"}, property);
493 break;
494 case PropertyKind::Vec4:
495 syncComposite(host, id, *value, {"x", "y", "z", "w"}, property);
496 break;
497 case PropertyKind::Array:
498 if (const auto *items = value->getIf<Value::Array>()) {
499 for (std::size_t index = 0; index < items->size(); ++index) {
500 const std::string elementId = id + "_" + std::to_string(index);
501 if (const auto *boolean = (*items)[index].getIf<bool>())
502 host.setCheckedById(elementId, *boolean);
503 else
504 host.setValueTextById(elementId, valueText((*items)[index]));
505 }
506 }
507 break;
508 case PropertyKind::Map:
509 case PropertyKind::Struct:
510 if (const auto *fields = value->getIf<Value::Object>()) {
511 for (const auto &[key, entry] : *fields) {
512 const std::string elementId = id + "_" + sanitize(key);
513 if (const auto *boolean = entry.getIf<bool>())
514 host.setCheckedById(elementId, *boolean);
515 else
516 host.setValueTextById(elementId, valueText(entry));
517 }
518 }
519 break;
520 case PropertyKind::String:
521 case PropertyKind::AssetRef:
522 case PropertyKind::ObjectRef:
523 case PropertyKind::Auto:
524 if (const auto *textValue = value->getIf<std::string>())
525 host.setValueTextById(id, *textValue);
526 break;
527 case PropertyKind::Action:
528 case PropertyKind::ReadOnlyText:
529 break;
530 }
531 }
532}
533
535 : model_(model), options_(std::move(options)) {
536 observe();
537}
538
540 subscription_.dispose();
541 model_ = model;
542 observe();
543 markDirty();
544}
545
547 options_ = std::move(options);
548 markDirty();
549}
550
552 if (!model_) return column({}, options_.idPrefix + "root");
553 return buildPropertyView(*model_, options_);
554}
555
556void PropertyComponent::observe() {
557 if (!model_) return;
558 subscription_ = model_->subscribe([this](const property_access::PropertyChange &) { markDirty(); });
559}
560
561} // namespace eve::ui
std::string selected
SQObjectPtr key
Definition ECS.cpp:155
std::vector< std::string > fields
Definition ECS.cpp:42
int rows
std::set< std::string > choices
std::string label
std::string id
Poco::JSON::Object::Ptr result
bool readOnly
std::array< std::uint64_t, kPixelChunkSize *kPixelChunkSize > updated
std::string path
Definition PlayHost.cpp:111
Object::Ptr value
glm::mat4 model
double number
bool found
std::string text
ScriptStructure out
unsigned column
size_t end
std::string kind
double current
std::string element
const SquirrelValueOptions & options
int count
Cell cell
bool visible
Json object
int children
Definition TreeMesh.cpp:432
UIHostHandle host
const char * category
uint32_t index
void dispose() noexcept
Cancels this registration; safe to call repeatedly.
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
std::map< std::string, Value > Object
Definition Value.h:34
std::vector< Value > Array
Definition Value.h:33
Renderer- and transaction-independent MVVM property surface.
virtual Subscription subscribe(ChangeCallback callback)=0
Observe changes until the returned token is destroyed.
void markDirty()
Schedule one rebuild; repeated calls before the next preparation phase coalesce. @thread Owner thread...
Definition Component.cpp:45
property_access::IPropertyAccess * model() const
Return the currently bound property model, or null when unbound.
void bind(property_access::IPropertyAccess *model)
Replace the model and reconnect change observation.
void setOptions(PropertyViewOptions options)
Replace generation policy and mark the component dirty.
WidgetDesc build() override
Build the current schema-driven tree.
ECS mount point for one UI panel/screen. Subclass to attach UI to game entities, e....
Definition UIHost.h:284
Result< double > numericValue(const Value &value)
Read an Integer or Number as an owning double without applying domain validation.
constexpr HexDirection next(HexDirection d) noexcept
The next direction clockwise (NW wraps to NE).
Definition HexMetrics.h:76
constexpr bool hasFlag(PropertyFlag value, PropertyFlag flag)
True when flag.
PropertyFlag
Cross-host property visibility and editing flags.
PropertyKind
Semantic property kind used by renderer-independent presenters.
int64_t integer(const RuntimeTensor &v, size_t i=0)
Integer.
WidgetDesc collapsingHeader(std::string label, std::vector< WidgetDesc > children, std::string id, bool defaultOpen)
Collapsible header containing child widgets.
Definition Widget.cpp:814
WidgetDesc buildPropertyView(property_access::IPropertyAccess &model, const PropertyViewOptions &options)
Generate a declarative, two-way property view from any model schema.
WidgetDesc checkbox(std::string label, bool checked, std::string id, std::function< void(bool)> onToggle)
Checkbox with a label; fires onToggle.
Definition Widget.cpp:387
WidgetDesc combo(std::string label, std::vector< std::string > options, int selected, std::string id, std::function< void(float)> onValue)
Combo.
Definition Widget.cpp:439
WidgetDesc slider(std::string label, float value, float minV, float maxV, std::string id, std::function< void(float)> onValue)
Horizontal slider; fires onValue.
Definition Widget.cpp:399
WidgetDesc inputText(std::string label, std::string value, std::string id, std::function< void(const std::string &)> onChange)
Editable text field; fires onTextChange.
Definition Widget.cpp:533
std::string propertyWidgetId(const PropertyViewOptions &options, const std::string &path)
Return the stable widget id generated for a property path.
@ Value
UINode.value (normalized HUD fill)
WidgetDesc buildPropertyField(property_access::IPropertyAccess &model, const std::string &path, const PropertyViewOptions &options)
Generate one field from a model property, or a diagnostic text row.
void syncPropertyView(UIHost &host, const property_access::IPropertyAccess &model, const PropertyViewOptions &options)
Pull current model values into an existing compatible UI tree.
WidgetDesc button(std::string label, std::string id, std::function< void()> onClick)
Clickable button; fires onClick.
Definition Widget.cpp:345
WidgetDesc row(std::vector< WidgetDesc > children, std::string id)
Horizontal elastic layout row.
Definition Widget.cpp:870
WidgetDesc sectionHeader(std::string label, std::string id)
Non-collapsible editor section heading with an accent marker.
Definition Widget.cpp:614
WidgetDesc separator(std::string id)
Horizontal separator line.
Definition Widget.cpp:379
AccessibilityRole
Platform-neutral accessibility role exposed by controls.
Definition UIHost.h:129
enum EVENGINE_API_FOUNDATION Array
OT_ARRAY (editable via Runtime array APIs / ReflectedPropertyModel).
Definition Runtime.h:120
Immutable notification emitted after a model property changes.
Policy controlling schema-to-widget generation for a UI shell.
Declarative widget description (build once / on dirty → flatten into UIHost::Tree).
Definition Widget.h:15
WidgetDesc & withMouseFilter(MouseFilter v)
Selects whether pointer input stops, passes through, or ignores this widget.
Definition Widget.h:185
WidgetDesc & withAccessibility(AccessibilityRole role, std::string name, std::string description={})
Supplies the semantic role and labels exposed to accessibility clients.
Definition Widget.h:215
WidgetDesc & withFocusMode(FocusMode v)
Selects how the widget participates in keyboard focus navigation.
Definition Widget.h:180