summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-04 22:31:37 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-04 22:31:37 +0100
commit58adfcd5145d571739eda8cc655aa2f95814e541 (patch)
tree7ce3dacb4f9309d66b9adf7553740a2db5c1f3e7
parentd7f32d47ba352616328f72323cad18351b326ae8 (diff)
downloadiced-58adfcd5145d571739eda8cc655aa2f95814e541.tar.gz
iced-58adfcd5145d571739eda8cc655aa2f95814e541.tar.bz2
iced-58adfcd5145d571739eda8cc655aa2f95814e541.zip
Fix `Split::apply` on vertical splits
-rw-r--r--native/src/widget/panes.rs19
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
},