Add styles for microphone and speakers buttons

This commit is contained in:
Piotr Osiewicz 2023-06-23 11:52:06 +02:00
parent 8bd9fe1fb0
commit 437e41f99d
3 changed files with 85 additions and 10 deletions

View file

@ -451,21 +451,22 @@ impl CollabTitlebarItem {
) -> AnyElement<Self> { ) -> AnyElement<Self> {
let icon; let icon;
let tooltip; let tooltip;
let background; let is_muted = room.read(cx).is_muted().unwrap_or(false);
if room.read(cx).is_muted().unwrap_or(false) { if is_muted {
icon = "icons/radix/mic-mute.svg"; icon = "icons/radix/mic-mute.svg";
tooltip = "Unmute microphone\nRight click for options"; tooltip = "Unmute microphone\nRight click for options";
background = Color::red();
} else { } else {
icon = "icons/radix/mic.svg"; icon = "icons/radix/mic.svg";
tooltip = "Mute microphone\nRight click for options"; tooltip = "Mute microphone\nRight click for options";
background = Color::transparent_black();
} }
let titlebar = &theme.workspace.titlebar; let titlebar = &theme.workspace.titlebar;
MouseEventHandler::<ToggleMute, Self>::new(0, cx, |state, _| { MouseEventHandler::<ToggleMute, Self>::new(0, cx, |state, _| {
let style = titlebar.call_control.style_for(state); let style = titlebar
Svg::new(icon) .toggle_microphone_button
.in_state(is_muted)
.style_for(state);
let image = Svg::new(icon)
.with_color(style.color) .with_color(style.color)
.constrained() .constrained()
.with_width(style.icon_width) .with_width(style.icon_width)
@ -474,8 +475,12 @@ impl CollabTitlebarItem {
.with_width(style.button_width) .with_width(style.button_width)
.with_height(style.button_width) .with_height(style.button_width)
.contained() .contained()
.with_style(style.container) .with_style(style.container);
.with_background_color(background) if let Some(color) = style.container.background_color {
image.with_background_color(color)
} else {
image
}
}) })
.with_cursor_style(CursorStyle::PointingHand) .with_cursor_style(CursorStyle::PointingHand)
.on_click(MouseButton::Left, move |_, _, cx| { .on_click(MouseButton::Left, move |_, _, cx| {
@ -499,7 +504,8 @@ impl CollabTitlebarItem {
) -> AnyElement<Self> { ) -> AnyElement<Self> {
let icon; let icon;
let tooltip; let tooltip;
if room.read(cx).is_deafened().unwrap_or(false) { let is_deafened = room.read(cx).is_deafened().unwrap_or(false);
if is_deafened {
icon = "icons/radix/speaker-off.svg"; icon = "icons/radix/speaker-off.svg";
tooltip = "Unmute speakers\nRight click for options"; tooltip = "Unmute speakers\nRight click for options";
} else { } else {
@ -509,7 +515,10 @@ impl CollabTitlebarItem {
let titlebar = &theme.workspace.titlebar; let titlebar = &theme.workspace.titlebar;
MouseEventHandler::<ToggleDeafen, Self>::new(0, cx, |state, _| { MouseEventHandler::<ToggleDeafen, Self>::new(0, cx, |state, _| {
let style = titlebar.call_control.style_for(state); let style = titlebar
.toggle_speakers_button
.in_state(is_deafened)
.style_for(state);
Svg::new(icon) Svg::new(icon)
.with_color(style.color) .with_color(style.color)
.constrained() .constrained()

View file

@ -133,6 +133,8 @@ pub struct Titlebar {
pub share_button: Toggleable<Interactive<ContainedText>>, pub share_button: Toggleable<Interactive<ContainedText>>,
pub call_control: Interactive<IconButton>, pub call_control: Interactive<IconButton>,
pub toggle_contacts_button: Toggleable<Interactive<IconButton>>, pub toggle_contacts_button: Toggleable<Interactive<IconButton>>,
pub toggle_microphone_button: Toggleable<Interactive<IconButton>>,
pub toggle_speakers_button: Toggleable<Interactive<IconButton>>,
pub user_menu_button: Toggleable<Interactive<IconButton>>, pub user_menu_button: Toggleable<Interactive<IconButton>>,
pub toggle_contacts_badge: ContainerStyle, pub toggle_contacts_badge: ContainerStyle,
} }

View file

@ -343,6 +343,70 @@ export default function workspace(colorScheme: ColorScheme) {
}, },
}, },
}), }),
toggleMicrophoneButton: toggleable({
base: interactive({
base: {
margin: { left: itemSpacing },
cornerRadius: 6,
color: foreground(layer, "variant"),
iconWidth: 14,
buttonWidth: 20,
},
state: {
clicked: {
background: background(layer, "variant", "pressed"),
},
hovered: {
background: background(layer, "variant", "hovered"),
},
},
}),
state: {
active: {
default: {
background: background(layer, "on", "default"),
},
hovered: {
background: background(layer, "on", "hovered"),
},
clicked: {
background: background(layer, "on", "pressed"),
},
},
},
}),
toggleSpeakersButton: toggleable({
base: interactive({
base: {
margin: { left: itemSpacing },
cornerRadius: 6,
color: foreground(layer, "variant"),
iconWidth: 14,
buttonWidth: 20,
},
state: {
clicked: {
background: background(layer, "variant", "pressed"),
},
hovered: {
background: background(layer, "variant", "hovered"),
},
},
}),
state: {
active: {
default: {
background: background(layer, "on", "default"),
},
hovered: {
background: background(layer, "on", "hovered"),
},
clicked: {
background: background(layer, "on", "pressed"),
},
},
},
}),
userMenuButton: merge(titlebarButton, { userMenuButton: merge(titlebarButton, {
inactive: { inactive: {
default: { default: {