Detailed changes
@@ -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",
@@ -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"] }
@@ -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<Editor>,
-}
-
-impl Entity for ContactsPopover {
- type Event = Event;
-}
-
-impl View for ContactsPopover {
- fn ui_name() -> &'static str {
- "ContactsPopover"
- }
-
- fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
- let theme = &cx.global::<Settings>().theme.contacts_popover;
-
- Flex::row()
- .with_child(
- ChildView::new(self.filter_editor.clone())
- .contained()
- .with_style(
- cx.global::<Settings>()
- .theme
- .contacts_panel
- .user_query_editor
- .container,
- )
- .flex(1., true)
- .boxed(),
- )
- // .with_child(
- // MouseEventHandler::<AddContact>::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::<Settings>()
- .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>) -> 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<Self>) {
- if !is_active {
- cx.emit(Event::Deactivated);
- }
- }
-}
@@ -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<ViewHandle<ContactsPopover>>,
-}
-
-impl Entity for ContactsStatusItem {
- type Event = ();
-}
-
-impl View for ContactsStatusItem {
- fn ui_name() -> &'static str {
- "ContactsStatusItem"
- }
-
- fn render(&mut self, cx: &mut RenderContext<Self>) -> ElementBox {
- let color = match cx.appearance {
- Appearance::Light | Appearance::VibrantLight => Color::black(),
- Appearance::Dark | Appearance::VibrantDark => Color::white(),
- };
- MouseEventHandler::<Self>::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<Self>) {
- 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<ContactsPopover>,
- event: &contacts_popover::Event,
- cx: &mut ViewContext<Self>,
- ) {
- match event {
- contacts_popover::Event::Deactivated => {
- self.popover.take();
- cx.remove_window(popover.window_id());
- }
- }
- }
-}
@@ -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)]
@@ -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" }