From 041cab0fa499a54d21d2742ba821583f55b2a8fc Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 8 Jun 2020 18:11:29 +0200 Subject: Resize `PaneGrid` without modifier keys --- native/src/widget/pane_grid/axis.rs | 24 ++++++++++++++++++++++++ native/src/widget/pane_grid/state.rs | 3 +++ 2 files changed, 27 insertions(+) (limited to 'native/src/widget/pane_grid') diff --git a/native/src/widget/pane_grid/axis.rs b/native/src/widget/pane_grid/axis.rs index b3a306d5..2320cb7c 100644 --- a/native/src/widget/pane_grid/axis.rs +++ b/native/src/widget/pane_grid/axis.rs @@ -53,6 +53,30 @@ impl Axis { } } } + + pub(super) fn split_line_bounds( + &self, + rectangle: Rectangle, + ratio: f32, + spacing: f32, + ) -> Rectangle { + match self { + Axis::Horizontal => Rectangle { + x: rectangle.x, + y: (rectangle.y + rectangle.height * ratio - spacing / 2.0) + .round(), + width: rectangle.width, + height: spacing, + }, + Axis::Vertical => Rectangle { + x: (rectangle.x + rectangle.width * ratio - spacing / 2.0) + .round(), + y: rectangle.y, + width: spacing, + height: rectangle.height, + }, + } + } } #[cfg(test)] diff --git a/native/src/widget/pane_grid/state.rs b/native/src/widget/pane_grid/state.rs index 4b13fb8e..7a53d6c7 100644 --- a/native/src/widget/pane_grid/state.rs +++ b/native/src/widget/pane_grid/state.rs @@ -4,6 +4,7 @@ use crate::{ Hasher, Point, Rectangle, Size, }; +use std::cell::RefCell; use std::collections::HashMap; /// The state of a [`PaneGrid`]. @@ -71,6 +72,7 @@ impl State { internal: Internal { layout, last_id, + split_cache: RefCell::new(None), action: Action::Idle { focus: None }, }, modifiers: keyboard::ModifiersState::default(), @@ -308,6 +310,7 @@ pub struct Internal { layout: Node, last_id: usize, action: Action, + split_cache: RefCell>>, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] -- cgit From dcc4bb77e942f8550b0d7ee08fa5a2882fd22ecd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 8 Jun 2020 18:25:46 +0200 Subject: Remove unused `split_cache` in `pane_grid` --- native/src/widget/pane_grid/state.rs | 3 --- 1 file changed, 3 deletions(-) (limited to 'native/src/widget/pane_grid') diff --git a/native/src/widget/pane_grid/state.rs b/native/src/widget/pane_grid/state.rs index 7a53d6c7..4b13fb8e 100644 --- a/native/src/widget/pane_grid/state.rs +++ b/native/src/widget/pane_grid/state.rs @@ -4,7 +4,6 @@ use crate::{ Hasher, Point, Rectangle, Size, }; -use std::cell::RefCell; use std::collections::HashMap; /// The state of a [`PaneGrid`]. @@ -72,7 +71,6 @@ impl State { internal: Internal { layout, last_id, - split_cache: RefCell::new(None), action: Action::Idle { focus: None }, }, modifiers: keyboard::ModifiersState::default(), @@ -310,7 +308,6 @@ pub struct Internal { layout: Node, last_id: usize, action: Action, - split_cache: RefCell>>, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] -- cgit