From 58adfcd5145d571739eda8cc655aa2f95814e541 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 4 Mar 2020 22:31:37 +0100 Subject: Fix `Split::apply` on vertical splits --- native/src/widget/panes.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'native/src/widget/panes.rs') diff --git a/native/src/widget/panes.rs b/native/src/widget/panes.rs index 69b54b47..22fa2b5a 100644 --- a/native/src/widget/panes.rs +++ b/native/src/widget/panes.rs @@ -160,6 +160,12 @@ where #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct Pane(usize); +impl Pane { + pub fn index(&self) -> usize { + self.0 + } +} + #[derive(Debug)] pub struct State { panes: HashMap, @@ -225,7 +231,12 @@ impl State { self.split(Split::Horizontal, pane, state) } - fn split(&mut self, kind: Split, pane: &Pane, state: T) -> Option { + pub fn split( + &mut self, + kind: Split, + pane: &Pane, + state: T, + ) -> Option { let node = self.internal.layout.find(pane)?; let new_pane = { @@ -320,13 +331,13 @@ impl Node { } #[derive(Debug, Clone, Copy, Hash)] -enum Split { +pub enum Split { Horizontal, Vertical, } impl Split { - pub fn apply( + fn apply( &self, rectangle: &Rectangle, ratio: f32, @@ -358,7 +369,7 @@ impl Split { ..*rectangle }, Rectangle { - x: rectangle.x + height_top, + y: rectangle.y + height_top, height: height_bottom, ..*rectangle }, -- cgit