Expand description
The value store: every value a widget, a setting or an agent edits
lives here at a stable path (settings/theme, view/zoom), never in a
widget.
- Each path has a
Descriptor: type, hard and soft range, fine and coarse steps, unit, display scale and precision, default, label, choices. - Every write is a
Set: an absolute value, a relative step, reset, top or bottom, with itsOrigin. The answer says what was applied and whether it was clamped; a refusal says why and gives the current value. - During a gesture (a drag), the paths it touched belong to it: a write
from another origin is refused. Otherwise the last writer wins; a
writer may ask to write only if nothing changed since it read
(
if_seq). - Every change is told to the listeners of its path and kept in a
short journal (
Changed: path, old, new, origin, sequence); a write equal to the value changes nothing and tells nothing, so a change never loops back. - Undo: one step per gesture or group, else one per write; the newest
HISTORY_CAPsteps are kept unless the host sets another cap. An undo or a redo never writes into a drag still going, the dragger’s own included. Steps go to a history by scope (ADR 0014): the application’s (APP) unless the write names another (Set::history, or the oneenter_historyset, such as the settings window’s). Each step has an id, its time on the store’s clock (Store::set_clock) and the place it was made in (Store::set_place); writes carrying the same merge key (Set::merge) from one origin less than a second apart are one step, untilStore::seal(the focus left). - A history also keeps its snapshots (
Store::take_snapshot, restored as a new step), the redo lists new steps dropped (Store::replaced_in, reachable byStore::jump_in), and undoes one step out of order unless a later step changed the same path (Store::undo_step_in);Store::values_atsays what differs at a point, for a preview. - A value changed outside a history since its step (an untracked
write,
Store::import, another history) keeps that change: undo, redo, jumps and cancels leave it and list it (Store::take_skipped). A group’s step goes before the steps made after its first write. - Paths are owned: a plugin’s settings and listeners go with it.
- One writer per value: a write names the scope issuing it
(
Set::by, or the scopeenter_scopeset, such as the plugin whose command runs). A scope that is not the path’s owner, not one of itsWritersand not the framework (acting for a person: the settings form, a bound widget, the user’svalue.set) is refused, or only warned about underWriterCheck::Warn. An agent or a script writes as itself (Origin::writer). A write naming no scope is the application’s own and is not checked; undo, redo and restoring saved values are never refused, but for an undo or redo issued by a writer (Store::undo_by).
use egui_pop_model::commands::Origin;
use egui_pop_model::ids::OwnerId;
use egui_pop_model::values::{Change, Descriptor, Set, Store, Value};
let mut store = Store::new();
store
.declare(&OwnerId::FRAMEWORK, "settings/volume", Descriptor::float("Volume", 0.0, 1.0, 0.5))
.unwrap();
let applied = store
.set(Set::new("settings/volume", Change::To(Value::Float(2.0)), Origin::User))
.unwrap();
assert_eq!(applied.value, Value::Float(1.0)); // clamped to the rangeRe-exports§
Structs§
- Applied
- What a write did.
- Changed
- A value changed.
- Descriptor
- What a value is and how it is shown and moved.
- Dropped
Steps - The undo steps one history lost when an owner went: those changing one of its paths, undo, redo and kept branches alike.
- Entry
- A value at its path.
- Gesture
Id - History
Guard - Leaves the history
enter_historyentered when dropped. - Listener
Id - A change listener, by id.
- Owner
Removal - What
Store::remove_owner_reportremoved with an owner. - Path
Hint - A text that names a path on disk: what it names and, for a file, the
extensions accepted (none: any). A form shows it with a Browse button,
whose chooser
title,purposeandfilter_namethe hint may give. Built withPathHint::neworDescriptor::path: a field added later breaks nobody. - Scope
Guard - Leaves the scope
enter_scopeentered when dropped. - Set
- A write.
- Settings
Doc - The
settingsdocument: the values that differ from their default. - Skipped
- A value an undo, a redo, a jump or a cancel left as it was: it was changed outside the history since the step (an untracked write, a settings file read back, another history), so the outside change is kept.
- Step
- One undo step.
- Store
- The store.
- Stray
Write - A write from a scope that is not one of a path’s writers.
Enums§
- Change
- What a write asks for.
- Clamped
- Which range held a write back.
- Declare
Error - Why a path could not be declared.
- Path
Kind - What a path names: a directory or a file.
- Refused
- Why a write was refused; each gives the current value.
- Type
- The type of a value.
- Value
- A value the store holds.
- Writer
Check - What a write from a scope that is not one of a path’s writers gets.
- Writers
- Who may write a path, besides the framework acting for a person (see
Store::set).
Constants§
- HISTORY_
CAP - How many undo steps a store keeps by default, the oldest dropped
first (
Store::set_history_cap). - JOURNAL
- How many changes the journal keeps.
- NOT_
A_ WRITER - The diagnostic code of a write from a scope that is not a writer.
Functions§
- check_
path - Checks a path: segments with the id syntax, separated by
/. - current_
history - The history
enter_historyset on this thread, elseAPP. - current_
scope - The scope
enter_scopeset on this thread, if any. - enter_
history - Steps made on this thread go to
scope’s history while the guard lives, unless a write names its own (Set::history); a gesture or a group keeps the history it was opened in. The settings window entersSETTINGSwhile it draws its form. Histories nest. - enter_
scope - Writes on this thread that name no scope are issued by
scopewhile the guard lives (the application sets the plugin connecting, the owner of the command running, the plugin a lifecycle hook belongs to). Scopes nest. - register
- Declares the
value.*commands on a registry, over a shared store, owned byowner. - register_
with - As
register, on a registry with another handler type:wrapturns each plain handler into one. - settings_
schema - The
settingsdocument’s schema. Version 2 reads a retired pointer profile id as the profile it names (adobeaslightroom); version 3 reads the file picker’s views as the file browser’s modes (listasdetails,gridasthumbnails).