pub struct VerticalLayout { /* private fields */ }
Expand description
Hold buttons and align them vertically for drawing within a Dialog
§Examples
use oxide::core::{HorizontalAlign, VerticalAlign, ButtonResult, Button, Widget};
use oxide::{Dialog, StdButton, VerticalLayout};
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 vlayout = VerticalLayout::from_vec(buttons, 1);
vlayout.pack(&maindlg, HorizontalAlign::Middle, VerticalAlign::Bottom, (0,1));
maindlg.add_layout(vlayout);
Implementations§
Source§impl VerticalLayout
impl VerticalLayout
Sourcepub fn from_vec(
widgets: Vec<Box<dyn Button>>,
inner_margin: usize,
) -> VerticalLayout
pub fn from_vec( widgets: Vec<Box<dyn Button>>, inner_margin: usize, ) -> VerticalLayout
Construct a VerticalLayout
object from a vector of boxed objects that implement
Button. The current API for this function will
change very soon
§Examples
use oxide::core::{Button, ButtonResult};
use oxide::{StdButton, VerticalLayout};
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 = VerticalLayout::from_vec(v, 1);
Trait Implementations§
Source§impl Layout for VerticalLayout
impl Layout for VerticalLayout
fn align_elems(&mut self)
fn forward_keys(&mut self, map: &mut HashMap<char, ButtonResult>)
Source§impl Widget for VerticalLayout
impl Widget for VerticalLayout
Source§fn draw(&mut self, parent: &mut dyn CellAccessor)
fn draw(&mut self, parent: &mut dyn CellAccessor)
Draws the widget to the valid
CellAccessor
passedSource§fn pack(
&mut self,
parent: &dyn HasSize,
halign: HorizontalAlign,
valign: VerticalAlign,
margin: (usize, usize),
)
fn pack( &mut self, parent: &dyn HasSize, halign: HorizontalAlign, valign: VerticalAlign, margin: (usize, usize), )
Aligns the widget with the
parent
as referenceAuto Trait Implementations§
impl Freeze for VerticalLayout
impl !RefUnwindSafe for VerticalLayout
impl !Send for VerticalLayout
impl !Sync for VerticalLayout
impl Unpin for VerticalLayout
impl !UnwindSafe for VerticalLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more