Reintroduce pane_grid::Split as an identifier
This commit is contained in:
parent
b55746b1e1
commit
db441a64b1
4 changed files with 11 additions and 7 deletions
|
|
@ -2,11 +2,13 @@ mod axis;
|
||||||
mod direction;
|
mod direction;
|
||||||
mod node;
|
mod node;
|
||||||
mod pane;
|
mod pane;
|
||||||
|
mod split;
|
||||||
mod state;
|
mod state;
|
||||||
|
|
||||||
pub use axis::Axis;
|
pub use axis::Axis;
|
||||||
pub use direction::Direction;
|
pub use direction::Direction;
|
||||||
pub use pane::Pane;
|
pub use pane::Pane;
|
||||||
|
pub use split::Split;
|
||||||
pub use state::{Focus, State};
|
pub use state::{Focus, State};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
pane_grid::{Axis, Pane},
|
pane_grid::{Axis, Pane, Split},
|
||||||
Rectangle, Size,
|
Rectangle, Size,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@ use std::collections::HashMap;
|
||||||
#[derive(Debug, Clone, Hash)]
|
#[derive(Debug, Clone, Hash)]
|
||||||
pub enum Node {
|
pub enum Node {
|
||||||
Split {
|
Split {
|
||||||
id: usize,
|
id: Split,
|
||||||
axis: Axis,
|
axis: Axis,
|
||||||
ratio: u32,
|
ratio: u32,
|
||||||
a: Box<Node>,
|
a: Box<Node>,
|
||||||
|
|
@ -33,7 +33,7 @@ impl Node {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn split(&mut self, id: usize, axis: Axis, new_pane: Pane) {
|
pub fn split(&mut self, id: Split, axis: Axis, new_pane: Pane) {
|
||||||
*self = Node::Split {
|
*self = Node::Split {
|
||||||
id,
|
id,
|
||||||
axis,
|
axis,
|
||||||
|
|
|
||||||
2
native/src/widget/pane_grid/split.rs
Normal file
2
native/src/widget/pane_grid/split.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||||
|
pub struct Split(pub(super) usize);
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
input::keyboard,
|
input::keyboard,
|
||||||
pane_grid::{node::Node, Axis, Direction, Pane},
|
pane_grid::{node::Node, Axis, Direction, Pane, Split},
|
||||||
Hasher, Point, Rectangle, Size,
|
Hasher, Point, Rectangle, Size,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -107,13 +107,13 @@ impl<T> State<T> {
|
||||||
Pane(self.internal.last_id)
|
Pane(self.internal.last_id)
|
||||||
};
|
};
|
||||||
|
|
||||||
let split_id = {
|
let new_split = {
|
||||||
self.internal.last_id = self.internal.last_id.checked_add(1)?;
|
self.internal.last_id = self.internal.last_id.checked_add(1)?;
|
||||||
|
|
||||||
self.internal.last_id
|
Split(self.internal.last_id)
|
||||||
};
|
};
|
||||||
|
|
||||||
node.split(split_id, axis, new_pane);
|
node.split(new_split, axis, new_pane);
|
||||||
|
|
||||||
let _ = self.panes.insert(new_pane, state);
|
let _ = self.panes.insert(new_pane, state);
|
||||||
self.focus(&new_pane);
|
self.focus(&new_pane);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue