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: u32Number of pixels to put between the left inside edge of adjacent windows
ig_right: u32Number of pixels to put between the right inside edge of adjacent windows
ig_bottom: u32Number of pixels to put between the bottom inside edge of adjacent windows
ig_top: u32Number of pixels to put between the top inside edge of adjacent windows
og_left: u32Number of pixels to put between the left screen edge and the adjacent windows
og_right: u32Number of pixels to put between the right screen edge and the adjacent windows
og_bottom: u32Number of pixels to put between the bottom screen edge and the adjacent windows
og_top: u32Number of pixels to put between the top screen edge and the adjacent windows
hsplit_perc: f32The 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: f32The 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: boolWhether 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: boolIf true, new views will be prepended to the list. Otherwise, new views will be appended.
Implementations§
Source§impl BSPLayout
impl BSPLayout
Sourcepub fn new() -> BSPLayout
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
Sourcepub fn set_all_outer_gaps(&mut self, new_gap: u32)
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
Sourcepub fn set_all_inner_gaps(&mut self, new_gap: u32)
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
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. 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>
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();
bsp.generate_layout(2, 1920, 1080, 0b000000001, "eDP-1").unwrap();Source§const NAMESPACE: &'static str = "bsp-layout"
const NAMESPACE: &'static str = "bsp-layout"
run will return Error::NamespaceInUse.