From 06456edf11df0dd753f8945b127251983ee7047d Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Tue, 24 May 2022 10:41:09 +0100 Subject: [PATCH] editor tab minum width --- defaults/settings.toml | 1 + lapce-data/src/config.rs | 7 +++++++ lapce-ui/src/editor/tab_header_content.rs | 3 ++- lapce-ui/src/settings.rs | 3 ++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/defaults/settings.toml b/defaults/settings.toml index 12f15a30..fbf614c4 100644 --- a/defaults/settings.toml +++ b/defaults/settings.toml @@ -8,6 +8,7 @@ font-family = "" font-size = 13 header-height = 30 status-height = 25 +tab-min-width = 100 activity-width = 50 scroll-width = 10 drop-shadow = true diff --git a/lapce-data/src/config.rs b/lapce-data/src/config.rs index c7a92ea2..725bd46e 100644 --- a/lapce-data/src/config.rs +++ b/lapce-data/src/config.rs @@ -170,6 +170,9 @@ pub struct UIConfig { #[field_names(desc = "Set the height for status line")] status_height: usize, + #[field_names(desc = "Set the minium width for editor tab")] + tab_min_width: usize, + #[field_names(desc = "Set the width for activity bar")] activity_width: usize, @@ -203,6 +206,10 @@ pub fn status_height(&self) -> usize { self.status_height.max(font_size) } + pub fn tab_min_width(&self) -> usize { + self.tab_min_width + } + pub fn activity_width(&self) -> usize { self.activity_width } diff --git a/lapce-ui/src/editor/tab_header_content.rs b/lapce-ui/src/editor/tab_header_content.rs index 8b5b9090..04d1f573 100644 --- a/lapce-ui/src/editor/tab_header_content.rs +++ b/lapce-ui/src/editor/tab_header_content.rs @@ -386,7 +386,8 @@ fn layout( .build() .unwrap(); let text_size = text_layout.size(); - let width = (text_size.width + height * 2.0).max(100.0); + let width = (text_size.width + height * 2.0) + .max(data.config.ui.tab_min_width() as f64); let close_size = 24.0; let inflate = (height - close_size) / 2.0; let tab_rect = TabRect { diff --git a/lapce-ui/src/settings.rs b/lapce-ui/src/settings.rs index 2060013e..c7a8a007 100644 --- a/lapce-ui/src/settings.rs +++ b/lapce-ui/src/settings.rs @@ -953,7 +953,8 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) { if ctx.is_hot() { ctx.fill( rect, - data.config.get_color_unchecked(LapceTheme::PANEL_HOVERED), + data.config + .get_color_unchecked(LapceTheme::EDITOR_CURRENT_LINE), ); }