BSPLayout

Struct BSPLayout 

Source
pub struct BSPLayout {
    pub ig_left: u32,
    pub ig_right: u32,
    pub ig_bottom: u32,
    pub ig_top: u32,
    pub og_left: u32,
    pub og_right: u32,
    pub og_bottom: u32,
    pub og_top: u32,
    pub hsplit_perc: f32,
    pub vsplit_perc: f32,
    pub start_hsplit: bool,
    pub reversed: bool,
}
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 evenly distributed across the screen

Fields§

§ig_left: u32

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

§ig_right: u32

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

§ig_bottom: u32

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

§ig_top: u32

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

§og_left: u32

Number of pixels to put between the left screen edge and the adjacent windows

§og_right: u32

Number of pixels to put between the right screen edge and the adjacent windows

§og_bottom: u32

Number of pixels to put between the bottom screen edge and the adjacent windows

§og_top: u32

Number of pixels to put between the top screen edge and the adjacent windows

§hsplit_perc: f32

The percentage (between 0.0 and 1.0) of space that should be occupied by the primary window when a horizontal split takes place

§vsplit_perc: f32

The percentage (between 0.0 and 1.0) of space that should be occupied by the primary window when a vertical split takes place

§start_hsplit: bool

Whether the first split should be horizontal or not. If true, then start by dividing the screen in half from right to left. If false, then start by dividing the screen in half from top to bottom

§reversed: bool

If true, new views will be prepended to the list. Otherwise, new views will be appended.

Implementations§

Source§

impl BSPLayout

Source

pub fn new() -> BSPLayout

Initialize a new instance of BSPLayout with inner gaps of 5 pixels and outer gaps of 10 pixels on each side, a split percent of 50%, and starting on a vertical split

§Returns

A new BSPLayout

Source

pub fn set_all_outer_gaps(&mut self, new_gap: u32)

Sets all sides of outer gap to new_gap

§Arguments
  • new_gap - The value to assign for the gap on all outer edges
Source

pub fn set_all_inner_gaps(&mut self, new_gap: u32)

Sets all inner gaps to new_gap

§Arguments
  • new_gap - The value to assign for the gap on all inner edges between windows

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. Supports individually setting the gaps on each side of the screen as well as inner edges. Also supports setting all outer and inner gaps at the same time

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

// Initialize layout with 0 gaps
let mut bsp = BSPLayout::new();
bsp.set_all_inner_gaps(0);
bsp.set_all_outer_gaps(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.og_top, 5);
assert_eq!(bsp.og_bottom, 5);
assert_eq!(bsp.og_right, 5);
assert_eq!(bsp.og_left, 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();
bsp.generate_layout(2, 1920, 1080, 0b000000001, "eDP-1").unwrap();
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.
Source§

type Error = BSPLayoutError

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

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

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.