Struct river_bsp_layout::BSPLayout
source · 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: u32Number of pixels to put between the edge of the display and each window
inner_gap: u32Number of pixels to put between the inside edge of adjacent windows
Implementations§
Trait Implementations§
source§impl Layout for BSPLayout
impl Layout for BSPLayout
source§fn user_cmd(
&mut self,
_cmd: String,
_tags: Option<u32>,
_output: &str
) -> Result<(), Self::Error>
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>
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 intousable_width- How many pixels wide the whole display isusable_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();