From 18c4d43ee718172cab2179100017fcc28ba172b3 Mon Sep 17 00:00:00 2001
From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Date: Thu, 22 Jun 2023 18:49:18 +0200
Subject: [PATCH] Add deafen button
---
assets/icons/speakers_active_12.svg | 1 +
assets/icons/speakers_inactive_12.svg | 1 +
crates/collab_ui/src/collab_titlebar_item.rs | 53 ++++++++++++++++++--
3 files changed, 51 insertions(+), 4 deletions(-)
create mode 100644 assets/icons/speakers_active_12.svg
create mode 100644 assets/icons/speakers_inactive_12.svg
diff --git a/assets/icons/speakers_active_12.svg b/assets/icons/speakers_active_12.svg
new file mode 100644
index 0000000000000000000000000000000000000000..10416a8f79248d09a28e47d9e117cebf524a5179
--- /dev/null
+++ b/assets/icons/speakers_active_12.svg
@@ -0,0 +1 @@
+
diff --git a/assets/icons/speakers_inactive_12.svg b/assets/icons/speakers_inactive_12.svg
new file mode 100644
index 0000000000000000000000000000000000000000..a74990d983e3cbae0822b3a6780074e7e227cd10
--- /dev/null
+++ b/assets/icons/speakers_inactive_12.svg
@@ -0,0 +1 @@
+
diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs
index 0bdca280376310b528d06ac1c42a63ea08c11cc9..ddc3f538018842586a71f7c19f480991688259f6 100644
--- a/crates/collab_ui/src/collab_titlebar_item.rs
+++ b/crates/collab_ui/src/collab_titlebar_item.rs
@@ -1,6 +1,7 @@
use crate::{
- contact_notification::ContactNotification, contacts_popover, face_pile::FacePile, toggle_mute,
- toggle_screen_sharing, ToggleMute, ToggleScreenSharing,
+ contact_notification::ContactNotification, contacts_popover, face_pile::FacePile,
+ toggle_deafen, toggle_mute, toggle_screen_sharing, ToggleDeafen, ToggleMute,
+ ToggleScreenSharing,
};
use call::{ActiveCall, ParticipantLocation, Room};
use client::{proto::PeerId, Client, ContactEventKind, SignIn, SignOut, User, UserStore};
@@ -88,7 +89,8 @@ impl View for CollabTitlebarItem {
left_container
.add_child(self.render_current_user(&workspace, &theme, &user, peer_id, cx));
left_container.add_children(self.render_collaborators(&workspace, &theme, &room, cx));
- right_container.add_child(self.render_toggle_microphone(&theme, &room, cx));
+ right_container.add_child(self.render_toggle_mute(&theme, &room, cx));
+ right_container.add_child(self.render_toggle_deafen(&theme, &room, cx));
right_container.add_child(self.render_toggle_screen_sharing_button(&theme, &room, cx));
}
@@ -441,7 +443,7 @@ impl CollabTitlebarItem {
.aligned()
.into_any()
}
- fn render_toggle_microphone(
+ fn render_toggle_mute(
&self,
theme: &Theme,
room: &ModelHandle,
@@ -489,7 +491,50 @@ impl CollabTitlebarItem {
.aligned()
.into_any()
}
+ fn render_toggle_deafen(
+ &self,
+ theme: &Theme,
+ room: &ModelHandle,
+ cx: &mut ViewContext,
+ ) -> AnyElement {
+ let icon;
+ let tooltip;
+ if room.read(cx).is_deafened().unwrap_or(false) {
+ icon = "icons/speakers_inactive_12.svg";
+ tooltip = "Unmute speakers\nRight click for options";
+ } else {
+ icon = "icons/speakers_active_12.svg";
+ tooltip = "Mute speakers\nRight click for options";
+ }
+ let titlebar = &theme.workspace.titlebar;
+ MouseEventHandler::::new(0, cx, |state, _| {
+ let style = titlebar.call_control.style_for(state);
+ 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)
+ })
+ .with_cursor_style(CursorStyle::PointingHand)
+ .on_click(MouseButton::Left, move |_, _, cx| {
+ toggle_deafen(&Default::default(), cx)
+ })
+ .with_tooltip::(
+ 0,
+ tooltip.into(),
+ Some(Box::new(ToggleDeafen)),
+ theme.tooltip.clone(),
+ cx,
+ )
+ .aligned()
+ .into_any()
+ }
fn render_in_call_share_unshare_button(
&self,
workspace: &ViewHandle,