Associate collaborator avatars with "ribbons" corresponding to their cursor color

This commit is contained in:
Nathan Sobo 2021-11-28 13:25:05 -07:00
parent a5039cad65
commit fbc307cd5e
6 changed files with 70 additions and 24 deletions

View file

@ -45,6 +45,7 @@ pub struct Titlebar {
pub height: f32,
pub title: TextStyle,
pub avatar_width: f32,
pub avatar_ribbon: AvatarRibbon,
pub offline_icon: OfflineIcon,
pub icon_color: Color,
pub avatar: ImageStyle,
@ -53,6 +54,14 @@ pub struct Titlebar {
pub outdated_warning: ContainedText,
}
#[derive(Clone, Deserialize, Default)]
pub struct AvatarRibbon {
#[serde(flatten)]
pub container: ContainerStyle,
pub width: f32,
pub height: f32,
}
#[derive(Clone, Deserialize, Default)]
pub struct OfflineIcon {
#[serde(flatten)]
@ -276,6 +285,15 @@ impl EditorStyle {
pub fn placeholder_text(&self) -> &TextStyle {
self.placeholder_text.as_ref().unwrap_or(&self.text)
}
pub fn replica_selection_style(&self, replica_id: u16) -> &SelectionStyle {
let style_ix = replica_id as usize % (self.guest_selections.len() + 1);
if style_ix == 0 {
&self.selection
} else {
&self.guest_selections[style_ix - 1]
}
}
}
impl InputEditorStyle {