Restore ability to reset pane split size by double clicking drag handle. (#3937)
Release notes - Fixed double clicking on pane drag handle not resetting pane's split size. - Fixed pane group sizes not being serialized.
This commit is contained in:
parent
53564fb269
commit
97aed8a4d7
1 changed files with 43 additions and 16 deletions
|
@ -487,6 +487,7 @@ impl PaneAxis {
|
||||||
basis,
|
basis,
|
||||||
self.flexes.clone(),
|
self.flexes.clone(),
|
||||||
self.bounding_boxes.clone(),
|
self.bounding_boxes.clone(),
|
||||||
|
cx.view().downgrade(),
|
||||||
)
|
)
|
||||||
.children(self.members.iter().enumerate().map(|(ix, member)| {
|
.children(self.members.iter().enumerate().map(|(ix, member)| {
|
||||||
if member.contains(active_pane) {
|
if member.contains(active_pane) {
|
||||||
|
@ -575,21 +576,25 @@ mod element {
|
||||||
use gpui::{
|
use gpui::{
|
||||||
px, relative, Along, AnyElement, Axis, Bounds, CursorStyle, Element, InteractiveBounds,
|
px, relative, Along, AnyElement, Axis, Bounds, CursorStyle, Element, InteractiveBounds,
|
||||||
IntoElement, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point,
|
IntoElement, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, Point,
|
||||||
Size, Style, WindowContext,
|
Size, Style, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
|
use util::ResultExt;
|
||||||
|
|
||||||
|
use crate::Workspace;
|
||||||
|
|
||||||
use super::{HANDLE_HITBOX_SIZE, HORIZONTAL_MIN_SIZE, VERTICAL_MIN_SIZE};
|
use super::{HANDLE_HITBOX_SIZE, HORIZONTAL_MIN_SIZE, VERTICAL_MIN_SIZE};
|
||||||
|
|
||||||
const DIVIDER_SIZE: f32 = 1.0;
|
const DIVIDER_SIZE: f32 = 1.0;
|
||||||
|
|
||||||
pub fn pane_axis(
|
pub(super) fn pane_axis(
|
||||||
axis: Axis,
|
axis: Axis,
|
||||||
basis: usize,
|
basis: usize,
|
||||||
flexes: Arc<Mutex<Vec<f32>>>,
|
flexes: Arc<Mutex<Vec<f32>>>,
|
||||||
bounding_boxes: Arc<Mutex<Vec<Option<Bounds<Pixels>>>>>,
|
bounding_boxes: Arc<Mutex<Vec<Option<Bounds<Pixels>>>>>,
|
||||||
|
workspace: WeakView<Workspace>,
|
||||||
) -> PaneAxisElement {
|
) -> PaneAxisElement {
|
||||||
PaneAxisElement {
|
PaneAxisElement {
|
||||||
axis,
|
axis,
|
||||||
|
@ -598,6 +603,7 @@ mod element {
|
||||||
bounding_boxes,
|
bounding_boxes,
|
||||||
children: SmallVec::new(),
|
children: SmallVec::new(),
|
||||||
active_pane_ix: None,
|
active_pane_ix: None,
|
||||||
|
workspace,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,6 +614,7 @@ mod element {
|
||||||
bounding_boxes: Arc<Mutex<Vec<Option<Bounds<Pixels>>>>>,
|
bounding_boxes: Arc<Mutex<Vec<Option<Bounds<Pixels>>>>>,
|
||||||
children: SmallVec<[AnyElement; 2]>,
|
children: SmallVec<[AnyElement; 2]>,
|
||||||
active_pane_ix: Option<usize>,
|
active_pane_ix: Option<usize>,
|
||||||
|
workspace: WeakView<Workspace>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PaneAxisElement {
|
impl PaneAxisElement {
|
||||||
|
@ -623,6 +630,7 @@ mod element {
|
||||||
axis: Axis,
|
axis: Axis,
|
||||||
child_start: Point<Pixels>,
|
child_start: Point<Pixels>,
|
||||||
container_size: Size<Pixels>,
|
container_size: Size<Pixels>,
|
||||||
|
workspace: WeakView<Workspace>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
) {
|
) {
|
||||||
let min_size = match axis {
|
let min_size = match axis {
|
||||||
|
@ -697,7 +705,9 @@ mod element {
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo!(schedule serialize)
|
// todo!(schedule serialize)
|
||||||
// workspace.schedule_serialize(cx);
|
workspace
|
||||||
|
.update(cx, |this, cx| this.schedule_serialize(cx))
|
||||||
|
.log_err();
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,6 +718,7 @@ mod element {
|
||||||
ix: usize,
|
ix: usize,
|
||||||
pane_bounds: Bounds<Pixels>,
|
pane_bounds: Bounds<Pixels>,
|
||||||
axis_bounds: Bounds<Pixels>,
|
axis_bounds: Bounds<Pixels>,
|
||||||
|
workspace: WeakView<Workspace>,
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
) {
|
) {
|
||||||
let handle_bounds = Bounds {
|
let handle_bounds = Bounds {
|
||||||
|
@ -742,24 +753,39 @@ mod element {
|
||||||
|
|
||||||
cx.on_mouse_event({
|
cx.on_mouse_event({
|
||||||
let dragged_handle = dragged_handle.clone();
|
let dragged_handle = dragged_handle.clone();
|
||||||
move |e: &MouseDownEvent, phase, _cx| {
|
let flexes = flexes.clone();
|
||||||
|
let workspace = workspace.clone();
|
||||||
|
move |e: &MouseDownEvent, phase, cx| {
|
||||||
if phase.bubble() && handle_bounds.contains(&e.position) {
|
if phase.bubble() && handle_bounds.contains(&e.position) {
|
||||||
dragged_handle.replace(Some(ix));
|
dragged_handle.replace(Some(ix));
|
||||||
|
if e.click_count >= 2 {
|
||||||
|
let mut borrow = flexes.lock();
|
||||||
|
*borrow = vec![1.; borrow.len()];
|
||||||
|
workspace
|
||||||
|
.update(cx, |this, cx| this.schedule_serialize(cx))
|
||||||
|
.log_err();
|
||||||
|
cx.notify();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cx.on_mouse_event(move |e: &MouseMoveEvent, phase, cx| {
|
cx.on_mouse_event({
|
||||||
let dragged_handle = dragged_handle.borrow();
|
let workspace = workspace.clone();
|
||||||
if phase.bubble() && *dragged_handle == Some(ix) {
|
move |e: &MouseMoveEvent, phase, cx| {
|
||||||
Self::compute_resize(
|
let dragged_handle = dragged_handle.borrow();
|
||||||
&flexes,
|
|
||||||
e,
|
if phase.bubble() && *dragged_handle == Some(ix) {
|
||||||
ix,
|
Self::compute_resize(
|
||||||
axis,
|
&flexes,
|
||||||
pane_bounds.origin,
|
e,
|
||||||
axis_bounds.size,
|
ix,
|
||||||
cx,
|
axis,
|
||||||
)
|
pane_bounds.origin,
|
||||||
|
axis_bounds.size,
|
||||||
|
workspace.clone(),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -840,6 +866,7 @@ mod element {
|
||||||
ix,
|
ix,
|
||||||
child_bounds,
|
child_bounds,
|
||||||
bounds,
|
bounds,
|
||||||
|
self.workspace.clone(),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue