summaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-14 06:32:56 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-03-14 06:32:56 +0100
commita79603e4ca5e0cee46a737ef0b1af5c69ddb49b6 (patch)
tree30c794fe0f767dafe710034bd57402f98f3e74d5 /native/src
parent00c2b55b569ea2ff2fc9de9bbf02475c6ede7e42 (diff)
downloadiced-a79603e4ca5e0cee46a737ef0b1af5c69ddb49b6.tar.gz
iced-a79603e4ca5e0cee46a737ef0b1af5c69ddb49b6.tar.bz2
iced-a79603e4ca5e0cee46a737ef0b1af5c69ddb49b6.zip
Rename `Split` to `Axis`
Diffstat (limited to 'native/src')
-rw-r--r--native/src/widget/pane_grid.rs4
-rw-r--r--native/src/widget/pane_grid/axis.rs (renamed from native/src/widget/pane_grid/split.rs)10
-rw-r--r--native/src/widget/pane_grid/node.rs12
-rw-r--r--native/src/widget/pane_grid/state.rs15
4 files changed, 18 insertions, 23 deletions
diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs
index e446b235..12d0b09d 100644
--- a/native/src/widget/pane_grid.rs
+++ b/native/src/widget/pane_grid.rs
@@ -1,12 +1,12 @@
+mod axis;
mod direction;
mod node;
mod pane;
-mod split;
mod state;
+pub use axis::Axis;
pub use direction::Direction;
pub use pane::Pane;
-pub use split::Split;
pub use state::{Focus, State};
use crate::{
diff --git a/native/src/widget/pane_grid/split.rs b/native/src/widget/pane_grid/axis.rs
index ca9ed5e1..375509b7 100644
--- a/native/src/widget/pane_grid/split.rs
+++ b/native/src/widget/pane_grid/axis.rs
@@ -1,20 +1,20 @@
use crate::Rectangle;
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
-pub enum Split {
+pub enum Axis {
Horizontal,
Vertical,
}
-impl Split {
- pub(super) fn apply(
+impl Axis {
+ pub(super) fn split(
&self,
rectangle: &Rectangle,
ratio: f32,
halved_spacing: f32,
) -> (Rectangle, Rectangle) {
match self {
- Split::Horizontal => {
+ Axis::Horizontal => {
let width_left =
(rectangle.width * ratio).round() - halved_spacing;
let width_right = rectangle.width - width_left - halved_spacing;
@@ -31,7 +31,7 @@ impl Split {
},
)
}
- Split::Vertical => {
+ Axis::Vertical => {
let height_top =
(rectangle.height * ratio).round() - halved_spacing;
let height_bottom =
diff --git a/native/src/widget/pane_grid/node.rs b/native/src/widget/pane_grid/node.rs
index 744e3e17..aaf775d8 100644
--- a/native/src/widget/pane_grid/node.rs
+++ b/native/src/widget/pane_grid/node.rs
@@ -1,5 +1,5 @@
use crate::{
- pane_grid::{Pane, Split},
+ pane_grid::{Axis, Pane},
Rectangle, Size,
};
@@ -9,7 +9,7 @@ use std::collections::HashMap;
pub enum Node {
Split {
id: usize,
- kind: Split,
+ axis: Axis,
ratio: u32,
a: Box<Node>,
b: Box<Node>,
@@ -33,10 +33,10 @@ impl Node {
}
}
- pub fn split(&mut self, id: usize, kind: Split, new_pane: Pane) {
+ pub fn split(&mut self, id: usize, axis: Axis, new_pane: Pane) {
*self = Node::Split {
id,
- kind,
+ axis,
ratio: 500_000,
a: Box::new(self.clone()),
b: Box::new(Node::Pane(new_pane)),
@@ -115,11 +115,11 @@ impl Node {
) {
match self {
Node::Split {
- kind, ratio, a, b, ..
+ axis, ratio, a, b, ..
} => {
let ratio = *ratio as f32 / 1_000_000.0;
let (region_a, region_b) =
- kind.apply(current, ratio, halved_spacing);
+ axis.split(current, ratio, halved_spacing);
a.compute_regions(halved_spacing, &region_a, regions);
b.compute_regions(halved_spacing, &region_b, regions);
diff --git a/native/src/widget/pane_grid/state.rs b/native/src/widget/pane_grid/state.rs
index 61576a29..dc66e32a 100644
--- a/native/src/widget/pane_grid/state.rs
+++ b/native/src/widget/pane_grid/state.rs
@@ -1,6 +1,6 @@
use crate::{
input::keyboard,
- pane_grid::{node::Node, Direction, Pane, Split},
+ pane_grid::{node::Node, Axis, Direction, Pane},
Hasher, Point, Rectangle, Size,
};
@@ -99,7 +99,7 @@ impl<T> State<T> {
}
pub fn split_vertically(&mut self, pane: &Pane, state: T) -> Option<Pane> {
- self.split(Split::Vertical, pane, state)
+ self.split(Axis::Vertical, pane, state)
}
pub fn split_horizontally(
@@ -107,15 +107,10 @@ impl<T> State<T> {
pane: &Pane,
state: T,
) -> Option<Pane> {
- self.split(Split::Horizontal, pane, state)
+ self.split(Axis::Horizontal, pane, state)
}
- pub fn split(
- &mut self,
- kind: Split,
- pane: &Pane,
- state: T,
- ) -> Option<Pane> {
+ pub fn split(&mut self, axis: Axis, pane: &Pane, state: T) -> Option<Pane> {
let node = self.internal.layout.find(pane)?;
let new_pane = {
@@ -130,7 +125,7 @@ impl<T> State<T> {
self.internal.last_id
};
- node.split(split_id, kind, new_pane);
+ node.split(split_id, axis, new_pane);
let _ = self.panes.insert(new_pane, state);
self.focus(&new_pane);