Expand description
Widget and property builder types.
§Examples
The example declares a new widget type, ShowProperties!
, that inherits from Text!
and display what properties
are set on itself by accessing the WidgetBuilder
at two points. First call is directly in the widget_intrinsic
that
is called after inherited intrinsics, but before the instance properties are set. Second call is in a build action that is called when
the widget starts building, after the instance properties are set.
mod widgets {
use std::fmt::Write as _;
use zng::prelude_wgt::*;
#[widget($crate::widgets::ShowProperties)]
pub struct ShowProperties(zng::text::Text);
impl ShowProperties {
fn widget_intrinsic(&mut self) {
let txt = var(Txt::from(""));
widget_set! {
self;
txt = txt.clone();
}
let builder = self.widget_builder();
let mut t = Txt::from("Properties set by default:\n");
for p in builder.properties() {
writeln!(&mut t, "• {}", p.args.property().name).unwrap();
}
builder.push_build_action(move |builder| {
writeln!(&mut t, "\nAll properties set:").unwrap();
for p in builder.properties() {
writeln!(&mut t, "• {}", p.args.property().name).unwrap();
}
txt.set(t.clone());
});
}
}
}
widgets::ShowProperties! {
font_size = 20;
}
§Full API
See zng_app::widget::builder
for the full API.
Macros§
- New
Box<PropertyArgs>
box from a property and value. - New
PropertyId
that represents the type and name. - New
PropertyInfo
from property path. - Gets the strong input storage types from a property path.
- New
SourceLocation
that represents the location you call this macro. - Gets the
WidgetType
info of a widget.
Structs§
- A
when
builder forAnyArcWidgetHandler
values. - Represents a
WidgetHandler<A>
that can be reused. - Represents a property removed from
WidgetBuilding
. - Represents a mutable reference to property in
WidgetBuilder
orWidgetBuilding
. - Represents a property in
WidgetBuilder
orWidgetBuilding
. - Value that indicates the override importance of a property instance, higher overrides lower.
- Property nest position group.
- Represents the sort index of a property or intrinsic node in a widget instance.
- Represents a custom build action targeting a property input that is applied after
when
is build. - Arguments for
PropertyBuildAction<I>
. - Unique ID of a property implementation.
- Property info.
- Property input info.
- Represents the strong types of each input of a property.
- Args for
PropertyInfo::new
. - A location in source-code.
- Data for a custom when build action associated with an
WhenInfo
. - Represents a
when
block in a widget. - Input var read in a
when
condition expression. - Represents a
WhenInput
variable that can be rebound. - Widget instance builder.
- Direct property access in
WidgetBuilder
andWidgetBuilding
. - Represents a finalizing
WidgetBuilder
. - Unique identifier of a widget type.
Enums§
- Kind of property input.
- Represents what member and how it was accessed in a
WhenInput
.
Traits§
- Represents a property instantiation request.
Type Aliases§
- Property build actions that must be applied to property args.
- Data for property build actions associated with when conditions.