aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/tree.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-02-09 06:59:42 +0000
committerBlaž Hrastnik2021-02-09 06:59:42 +0000
commit5e73f83efa406a6989fff6077b90dd77a7328b36 (patch)
tree84c41b5ba0242244ed174a4c902d4ee50a116bfa /helix-view/src/tree.rs
parentd4b85ce18d8a9bb535eaeae9e2c7421ef81c81e9 (diff)
Implement vertical split calculations.
Diffstat (limited to 'helix-view/src/tree.rs')
-rw-r--r--helix-view/src/tree.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs
index a5b59a79..dd07d76d 100644
--- a/helix-view/src/tree.rs
+++ b/helix-view/src/tree.rs
@@ -156,7 +156,31 @@ impl Tree {
container.area = area;
match container.layout {
- Layout::Vertical => unimplemented!(),
+ Layout::Vertical => {
+ let len = container.children.len();
+
+ let height = area.height / len as u16;
+
+ let mut child_y = area.y;
+
+ for (i, child) in container.children.iter().enumerate() {
+ let mut area = Rect::new(
+ container.area.x,
+ child_y,
+ container.area.width,
+ height,
+ );
+ child_y += height;
+
+ // last child takes the remaining width because we can get uneven
+ // space from rounding
+ if i == len - 1 {
+ area.height = container.area.y + container.area.height - area.y;
+ }
+
+ self.stack.push((*child, area));
+ }
+ }
Layout::Horizontal => {
let len = container.children.len();