Skip to main content

Alignable

Trait Alignable 

Source
pub trait Alignable: View + Sized {
    // Provided methods
    fn align_top_left(self) -> AlignedView<Self> { ... }
    fn align_top_center(self) -> AlignedView<Self> { ... }
    fn align_top_right(self) -> AlignedView<Self> { ... }
    fn align_center_left(self) -> AlignedView<Self> { ... }
    fn align_center(self) -> AlignedView<Self> { ... }
    fn align_center_right(self) -> AlignedView<Self> { ... }
    fn align_bottom_left(self) -> AlignedView<Self> { ... }
    fn align_bottom_center(self) -> AlignedView<Self> { ... }
    fn align_bottom_right(self) -> AlignedView<Self> { ... }
}
Expand description

Use this trait to extend all cursive::view::View instances to support the align_... methods.

This trait provides chainable constructors for the AlignedView.

§Usage Example

use cursive::{Cursive, CursiveExt};
use cursive::view::Resizable;
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(); // constructing `AlignedView`

    siv.add_fullscreen_layer(panel);
    // siv.run()
}

Provided Methods§

Source

fn align_top_left(self) -> AlignedView<Self>

Align a child view at the top-left of the parent.

Source

fn align_top_center(self) -> AlignedView<Self>

Align a child view at the top-center of the parent.

Source

fn align_top_right(self) -> AlignedView<Self>

Align a child view at the top-right of the parent.

Source

fn align_center_left(self) -> AlignedView<Self>

Align a child view at the center-left of the parent.

Source

fn align_center(self) -> AlignedView<Self>

Align a child view at the center of the parent.

Source

fn align_center_right(self) -> AlignedView<Self>

Align a child view at the center-right of the parent.

Source

fn align_bottom_left(self) -> AlignedView<Self>

Align a child view at the bottom-left of the parent.

Source

fn align_bottom_center(self) -> AlignedView<Self>

Align a child view at the bottom-center of the parent.

Source

fn align_bottom_right(self) -> AlignedView<Self>

Align a child view at the bottom-right of the parent.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: View> Alignable for T