Struct HorizontalLayout

Source
pub struct HorizontalLayout { /* private fields */ }
Expand description

Hold buttons and align them horizontally for drawing within a Dialog

§Examples

use oxide::core::{HorizontalAlign, VerticalAlign, ButtonResult, Widget, Button};
use oxide::ui::{Dialog, StdButton, HorizontalLayout};

let mut maindlg = Dialog::new(60, 10);

let b1 = StdButton::new("Quit", 'q', ButtonResult::Ok);
let b2 = StdButton::new("Foo!", 'f', ButtonResult::Custom(1));
let b3 = StdButton::new("Bar!", 'b', ButtonResult::Custom(2));

let buttons = vec![b1, b2, b3].into_iter().map(Box::new);
let buttons = buttons.map(|x| x as Box<Button>).collect();

let mut hlayout = HorizontalLayout::from_vec(buttons, 1);
hlayout.pack(&maindlg, HorizontalAlign::Middle, VerticalAlign::Bottom, (0,1));
     
maindlg.add_layout(hlayout);

Implementations§

Source§

impl HorizontalLayout

Source

pub fn from_vec( widgets: Vec<Box<dyn Button>>, inner_margin: usize, ) -> HorizontalLayout

Construct a HorizontalLayout object from a vector of boxed objects that implement Button. The current API for this function will change very soon

§Examples
use oxide::core::{ButtonResult, Button};
use oxide::{StdButton, HorizontalLayout};

let b1 = StdButton::new("Quit", 'q', ButtonResult::Ok);
let b2 = StdButton::new("Foo!", 'f', ButtonResult::Custom(1));
let b3 = StdButton::new("Bar!", 'b', ButtonResult::Custom(2));

let v = vec![b1, b2, b3].into_iter().map(Box::new).map(|x| x as Box<Button>).collect();
let mut hlayout = HorizontalLayout::from_vec(v, 1);

Trait Implementations§

Source§

impl Layout for HorizontalLayout

Source§

fn align_elems(&mut self)

Source§

fn forward_keys(&mut self, map: &mut HashMap<char, ButtonResult>)

Source§

impl Widget for HorizontalLayout

Source§

fn draw(&mut self, parent: &mut dyn CellAccessor)

Draws the widget to the valid CellAccessor passed
Source§

fn pack( &mut self, parent: &dyn HasSize, halign: HorizontalAlign, valign: VerticalAlign, margin: (usize, usize), )

Aligns the widget with the parent as reference
Source§

fn draw_box(&mut self)

Expose the painter trait draw_box for all widgets, which outlines the space enclosed within the widget
Source§

fn resize(&mut self, new_size: Size)

Resize the given widget to new dimensions given by Size
Source§

fn frame(&self) -> &Frame

Return a reference the renderer, Base in general cases
Source§

fn frame_mut(&mut self) -> &mut Frame

Return a mutable reference to the renderer, Base in general cases

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.