Add active pane magnification setting which grows the active pane making it easier to see it's contents

This commit is contained in:
K Simmons 2022-10-25 17:24:19 -07:00
parent 076d353e84
commit e2ba8d6df7
4 changed files with 273 additions and 230 deletions

View File

@ -5,6 +5,9 @@
"buffer_font_family": "Zed Mono",
// The default font size for text in the editor
"buffer_font_size": 15,
// The factor to grow the active pane by. Defaults to 1.0
// which gives the same size as all other panes.
"active_pane_magnification": 1.0,
// Whether to enable vim modes and key bindings
"vim_mode": false,
// Whether to show the informational hover box when moving the mouse

View File

@ -28,6 +28,7 @@ pub struct Settings {
pub buffer_font_family: FamilyId,
pub default_buffer_font_size: f32,
pub buffer_font_size: f32,
pub active_pane_magnification: f32,
pub cursor_blink: bool,
pub hover_popover_enabled: bool,
pub show_completions_on_input: bool,
@ -235,6 +236,8 @@ pub struct SettingsFileContent {
#[serde(default)]
pub buffer_font_size: Option<f32>,
#[serde(default)]
pub active_pane_magnification: Option<f32>,
#[serde(default)]
pub cursor_blink: Option<bool>,
#[serde(default)]
pub hover_popover_enabled: Option<bool>,
@ -294,6 +297,7 @@ impl Settings {
.load_family(&[defaults.buffer_font_family.as_ref().unwrap()])
.unwrap(),
buffer_font_size: defaults.buffer_font_size.unwrap(),
active_pane_magnification: defaults.active_pane_magnification.unwrap(),
default_buffer_font_size: defaults.buffer_font_size.unwrap(),
cursor_blink: defaults.cursor_blink.unwrap(),
hover_popover_enabled: defaults.hover_popover_enabled.unwrap(),
@ -349,6 +353,10 @@ impl Settings {
data.projects_online_by_default,
);
merge(&mut self.buffer_font_size, data.buffer_font_size);
merge(
&mut self.active_pane_magnification,
data.active_pane_magnification,
);
merge(&mut self.default_buffer_font_size, data.buffer_font_size);
merge(&mut self.cursor_blink, data.cursor_blink);
merge(&mut self.hover_popover_enabled, data.hover_popover_enabled);
@ -440,6 +448,7 @@ impl Settings {
experiments: FeatureFlags::default(),
buffer_font_family: cx.font_cache().load_family(&["Monaco"]).unwrap(),
buffer_font_size: 14.,
active_pane_magnification: 1.,
default_buffer_font_size: 14.,
cursor_blink: true,
hover_popover_enabled: true,

View File

@ -6,6 +6,7 @@ use gpui::{
};
use project::Project;
use serde::Deserialize;
use settings::Settings;
use theme::Theme;
#[derive(Clone, Debug, Eq, PartialEq)]
@ -61,10 +62,17 @@ impl PaneGroup {
theme: &Theme,
follower_states: &FollowerStatesByLeader,
active_call: Option<&ModelHandle<ActiveCall>>,
active_pane: &ViewHandle<Pane>,
cx: &mut RenderContext<Workspace>,
) -> ElementBox {
self.root
.render(project, theme, follower_states, active_call, cx)
self.root.render(
project,
theme,
follower_states,
active_call,
active_pane,
cx,
)
}
pub(crate) fn panes(&self) -> Vec<&ViewHandle<Pane>> {
@ -102,12 +110,20 @@ impl Member {
Member::Axis(PaneAxis { axis, members })
}
fn contains(&self, needle: &ViewHandle<Pane>) -> bool {
match self {
Member::Axis(axis) => axis.members.iter().any(|member| member.contains(needle)),
Member::Pane(pane) => pane == needle,
}
}
pub fn render(
&self,
project: &ModelHandle<Project>,
theme: &Theme,
follower_states: &FollowerStatesByLeader,
active_call: Option<&ModelHandle<ActiveCall>>,
active_pane: &ViewHandle<Pane>,
cx: &mut RenderContext<Workspace>,
) -> ElementBox {
enum FollowIntoExternalProject {}
@ -234,7 +250,14 @@ impl Member {
.with_children(prompt)
.boxed()
}
Member::Axis(axis) => axis.render(project, theme, follower_states, active_call, cx),
Member::Axis(axis) => axis.render(
project,
theme,
follower_states,
active_call,
active_pane,
cx,
),
}
}
@ -340,12 +363,19 @@ impl PaneAxis {
theme: &Theme,
follower_state: &FollowerStatesByLeader,
active_call: Option<&ModelHandle<ActiveCall>>,
active_pane: &ViewHandle<Pane>,
cx: &mut RenderContext<Workspace>,
) -> ElementBox {
let last_member_ix = self.members.len() - 1;
Flex::new(self.axis)
.with_children(self.members.iter().enumerate().map(|(ix, member)| {
let mut member = member.render(project, theme, follower_state, active_call, cx);
let mut flex = 1.0;
if member.contains(active_pane) {
flex = cx.global::<Settings>().active_pane_magnification;
}
let mut member =
member.render(project, theme, follower_state, active_call, active_pane, cx);
if ix < last_member_ix {
let mut border = theme.workspace.pane_divider;
border.left = false;
@ -359,7 +389,7 @@ impl PaneAxis {
member = Container::new(member).with_border(border).boxed();
}
FlexItem::new(member).flex(1.0, true).boxed()
FlexItem::new(member).flex(flex, true).boxed()
}))
.boxed()
}

View File

@ -2670,6 +2670,7 @@ impl View for Workspace {
&theme,
&self.follower_states_by_leader,
self.active_call(),
self.active_pane(),
cx,
))
.flex(1., true)