mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-07 19:19:12 +00:00
Restore the active pane magnification feature (#3961)
As it says on the tin Release Notes: - Restored the active pane magnification setting.
This commit is contained in:
commit
68e705db5b
1 changed files with 45 additions and 20 deletions
|
@ -579,12 +579,15 @@ mod element {
|
||||||
Size, Style, WeakView, WindowContext,
|
Size, Style, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use settings::Settings;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
use crate::Workspace;
|
use crate::Workspace;
|
||||||
|
|
||||||
|
use crate::WorkspaceSettings;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -834,20 +837,39 @@ mod element {
|
||||||
debug_assert!(flexes.len() == len);
|
debug_assert!(flexes.len() == len);
|
||||||
debug_assert!(flex_values_in_bounds(flexes.as_slice()));
|
debug_assert!(flex_values_in_bounds(flexes.as_slice()));
|
||||||
|
|
||||||
|
let magnification_value = WorkspaceSettings::get(None, cx).active_pane_magnification;
|
||||||
|
let active_pane_magnification = if magnification_value == 1. {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(magnification_value)
|
||||||
|
};
|
||||||
|
|
||||||
|
let total_flex = if let Some(flex) = active_pane_magnification {
|
||||||
|
self.children.len() as f32 - 1. + flex
|
||||||
|
} else {
|
||||||
|
len as f32
|
||||||
|
};
|
||||||
|
|
||||||
let mut origin = bounds.origin;
|
let mut origin = bounds.origin;
|
||||||
let space_per_flex = bounds.size.along(self.axis) / len as f32;
|
let space_per_flex = bounds.size.along(self.axis) / total_flex;
|
||||||
|
|
||||||
let mut bounding_boxes = self.bounding_boxes.lock();
|
let mut bounding_boxes = self.bounding_boxes.lock();
|
||||||
bounding_boxes.clear();
|
bounding_boxes.clear();
|
||||||
|
|
||||||
for (ix, child) in self.children.iter_mut().enumerate() {
|
for (ix, child) in self.children.iter_mut().enumerate() {
|
||||||
//todo!(active_pane_magnification)
|
let child_flex = active_pane_magnification
|
||||||
// If using active pane magnification, need to switch to using
|
.map(|magnification| {
|
||||||
// 1 for all non-active panes, and then the magnification for the
|
if self.active_pane_ix == Some(ix) {
|
||||||
// active pane.
|
magnification
|
||||||
|
} else {
|
||||||
|
1.
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| flexes[ix]);
|
||||||
|
|
||||||
let child_size = bounds
|
let child_size = bounds
|
||||||
.size
|
.size
|
||||||
.apply_along(self.axis, |_| space_per_flex * flexes[ix]);
|
.apply_along(self.axis, |_| space_per_flex * child_flex);
|
||||||
|
|
||||||
let child_bounds = Bounds {
|
let child_bounds = Bounds {
|
||||||
origin,
|
origin,
|
||||||
|
@ -857,20 +879,23 @@ mod element {
|
||||||
cx.with_z_index(0, |cx| {
|
cx.with_z_index(0, |cx| {
|
||||||
child.draw(origin, child_size.into(), cx);
|
child.draw(origin, child_size.into(), cx);
|
||||||
});
|
});
|
||||||
cx.with_z_index(1, |cx| {
|
|
||||||
if ix < len - 1 {
|
if active_pane_magnification.is_none() {
|
||||||
Self::push_handle(
|
cx.with_z_index(1, |cx| {
|
||||||
self.flexes.clone(),
|
if ix < len - 1 {
|
||||||
state.clone(),
|
Self::push_handle(
|
||||||
self.axis,
|
self.flexes.clone(),
|
||||||
ix,
|
state.clone(),
|
||||||
child_bounds,
|
self.axis,
|
||||||
bounds,
|
ix,
|
||||||
self.workspace.clone(),
|
child_bounds,
|
||||||
cx,
|
bounds,
|
||||||
);
|
self.workspace.clone(),
|
||||||
}
|
cx,
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
origin = origin.apply_along(self.axis, |val| val + child_size.along(self.axis));
|
origin = origin.apply_along(self.axis, |val| val + child_size.along(self.axis));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue