Struct cursive::views::StackView [−][src]
pub struct StackView { /* fields omitted */ }
Simple stack of views. Only the top-most view is active and can receive input.
Methods
impl StackView
[src]
impl StackView
pub fn new() -> Self
[src]
pub fn new() -> Self
Creates a new empty StackView
pub fn add_fullscreen_layer<T>(&mut self, view: T) where
T: IntoBoxedView,
[src]
pub fn add_fullscreen_layer<T>(&mut self, view: T) where
T: IntoBoxedView,
Adds a new full-screen layer on top of the stack.
Fullscreen layers have no shadow.
pub fn add_layer<T>(&mut self, view: T) where
T: IntoBoxedView,
[src]
pub fn add_layer<T>(&mut self, view: T) where
T: IntoBoxedView,
Adds new view on top of the stack in the center of the screen.
pub fn layer<T>(self, view: T) -> Self where
T: IntoBoxedView,
[src]
pub fn layer<T>(self, view: T) -> Self where
T: IntoBoxedView,
Adds new view on top of the stack in the center of the screen.
Chainable variant.
pub fn get(&self, pos: LayerPosition) -> Option<&View>
[src]
pub fn get(&self, pos: LayerPosition) -> Option<&View>
Returns a reference to the layer at the given position.
pub fn get_mut(&mut self, pos: LayerPosition) -> Option<&mut View>
[src]
pub fn get_mut(&mut self, pos: LayerPosition) -> Option<&mut View>
Returns a mutable reference to the layer at the given position.
pub fn find_layer_from_id(&mut self, id: &str) -> Option<LayerPosition>
[src]
pub fn find_layer_from_id(&mut self, id: &str) -> Option<LayerPosition>
Looks for the layer containing a view with the given ID.
Returns Some(pos)
if self.get(pos)
has the given ID,
or is a parent of a view with this ID.
Returns None
if the given ID is not found.
Examples
let mut stack = StackView::new(); stack.add_layer(TextView::new("Back")); stack.add_layer(Dialog::around(TextView::new("Middle").with_id("text"))); stack.add_layer(TextView::new("Front")); assert_eq!(stack.find_layer_from_id("text"), Some(LayerPosition::FromBack(1)));
pub fn fullscreen_layer<T>(self, view: T) -> Self where
T: IntoBoxedView,
[src]
pub fn fullscreen_layer<T>(self, view: T) -> Self where
T: IntoBoxedView,
Adds a new full-screen layer on top of the stack.
Chainable variant.
pub fn transparent_layer<T>(self, view: T) -> Self where
T: IntoBoxedView,
[src]
pub fn transparent_layer<T>(self, view: T) -> Self where
T: IntoBoxedView,
Adds a new transparent layer on top of the stack.
Chainable variant.
pub fn add_layer_at<T>(&mut self, position: Position, view: T) where
T: IntoBoxedView,
[src]
pub fn add_layer_at<T>(&mut self, position: Position, view: T) where
T: IntoBoxedView,
Adds a view on top of the stack.
pub fn add_transparent_layer<T>(&mut self, view: T) where
T: IntoBoxedView,
[src]
pub fn add_transparent_layer<T>(&mut self, view: T) where
T: IntoBoxedView,
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: Position, view: T) where
T: IntoBoxedView,
[src]
pub fn add_transparent_layer_at<T>(&mut self, position: Position, view: T) where
T: IntoBoxedView,
Adds a transparent view on top of the stack.
pub fn layer_at<T>(self, position: Position, view: T) -> Self where
T: IntoBoxedView,
[src]
pub fn layer_at<T>(self, position: Position, view: T) -> Self where
T: IntoBoxedView,
Adds a view on top of the stack.
Chainable variant.
pub fn pop_layer(&mut self) -> Option<Box<View>>
[src]
pub fn pop_layer(&mut self) -> Option<Box<View>>
Remove the top-most layer.
pub fn offset(&self) -> Vec2
[src]
pub fn offset(&self) -> Vec2
Computes the offset of the current top view.
pub fn layer_sizes(&self) -> Vec<Vec2>
[src]
pub fn layer_sizes(&self) -> Vec<Vec2>
Returns the size for each layer in this view.
pub fn move_layer(&mut self, from: LayerPosition, to: LayerPosition)
[src]
pub fn move_layer(&mut self, from: LayerPosition, to: LayerPosition)
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).
pub fn move_to_front(&mut self, layer: LayerPosition)
[src]
pub fn move_to_front(&mut self, layer: LayerPosition)
Brings the given view to the front of the stack.
pub fn move_to_back(&mut self, layer: LayerPosition)
[src]
pub fn move_to_back(&mut self, layer: LayerPosition)
Pushes the given view to the back of the stack.
pub fn reposition_layer(&mut self, layer: LayerPosition, position: Position)
[src]
pub fn reposition_layer(&mut self, layer: LayerPosition, position: Position)
Moves a layer to a new position on the screen.
Has no effect on fullscreen layers Has no effect if layer is not found
pub fn draw_bg(&self, printer: &Printer)
[src]
pub fn draw_bg(&self, printer: &Printer)
Background drawing
Drawing functions are split into forground and background to ease inserting layers under the stackview but above it's background you probably just want to call draw()
pub fn draw_fg(&self, printer: &Printer)
[src]
pub fn draw_fg(&self, printer: &Printer)
Forground drawing
Drawing functions are split into forground and background to ease inserting layers under the stackview but above it's background you probably just want to call draw()
Trait Implementations
impl Default for StackView
[src]
impl Default for StackView
impl View for StackView
[src]
impl View for StackView
fn draw(&self, printer: &Printer)
[src]
fn draw(&self, printer: &Printer)
Draws the view with the given printer (includes bounds) and focus. Read more
fn on_event(&mut self, event: Event) -> EventResult
[src]
fn on_event(&mut self, event: Event) -> EventResult
Called when an event is received (key press, mouse event, ...). Read more
fn layout(&mut self, size: Vec2)
[src]
fn layout(&mut self, size: Vec2)
Called once the size for this view has been decided. Read more
fn required_size(&mut self, size: Vec2) -> Vec2
[src]
fn required_size(&mut self, size: Vec2) -> Vec2
Returns the minimum size the view requires with the given restrictions. Read more
fn take_focus(&mut self, source: Direction) -> bool
[src]
fn take_focus(&mut self, source: Direction) -> bool
This view is offered focus. Will it take it? Read more
fn call_on_any<'a>(&mut self, selector: &Selector, callback: AnyCb<'a>)
[src]
fn call_on_any<'a>(&mut self, selector: &Selector, callback: AnyCb<'a>)
Runs a closure on the view identified by the given selector. Read more
fn focus_view(&mut self, selector: &Selector) -> Result<(), ()>
[src]
fn focus_view(&mut self, selector: &Selector) -> Result<(), ()>
Moves the focus to the view identified by the given selector. Read more
fn needs_relayout(&self) -> bool
[src]
fn needs_relayout(&self) -> bool
Returns true
if the view content changed since last layout phase. Read more
fn important_area(&self, view_size: Vec2) -> Rect
[src]
fn important_area(&self, view_size: Vec2) -> Rect
What part of the view is important and should be visible? Read more