mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Add chainable methods for StackView
This commit is contained in:
parent
bdbf6d759e
commit
2643ecbb15
@ -1,5 +1,6 @@
|
|||||||
use Printer;
|
use Printer;
|
||||||
|
|
||||||
|
use ::With;
|
||||||
use direction::Direction;
|
use direction::Direction;
|
||||||
use event::{Event, EventResult};
|
use event::{Event, EventResult};
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
@ -79,6 +80,24 @@ impl StackView {
|
|||||||
self.add_layer_at(Position::center(), view);
|
self.add_layer_at(Position::center(), view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds new view on top of the stack in the center of the screen.
|
||||||
|
///
|
||||||
|
/// Chainable variant.
|
||||||
|
pub fn layer<T>(self, view: T) -> Self
|
||||||
|
where T: 'static + View
|
||||||
|
{
|
||||||
|
self.with(|s| s.add_layer(view))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Adds a new full-screen layer on top of the stack.
|
||||||
|
///
|
||||||
|
/// Chainable variant.
|
||||||
|
pub fn fullscreen_layer<T>(self, view: T) -> Self
|
||||||
|
where T: 'static + View
|
||||||
|
{
|
||||||
|
self.with(|s| s.add_fullscreen_layer(view))
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds a view on top of the stack.
|
/// Adds a view on top of the stack.
|
||||||
pub fn add_layer_at<T>(&mut self, position: Position, view: T)
|
pub fn add_layer_at<T>(&mut self, position: Position, view: T)
|
||||||
where T: 'static + View
|
where T: 'static + View
|
||||||
@ -94,6 +113,15 @@ impl StackView {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds a view on top of the stack.
|
||||||
|
///
|
||||||
|
/// Chainable variant.
|
||||||
|
pub fn layer_at<T>(self, position: Position, view: T) -> Self
|
||||||
|
where T: 'static + View
|
||||||
|
{
|
||||||
|
self.with(|s| s.add_layer_at(position, view))
|
||||||
|
}
|
||||||
|
|
||||||
/// Remove the top-most layer.
|
/// Remove the top-most layer.
|
||||||
pub fn pop_layer(&mut self) {
|
pub fn pop_layer(&mut self) {
|
||||||
self.layers.pop();
|
self.layers.pop();
|
||||||
|
Loading…
Reference in New Issue
Block a user