Add same grayscale logic to followers which leaders have

This commit is contained in:
Julia 2023-02-23 15:59:37 -05:00
parent 6ccc90327c
commit e1df85e86d
3 changed files with 36 additions and 31 deletions

View file

@ -278,7 +278,7 @@ impl CollabTitlebarItem {
pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext<Self>) { pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext<Self>) {
let theme = cx.global::<Settings>().theme.clone(); let theme = cx.global::<Settings>().theme.clone();
let avatar_style = theme.workspace.titlebar.avatar.clone(); let avatar_style = theme.workspace.titlebar.leader_avatar.clone();
let item_style = theme.context_menu.item.disabled_style().clone(); let item_style = theme.context_menu.item.disabled_style().clone();
self.user_menu.update(cx, |user_menu, cx| { self.user_menu.update(cx, |user_menu, cx| {
let items = if let Some(user) = self.user_store.read(cx).current_user() { let items = if let Some(user) = self.user_store.read(cx).current_user() {
@ -653,20 +653,8 @@ impl CollabTitlebarItem {
}) })
.unwrap_or(false); .unwrap_or(false);
let avatar_style; let leader_style = theme.workspace.titlebar.leader_avatar;
if let Some(location) = location { let follower_style = theme.workspace.titlebar.follower_avatar;
if let ParticipantLocation::SharedProject { project_id } = location {
if Some(project_id) == workspace.read(cx).project().read(cx).remote_id() {
avatar_style = &theme.workspace.titlebar.avatar;
} else {
avatar_style = &theme.workspace.titlebar.inactive_avatar;
}
} else {
avatar_style = &theme.workspace.titlebar.inactive_avatar;
}
} else {
avatar_style = &theme.workspace.titlebar.avatar;
}
let mut background_color = theme let mut background_color = theme
.workspace .workspace
@ -687,7 +675,7 @@ impl CollabTitlebarItem {
let face_pile = FacePile::new(theme.workspace.titlebar.follower_avatar_overlap) let face_pile = FacePile::new(theme.workspace.titlebar.follower_avatar_overlap)
.with_child(Self::render_face( .with_child(Self::render_face(
avatar.clone(), avatar.clone(),
avatar_style.clone(), Self::location_style(workspace, location, leader_style, cx),
background_color, background_color,
)) ))
.with_children( .with_children(
@ -696,9 +684,11 @@ impl CollabTitlebarItem {
let followers = room.followers_for(peer_id); let followers = room.followers_for(peer_id);
Some(followers.into_iter().flat_map(|&follower| { Some(followers.into_iter().flat_map(|&follower| {
let avatar = room let remote_participant =
.remote_participant_for_peer_id(follower) room.remote_participant_for_peer_id(follower);
.and_then(|participant| participant.user.avatar.clone())
let avatar = remote_participant
.and_then(|p| p.user.avatar.clone())
.or_else(|| { .or_else(|| {
if follower == workspace.read(cx).client().peer_id()? { if follower == workspace.read(cx).client().peer_id()? {
workspace workspace
@ -713,9 +703,11 @@ impl CollabTitlebarItem {
} }
})?; })?;
let location = remote_participant.map(|p| p.location);
Some(Self::render_face( Some(Self::render_face(
avatar.clone(), avatar.clone(),
theme.workspace.titlebar.follower_avatar.clone(), Self::location_style(workspace, location, follower_style, cx),
background_color, background_color,
)) ))
})) }))
@ -801,6 +793,25 @@ impl CollabTitlebarItem {
content content
} }
fn location_style(
workspace: &ViewHandle<Workspace>,
location: Option<ParticipantLocation>,
mut style: AvatarStyle,
cx: &RenderContext<Self>,
) -> AvatarStyle {
if let Some(location) = location {
if let ParticipantLocation::SharedProject { project_id } = location {
if Some(project_id) != workspace.read(cx).project().read(cx).remote_id() {
style.image.grayscale = true;
}
} else {
style.image.grayscale = true;
}
}
style
}
fn render_face( fn render_face(
avatar: Arc<ImageData>, avatar: Arc<ImageData>,
avatar_style: AvatarStyle, avatar_style: AvatarStyle,

View file

@ -80,9 +80,9 @@ pub struct Titlebar {
pub follower_avatar_overlap: f32, pub follower_avatar_overlap: f32,
pub leader_selection: ContainerStyle, pub leader_selection: ContainerStyle,
pub offline_icon: OfflineIcon, pub offline_icon: OfflineIcon,
pub avatar: AvatarStyle, pub leader_avatar: AvatarStyle,
pub inactive_avatar: AvatarStyle,
pub follower_avatar: AvatarStyle, pub follower_avatar: AvatarStyle,
pub inactive_avatar_grayscale: bool,
pub sign_in_prompt: Interactive<ContainedText>, pub sign_in_prompt: Interactive<ContainedText>,
pub outdated_warning: ContainedText, pub outdated_warning: ContainedText,
pub share_button: Interactive<ContainedText>, pub share_button: Interactive<ContainedText>,
@ -92,7 +92,7 @@ pub struct Titlebar {
pub toggle_contacts_badge: ContainerStyle, pub toggle_contacts_badge: ContainerStyle,
} }
#[derive(Clone, Deserialize, Default)] #[derive(Copy, Clone, Deserialize, Default)]
pub struct AvatarStyle { pub struct AvatarStyle {
#[serde(flatten)] #[serde(flatten)]
pub image: ImageStyle, pub image: ImageStyle,

View file

@ -97,25 +97,19 @@ export default function workspace(colorScheme: ColorScheme) {
title: text(layer, "sans", "variant"), title: text(layer, "sans", "variant"),
// Collaborators // Collaborators
avatar: { leaderAvatar: {
width: avatarWidth, width: avatarWidth,
outerWidth: avatarOuterWidth, outerWidth: avatarOuterWidth,
cornerRadius: avatarWidth / 2, cornerRadius: avatarWidth / 2,
outerCornerRadius: avatarOuterWidth / 2, outerCornerRadius: avatarOuterWidth / 2,
}, },
inactiveAvatar: {
width: avatarWidth,
outerWidth: avatarOuterWidth,
cornerRadius: avatarWidth / 2,
outerCornerRadius: avatarOuterWidth / 2,
grayscale: true,
},
followerAvatar: { followerAvatar: {
width: followerAvatarWidth, width: followerAvatarWidth,
outerWidth: followerAvatarOuterWidth, outerWidth: followerAvatarOuterWidth,
cornerRadius: followerAvatarWidth / 2, cornerRadius: followerAvatarWidth / 2,
outerCornerRadius: followerAvatarOuterWidth / 2, outerCornerRadius: followerAvatarOuterWidth / 2,
}, },
inactiveAvatarGrayscale: true,
followerAvatarOverlap: 8, followerAvatarOverlap: 8,
leaderSelection: { leaderSelection: {
margin: { margin: {