Struct cursive::views::StackView [−][src]
pub struct StackView { /* fields omitted */ }
Expand description
Simple stack of views. Only the top-most view is active and can receive input.
Implementations
Returns true
if position
points to a valid layer.
Returns false
if it exceeds the bounds.
Adds a new full-screen layer on top of the stack.
Fullscreen layers have no shadow.
Adds new view on top of the stack in the center of the screen.
Adds new view on top of the stack in the center of the screen.
Chainable variant.
Returns a reference to the layer at the given position.
Returns a mutable reference to the layer at the given position.
Looks for the layer containing a view with the given name.
Returns Some(pos)
if self.get(pos)
has the given name,
or is a parent of a view with this name.
Returns None
if the given name is not found.
Note that the returned position may be invalidated if some layers are removed from the view.
Examples
let mut stack = StackView::new();
stack.add_layer(TextView::new("Back"));
stack.add_layer(Dialog::around(TextView::new("Middle").with_name("text")));
stack.add_layer(TextView::new("Front"));
assert_eq!(stack.find_layer_from_name("text"), Some(LayerPosition::FromBack(1)));
Adds a new full-screen layer on top of the stack.
Chainable variant.
Adds a new transparent layer on top of the stack.
Chainable variant.
Adds a view on top of the stack.
Adds a transparent view on top of the stack in the center of the screen.
pub fn add_transparent_layer_at<T>(&mut self, position: XY<Offset>, view: T) where
T: IntoBoxedView,
pub fn add_transparent_layer_at<T>(&mut self, position: XY<Offset>, view: T) where
T: IntoBoxedView,
Adds a transparent view on top of the stack.
Adds a view on top of the stack at the given position.
Chainable variant.
pub fn remove_layer(
&mut self,
position: LayerPosition
) -> Box<dyn View + 'static, Global>ⓘ
pub fn remove_layer(
&mut self,
position: LayerPosition
) -> Box<dyn View + 'static, Global>ⓘ
Remove the top-most layer.
Computes the offset of the selected view.
👎 Deprecated since 0.17.0: Use StackView::layer_offset instead.
Use StackView::layer_offset instead.
Computes the offset of the current top view.
Returns the size for each layer in this view.
Moves a layer to a new position in the stack.
This only affects the elevation of a layer (whether it is drawn over or under other views).
Panics
If either from
or to
is out of bounds.
Background drawing
Drawing functions are split into forground and background to ease inserting layers under the stackview but above its background.
you probably just want to call draw()
Trait Implementations
Draws the view with the given printer (includes bounds) and focus. Read more
Called when an event is received (key press, mouse event, …). Read more
Called once the size for this view has been decided. Read more
Returns the minimum size the view requires with the given restrictions. Read more
Attempt to give this view the focus. Read more
pub fn call_on_any(
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
pub fn call_on_any(
&mut self,
selector: &Selector<'_>,
callback: &'a mut (dyn FnMut(&mut (dyn View + 'static)) + 'a)
)
Runs a closure on the view identified by the given selector. Read more
Moves the focus to the view identified by the given selector. Read more
Should return true
if the view content changed since the last call
to layout()
. Read more
What part of the view is important and should be visible? Read more
Auto Trait Implementations
impl !RefUnwindSafe for StackView
impl !UnwindSafe for StackView
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn into_boxed_view(self) -> Box<dyn View + 'static, Global>ⓘ
pub fn into_boxed_view(self) -> Box<dyn View + 'static, Global>ⓘ
Returns a Box<View>
.
Wraps self
in a ResizedView
with the given size constraints.
Wraps self
into a fixed-size ResizedView
.
Wraps self
into a fixed-width ResizedView
.
Wraps self
into a fixed-width ResizedView
.
Wraps self
into a full-screen ResizedView
.
Wraps self
into a full-width ResizedView
.
Wraps self
into a full-height ResizedView
.
Wraps self
into a limited-size ResizedView
.
Wraps self
into a limited-width ResizedView
.
Wraps self
into a limited-height ResizedView
.
Wraps self
into a ResizedView
at least sized size
.
Wraps self
in a ResizedView
at least min_width
wide.
Wraps self
in a ResizedView
at least min_height
tall.
Wraps self
in a ScrollView
.
Calls the given closure and return the result. Read more
Calls the given closure on self
.