pub struct KnobValues { /* private fields */ }Expand description
Runtime container of one Signal<T> per declared knob, populated
from a KnobSpec and an optional set of variant overrides.
Construct once per (widget, variant) selection in the previewer; pass
by reference to WidgetCatalog::build. The widget reads each knob’s
signal via the typed accessor methods (bool_("disabled"), …) and
threads it into the constructed widget through Prop::Bound.
All accessors return a Signal<T> clone. Cheap — Signal<T> is Rc-backed.
Implementations§
Source§impl KnobValues
impl KnobValues
Sourcepub fn from_spec(spec: &KnobSpec, overrides: Option<&KnobOverrides>) -> Self
pub fn from_spec(spec: &KnobSpec, overrides: Option<&KnobOverrides>) -> Self
Build a fresh runtime view for a spec, applying optional variant overrides on top of each knob’s declared default.
pub fn bool_(&self, id: &str) -> Signal<bool>
pub fn opt_bool(&self, id: &str) -> Signal<Option<bool>>
pub fn i32_(&self, id: &str) -> Signal<i32>
pub fn opt_i32(&self, id: &str) -> Signal<Option<i32>>
pub fn f32_(&self, id: &str) -> Signal<f32>
pub fn opt_f32(&self, id: &str) -> Signal<Option<f32>>
pub fn text(&self, id: &str) -> Signal<String>
pub fn opt_text(&self, id: &str) -> Signal<Option<String>>
pub fn choice(&self, id: &str) -> Signal<usize>
Sourcepub fn enum_(&self, id: &str) -> Signal<usize>
pub fn enum_(&self, id: &str) -> Signal<usize>
Enum knobs share the Choice storage (a usize index); alias of
choice that reads clearer at enum build sites.
pub fn text_role(&self, id: &str) -> Signal<TextRole>
pub fn surface_role(&self, id: &str) -> Signal<SurfaceRole>
pub fn border_role(&self, id: &str) -> Signal<BorderRole>
pub fn text_style(&self, id: &str) -> Signal<TextStyleRole>
Sourcepub fn bind_all(
&self,
widget_id: WidgetId,
registry: &BindingRegistry,
level: BindingLevel,
)
pub fn bind_all( &self, widget_id: WidgetId, registry: &BindingRegistry, level: BindingLevel, )
Bind every knob signal to widget_id at the given level via
the supplied registry. Used by the canvas to force a rebuild
whenever any knob mutates — many widgets read knob values
once at construction time (no Prop::Bound for every property)
so the catch-all is a rebuild on each change.
Trait Implementations§
Source§impl Clone for KnobValues
impl Clone for KnobValues
Source§fn clone(&self) -> KnobValues
fn clone(&self) -> KnobValues
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more