Module widget

Module widget 

Source
Expand description

Widget info, builder and base, UI node and list.

The Wgt! widget is a blank widget that entirely shaped by properties.

use zng::prelude::*;

Wgt! {
    id = "sun";

    widget::background_gradient = {
        axis: 0.deg(),
        stops: color::gradient::stops![hex!(#ff5226), hex!(#ffc926)],
    };
    layout::size = 100;
    widget::corner_radius = 100;
    layout::align = layout::Align::BOTTOM;

    #[easing(2.secs())]
    layout::y = 100;
    when *#widget::is_inited {
        layout::y = -30;
    }
}

To learn more about the widget macros syntax see widget_set!.

To learn more about how widgets are declared see widget.

To learn more about how properties are declared see property.

§Full API

See zng_app::widget, zng_wgt, zng_wgt_fill, zng_wgt_image::border, zng_wgt_image::fill for the full API.

Modules§

builder
Widget and property builder types.
info
Widget info tree and info builder.
node
Widget node types, UiNode, UiVec and others.

Macros§

wgt_fn
Declares a widget function closure.
widget_impl
Implement a property on the widget to strongly associate it with the widget.
widget_set
Sets properties and when condition on a widget builder.

Structs§

BORDER
Coordinates nested borders and corner-radius.
BorderRepeats
Defines how the 9-patch edge slices are used to fill the widths.
BorderSide
The line style and color for the sides of a widget’s border.
BorderSides
The line style and color for each side of a widget’s border.
CornerRadius
Radius of each corner of a border defined from Size values.
EDITORS
Service that provides editor widgets for a given variable.
EditorRequestArgs
Arguments for EDITORS.register.
NonWidgetBase
Base widget for types that build to a custom type that is not used as a part of the UI tree.
OnNodeOpArgs
Arguments for the node operation event properties.
Parallel
Node list methods that are made parallel.
WIDGET
Current context widget.
WeakWidgetFn
Weak reference to a WidgetFn<D>.
Wgt
W Minimal widget.
WidgetBase
Base widget.
WidgetFn
Boxed shared closure that generates a widget for a given data.
WidgetId
Unique ID of a widget.
ZIndex
Position of a widget inside an UI node list render operation.

Enums§

BorderStyle
The line style for the sides of a widget’s border.
CornerRadiusFit
Defines how the corner radius is computed for each usage.
HitTestMode
Defines if and how a widget is hit-tested.
LineOrientation
Orientation of a straight line.
LineStyle
Represents a line style.
RepeatMode
Nine-patch border repeat mode.
Visibility
Widget visibility.
WidgetUpdateMode
Defines how widget update requests inside WIDGET::with_context are handled.

Statics§

IS_MOBILE_VAR
Variable that indicates the context should use mobile UI themes.
PARALLEL_VAR
Defines what node list methods can run in parallel in a widget and descendants.

Traits§

WidgetImpl
Trait implemented by all #[widget].

Functions§

auto_hide
P Defines if the widget only renders if it’s bounds intersects with the viewport auto-hide rectangle.
background
P Custom background. Allows using any other UI node as a background.
background_color
P Fill color background.
background_conic
P Conic gradient background.
background_fn
P Custom background generated using a WidgetFn<()>.
background_gradient
P Linear gradient background.
background_img
P Background image.
background_img_align
P Sets the background image alignment.
background_img_crop
P Sets the background image crop.
background_img_fit
P Sets the background image fit.
background_img_offset
P Sets the background image offset.
background_img_opacity
P Sets the background image opacity.
background_img_repeat
P Sets the background image repeat.
background_img_repeat_spacing
P Sets the background image repeat spacing.
background_radial
P Radial gradient background.
border
P Border widths, color and style.
border_align
P Position of a widget borders in relation to the widget fill.
border_img
P 9-patch image border.
border_img_fill
P Defines if the middle slice of the 9-patch image is also rendered.
border_img_repeat
P Defines how the 9-patch edge slices are used to fill the widths.
border_over
P If the border is rendered over the fill and child visuals.
clip_to_bounds
P Clips the widget child to the area of the widget when set to true.
corner_radius
P Corner radius of widget and inner widgets.
corner_radius_fit
P Defines how the corner_radius is computed for each usage.
enabled
P Defines if default interaction is allowed in the widget and its descendants.
foreground
P Custom foreground fill. Allows using any other UI node as a foreground overlay.
foreground_color
P Fill color overlay.
foreground_conic
P Conic gradient foreground.
foreground_fn
P Custom foreground generated using a WidgetFn<()>.
foreground_gradient
P Linear gradient overlay.
foreground_highlight
P Foreground highlight border overlay.
foreground_img
P Foreground image.
foreground_img_align
P Sets the foreground image alignment.
foreground_img_crop
P Sets the foreground image crop.
foreground_img_fit
P Sets the foreground image fit.
foreground_img_offset
P Sets the foreground image offset.
foreground_img_opacity
P Sets the foreground image opacity.
foreground_img_repeat
P Sets the foreground image repeat.
foreground_img_repeat_spacing
P Sets the foreground image repeat spacing.
foreground_radial
P Radial gradient foreground.
hit_test_mode
P Defines if and how the widget is hit-tested.
inline
P Enforce an inline mode on the widget.
interactive
P Defines if any interaction is allowed in the widget and its descendants.
is_collapsed
P If the widget is Collapsed.
is_disabled
P If the widget is disabled for interaction.
is_enabled
P If the widget is enabled for interaction.
is_hidden
P If the widget is Hidden.
is_hit_testable
P If the widget is visible for hit-tests.
is_inited
P If the widget has been initialized.
is_mobile
P Gets the IS_MOBILE_VAR that indicates the window or widget should use mobile UI themes.
is_visible
P If the widget is Visible.
modal
P Only allow interaction inside the widget, descendants and ancestors.
modal_included
P Include itself in the allow list of another widget that is modal or descendant of modal.
modal_includes
P Extra widgets that are allowed interaction by this widget when it is modal.
on_block
P Widget interactions now blocked.
on_blocked_changed
P Widget interactions where blocked or unblocked.
on_collapse
P Widget visibility changed to collapsed.
on_deinit
P Widget deinited.
on_disable
P Widget normal interactions now disabled.
on_enable
P Widget normal interactions now enabled.
on_enabled_changed
P Widget was enabled or disabled.
on_hide
P Widget visibility changed to hidden.
on_info_init
P Widget info is now available.
on_init
P Widget initialized.
on_interactivity_changed
P Widget interactivity changed.
on_move
P Widget global position changed.
on_node_op
P On any node operation.
on_pre_block
P Preview on_block event.
on_pre_blocked_changed
P Preview on_blocked_changed event.
on_pre_collapse
P Preview on_collapse event.
on_pre_deinit
P Preview on_deinit event.
on_pre_disable
P Preview on_disable event.
on_pre_enable
P Preview on_enable event.
on_pre_enabled_changed
P Preview on_enabled_changed event.
on_pre_hide
P Preview on_hide event.
on_pre_init
P Preview on_init event.
on_pre_interactivity_changed
P Preview on_interactivity_changed event.
on_pre_move
P Preview on_move event.
on_pre_node_op
P Preview on_node_op event.
on_pre_show
P Preview on_show event.
on_pre_transform_changed
P Preview on_transform_changed event.
on_pre_unblock
P Preview on_unblock event.
on_pre_update
P Preview on_update event.
on_pre_vis_disable
P Preview on_vis_disable event.
on_pre_vis_enable
P Preview on_vis_enable event.
on_pre_vis_enabled_changed
P Preview on_vis_enabled_changed event.
on_pre_visibility_changed
P Preview on_visibility_changed event.
on_show
P Widget visibility changed to visible.
on_transform_changed
P Widget global inner transform changed.
on_unblock
P Widget interactions now unblocked.
on_update
P Widget update event.
on_vis_disable
P Widget now looks disabled.
on_vis_enable
P Widget now looks enabled.
on_vis_enabled_changed
P Widget changed to enabled or disabled visuals.
on_visibility_changed
P Widget visibility changed.
parallel
P Defines what node list methods can run in parallel in the widget and descendants.
visibility
P Sets the widget visibility.
z_index
P Defines the render order of a widget in a layout panel.

Attribute Macros§

easing
Expands a property assign to include an easing animation.
property
Expands a function to a widget property.
widget
Expands a struct to a widget struct and macro.
widget_mixin
Expands a struct to a widget mixin.