pub struct WidgetBuilder { /* private fields */ }
Expand description
Widget instance builder.
Implementations§
source§impl WidgetBuilder
impl WidgetBuilder
sourcepub fn new(widget: WidgetType) -> WidgetBuilder
pub fn new(widget: WidgetType) -> WidgetBuilder
New empty default.
sourcepub fn widget_type(&self) -> WidgetType
pub fn widget_type(&self) -> WidgetType
The widget that started this builder.
sourcepub fn push_property(
&mut self,
importance: Importance,
args: Box<dyn PropertyArgs>,
)
pub fn push_property( &mut self, importance: Importance, args: Box<dyn PropertyArgs>, )
Insert/override a property.
You can use the property_args!
macro to collect args for a property.
sourcepub fn push_property_positioned(
&mut self,
importance: Importance,
position: NestPosition,
args: Box<dyn PropertyArgs>,
)
pub fn push_property_positioned( &mut self, importance: Importance, position: NestPosition, args: Box<dyn PropertyArgs>, )
Insert property with custom nest position.
sourcepub fn push_when(&mut self, importance: Importance, when: WhenInfo)
pub fn push_when(&mut self, importance: Importance, when: WhenInfo)
Insert a when
block.
sourcepub fn push_unset(&mut self, importance: Importance, property_id: PropertyId)
pub fn push_unset(&mut self, importance: Importance, property_id: PropertyId)
Insert a name = unset!;
property.
sourcepub fn push_property_build_action(
&mut self,
property_id: PropertyId,
action_name: &'static str,
importance: Importance,
input_actions: Vec<Box<dyn AnyPropertyBuildAction>>,
)
pub fn push_property_build_action( &mut self, property_id: PropertyId, action_name: &'static str, importance: Importance, input_actions: Vec<Box<dyn AnyPropertyBuildAction>>, )
Add or override custom builder actions that are called to finalize the inputs for a property.
The importance
overrides previous build action of the same name and property. The input_actions
vec must
contain one action for each property input.
sourcepub fn push_unset_property_build_action(
&mut self,
property_id: PropertyId,
action_name: &'static str,
importance: Importance,
)
pub fn push_unset_property_build_action( &mut self, property_id: PropertyId, action_name: &'static str, importance: Importance, )
Insert a property build action filter.
sourcepub fn clear_property_build_actions(&mut self)
pub fn clear_property_build_actions(&mut self)
Remove all registered property build actions.
sourcepub fn push_build_action(
&mut self,
action: impl FnMut(&mut WidgetBuilding) + Send + 'static,
)
pub fn push_build_action( &mut self, action: impl FnMut(&mut WidgetBuilding) + Send + 'static, )
Add an action
closure that is called every time this builder or a clone of it builds a widget instance.
sourcepub fn clear_build_actions(&mut self)
pub fn clear_build_actions(&mut self)
Remove all registered build actions.
sourcepub fn is_custom_build(&self) -> bool
pub fn is_custom_build(&self) -> bool
Returns true
if a custom build handler is registered.
sourcepub fn set_custom_build<R>(
&mut self,
build: impl FnMut(WidgetBuilder) -> R + Send + 'static,
)where
R: UiNode,
pub fn set_custom_build<R>(
&mut self,
build: impl FnMut(WidgetBuilder) -> R + Send + 'static,
)where
R: UiNode,
Set a build
closure to run instead of default_build
when build
is called.
Overrides the previous custom build, if any was set.
sourcepub fn clear_custom_build(&mut self)
pub fn clear_custom_build(&mut self)
Remove the custom build handler, if any was set.
sourcepub fn extend(&mut self, other: WidgetBuilder)
pub fn extend(&mut self, other: WidgetBuilder)
Apply other
over self
.
All properties, unsets, whens, build actions and custom build of other
are inserted in self
,
override importance rules apply, other
items only replace self
items if they have the
same or greater importance.
Note that properties of the same position index from other
are pushed after properties of the
same position in self
, this means that fill properties of other
will render over fill properties
of self
.
sourcepub fn has_properties(&self) -> bool
pub fn has_properties(&self) -> bool
If any property is present in the builder.
sourcepub fn has_unsets(&self) -> bool
pub fn has_unsets(&self) -> bool
If any unset filter is present in the builder.
sourcepub fn split_off(
&mut self,
properties: impl IntoIterator<Item = PropertyId>,
out: &mut WidgetBuilder,
)
pub fn split_off( &mut self, properties: impl IntoIterator<Item = PropertyId>, out: &mut WidgetBuilder, )
Move all properties
to a new builder.
The properties are removed from self
, any when
assign is also moved, properties used in WhenInput
that
affect the properties are cloned or moved into the new builder.
Note that properties can depend on others in the widget contextually, this is not preserved on split-off.
sourcepub fn build(self) -> Box<dyn UiNodeBoxed>
pub fn build(self) -> Box<dyn UiNodeBoxed>
Instantiate the widget.
If a custom build is set it is run, unless it is already running, otherwise the default_build
is called.
sourcepub fn default_build(self) -> Box<dyn UiNodeBoxed>
pub fn default_build(self) -> Box<dyn UiNodeBoxed>
Instantiate the widget.
Runs all build actions, but ignores custom build.
Methods from Deref<Target = WidgetBuilderProperties>§
sourcepub fn property(
&self,
property_id: PropertyId,
) -> Option<BuilderPropertyRef<'_>>
pub fn property( &self, property_id: PropertyId, ) -> Option<BuilderPropertyRef<'_>>
Reference the property, if it is present.
sourcepub fn property_mut(
&mut self,
property_id: PropertyId,
) -> Option<BuilderPropertyMut<'_>>
pub fn property_mut( &mut self, property_id: PropertyId, ) -> Option<BuilderPropertyMut<'_>>
Modify the property, if it is present.
sourcepub fn properties(&self) -> impl Iterator<Item = BuilderPropertyRef<'_>>
pub fn properties(&self) -> impl Iterator<Item = BuilderPropertyRef<'_>>
Iterate over the current properties.
The properties may not be sorted in the correct order if the builder has never built.
sourcepub fn properties_mut(&mut self) -> impl Iterator<Item = BuilderPropertyMut<'_>>
pub fn properties_mut(&mut self) -> impl Iterator<Item = BuilderPropertyMut<'_>>
iterate over mutable references to the current properties.
sourcepub fn capture_value<T>(&mut self, property_id: PropertyId) -> Option<T>where
T: VarValue,
pub fn capture_value<T>(&mut self, property_id: PropertyId) -> Option<T>where
T: VarValue,
Flags the property as captured and downcast the input value.
Unlike other property kinds you can capture values in the WidgetBuilder
, note that the value may not
the final value, unless you are capturing on build.
Other property kinds can only be captured in WidgetBuilding
as
their values strongly depend on the final when
blocks that are only applied after building starts.
sourcepub fn capture_value_or_else<T>(
&mut self,
property_id: PropertyId,
or_else: impl FnOnce() -> T,
) -> Twhere
T: VarValue,
pub fn capture_value_or_else<T>(
&mut self,
property_id: PropertyId,
or_else: impl FnOnce() -> T,
) -> Twhere
T: VarValue,
Flags the property as captured and downcast the input value, or calls or_else
to generate the value.
sourcepub fn capture_value_or_default<T>(&mut self, property_id: PropertyId) -> T
pub fn capture_value_or_default<T>(&mut self, property_id: PropertyId) -> T
Flags the property as captured and downcast the input value, or returns the default value.
Trait Implementations§
source§impl Clone for WidgetBuilder
impl Clone for WidgetBuilder
source§fn clone(&self) -> WidgetBuilder
fn clone(&self) -> WidgetBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for WidgetBuilder
impl Debug for WidgetBuilder
source§impl Deref for WidgetBuilder
impl Deref for WidgetBuilder
source§type Target = WidgetBuilderProperties
type Target = WidgetBuilderProperties
source§impl DerefMut for WidgetBuilder
impl DerefMut for WidgetBuilder
source§impl From<StyleBuilder> for WidgetBuilder
impl From<StyleBuilder> for WidgetBuilder
source§fn from(t: StyleBuilder) -> WidgetBuilder
fn from(t: StyleBuilder) -> WidgetBuilder
source§impl From<WidgetBuilder> for StyleBuilder
impl From<WidgetBuilder> for StyleBuilder
source§fn from(p: WidgetBuilder) -> StyleBuilder
fn from(p: WidgetBuilder) -> StyleBuilder
Auto Trait Implementations§
impl Freeze for WidgetBuilder
impl !RefUnwindSafe for WidgetBuilder
impl Send for WidgetBuilder
impl Sync for WidgetBuilder
impl Unpin for WidgetBuilder
impl !UnwindSafe for WidgetBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more