diff options
author | 2020-03-04 22:31:37 +0100 | |
---|---|---|
committer | 2020-03-04 22:31:37 +0100 | |
commit | 58adfcd5145d571739eda8cc655aa2f95814e541 (patch) | |
tree | 7ce3dacb4f9309d66b9adf7553740a2db5c1f3e7 | |
parent | d7f32d47ba352616328f72323cad18351b326ae8 (diff) | |
download | iced-58adfcd5145d571739eda8cc655aa2f95814e541.tar.gz iced-58adfcd5145d571739eda8cc655aa2f95814e541.tar.bz2 iced-58adfcd5145d571739eda8cc655aa2f95814e541.zip |
Fix `Split::apply` on vertical splits
-rw-r--r-- | native/src/widget/panes.rs | 19 |
1 files changed, 15 insertions, 4 deletions
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<T> { panes: HashMap<Pane, T>, @@ -225,7 +231,12 @@ impl<T> State<T> { 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 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 }, |