mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Remove FullView
This commit is contained in:
parent
8a09702f66
commit
e79cc61e08
@ -23,9 +23,7 @@ fn main() {
|
||||
});
|
||||
|
||||
// And sets the view to read from the other end of the channel.
|
||||
// (We use FullView to force fullscreen because
|
||||
// we have no min_size for the BufferView).
|
||||
siv.add_layer(FullView::new(BufferView::new(200, rx)));
|
||||
siv.add_layer(BufferView::new(200, rx).full_screen());
|
||||
|
||||
siv.run();
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ fn phase_1(s: &mut Cursive) {
|
||||
let cb = s.cb_sink().clone();
|
||||
|
||||
s.pop_layer();
|
||||
s.add_layer(Panel::new(FullView::full_width(ProgressBar::new()
|
||||
s.add_layer(Panel::new(ProgressBar::new()
|
||||
.range(0, n_max)
|
||||
.with_task(move |counter| {
|
||||
// This closure will be called in a separate thread.
|
||||
@ -52,7 +52,8 @@ fn phase_1(s: &mut Cursive) {
|
||||
|
||||
// When we're done, send a callback through the channel
|
||||
cb.send(Box::new(coffee_break)).unwrap();
|
||||
}))));
|
||||
})
|
||||
.full_width()));
|
||||
}
|
||||
|
||||
fn coffee_break(s: &mut Cursive) {
|
||||
@ -87,7 +88,7 @@ fn phase_2(s: &mut Cursive) {
|
||||
}
|
||||
|
||||
s.pop_layer();
|
||||
s.add_layer(Dialog::new(FullView::full_width(linear))
|
||||
s.add_layer(Dialog::new(linear.full_width())
|
||||
.title("Just a moment..."));
|
||||
|
||||
// And we start the worker thread.
|
||||
|
@ -9,8 +9,8 @@
|
||||
pub use {Cursive, Printer, With};
|
||||
pub use event::{Event, Key};
|
||||
pub use view::{Boxable, Identifiable, Selector, View};
|
||||
pub use views::{BoxView, Button, Checkbox, Dialog, EditView, FullView,
|
||||
IdView, KeyEventView, LinearLayout, ListView, Panel,
|
||||
ProgressBar, SelectView, TextArea, TextView};
|
||||
pub use views::{BoxView, Button, Checkbox, Dialog, EditView, IdView,
|
||||
KeyEventView, LinearLayout, ListView, Panel, ProgressBar,
|
||||
SelectView, TextArea, TextView};
|
||||
pub use vec::Vec2;
|
||||
pub use menu::MenuTree;
|
||||
|
@ -1,62 +0,0 @@
|
||||
use view::{View, ViewWrapper};
|
||||
use direction::Orientation;
|
||||
use vec::Vec2;
|
||||
|
||||
/// Simple wrapper view that asks for all the space it can get.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use cursive::prelude::*;
|
||||
/// let view = FullView::new(TextView::new("Big box for little text!"));
|
||||
/// ```
|
||||
pub struct FullView<T: View> {
|
||||
view: T,
|
||||
orientation: Option<Orientation>,
|
||||
}
|
||||
|
||||
impl<T: View> FullView<T> {
|
||||
/// Wraps the given view into a new FullView.
|
||||
///
|
||||
/// It will always take the entire space available.
|
||||
pub fn new(view: T) -> Self {
|
||||
FullView {
|
||||
view: view,
|
||||
orientation: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new wrapper around `view` with full width.
|
||||
///
|
||||
/// It will always take the maximum width available.
|
||||
pub fn full_width(view: T) -> Self {
|
||||
FullView {
|
||||
view: view,
|
||||
orientation: Some(Orientation::Horizontal),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new wrapper around `view` with full height.
|
||||
///
|
||||
/// It will always take the maximum height available.
|
||||
pub fn full_height(view: T) -> Self {
|
||||
FullView {
|
||||
view: view,
|
||||
orientation: Some(Orientation::Vertical),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: View> ViewWrapper for FullView<T> {
|
||||
wrap_impl!(&self.view);
|
||||
|
||||
fn wrap_get_min_size(&mut self, mut req: Vec2) -> Vec2 {
|
||||
if let Some(orientation) = self.orientation {
|
||||
let child_size = self.view.get_min_size(req);
|
||||
let orientation = orientation.swap();
|
||||
*orientation.get_ref(&mut req) = orientation.get(&child_size);
|
||||
}
|
||||
|
||||
req
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ mod checkbox;
|
||||
mod dialog;
|
||||
mod dummy;
|
||||
mod edit_view;
|
||||
mod full_view;
|
||||
mod id_view;
|
||||
mod key_event_view;
|
||||
mod linear_layout;
|
||||
@ -30,7 +29,6 @@ pub use self::checkbox::Checkbox;
|
||||
pub use self::dialog::Dialog;
|
||||
pub use self::dummy::DummyView;
|
||||
pub use self::edit_view::EditView;
|
||||
pub use self::full_view::FullView;
|
||||
pub use self::key_event_view::KeyEventView;
|
||||
pub use self::linear_layout::LinearLayout;
|
||||
pub use self::list_view::ListView;
|
||||
|
Loading…
Reference in New Issue
Block a user