From e79cc61e08a08e27dc6ae6f55428bcb0f98903e7 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Thu, 4 Aug 2016 20:03:48 -0700 Subject: [PATCH] Remove FullView --- examples/logs.rs | 4 +-- examples/progress.rs | 7 +++-- src/prelude.rs | 6 ++-- src/views/full_view.rs | 62 ------------------------------------------ src/views/mod.rs | 2 -- 5 files changed, 8 insertions(+), 73 deletions(-) delete mode 100644 src/views/full_view.rs diff --git a/examples/logs.rs b/examples/logs.rs index f39337c..0c7a7d9 100644 --- a/examples/logs.rs +++ b/examples/logs.rs @@ -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(); } diff --git a/examples/progress.rs b/examples/progress.rs index 5cfc962..b0645c6 100644 --- a/examples/progress.rs +++ b/examples/progress.rs @@ -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. diff --git a/src/prelude.rs b/src/prelude.rs index d9e90b9..578f081 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -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; diff --git a/src/views/full_view.rs b/src/views/full_view.rs deleted file mode 100644 index 322831e..0000000 --- a/src/views/full_view.rs +++ /dev/null @@ -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 { - view: T, - orientation: Option, -} - -impl FullView { - /// 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 ViewWrapper for FullView { - 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 - } -} diff --git a/src/views/mod.rs b/src/views/mod.rs index 6824f9c..2589cbf 100644 --- a/src/views/mod.rs +++ b/src/views/mod.rs @@ -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;