diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index 42ddd3c5da..3dda0b2e22 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -25,7 +25,7 @@ actions!( collab, [ ToggleCollaboratorList, - ToggleCollaborationMenu, + ToggleContactsMenu, ShareProject, UnshareProject ] @@ -87,24 +87,19 @@ impl View for CollabTitlebarItem { left_container.add_child(self.render_toggle_collaborator_list_button(&theme, cx)); left_container.add_child(self.render_current_user(&workspace, &theme, &user, cx)); left_container.add_children(self.render_collaborators(&workspace, &theme, room, cx)); + left_container.add_child(self.render_toggle_contacts_button(&theme, cx)); } let mut right_container = Flex::row(); right_container.add_children(self.render_toggle_screen_sharing_button(&theme, cx)); - if workspace.read(cx).client().status().borrow().is_connected() { - let project = workspace.read(cx).project().read(cx); - if project.is_shared() - || project.is_remote() - || ActiveCall::global(cx).read(cx).room().is_none() - { - right_container.add_child(self.render_toggle_contacts_button(&theme, cx)); - } - } - if ActiveCall::global(cx).read(cx).room().is_some() { - right_container.add_child(self.render_share_unshare_button(&workspace, &theme, cx)); + right_container + .add_child(self.render_in_call_share_unshare_button(&workspace, &theme, cx)); + } else { + right_container + .add_child(self.render_outside_call_share_button(&workspace, &theme, cx)); } right_container.add_children(self.render_connection_status(&workspace, cx)); @@ -310,11 +305,7 @@ impl CollabTitlebarItem { cx.notify(); } - pub fn toggle_contacts_popover( - &mut self, - _: &ToggleCollaborationMenu, - cx: &mut ViewContext, - ) { + pub fn toggle_contacts_popover(&mut self, _: &ToggleContactsMenu, cx: &mut ViewContext) { match self.contacts_popover.take() { Some(_) => {} None => { @@ -369,7 +360,7 @@ impl CollabTitlebarItem { Stack::new() .with_child( - MouseEventHandler::::new(0, cx, |state, _| { + MouseEventHandler::::new(0, cx, |state, _| { let style = titlebar .toggle_contacts_button .style_for(state, self.contacts_popover.is_some()); @@ -387,7 +378,7 @@ impl CollabTitlebarItem { }) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, move |_, cx| { - cx.dispatch_action(ToggleCollaborationMenu); + cx.dispatch_action(ToggleContactsMenu); }) .aligned() .boxed(), @@ -460,7 +451,7 @@ impl CollabTitlebarItem { ) } - fn render_share_unshare_button( + fn render_in_call_share_unshare_button( &self, workspace: &ViewHandle, theme: &Theme, @@ -476,8 +467,8 @@ impl CollabTitlebarItem { let titlebar = &theme.workspace.titlebar; - enum Share {} - MouseEventHandler::::new(0, cx, |state, _| { + enum ShareUnshare {} + MouseEventHandler::::new(0, cx, |state, _| { //TODO: Ensure this button has consistant width for both text variations let style = titlebar.share_button.style_for(state, false); Label::new(label, style.text.clone()) @@ -493,13 +484,68 @@ impl CollabTitlebarItem { cx.dispatch_action(ShareProject); } }) - .with_tooltip::(0, tooltip.to_owned(), None, theme.tooltip.clone(), cx) + .with_tooltip::(0, tooltip.to_owned(), None, theme.tooltip.clone(), cx) .aligned() .contained() .with_margin_left(theme.workspace.titlebar.avatar_margin) + .with_margin_right(theme.workspace.titlebar.avatar_margin) .boxed() } + fn render_outside_call_share_button( + &self, + workspace: &ViewHandle, + theme: &Theme, + cx: &mut RenderContext, + ) -> ElementBox { + let tooltip = "Share project with new call"; + let titlebar = &theme.workspace.titlebar; + + enum OutsideCallShare {} + Stack::new() + .with_child( + MouseEventHandler::::new(0, cx, |state, _| { + //TODO: Ensure this button has consistant width for both text variations + let style = titlebar.share_button.style_for(state, false); + Label::new("Share".to_owned(), style.text.clone()) + .contained() + .with_style(style.container) + .boxed() + }) + .with_cursor_style(CursorStyle::PointingHand) + .on_click(MouseButton::Left, move |_, cx| { + cx.dispatch_action(ToggleContactsMenu); + }) + .with_tooltip::( + 0, + tooltip.to_owned(), + None, + theme.tooltip.clone(), + cx, + ) + .boxed(), + ) + .with_children(self.contacts_popover.as_ref().map(|popover| { + Overlay::new( + ChildView::new(popover, cx) + .contained() + .with_margin_top(titlebar.height) + .with_margin_left(titlebar.toggle_contacts_button.default.button_width) + .with_margin_right(-titlebar.toggle_contacts_button.default.button_width) + .boxed(), + ) + .with_fit_mode(OverlayFitMode::SwitchAnchor) + .with_anchor_corner(AnchorCorner::BottomLeft) + .with_z_index(999) + .boxed() + })) + .aligned() + .contained() + .with_margin_left(theme.workspace.titlebar.avatar_margin) + .with_margin_right(theme.workspace.titlebar.avatar_margin) + .boxed() + } + fn render_collaborators( &self, workspace: &ViewHandle, diff --git a/crates/collab_ui/src/collab_ui.rs b/crates/collab_ui/src/collab_ui.rs index a99a7c4f0b..d250ce5576 100644 --- a/crates/collab_ui/src/collab_ui.rs +++ b/crates/collab_ui/src/collab_ui.rs @@ -11,7 +11,7 @@ mod sharing_status_indicator; use anyhow::anyhow; use call::ActiveCall; -pub use collab_titlebar_item::{CollabTitlebarItem, ToggleCollaborationMenu}; +pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu}; use gpui::{actions, MutableAppContext, Task}; use std::sync::Arc; use workspace::{AppState, JoinProject, ToggleFollow, Workspace}; diff --git a/crates/collab_ui/src/contacts_popover.rs b/crates/collab_ui/src/contacts_popover.rs index 37280f929e..0c67ef4c7c 100644 --- a/crates/collab_ui/src/contacts_popover.rs +++ b/crates/collab_ui/src/contacts_popover.rs @@ -1,4 +1,4 @@ -use crate::{contact_finder::ContactFinder, contact_list::ContactList, ToggleCollaborationMenu}; +use crate::{contact_finder::ContactFinder, contact_list::ContactList, ToggleContactsMenu}; use client::UserStore; use gpui::{ actions, elements::*, ClipboardItem, CursorStyle, Entity, ModelHandle, MouseButton, @@ -155,7 +155,7 @@ impl View for ContactsPopover { .boxed() }) .on_down_out(MouseButton::Left, move |_, cx| { - cx.dispatch_action(ToggleCollaborationMenu); + cx.dispatch_action(ToggleContactsMenu); }) .boxed() } diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 754195e099..19721547bd 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -6,7 +6,7 @@ use anyhow::{anyhow, Context, Result}; use assets::Assets; use breadcrumbs::Breadcrumbs; pub use client; -use collab_ui::{CollabTitlebarItem, ToggleCollaborationMenu}; +use collab_ui::{CollabTitlebarItem, ToggleContactsMenu}; use collections::VecDeque; pub use editor; use editor::{Editor, MultiBuffer}; @@ -99,9 +99,7 @@ pub fn init(app_state: &Arc, cx: &mut gpui::MutableAppContext) { }, ); cx.add_action( - |workspace: &mut Workspace, - _: &ToggleCollaborationMenu, - cx: &mut ViewContext| { + |workspace: &mut Workspace, _: &ToggleContactsMenu, cx: &mut ViewContext| { if let Some(item) = workspace .titlebar_item() .and_then(|item| item.downcast::())