Resize PaneGrid without modifier keys
This commit is contained in:
parent
4960a8827e
commit
041cab0fa4
3 changed files with 139 additions and 97 deletions
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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<T> State<T> {
|
|||
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<Option<HashMap<Split, (Axis, f32, Rectangle)>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue