Enum cursive_core::direction::Orientation
source · [−]pub enum Orientation {
Horizontal,
Vertical,
}Expand description
Describes a vertical or horizontal orientation for a view.
Variants
Horizontal
Horizontal orientation
Vertical
Vertical orientation
Implementations
sourceimpl Orientation
impl Orientation
sourcepub fn pair() -> XY<Orientation>
pub fn pair() -> XY<Orientation>
Returns a XY(Horizontal, Vertical).
sourcepub fn get<T: Clone>(self, v: &XY<T>) -> T
pub fn get<T: Clone>(self, v: &XY<T>) -> T
Returns the component of v corresponding to this orientation.
(Horizontal will return the x value,
and Vertical will return the y value.)
sourcepub fn get_ref<T>(self, v: &mut XY<T>) -> &mut T
pub fn get_ref<T>(self, v: &mut XY<T>) -> &mut T
Returns a mutable reference to the component of the given vector corresponding to this orientation.
Examples
let o = Orientation::Horizontal;
let mut xy = XY::new(1, 2);
*o.get_ref(&mut xy) = 42;
assert_eq!(xy, XY::new(42, 2));sourcepub fn stack<T: Iterator<Item = Vec2>>(self, iter: T) -> Vec2
pub fn stack<T: Iterator<Item = Vec2>>(self, iter: T) -> Vec2
Takes an iterator on sizes, and stack them in the current orientation, returning the size of the required bounding box.
- For an horizontal view, returns
(Sum(x), Max(y)). - For a vertical view, returns
(Max(x), Sum(y)).
sourcepub fn make_vec(self, main_axis: usize, second_axis: usize) -> Vec2
pub fn make_vec(self, main_axis: usize, second_axis: usize) -> Vec2
Creates a new Vec2 with main_axis in self’s axis, and
second_axis for the other axis.
Examples
let o = Orientation::Horizontal;
let vec = o.make_vec(1, 2);
assert_eq!(vec, Vec2::new(1, 2));
let o = Orientation::Vertical;
let vec = o.make_vec(1, 2);
assert_eq!(vec, Vec2::new(2, 1));Trait Implementations
sourceimpl Clone for Orientation
impl Clone for Orientation
sourcefn clone(&self) -> Orientation
fn clone(&self) -> Orientation
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for Orientation
impl Debug for Orientation
sourceimpl Hash for Orientation
impl Hash for Orientation
sourceimpl PartialEq<Orientation> for Orientation
impl PartialEq<Orientation> for Orientation
sourcefn eq(&self, other: &Orientation) -> bool
fn eq(&self, other: &Orientation) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
impl Copy for Orientation
impl Eq for Orientation
impl StructuralEq for Orientation
impl StructuralPartialEq for Orientation
Auto Trait Implementations
impl RefUnwindSafe for Orientation
impl Send for Orientation
impl Sync for Orientation
impl Unpin for Orientation
impl UnwindSafe for Orientation
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more