Replace FocusedPane with Action in pane_grid

This commit is contained in:
Héctor Ramón Jiménez 2020-03-14 06:26:09 +01:00
parent 5c8ec4504b
commit 00c2b55b56
3 changed files with 52 additions and 50 deletions

View file

@ -8,6 +8,7 @@ use std::collections::HashMap;
#[derive(Debug, Clone, Hash)]
pub enum Node {
Split {
id: usize,
kind: Split,
ratio: u32,
a: Box<Node>,
@ -32,8 +33,9 @@ impl Node {
}
}
pub fn split(&mut self, kind: Split, new_pane: Pane) {
pub fn split(&mut self, id: usize, kind: Split, new_pane: Pane) {
*self = Node::Split {
id,
kind,
ratio: 500_000,
a: Box::new(self.clone()),
@ -112,7 +114,9 @@ impl Node {
regions: &mut HashMap<Pane, Rectangle>,
) {
match self {
Node::Split { kind, ratio, a, b } => {
Node::Split {
kind, ratio, a, b, ..
} => {
let ratio = *ratio as f32 / 1_000_000.0;
let (region_a, region_b) =
kind.apply(current, ratio, halved_spacing);