Expand description
Window layers.
The window layers is a z-order stacking panel that fills the window content area, widgets can be inserted
with a z-index that is the LayerIndex. Layers can be anchored to a normal widget, positioned relative
to it with linked visibility.
The LAYERS service can be used to insert and remove layers, the example below uses it to toggle a
an adorner positioned relative to the button that inserts and removes it.
use zng::prelude::*;
let inserted = var(false);
let anchored = WidgetId::new_unique();
Button! {
on_click = hn!(inserted, |_| {
if !inserted.get() {
LAYERS.insert_anchored(
LayerIndex::ADORNER,
WIDGET.id(),
layer::AnchorOffset::out_top(),
Text! {
id = anchored;
txt = "Example";
widget::background_color = colors::BLUE;
layout::y = 5;
},
);
} else {
LAYERS.remove(anchored);
}
inserted.set(!inserted.get());
});
layout::align = layout::Align::CENTER;
child = Text!(inserted.map(|&o| if o { "Remove Layer" } else { "Insert Layer" }.into()));
}Node operations always apply to the window content first then the layers, even with parallelism enabled, this means that layers always render over the window content and that layer widgets can react to normal widget updates within the same frame.
§Full API
See zng_wgt_layer for the full layers API.
Structs§
- Anchor
Mode - Defines what properties the layered widget takes from the anchor widget.
- Anchor
Offset - Represents two points that position a layer widget with its anchor widget.
- LAYERS
- Windows layers.
- Layer
Index - Represents a layer in a window.
Enums§
- Anchor
Size - Options for
AnchorModesize constraints. - Anchor
Transform - Options for
AnchorMode::transform.
Statics§
- LAYERS_
INSERT_ CMD - Insert a layer widget on the scoped window.
- LAYERS_
REMOVE_ CMD - Remove a layer widget on the scoped window.
Functions§
- adorner
PCustom layered foreground.- adorner_
fn PCustom layered foreground generated using aWidgetFn<()>.