[−][src]Struct cursive_aligned_view::AlignedView
This struct aligns a child view with a given alignment.
The child view will have its minimum allowed size. Additionally, the child may get cropped if it is larger than the available size.
The padded space around the child view is filled with the View
color from
cursive's color palette.
Usage
The AlignedView
may be used in 2 different ways:
- Via the
Alignable
composition trait - Via normal constructors
Using Alignable
use cursive::Cursive; use cursive::view::Boxable; use cursive::views::{Panel, DummyView}; use cursive_aligned_view::Alignable; fn main() { let mut siv = Cursive::default(); let panel = Panel::new(DummyView) .title("Hello, world!") .fixed_width(20) .align_top_center(); // `align_...` methods from `Alignable` siv.add_fullscreen_layer(panel); // siv.run() }
Constructors
use cursive::Cursive; use cursive::view::Boxable; use cursive::views::{Panel, DummyView}; use cursive_aligned_view::AlignedView; fn main() { let mut siv = Cursive::default(); let panel = Panel::new(DummyView) .title("Hello, world!") .fixed_width(20); let aligned = AlignedView::with_bottom_center(panel); // constructor siv.add_fullscreen_layer(aligned); // siv.run() }
Methods
impl<T: View> AlignedView<T>
[src]
pub fn with_top_left(view: T) -> Self
[src]
Wrap a child view and align it at the top-left of the parent.
pub fn with_top_center(view: T) -> Self
[src]
Wrap a child view and align it at the top-center of the parent.
pub fn with_top_right(view: T) -> Self
[src]
Wrap a child view and align it at the top-right of the parent.
pub fn with_center_left(view: T) -> Self
[src]
Wrap a child view and align it at the center-left of the parent.
pub fn with_center(view: T) -> Self
[src]
Wrap a child view and align it at the center of the parent.
pub fn with_center_right(view: T) -> Self
[src]
Wrap a child view and align it at the center-right of the parent.
pub fn with_bottom_left(view: T) -> Self
[src]
Wrap a child view and align it at the bottom-left of the parent.
pub fn with_bottom_center(view: T) -> Self
[src]
Wrap a child view and align it at the bottom-center of the parent.
pub fn with_bottom_right(view: T) -> Self
[src]
Wrap a child view and align it at the bottom-right of the parent.
pub fn set_top_left(&mut self)
[src]
Set the alignment of this view to top-left.
pub fn set_top_center(&mut self)
[src]
Set the alignment of this view to top-center.
pub fn set_top_right(&mut self)
[src]
Set the alignment of this view to top-right.
pub fn set_center_left(&mut self)
[src]
Set the alignment of this view to center-left.
pub fn set_center(&mut self)
[src]
Set the alignment of this view to center.
pub fn set_center_right(&mut self)
[src]
Set the alignment of this view to center-right.
pub fn set_bottom_left(&mut self)
[src]
Set the alignment of this view to bottom-left.
pub fn set_bottom_center(&mut self)
[src]
Set the alignment of this view to bottom-center.
pub fn set_bottom_right(&mut self)
[src]
Set the alignment of this view to bottom-right.
pub fn alignment(&self) -> &Align
[src]
Get the current alignment of this view.
Trait Implementations
impl<T: View> View for AlignedView<T>
[src]
fn draw(&self, printer: &Printer)
[src]
fn layout(&mut self, size: Vec2)
[src]
fn needs_relayout(&self) -> bool
[src]
fn required_size(&mut self, constraint: Vec2) -> Vec2
[src]
fn on_event(&mut self, ev: Event) -> EventResult
[src]
fn call_on_any<'a>(&mut self, sel: &Selector, cb: AnyCb<'a>)
[src]
fn focus_view(&mut self, sel: &Selector) -> Result<(), ()>
[src]
fn take_focus(&mut self, source: Direction) -> bool
[src]
fn important_area(&self, view_size: Vec2) -> Rect
[src]
Auto Trait Implementations
impl<T> Unpin for AlignedView<T> where
T: Unpin,
T: Unpin,
impl<T> Sync for AlignedView<T> where
T: Sync,
T: Sync,
impl<T> Send for AlignedView<T> where
T: Send,
T: Send,
impl<T> UnwindSafe for AlignedView<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for AlignedView<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Alignable for T where
T: View,
[src]
T: View,
fn align_top_left(self) -> AlignedView<Self>
[src]
fn align_top_center(self) -> AlignedView<Self>
[src]
fn align_top_right(self) -> AlignedView<Self>
[src]
fn align_center_left(self) -> AlignedView<Self>
[src]
fn align_center(self) -> AlignedView<Self>
[src]
fn align_center_right(self) -> AlignedView<Self>
[src]
fn align_bottom_left(self) -> AlignedView<Self>
[src]
fn align_bottom_center(self) -> AlignedView<Self>
[src]
fn align_bottom_right(self) -> AlignedView<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Identifiable for T where
T: View,
[src]
T: View,
impl<T> Boxable for T where
T: View,
[src]
T: View,
fn boxed(self, width: SizeConstraint, height: SizeConstraint) -> BoxView<Self>
[src]
fn fixed_size<S>(self, size: S) -> BoxView<Self> where
S: Into<XY<usize>>,
[src]
S: Into<XY<usize>>,
fn fixed_width(self, width: usize) -> BoxView<Self>
[src]
fn fixed_height(self, height: usize) -> BoxView<Self>
[src]
fn full_screen(self) -> BoxView<Self>
[src]
fn full_width(self) -> BoxView<Self>
[src]
fn full_height(self) -> BoxView<Self>
[src]
fn max_size<S>(self, size: S) -> BoxView<Self> where
S: Into<XY<usize>>,
[src]
S: Into<XY<usize>>,
fn max_width(self, max_width: usize) -> BoxView<Self>
[src]
fn max_height(self, max_height: usize) -> BoxView<Self>
[src]
fn min_size<S>(self, size: S) -> BoxView<Self> where
S: Into<XY<usize>>,
[src]
S: Into<XY<usize>>,
fn min_width(self, min_width: usize) -> BoxView<Self>
[src]
fn min_height(self, min_height: usize) -> BoxView<Self>
[src]
impl<T> With for T
[src]
fn with<F>(self, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),
fn try_with<E, F>(self, f: F) -> Result<Self, E> where
F: FnOnce(&mut Self) -> Result<(), E>,
[src]
F: FnOnce(&mut Self) -> Result<(), E>,
fn with_if<F>(self, condition: bool, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),
impl<T> View for T where
T: ViewWrapper,
[src]
T: ViewWrapper,
fn draw(&self, printer: &Printer)
[src]
fn required_size(&mut self, req: XY<usize>) -> XY<usize>
[src]
fn on_event(&mut self, ch: Event) -> EventResult
[src]
fn layout(&mut self, size: XY<usize>)
[src]
fn take_focus(&mut self, source: Direction) -> bool
[src]
fn call_on_any(
&mut self,
selector: &Selector,
callback: Box<dyn FnMut(&mut (dyn Any + 'static)) + 'a>
)
[src]
&mut self,
selector: &Selector,
callback: Box<dyn FnMut(&mut (dyn Any + 'static)) + 'a>
)
fn needs_relayout(&self) -> bool
[src]
fn focus_view(&mut self, selector: &Selector) -> Result<(), ()>
[src]
fn important_area(&self, size: XY<usize>) -> Rect
[src]
impl<T> Scrollable for T where
T: View,
[src]
T: View,
fn scrollable(self) -> ScrollView<Self>
[src]
impl<T> Finder for T where
T: View,
[src]
T: View,
fn call_on<V, F, R>(&mut self, sel: &Selector, callback: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
V: View + Any,
[src]
F: FnOnce(&mut V) -> R,
V: View + Any,
fn call_on_id<V, F, R>(&mut self, id: &str, callback: F) -> Option<R> where
F: FnOnce(&mut V) -> R,
V: View + Any,
[src]
F: FnOnce(&mut V) -> R,
V: View + Any,
fn find_id<V>(
&mut self,
id: &str
) -> Option<OwningHandle<OwningRef<Rc<RefCell<V>>, RefCell<V>>, RefMut<'static, V>>> where
V: View + Any,
[src]
&mut self,
id: &str
) -> Option<OwningHandle<OwningRef<Rc<RefCell<V>>, RefCell<V>>, RefMut<'static, V>>> where
V: View + Any,
impl<T> AnyView for T where
T: View,
[src]
T: View,
fn as_any(&self) -> &(dyn Any + 'static)
[src]
Downcast self to a Any
.
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
Downcast self to a mutable Any
.
fn as_boxed_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
impl<T> IntoBoxedView for T where
T: View,
[src]
T: View,