Fix Split::apply on vertical splits

This commit is contained in:
Héctor Ramón Jiménez 2020-03-04 22:31:37 +01:00
parent d7f32d47ba
commit 58adfcd514

View File

@ -160,6 +160,12 @@ where
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Pane(usize); pub struct Pane(usize);
impl Pane {
pub fn index(&self) -> usize {
self.0
}
}
#[derive(Debug)] #[derive(Debug)]
pub struct State<T> { pub struct State<T> {
panes: HashMap<Pane, T>, panes: HashMap<Pane, T>,
@ -225,7 +231,12 @@ impl<T> State<T> {
self.split(Split::Horizontal, pane, state) self.split(Split::Horizontal, pane, state)
} }
fn split(&mut self, kind: Split, pane: &Pane, state: T) -> Option<Pane> { pub fn split(
&mut self,
kind: Split,
pane: &Pane,
state: T,
) -> Option<Pane> {
let node = self.internal.layout.find(pane)?; let node = self.internal.layout.find(pane)?;
let new_pane = { let new_pane = {
@ -320,13 +331,13 @@ impl Node {
} }
#[derive(Debug, Clone, Copy, Hash)] #[derive(Debug, Clone, Copy, Hash)]
enum Split { pub enum Split {
Horizontal, Horizontal,
Vertical, Vertical,
} }
impl Split { impl Split {
pub fn apply( fn apply(
&self, &self,
rectangle: &Rectangle, rectangle: &Rectangle,
ratio: f32, ratio: f32,
@ -358,7 +369,7 @@ impl Split {
..*rectangle ..*rectangle
}, },
Rectangle { Rectangle {
x: rectangle.x + height_top, y: rectangle.y + height_top,
height: height_bottom, height: height_bottom,
..*rectangle ..*rectangle
}, },