From f5b2d56efd2ade03a9491aa4a57c92423be57275 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 28 Sep 2022 09:06:28 -0600 Subject: [PATCH] Remove contacts menu bar extra Co-Authored-By: Antonio Scandurra --- Cargo.lock | 25 ----- crates/contacts_status_item/Cargo.toml | 32 ------- .../src/contacts_popover.rs | 94 ------------------- .../src/contacts_status_item.rs | 94 ------------------- crates/theme/src/theme.rs | 6 -- crates/zed/Cargo.toml | 1 - 6 files changed, 252 deletions(-) delete mode 100644 crates/contacts_status_item/Cargo.toml delete mode 100644 crates/contacts_status_item/src/contacts_popover.rs delete mode 100644 crates/contacts_status_item/src/contacts_status_item.rs diff --git a/Cargo.lock b/Cargo.lock index a8a89478fe3d8d83555637accd12496f12d714ea..c06a3ee93cc1abd90b71e362771dcd8ccd5727ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1150,30 +1150,6 @@ dependencies = [ "workspace", ] -[[package]] -name = "contacts_status_item" -version = "0.1.0" -dependencies = [ - "anyhow", - "client", - "collections", - "editor", - "futures", - "fuzzy", - "gpui", - "language", - "log", - "menu", - "picker", - "postage", - "project", - "serde", - "settings", - "theme", - "util", - "workspace", -] - [[package]] name = "context_menu" version = "0.1.0" @@ -7185,7 +7161,6 @@ dependencies = [ "collections", "command_palette", "contacts_panel", - "contacts_status_item", "context_menu", "ctor", "diagnostics", diff --git a/crates/contacts_status_item/Cargo.toml b/crates/contacts_status_item/Cargo.toml deleted file mode 100644 index df115a384220553afd75c37b6276931fe6794fb3..0000000000000000000000000000000000000000 --- a/crates/contacts_status_item/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "contacts_status_item" -version = "0.1.0" -edition = "2021" - -[lib] -path = "src/contacts_status_item.rs" -doctest = false - -[dependencies] -client = { path = "../client" } -collections = { path = "../collections" } -editor = { path = "../editor" } -fuzzy = { path = "../fuzzy" } -gpui = { path = "../gpui" } -menu = { path = "../menu" } -picker = { path = "../picker" } -project = { path = "../project" } -settings = { path = "../settings" } -theme = { path = "../theme" } -util = { path = "../util" } -workspace = { path = "../workspace" } -anyhow = "1.0" -futures = "0.3" -log = "0.4" -postage = { version = "0.4.1", features = ["futures-traits"] } -serde = { version = "1.0", features = ["derive", "rc"] } - -[dev-dependencies] -language = { path = "../language", features = ["test-support"] } -project = { path = "../project", features = ["test-support"] } -workspace = { path = "../workspace", features = ["test-support"] } diff --git a/crates/contacts_status_item/src/contacts_popover.rs b/crates/contacts_status_item/src/contacts_popover.rs deleted file mode 100644 index 2998d74ed8c3b608210c9d482831c3407a973c7f..0000000000000000000000000000000000000000 --- a/crates/contacts_status_item/src/contacts_popover.rs +++ /dev/null @@ -1,94 +0,0 @@ -use editor::Editor; -use gpui::{elements::*, Entity, RenderContext, View, ViewContext, ViewHandle}; -use settings::Settings; - -pub enum Event { - Deactivated, -} - -pub struct ContactsPopover { - filter_editor: ViewHandle, -} - -impl Entity for ContactsPopover { - type Event = Event; -} - -impl View for ContactsPopover { - fn ui_name() -> &'static str { - "ContactsPopover" - } - - fn render(&mut self, cx: &mut RenderContext) -> ElementBox { - let theme = &cx.global::().theme.contacts_popover; - - Flex::row() - .with_child( - ChildView::new(self.filter_editor.clone()) - .contained() - .with_style( - cx.global::() - .theme - .contacts_panel - .user_query_editor - .container, - ) - .flex(1., true) - .boxed(), - ) - // .with_child( - // MouseEventHandler::::new(0, cx, |_, _| { - // Svg::new("icons/user_plus_16.svg") - // .with_color(theme.add_contact_button.color) - // .constrained() - // .with_height(16.) - // .contained() - // .with_style(theme.add_contact_button.container) - // .aligned() - // .boxed() - // }) - // .with_cursor_style(CursorStyle::PointingHand) - // .on_click(MouseButton::Left, |_, cx| { - // cx.dispatch_action(contact_finder::Toggle) - // }) - // .boxed(), - // ) - .constrained() - .with_height( - cx.global::() - .theme - .contacts_panel - .user_query_editor_height, - ) - .aligned() - .top() - .contained() - .with_background_color(theme.background) - .with_uniform_padding(4.) - .boxed() - } -} - -impl ContactsPopover { - pub fn new(cx: &mut ViewContext) -> Self { - cx.observe_window_activation(Self::window_activation_changed) - .detach(); - - let filter_editor = cx.add_view(|cx| { - let mut editor = Editor::single_line( - Some(|theme| theme.contacts_panel.user_query_editor.clone()), - cx, - ); - editor.set_placeholder_text("Filter contacts", cx); - editor - }); - - Self { filter_editor } - } - - fn window_activation_changed(&mut self, is_active: bool, cx: &mut ViewContext) { - if !is_active { - cx.emit(Event::Deactivated); - } - } -} diff --git a/crates/contacts_status_item/src/contacts_status_item.rs b/crates/contacts_status_item/src/contacts_status_item.rs deleted file mode 100644 index 5d471abcdf51f2153a5cd98627ef5478fb3ceccb..0000000000000000000000000000000000000000 --- a/crates/contacts_status_item/src/contacts_status_item.rs +++ /dev/null @@ -1,94 +0,0 @@ -mod contacts_popover; - -use contacts_popover::ContactsPopover; -use gpui::{ - actions, - color::Color, - elements::*, - geometry::{rect::RectF, vector::vec2f}, - Appearance, Entity, MouseButton, MutableAppContext, RenderContext, View, ViewContext, - ViewHandle, WindowKind, -}; - -actions!(contacts_status_item, [ToggleContactsPopover]); - -pub fn init(cx: &mut MutableAppContext) { - cx.add_action(ContactsStatusItem::toggle_contacts_popover); -} - -pub struct ContactsStatusItem { - popover: Option>, -} - -impl Entity for ContactsStatusItem { - type Event = (); -} - -impl View for ContactsStatusItem { - fn ui_name() -> &'static str { - "ContactsStatusItem" - } - - fn render(&mut self, cx: &mut RenderContext) -> ElementBox { - let color = match cx.appearance { - Appearance::Light | Appearance::VibrantLight => Color::black(), - Appearance::Dark | Appearance::VibrantDark => Color::white(), - }; - MouseEventHandler::::new(0, cx, |_, _| { - Svg::new("icons/zed_22.svg") - .with_color(color) - .aligned() - .boxed() - }) - .on_click(MouseButton::Left, |_, cx| { - cx.dispatch_action(ToggleContactsPopover); - }) - .boxed() - } -} - -impl ContactsStatusItem { - pub fn new() -> Self { - Self { popover: None } - } - - fn toggle_contacts_popover(&mut self, _: &ToggleContactsPopover, cx: &mut ViewContext) { - match self.popover.take() { - Some(popover) => { - cx.remove_window(popover.window_id()); - } - None => { - let window_bounds = cx.window_bounds(); - let size = vec2f(360., 460.); - let origin = window_bounds.lower_left() - + vec2f(window_bounds.width() / 2. - size.x() / 2., 0.); - let (_, popover) = cx.add_window( - gpui::WindowOptions { - bounds: gpui::WindowBounds::Fixed(RectF::new(origin, size)), - titlebar: None, - center: false, - kind: WindowKind::PopUp, - is_movable: false, - }, - |cx| ContactsPopover::new(cx), - ); - cx.subscribe(&popover, Self::on_popover_event).detach(); - self.popover = Some(popover); - } - } - } - - fn on_popover_event( - &mut self, - popover: ViewHandle, - event: &contacts_popover::Event, - cx: &mut ViewContext, - ) { - match event { - contacts_popover::Event::Deactivated => { - self.popover.take(); - cx.remove_window(popover.window_id()); - } - } - } -} diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 4446e4e06fec57dc07f3926fb55a30e5d5b8b2ee..4192bc0752c51ea3835b3a98631cb564a20b1672 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -19,7 +19,6 @@ pub struct Theme { pub workspace: Workspace, pub context_menu: ContextMenu, pub chat_panel: ChatPanel, - pub contacts_popover: ContactsPopover, pub contacts_panel: ContactsPanel, pub contact_finder: ContactFinder, pub project_panel: ProjectPanel, @@ -325,11 +324,6 @@ pub struct CommandPalette { pub keystroke_spacing: f32, } -#[derive(Deserialize, Default)] -pub struct ContactsPopover { - pub background: Color, -} - #[derive(Deserialize, Default)] pub struct ContactsPanel { #[serde(flatten)] diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 6c2ce8ff07b9aecdc8e204d0c162761a719d75c5..82629705a169c8ec3c0bcb8dfa68b01aa7b4ab5a 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -28,7 +28,6 @@ context_menu = { path = "../context_menu" } client = { path = "../client" } clock = { path = "../clock" } contacts_panel = { path = "../contacts_panel" } -contacts_status_item = { path = "../contacts_status_item" } diagnostics = { path = "../diagnostics" } editor = { path = "../editor" } file_finder = { path = "../file_finder" }