From df1810a3b001d46503733014d9c509e7e5b53007 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 27 Jan 2022 18:59:44 -0700 Subject: [PATCH] A bit more progress styling find Fix the pinwheel when hovering mode buttons. --- crates/find/src/find.rs | 13 ++++++++----- crates/theme/src/theme.rs | 11 ++++++++++- crates/zed/assets/themes/_base.toml | 7 +++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/crates/find/src/find.rs b/crates/find/src/find.rs index 41dcbe38b2..2b862fc075 100644 --- a/crates/find/src/find.rs +++ b/crates/find/src/find.rs @@ -53,15 +53,17 @@ impl View for FindBar { fn render(&mut self, cx: &mut RenderContext) -> ElementBox { let theme = &self.settings.borrow().theme.find; - Flex::column() + Flex::row() .with_child( ChildView::new(&self.query_editor) .contained() - .with_style(theme.query.container) + .with_style(theme.editor.input.container) + .constrained() + .with_max_width(theme.editor.max_width) .boxed(), ) .with_child( - Flex::column() + Flex::row() .with_child(self.render_mode_button("Aa", SearchMode::CaseSensitive, theme, cx)) .with_child(self.render_mode_button("|ab|", SearchMode::WholeWord, theme, cx)) .with_child(self.render_mode_button(".*", SearchMode::Regex, theme, cx)) @@ -70,6 +72,7 @@ impl View for FindBar { .boxed(), ) .contained() + .with_style(theme.container) .boxed() } } @@ -94,7 +97,7 @@ impl FindBar { Arc::new(move |_| { let settings = settings.borrow(); EditorSettings { - style: settings.theme.find.query.as_editor(), + style: settings.theme.find.editor.input.as_editor(), tab_size: settings.tab_size, soft_wrap: editor::SoftWrap::None, } @@ -124,7 +127,7 @@ impl FindBar { cx: &mut RenderContext, ) -> ElementBox { let is_active = self.is_mode_enabled(mode); - MouseEventHandler::new::(0, cx, |state, _| { + MouseEventHandler::new::(mode as usize, cx, |state, _| { let style = match (is_active, state.hovered) { (false, false) => &theme.mode_button, (false, true) => &theme.hovered_mode_button, diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 0ea5ebee40..e4274653e8 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -90,7 +90,9 @@ pub struct Tab { #[derive(Clone, Deserialize, Default)] pub struct Find { - pub query: InputEditorStyle, + #[serde(flatten)] + pub container: ContainerStyle, + pub editor: FindEditor, pub mode_button_group: ContainerStyle, pub mode_button: ContainedText, pub active_mode_button: ContainedText, @@ -99,6 +101,13 @@ pub struct Find { pub match_background: Color, } +#[derive(Clone, Deserialize, Default)] +pub struct FindEditor { + #[serde(flatten)] + pub input: InputEditorStyle, + pub max_width: f32, +} + #[derive(Deserialize, Default)] pub struct Sidebar { #[serde(flatten)] diff --git a/crates/zed/assets/themes/_base.toml b/crates/zed/assets/themes/_base.toml index 0f8326e838..b52e80e400 100644 --- a/crates/zed/assets/themes/_base.toml +++ b/crates/zed/assets/themes/_base.toml @@ -321,6 +321,7 @@ tab_summary_spacing = 10 [find] match_background = "$state.highlighted_line" +background = "$surface.1" [find.mode_button] extends = "$text.1" @@ -341,10 +342,12 @@ background = "$surface.2" extends = "$find.mode_button" background = "$surface.2" -[find.query] -background = "$surface.1" +[find.editor] +max_width = 400 +background = "$surface.0" corner_radius = 6 padding = { left = 16, right = 16, top = 7, bottom = 7 } +margin = { top = 5, bottom = 5, left = 5, right = 5 } text = "$text.0" placeholder_text = "$text.2" selection = "$selection.host"