Add deafen button

This commit is contained in:
Piotr Osiewicz
2023-06-22 18:51:26 +02:00
parent 1a0b2bfef8
commit 18c4d43ee7
3 changed files with 51 additions and 4 deletions
+49 -4
View File
@@ -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<Room>,
@@ -489,7 +491,50 @@ impl CollabTitlebarItem {
.aligned()
.into_any()
}
fn render_toggle_deafen(
&self,
theme: &Theme,
room: &ModelHandle<Room>,
cx: &mut ViewContext<Self>,
) -> AnyElement<Self> {
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::<ToggleDeafen, Self>::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::<ToggleDeafen>(
0,
tooltip.into(),
Some(Box::new(ToggleDeafen)),
theme.tooltip.clone(),
cx,
)
.aligned()
.into_any()
}
fn render_in_call_share_unshare_button(
&self,
workspace: &ViewHandle<Workspace>,