Enum cursive_core::direction::Orientation
source · pub enum Orientation {
Horizontal,
Vertical,
}
Expand description
Describes a vertical or horizontal orientation for a view.
Variants§
Implementations§
source§impl 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§
source§impl Clone for Orientation
impl Clone for Orientation
source§fn clone(&self) -> Orientation
fn clone(&self) -> Orientation
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more