Struct Layout

Source
pub struct Layout {
    pub name: String,
    pub flip: Flip,
    pub rotate: Rotation,
    pub reserve: Reserve,
    pub columns: Columns,
}
Expand description

Describes a layout or pattern in which tiles (windows) will be arranged. The Layout allows to describe various types of “fixed” layouts used by a dynamic tiling manager. Those include layouts like MainAndStack, Fibonacci, Dwindle, CenterMain, etc.

Fields§

§name: String

Name and identifier of the layout. This is user chosen and no two layouts can have the same name.

§flip: Flip

Flips the entire result of tiles as a whole if specified to be anything other than Flip::None

§rotate: Rotation

Rotate the entire result of tiles as a whole, if specified to be anything other than Rotation::North

§reserve: Reserve

Defines the layouts behavior if certain “columns” (eg. main, stack, or second-stack) are empty. See Reserve for more information.

§columns: Columns

Configuration concerning the Main, Stack, and SecondStack columns. See Columns for more information.

Implementations§

Source§

impl Layout

Source

pub fn is_monocle(&self) -> bool

Returns true if the layout must be considered a Monocle layout.

The Monocle layout is a special layout that always consists of 0 or 1 windows. If there is a window, it is shown full screen.

Source

pub fn is_main_and_deck(&self) -> bool

Returns true if the layout must be considered a MainAndDeck layout.

The MainAndDeck layout is a special layout that always consists of 0, 1 or 2 windows.

Source

pub fn main_size(&self) -> Option<Size>

Source

pub fn main_window_count(&self) -> Option<usize>

Source

pub fn set_main_size(&mut self, size: Size)

Set the Size of the Main column to a specific value

Source

pub fn increase_main_size(&mut self, upper_bound: i32)

Increase the Size of the Main column, but to no larger value than what is set in upper_bound.

The column is increased by a default amount, either [DEFAULT_MAIN_SIZE_CHANGE_PIXEL] or [DEFAULT_MAIN_SIZE_CHANGE_PERCENTAGE] depending on whether the current Size is a Size::Pixel or Size::Ratio.

If the current layout has no Main column, nothing happens

Source

pub fn decrease_main_size(&mut self)

Decrease the Size of the Main column, but to no smaller value than zero.

The column is decreased by a default amount, either [DEFAULT_MAIN_SIZE_CHANGE_PIXEL] or [DEFAULT_MAIN_SIZE_CHANGE_PERCENTAGE] depending on whether the current Size is a Size::Pixel or Size::Ratio.

If the current layout has no Main column, nothing happens

Source

pub fn change_main_size(&mut self, delta: i32, upper_bound: i32)

Change the Size of the Main column by a delta value.

The delta value can be positive or negative and is interpreted as either Size::Pixel or Size::Ratio based on the current Size of the Main column.

When the current Size is a Size::Pixel, the delta is interpreted as a pixel value.

use leftwm_layouts::Layout;
use leftwm_layouts::geometry::Size;

let mut layout = Layout::default();
layout.set_main_size(Size::Pixel(200));
layout.change_main_size(100, 500);
assert_eq!(Size::Pixel(300), layout.columns.main.unwrap().size);

When the current Size is a Size::Ratio, the delta is interpreted as a percentage value and converted into a ratio (i.e. 5 (percent) => Size::Ratio(0.05)).

use leftwm_layouts::Layout;
use leftwm_layouts::geometry::Size;

let mut layout = Layout::default();
layout.set_main_size(Size::Ratio(0.5));
layout.change_main_size(5, 500);
assert_eq!(Size::Ratio(0.55), layout.columns.main.unwrap().size);
Source

pub fn set_main_window_count(&mut self, count: usize)

Source

pub fn increase_main_window_count(&mut self)

Source

pub fn decrease_main_window_count(&mut self)

Source

pub fn rotate(&mut self, clockwise: bool)

Source

pub fn check(&self)

Source

pub fn update_defaults(custom: &Vec<Layout>) -> Vec<Layout>

Trait Implementations§

Source§

impl Clone for Layout

Source§

fn clone(&self) -> Layout

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Layout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Layout

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Layout
where Layout: Default,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Layout

Source§

fn eq(&self, other: &Layout) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Layout

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Layout

Auto Trait Implementations§

§

impl Freeze for Layout

§

impl RefUnwindSafe for Layout

§

impl Send for Layout

§

impl Sync for Layout

§

impl Unpin for Layout

§

impl UnwindSafe for Layout

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,