pub struct BSPLayout {
    pub outer_gap: u32,
    pub inner_gap: u32,
}
Expand description

Create a Binary Space Partitioned layout. Specifically, this layout recursively divides the screen in half. The split will alternate between vertical and horizontal based on which side of the container is longer. This will result in a grid like layout with more-or-less equal sized windows even distributed across the screen

Fields§

§outer_gap: u32

Number of pixels to put between the edge of the display and each window

§inner_gap: u32

Number of pixels to put between the inside edge of adjacent windows

Implementations§

source§

impl BSPLayout

source

pub fn new(outer_gap: u32, inner_gap: u32) -> BSPLayout

Initialize a new instance of BSPLayout with given inner and outer gaps

§Arguments
  • outer_gap - Number of pixels to put between the edge of the display and the outside edge of the nearest windows

  • inner_gap - Number of pixels to put between the inside edge of adjacent windows

§Returns

A new BSPLayout

Trait Implementations§

source§

impl Layout for BSPLayout

source§

fn user_cmd( &mut self, _cmd: String, _tags: Option<u32>, _output: &str ) -> Result<(), Self::Error>

Handle commands passed to the layout with send-layout-cmd. Currently supports “outer-gap #” and “inner-gap #”, which will set set the outer and inner gaps of the window at runtime

§Examples
use river_bsp_layout::BSPLayout;
use river_layout_toolkit::Layout;

// Initialize layout with 0 gaps
let mut bsp = BSPLayout::new(0, 0);

// Set gap between windows and the monitor edge to be 5 pixels
let res = bsp.user_cmd("outer-gap 5".to_string(), None, "eDP-1").unwrap();
assert_eq!(bsp.outer_gap, 5);
§Errors

Will return BSPLayoutError::CmdError if an unrecognized command is passed or if an invalid argument is passed to a valid command.

source§

fn generate_layout( &mut self, view_count: u32, usable_width: u32, usable_height: u32, _tags: u32, _output: &str ) -> Result<GeneratedLayout, Self::Error>

Create the geometry for the BSPLayout

§Arguments
  • view_count - The number of views / windows / containers to divide the screen into
  • usable_width - How many pixels wide the whole display is
  • usable_height - How many pixels tall the whole display is
  • _tags - Int representing which tags are currently active based on which bit is toggled
  • _output - The name of the output to generate the layout on
§Examples
use river_bsp_layout::BSPLayout;
use river_layout_toolkit::Layout;

let mut bsp = BSPLayout::new(10, 10);
bsp.generate_layout(2, 1920, 1080, 0b000000001, "eDP-1").unwrap();
§

type Error = BSPLayoutError

The error type of user_cmd and generate_layout functions. Use Infallible if you don’t need it.
source§

const NAMESPACE: &'static str = "bsp-layout"

The namespace is used by the compositor to distinguish between layout generators. Two separate clients may not share a namespace. Otherwise, run will return Error::NamespaceInUse.

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>,

§

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>,

§

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.