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§
- property_
args - New
Box<PropertyArgs>box from a property and value. - property_
id - New
PropertyIdthat represents the type and name. - property_
info - New
PropertyInfofrom property path. - property_
input_ types - Gets the strong input storage types from a property path.
- source_
location - New
SourceLocationthat represents the location you call this macro. - widget_
type - Gets the
WidgetTypeinfo of a widget.
Structs§
- AnyWhen
ArcHandler Builder - A
whenbuilder forAnyArcHandlervalues. - Builder
Property - Represents a property removed from
WidgetBuilding. - Builder
Property Mut - Represents a mutable reference to property in
WidgetBuilderorWidgetBuilding. - Builder
Property Ref - Represents a property in
WidgetBuilderorWidgetBuilding. - Importance
- Value that indicates the override importance of a property instance, higher overrides lower.
- Nest
Group - Property nest position group.
- Nest
Position - Represents the sort index of a property or intrinsic node in a widget instance.
- Property
Attribute - Represents a custom build action targeting a property input that is applied after
whenis build. - Property
Attribute Args - Arguments for
PropertyAttribute<I>build action. - Property
Attribute When - Data for a property attribute associated with an
WhenInfo. - Property
Id - Unique ID of a property implementation.
- Property
Info - Property info.
- Property
Input - Property input info.
- Property
Input Types - Represents the strong types of each input of a property.
- Property
NewArgs - Args for
PropertyInfo::newclosure. - Source
Location - A location in source-code.
- When
Info - Represents a
whenblock in a widget. - When
Input - Input var read in a
whencondition expression. - When
Input Var - Represents a
WhenInputvariable that can be rebound. - Widget
Builder - Widget instance builder.
- Widget
Builder Properties - Direct property access in
WidgetBuilderandWidgetBuilding. - Widget
Building - Represents a finalizing
WidgetBuilder. - Widget
Type - Unique identifier of a widget type.
Enums§
- Input
Kind - Kind of property input.
- When
Input Member - Represents what member and how it was accessed in a
WhenInput.
Traits§
- Property
Args - Represents a property instantiation request.
Type Aliases§
- Property
Attributes - Property attribute build actions that must be applied to property args.
- Property
Attributes When Data - Data for property build actions associated with when condition assigns.