diff --git a/assets/icons/leave_12.svg b/assets/icons/leave_12.svg
new file mode 100644
index 0000000000000000000000000000000000000000..84491384b8cc7f80d4a727e75c142ee509b451ac
--- /dev/null
+++ b/assets/icons/leave_12.svg
@@ -0,0 +1,3 @@
+
diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs
index ffe5c161fd78ece6838bbcabc0397e2a64386441..e190deef84f4965af1dd2d94fe1be9963d1683ec 100644
--- a/crates/collab_ui/src/collab_titlebar_item.rs
+++ b/crates/collab_ui/src/collab_titlebar_item.rs
@@ -12,6 +12,7 @@ use gpui::{
color::Color,
elements::*,
geometry::{rect::RectF, vector::vec2f, PathBuilder},
+ impl_internal_actions,
json::{self, ToJson},
CursorStyle, Entity, ImageData, ModelHandle, MouseButton, MutableAppContext, RenderContext,
Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
@@ -32,6 +33,11 @@ actions!(
]
);
+impl_internal_actions!(collab, [LeaveCall]);
+
+#[derive(Copy, Clone, PartialEq)]
+pub(crate) struct LeaveCall;
+
#[derive(PartialEq, Eq)]
enum ContactsPopoverSide {
Left,
@@ -43,6 +49,7 @@ pub fn init(cx: &mut MutableAppContext) {
cx.add_action(CollabTitlebarItem::toggle_contacts_popover);
cx.add_action(CollabTitlebarItem::share_project);
cx.add_action(CollabTitlebarItem::unshare_project);
+ cx.add_action(CollabTitlebarItem::leave_call);
}
pub struct CollabTitlebarItem {
@@ -104,9 +111,9 @@ impl View for CollabTitlebarItem {
let mut right_container = Flex::row();
- right_container.add_children(self.render_toggle_screen_sharing_button(&theme, cx));
-
- if ActiveCall::global(cx).read(cx).room().is_some() {
+ if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
+ right_container.add_child(self.render_toggle_screen_sharing_button(&theme, &room, cx));
+ right_container.add_child(self.render_leave_call_button(&theme, cx));
right_container
.add_children(self.render_in_call_share_unshare_button(&workspace, &theme, cx));
} else {
@@ -284,6 +291,12 @@ impl CollabTitlebarItem {
cx.notify();
}
+ fn leave_call(&mut self, _: &LeaveCall, cx: &mut ViewContext) {
+ ActiveCall::global(cx)
+ .update(cx, |call, cx| call.hang_up(cx))
+ .log_err();
+ }
+
fn render_toggle_contacts_button(
&self,
theme: &Theme,
@@ -351,13 +364,11 @@ impl CollabTitlebarItem {
fn render_toggle_screen_sharing_button(
&self,
theme: &Theme,
+ room: &ModelHandle,
cx: &mut RenderContext,
- ) -> Option {
- let active_call = ActiveCall::global(cx);
- let room = active_call.read(cx).room().cloned()?;
+ ) -> ElementBox {
let icon;
let tooltip;
-
if room.read(cx).is_screen_sharing() {
icon = "icons/disable_screen_sharing_12.svg";
tooltip = "Stop Sharing Screen"
@@ -367,35 +378,67 @@ impl CollabTitlebarItem {
}
let titlebar = &theme.workspace.titlebar;
- Some(
- MouseEventHandler::::new(0, cx, |state, _| {
- let style = titlebar.call_control.style_for(state, false);
- Svg::new(icon)
- .with_color(style.color)
- .constrained()
- .with_width(style.icon_width)
- .aligned()
- .constrained()
- .with_width(style.button_width)
- .with_height(style.button_width)
- .contained()
- .with_style(style.container)
- .boxed()
- })
- .with_cursor_style(CursorStyle::PointingHand)
- .on_click(MouseButton::Left, move |_, cx| {
- cx.dispatch_action(ToggleScreenSharing);
- })
- .with_tooltip::(
- 0,
- tooltip.into(),
- Some(Box::new(ToggleScreenSharing)),
- theme.tooltip.clone(),
- cx,
- )
- .aligned()
- .boxed(),
+ MouseEventHandler::::new(0, cx, |state, _| {
+ let style = titlebar.call_control.style_for(state, false);
+ Svg::new(icon)
+ .with_color(style.color)
+ .constrained()
+ .with_width(style.icon_width)
+ .aligned()
+ .constrained()
+ .with_width(style.button_width)
+ .with_height(style.button_width)
+ .contained()
+ .with_style(style.container)
+ .boxed()
+ })
+ .with_cursor_style(CursorStyle::PointingHand)
+ .on_click(MouseButton::Left, move |_, cx| {
+ cx.dispatch_action(ToggleScreenSharing);
+ })
+ .with_tooltip::(
+ 0,
+ tooltip.into(),
+ Some(Box::new(ToggleScreenSharing)),
+ theme.tooltip.clone(),
+ cx,
)
+ .aligned()
+ .boxed()
+ }
+
+ fn render_leave_call_button(&self, theme: &Theme, cx: &mut RenderContext) -> ElementBox {
+ let titlebar = &theme.workspace.titlebar;
+
+ MouseEventHandler::::new(0, cx, |state, _| {
+ let style = titlebar.call_control.style_for(state, false);
+ Svg::new("icons/leave_12.svg")
+ .with_color(style.color)
+ .constrained()
+ .with_width(style.icon_width)
+ .aligned()
+ .constrained()
+ .with_width(style.button_width)
+ .with_height(style.button_width)
+ .contained()
+ .with_style(style.container)
+ .boxed()
+ })
+ .with_cursor_style(CursorStyle::PointingHand)
+ .on_click(MouseButton::Left, move |_, cx| {
+ cx.dispatch_action(LeaveCall);
+ })
+ .with_tooltip::(
+ 0,
+ "Leave call".to_owned(),
+ Some(Box::new(LeaveCall)),
+ theme.tooltip.clone(),
+ cx,
+ )
+ .contained()
+ .with_margin_left(theme.workspace.titlebar.item_spacing)
+ .aligned()
+ .boxed()
}
fn render_in_call_share_unshare_button(
diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs
index 0e129674d871b0d9785cba927b25464f1b1efd26..ba9bc8ad63dd75188a646ae2fc5ff875191889a5 100644
--- a/crates/collab_ui/src/contact_list.rs
+++ b/crates/collab_ui/src/contact_list.rs
@@ -1,3 +1,4 @@
+use super::collab_titlebar_item::LeaveCall;
use crate::contacts_popover;
use call::ActiveCall;
use client::{proto::PeerId, Contact, User, UserStore};
@@ -18,11 +19,10 @@ use serde::Deserialize;
use settings::Settings;
use std::{mem, sync::Arc};
use theme::IconButton;
-use util::ResultExt;
use workspace::{JoinProject, OpenSharedScreen};
impl_actions!(contact_list, [RemoveContact, RespondToContactRequest]);
-impl_internal_actions!(contact_list, [ToggleExpanded, Call, LeaveCall]);
+impl_internal_actions!(contact_list, [ToggleExpanded, Call]);
pub fn init(cx: &mut MutableAppContext) {
cx.add_action(ContactList::remove_contact);
@@ -33,7 +33,6 @@ pub fn init(cx: &mut MutableAppContext) {
cx.add_action(ContactList::confirm);
cx.add_action(ContactList::toggle_expanded);
cx.add_action(ContactList::call);
- cx.add_action(ContactList::leave_call);
}
#[derive(Clone, PartialEq)]
@@ -45,9 +44,6 @@ struct Call {
initial_project: Option>,
}
-#[derive(Copy, Clone, PartialEq)]
-struct LeaveCall;
-
#[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
enum Section {
ActiveCall,
@@ -981,6 +977,7 @@ impl ContactList {
cx: &mut RenderContext,
) -> ElementBox {
enum Header {}
+ enum LeaveCallContactList {}
let header_style = theme
.header_row
@@ -993,9 +990,9 @@ impl ContactList {
};
let leave_call = if section == Section::ActiveCall {
Some(
- MouseEventHandler::::new(0, cx, |state, _| {
+ MouseEventHandler::::new(0, cx, |state, _| {
let style = theme.leave_call.style_for(state, false);
- Label::new("Leave Session", style.text.clone())
+ Label::new("Leave Call", style.text.clone())
.contained()
.with_style(style.container)
.boxed()
@@ -1284,12 +1281,6 @@ impl ContactList {
})
.detach_and_log_err(cx);
}
-
- fn leave_call(&mut self, _: &LeaveCall, cx: &mut ViewContext) {
- ActiveCall::global(cx)
- .update(cx, |call, cx| call.hang_up(cx))
- .log_err();
- }
}
impl Entity for ContactList {