From 14ea2065218fd0c1f3abf910939fdfedb1fe9a9b Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 7 Oct 2026 19:06:10 +0000 Subject: [PATCH] ui: a colour per server, one letter in small avatars, one channel icon Servers took their colour from a palette of people's colours by a hash of the name, so two of the three sample servers were the same blue. vm::servers::tints gives each server, in the rail's order, a colour from ten hues around the wheel: its name's, or the next free one when an earlier server has it. The rail, Home, search, live rooms and the server chats in the chat lists use it. A server icon at most half as wide as its avatar (TeamSpeak's 16 px ones) is drawn at twice its size, sharp, on that colour instead of stretched. Avatars under 28 px show one letter (Images.first-letter, as Slint cannot cut a string). Channels show the speaker (Icons.channel) everywhere the hash or the volume icon stood for one, and tab titles, notifications and subtitles name them without a '#' (vm::chat::tab_title; private chats keep '@'). Member rows showed everyone's talk power as a bare number. They now show a muted hand, "Needs talk power to speak", only on those whose channel needs more than they have and who are no talker (vm::tree::cannot_talk); the member card keeps the number. The sample's Raid Night needs 50. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ --- CHANGELOG.md | 8 ++ crates/voelin-ui/src/bind/emoji.rs | 5 +- crates/voelin-ui/src/chat.rs | 36 ++------- crates/voelin-ui/src/dev.rs | 8 +- crates/voelin-ui/src/events.rs | 2 +- crates/voelin-ui/src/home.rs | 3 +- crates/voelin-ui/src/inbox.rs | 2 +- crates/voelin-ui/src/messages.rs | 14 ++-- crates/voelin-ui/src/servers.rs | 12 ++- crates/voelin-ui/src/social.rs | 15 ++-- crates/voelin-ui/src/studio.rs | 2 +- crates/voelin-ui/src/vm/avatar.rs | 32 +++++++- crates/voelin-ui/src/vm/chat.rs | 44 ++++++++++- crates/voelin-ui/src/vm/servers.rs | 85 ++++++++++++++++++++- crates/voelin-ui/src/vm/tree.rs | 50 +++++++++++- crates/voelin-ui/ui/bridge.slint | 16 ++-- crates/voelin-ui/ui/components/avatar.slint | 25 ++++-- crates/voelin-ui/ui/screens/channels.slint | 4 +- crates/voelin-ui/ui/screens/chat.slint | 6 +- crates/voelin-ui/ui/screens/events.slint | 4 +- crates/voelin-ui/ui/screens/members.slint | 19 +++-- crates/voelin-ui/ui/screens/overlays.slint | 2 +- crates/voelin-ui/ui/screens/streams.slint | 2 +- crates/voelin-ui/ui/screens/voice.slint | 2 +- crates/voelin-ui/ui/shells/mobile.slint | 2 +- docs/ui.md | 15 +++- 26 files changed, 320 insertions(+), 95 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 557dfa7..0b640c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,14 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows click) and your unread mentions; the welcome banner shows only before the first server. Friends show once, the quick actions are gone, and the sidebar lists your recent private chats. +- Each server has a colour of its own (two often shared a blue), and small + server icons are drawn sharp at twice their size instead of stretched. + Small avatars, as in the channel tree, show one letter. +- Channels have one icon everywhere, the speaker, and are named without a + `#` in tabs and elsewhere. +- The members panel shows a hand on those who need talk power to speak, + instead of everyone's talk power as a bare number (the member card still + has it). ### Fixed diff --git a/crates/voelin-ui/src/bind/emoji.rs b/crates/voelin-ui/src/bind/emoji.rs index b6aa01d..f82e990 100644 --- a/crates/voelin-ui/src/bind/emoji.rs +++ b/crates/voelin-ui/src/bind/emoji.rs @@ -1,4 +1,5 @@ -//! Emoji: images for the `Images` global, and the picker's rows. +//! Emoji: images for the `Images` global (and an avatar's one letter), and +//! the picker's rows. use std::rc::Rc; @@ -7,6 +8,7 @@ use slint::{ComponentHandle, Model, ModelRc, VecModel}; use crate::app::{Emoji, EmojiCell, EmojiRow, Images, MainWindow}; use crate::emoji::{self, PickerEmoji}; use crate::images; +use crate::vm::avatar; /// Rows of `columns` cells. fn rows(emoji: Vec, columns: usize) -> Vec { @@ -38,6 +40,7 @@ pub(super) fn wire(ui: &MainWindow) { let images_global = ui.global::(); images_global.on_emoji(|key| images::emoji(&key)); images_global.on_emoji_text(|key| emoji::text_of(&key).into()); + images_global.on_first_letter(|initials| avatar::first_letter(&initials).into()); let global = ui.global::(); let weak = ui.as_weak(); global.on_load(move || { diff --git a/crates/voelin-ui/src/chat.rs b/crates/voelin-ui/src/chat.rs index bb4f40d..c44d93a 100644 --- a/crates/voelin-ui/src/chat.rs +++ b/crates/voelin-ui/src/chat.rs @@ -103,19 +103,12 @@ fn ago(ts_ms: i64) -> String { impl App { pub(crate) fn open_chat(&mut self, target: ChatTarget, focus: bool) { let Some(id) = self.current else { return }; - let title = match &target { - ChatTarget::Channel(cid) => { - let name = self - .sessions - .get(&id) - .and_then(|v| v.presence.channels.get(cid)) - .map(|c| vm::tree::channel_title(c).0.to_owned()); - format!("#{}", name.unwrap_or_else(|| cid.to_string())) - } - ChatTarget::Server => "Server".into(), - ChatTarget::Private(uid) => format!("@{}", self.peer_name(uid, None)), + let peer = match &target { + ChatTarget::Private(uid) => self.peer_name(uid, None), + _ => String::new(), }; let view = self.sessions.entry(id).or_default(); + let title = vm::chat::tab_title(&view.presence, &target, &peer); let index = match view.tabs.iter().position(|t| t.target == target) { Some(i) => i, None => { @@ -189,21 +182,6 @@ impl App { } } - fn tab_title(view: &SessionView, target: &ChatTarget, author: &str) -> String { - match target { - ChatTarget::Channel(cid) => format!( - "#{}", - view.presence - .channels - .get(cid) - .map(|c| vm::tree::channel_title(c).0.to_owned()) - .unwrap_or_else(|| cid.to_string()) - ), - ChatTarget::Private(_) => format!("@{author}"), - ChatTarget::Server => "Server".into(), - } - } - /// A live message of a session without stored history: appended as it /// comes, without an id. pub(crate) fn add_message(&mut self, id: i64, message: ChatMessage) { @@ -211,7 +189,7 @@ impl App { let reading = self.reads_now(id); let new = !self.is_own(id, &message); let view = self.sessions.entry(id).or_default(); - let title = Self::tab_title(view, &message.target, &message.author_name); + let title = vm::chat::tab_title(&view.presence, &message.target, &message.author_name); let index = Self::tab_for(view, &message.target, || title); let seen = reading && view.current_tab == index; let tab = &mut view.tabs[index]; @@ -255,7 +233,7 @@ impl App { }; let view = self.sessions.entry(id).or_default(); let author = messages.first().map_or("", |m| m.message.author_name.as_str()); - let title = peer.unwrap_or_else(|| Self::tab_title(view, target, author)); + let title = peer.unwrap_or_else(|| vm::chat::tab_title(&view.presence, target, author)); let index = Self::tab_for(view, target, || title); let seen = reading && view.current_tab == index; let own_client = view.state.own_client; @@ -506,7 +484,7 @@ impl App { last: last.into(), time: time.into(), title: t.title.clone().into(), - name: t.title.trim_start_matches(['#', '@']).into(), + name: vm::chat::tab_name(&t.title, &t.target).into(), kind: match t.target { ChatTarget::Server => 0, ChatTarget::Channel(_) => 1, diff --git a/crates/voelin-ui/src/dev.rs b/crates/voelin-ui/src/dev.rs index de9efda..2f68fb7 100644 --- a/crates/voelin-ui/src/dev.rs +++ b/crates/voelin-ui/src/dev.rs @@ -559,6 +559,8 @@ fn demo_ui(app: &mut App) { let mut raid = channel(4, 3, 0, "Raid Night"); raid.banner_gfx_url = Some(DEMO_RAID_BANNER.into()); raid.banner_mode = BannerMode::KeepAspect; + // Only the raid leads speak there: Zeph cannot (the members panel's hand). + raid.needed_talk_power = 50; let mut music = channel(5, 0, 3, "Music"); music.icon = DEMO_MUSIC_ICON; music.banner_gfx_url = Some(DEMO_MUSIC_BANNER.into()); @@ -1117,7 +1119,7 @@ fn demo_social(app: &mut App) { app.notify( NoticeKind::Mention, "Talon mentioned you".into(), - "Nova, can you open the raid at 20:00? — #Chill Zone · Nightfall Guild".into(), + "Nova, can you open the raid at 20:00? — Chill Zone · Nightfall Guild".into(), NoticeTarget::Chat(DEMO, ChatTarget::Channel(2)), "Talon".into(), Some("demo-6".into()), @@ -1125,7 +1127,7 @@ fn demo_social(app: &mut App) { app.notify( NoticeKind::Mention, "Zeph mentioned you".into(), - "Nova, are you healing tonight? — #Raid Night · Nightfall Guild".into(), + "Nova, are you healing tonight? — Raid Night · Nightfall Guild".into(), NoticeTarget::Chat(DEMO, ChatTarget::Channel(4)), "Zeph".into(), Some("demo-7".into()), @@ -1141,7 +1143,7 @@ fn demo_social(app: &mut App) { app.notify( NoticeKind::Friend, "Ivy is online".into(), - "on Pixel Lounge · #Art Corner".into(), + "on Pixel Lounge · Art Corner".into(), NoticeTarget::Contact("demo-ivy".into()), "Ivy".into(), Some("demo-ivy".into()), diff --git a/crates/voelin-ui/src/events.rs b/crates/voelin-ui/src/events.rs index d3ca4e0..4758555 100644 --- a/crates/voelin-ui/src/events.rs +++ b/crates/voelin-ui/src/events.rs @@ -135,7 +135,7 @@ impl App { view.presence .channels .values() - .filter_map(|c| Some((Some(c.id), format!("#{}", vm::tree::listed_title(c)?)))), + .filter_map(|c| Some((Some(c.id), vm::tree::listed_title(c)?.to_owned()))), ); } out diff --git a/crates/voelin-ui/src/home.rs b/crates/voelin-ui/src/home.rs index f6bbe81..aa0c5ac 100644 --- a/crates/voelin-ui/src/home.rs +++ b/crates/voelin-ui/src/home.rs @@ -36,14 +36,13 @@ impl App { /// streaming. fn live_rooms(&self) -> Vec { let mut rooms = Vec::new(); - for b in &self.bookmarks { + for (b, backdrop) in self.bookmarks.iter().zip(vm::servers::tints(&self.bookmarks)) { let Some(view) = self.sessions.get(&b.id) else { continue }; let channel_of = |cid: Option| { cid.and_then(|c| view.presence.channels.get(&c)) .map(|c| vm::tree::channel_title(c).0.to_owned()) .unwrap_or_default() }; - let backdrop = vm::avatar::tint(&b.name); let item = |id: String, title: String, client: Option, diff --git a/crates/voelin-ui/src/inbox.rs b/crates/voelin-ui/src/inbox.rs index 441dc14..af7593c 100644 --- a/crates/voelin-ui/src/inbox.rs +++ b/crates/voelin-ui/src/inbox.rs @@ -76,7 +76,7 @@ impl App { .map(|c| { let name = view.presence.channels.get(&c).map(|c| crate::vm::tree::channel_title(c).0); - (c, name.map_or_else(|| "the channel".to_owned(), |n| format!("#{n}"))) + (c, name.map_or_else(|| "the channel".to_owned(), str::to_owned)) }); Some((id, tab.title.clone(), channel)) }); diff --git a/crates/voelin-ui/src/messages.rs b/crates/voelin-ui/src/messages.rs index 7c34abc..b728b69 100644 --- a/crates/voelin-ui/src/messages.rs +++ b/crates/voelin-ui/src/messages.rs @@ -196,8 +196,8 @@ impl App { .and_then(|s| self.sessions.get(&s)) .and_then(|v| v.presence.channels.get(cid)) .map_or_else( - || format!("#channel {cid}"), - |c| format!("#{}", vm::tree::channel_title(c).0), + || format!("Channel {cid}"), + |c| vm::tree::channel_title(c).0.to_owned(), ); (name, slint::Image::default(), false, 1) } @@ -226,7 +226,11 @@ impl App { ago: ago(ts).into(), unread: chat.unread, initials: vm::avatar::initials(&title).into(), - tint: vm::avatar::tint(&title), + // A server's chat in the server's colour. + tint: match (kind, session) { + (0, Some(s)) => self.server_tint(s), + _ => vm::avatar::tint(&title), + }, avatar, online, selected: open.is_some_and(|o| { @@ -477,7 +481,7 @@ impl App { Some(m) if !m.is_empty() => format!("Away: {m} · {}", s.server), Some(_) => format!("Away · {}", s.server), None if s.channel_title.is_empty() => format!("Online · {}", s.server), - None => format!("Online · {} · #{}", s.server, s.channel_title), + None => format!("Online · {} · {}", s.server, s.channel_title), }, None => match contact.filter(|c| c.last_seen_ms > 0) { Some(c) => format!("Offline · last seen {}", ago(c.last_seen_ms)), @@ -510,7 +514,7 @@ impl App { if s.channel_title.is_empty() { s.server.clone().into() } else { - format!("{} · #{}", s.server, s.channel_title).into() + format!("{} · {}", s.server, s.channel_title).into() } }) .collect() diff --git a/crates/voelin-ui/src/servers.rs b/crates/voelin-ui/src/servers.rs index f87d445..75fceec 100644 --- a/crates/voelin-ui/src/servers.rs +++ b/crates/voelin-ui/src/servers.rs @@ -375,14 +375,22 @@ impl App { } } + /// A server's colour, as the rail shows it ([`vm::servers::tints`]). + pub(crate) fn server_tint(&self, id: i64) -> slint::Color { + let tints = vm::servers::tints(&self.bookmarks); + self.bookmarks.iter().position(|b| b.id == id).map(|i| tints[i]).unwrap_or_default() + } + /// The rail: servers with their state, unread count and streams. pub(crate) fn refresh_servers(&self) { let Some(ui) = self.ui.upgrade() else { return }; let bridge = ui.global::(); + let tints = vm::servers::tints(&self.bookmarks); let items: Vec<_> = self .bookmarks .iter() - .map(|b| { + .zip(tints) + .map(|(b, tint)| { let view = self.sessions.get(&b.id); let state = view.map(|v| v.state.clone()).unwrap_or_default(); let unread = view.map_or(0, |v| v.unread()); @@ -393,7 +401,7 @@ impl App { .unwrap_or_default(); let flavor = view.map(|v| v.extra.flavor.clone()).unwrap_or_default(); let icon = self.server_list_icon(b); - vm::servers::item(b, &state, unread, live, detail, flavor, icon) + vm::servers::item(b, &state, unread, live, detail, flavor, icon, tint) }) .collect(); vm::list::sync(&self.models.servers, &items); diff --git a/crates/voelin-ui/src/social.rs b/crates/voelin-ui/src/social.rs index 2d44fa4..b5d7d61 100644 --- a/crates/voelin-ui/src/social.rs +++ b/crates/voelin-ui/src/social.rs @@ -375,7 +375,7 @@ impl App { if s.channel_title.is_empty() { s.server.clone().into() } else { - format!("{} · #{}", s.server, s.channel_title).into() + format!("{} · {}", s.server, s.channel_title).into() } }) .collect(); @@ -743,7 +743,7 @@ impl App { .sessions .get(&session) .and_then(|v| v.presence.channels.get(cid)) - .map(|c| format!("#{} · {server}", vm::tree::channel_title(c).0)) + .map(|c| format!("{} · {server}", vm::tree::channel_title(c).0)) .unwrap_or(server), _ => server, }; @@ -915,7 +915,7 @@ impl App { let place = if channel.is_empty() { format!("on {}", self.server_name(s.session as i64)) } else { - format!("on {} · #{channel}", self.server_name(s.session as i64)) + format!("on {} · {channel}", self.server_name(s.session as i64)) }; self.notify( NoticeKind::Friend, @@ -955,15 +955,16 @@ impl App { let servers = self .bookmarks .iter() - .filter(|b| matches(&query, &[&b.name, &b.address])) - .map(|b| { + .zip(vm::servers::tints(&self.bookmarks)) + .filter(|(b, _)| matches(&query, &[&b.name, &b.address])) + .map(|(b, tint)| { ( SearchItem { kind: "server".into(), title: b.name.clone().into(), subtitle: b.address.clone().into(), initials: vm::avatar::initials(&b.name).into(), - tint: vm::avatar::tint(&b.name), + tint, avatar: self.server_list_icon(b), ..Default::default() }, @@ -1017,7 +1018,7 @@ impl App { SearchItem { kind: "person".into(), title: c.nickname.clone().into(), - subtitle: format!("{} · #{channel}", b.name).into(), + subtitle: format!("{} · {channel}", b.name).into(), initials: vm::avatar::initials(&c.nickname).into(), tint: vm::avatar::tint(&c.nickname), avatar: vm::avatar::image(view.avatar(c.id)), diff --git a/crates/voelin-ui/src/studio.rs b/crates/voelin-ui/src/studio.rs index 6d9c241..0d20385 100644 --- a/crates/voelin-ui/src/studio.rs +++ b/crates/voelin-ui/src/studio.rs @@ -936,7 +936,7 @@ impl App { .map(|c| vm::tree::channel_title(c).0.to_owned()) .unwrap_or_default(); if !view.tabs.iter().any(|t| t.target == target) { - let tab = view.new_tab(target.clone(), format!("#{name}")); + let tab = view.new_tab(target.clone(), name.clone()); view.tabs.push(tab); if !demo { self.engine.send(Command::OpenChat { session: id as u64, target }); diff --git a/crates/voelin-ui/src/vm/avatar.rs b/crates/voelin-ui/src/vm/avatar.rs index 2b09d8d..74af518 100644 --- a/crates/voelin-ui/src/vm/avatar.rs +++ b/crates/voelin-ui/src/vm/avatar.rs @@ -1,6 +1,7 @@ //! Avatars without pictures: initials on a colour from the name. use slint::Color; +use unicode_segmentation::UnicodeSegmentation; /// Background colours for initials; white text reads on all of them. const TINTS: [u32; 10] = [ @@ -24,23 +25,38 @@ pub fn initials(name: &str) -> String { letters.to_uppercase() } +/// The first letter of `initials`, for avatars too small for two ("NS" → +/// "N"). +pub fn first_letter(initials: &str) -> String { + initials.graphemes(true).next().unwrap_or_default().to_owned() +} + /// A picture from the engine's cache (an avatar, a group icon), decoded /// once; an empty image when there is none. pub fn image(path: Option<&std::path::PathBuf>) -> slint::Image { path.map(|p| crate::images::file(p)).unwrap_or_default() } -/// A stable colour for a name (FNV-1a). -pub fn tint(name: &str) -> Color { +/// A stable number for a name, in any case (FNV-1a). +pub fn name_hash(name: &str) -> u32 { let mut hash: u32 = 0x811c_9dc5; for b in name.to_lowercase().bytes() { hash ^= u32::from(b); hash = hash.wrapping_mul(0x0100_0193); } - let rgb = TINTS[(hash % TINTS.len() as u32) as usize]; + hash +} + +/// `0xrrggbb` as a colour. +pub fn rgb(rgb: u32) -> Color { Color::from_rgb_u8((rgb >> 16) as u8, (rgb >> 8) as u8, rgb as u8) } +/// A stable colour for a name. +pub fn tint(name: &str) -> Color { + rgb(TINTS[(name_hash(name) % TINTS.len() as u32) as usize]) +} + #[cfg(test)] mod tests { use super::*; @@ -56,6 +72,16 @@ mod tests { assert_eq!(initials("Ärger über"), "ÄÜ"); } + #[test] + fn first_letter_of_initials() { + assert_eq!(first_letter("NS"), "N"); + assert_eq!(first_letter("ÄÜ"), "Ä"); + assert_eq!(first_letter(""), ""); + assert_eq!(first_letter("X"), "X"); + // A letter with a combining mark stays whole. + assert_eq!(first_letter("A\u{308}B"), "A\u{308}"); + } + #[test] fn tints_are_stable() { assert_eq!(tint("Alice"), tint("alice")); diff --git a/crates/voelin-ui/src/vm/chat.rs b/crates/voelin-ui/src/vm/chat.rs index e141473..5bda4dd 100644 --- a/crates/voelin-ui/src/vm/chat.rs +++ b/crates/voelin-ui/src/vm/chat.rs @@ -11,7 +11,7 @@ use std::rc::Rc; use slint::{Color, Image, ModelRc, VecModel}; use unicode_segmentation::UnicodeSegmentation; use voelin_core::HistoryMessage; -use voelin_model::{ChatMessage, ChatTarget, FileRef}; +use voelin_model::{ChatMessage, ChatTarget, FileRef, Presence}; use crate::app::{ChatLine, FileItem, ReactionItem, TextBlock, TextRun}; use crate::emoji; @@ -411,6 +411,28 @@ fn picture_name(url: &str) -> &str { path.rsplit('/').find(|s| !s.is_empty()).unwrap_or(url) } +/// A chat tab's title: a channel's name (a spacer's text), a private chat's +/// "@peer", or "Server". +pub fn tab_title(presence: &Presence, target: &ChatTarget, peer: &str) -> String { + match target { + ChatTarget::Channel(cid) => presence.channels.get(cid).map_or_else( + || format!("Channel {cid}"), + |c| crate::vm::tree::channel_title(c).0.to_owned(), + ), + ChatTarget::Private(_) => format!("@{peer}"), + ChatTarget::Server => "Server".into(), + } +} + +/// A chat tab's name for its header: the title without a private chat's +/// "@" (a channel may start with one). +pub fn tab_name<'a>(title: &'a str, target: &ChatTarget) -> &'a str { + match target { + ChatTarget::Private(_) => title.strip_prefix('@').unwrap_or(title), + _ => title, + } +} + /// A chat's last message for a list of chats, on one line ("Mira: the /// banner I promised: guild-banner.png"), and when it came. pub fn preview(message: &ChatMessage) -> (String, String) { @@ -795,6 +817,26 @@ mod tests { assert_eq!(quote(&line.author, &line.text), "> Kairo: > Nova: bring elixirs\n> ok\n"); } + #[test] + fn tab_titles_name_channels_without_a_hash() { + let mut presence = Presence::default(); + for (id, name) in [(1, "Lobby"), (2, "[cspacer0]Gaming"), (3, "#general")] { + let channel = voelin_model::ChannelInfo { id, name: name.into(), ..Default::default() }; + presence.channels.insert(id, channel); + } + let title = |target: &ChatTarget| tab_title(&presence, target, "Nova"); + assert_eq!(title(&ChatTarget::Channel(1)), "Lobby"); + assert_eq!(title(&ChatTarget::Channel(2)), "Gaming"); + assert_eq!(title(&ChatTarget::Channel(9)), "Channel 9"); + assert_eq!(title(&ChatTarget::Server), "Server"); + let private = ChatTarget::Private("uid".into()); + assert_eq!(title(&private), "@Nova"); + // The header's name: only a private chat loses its "@". + assert_eq!(tab_name("@Nova", &private), "Nova"); + assert_eq!(tab_name(&title(&ChatTarget::Channel(3)), &ChatTarget::Channel(3)), "#general"); + assert_eq!(tab_name("@home", &ChatTarget::Channel(4)), "@home"); + } + /// A run does not wrap: long words (addresses) and long inline code /// are cut so the line can break inside them. #[test] diff --git a/crates/voelin-ui/src/vm/servers.rs b/crates/voelin-ui/src/vm/servers.rs index dc5ee4b..6cde1ed 100644 --- a/crates/voelin-ui/src/vm/servers.rs +++ b/crates/voelin-ui/src/vm/servers.rs @@ -1,6 +1,6 @@ //! The server rail, the server dialog, and joining a channel. -use slint::SharedString; +use slint::{Color, SharedString}; use voelin_core::{ObserveState, SessionState, VoiceState}; use voelin_model::{ChannelId, ChannelInfo, Presence, ServerLink}; use voelin_store::Bookmark; @@ -14,6 +14,43 @@ pub fn cached_icon(bookmark: &Bookmark, cache: &voelin_core::Cache) -> slint::Im avatar::image(bookmark.server_icon_id().and_then(|id| cache.icon(id)).as_ref()) } +/// Server colours: hues around the wheel, each far from the one before it +/// (where a server goes when its own is taken). White initials read on all. +const SERVER_TINTS: [u32; 10] = [ + 0x2d6bff, // blue + 0xc2379a, // magenta + 0xc08400, // gold + 0x0c8fb0, // teal + 0x9c3fd1, // purple + 0xe0652a, // orange + 0x1f9d55, // green + 0x7c4dff, // violet + 0xd63a3a, // red + 0x6e8f1c, // olive +]; + +/// A colour for each server, in `bookmarks` order: its name picks one, and +/// when an earlier server has it, it takes the next free one. So no two +/// share a colour until there are more servers than colours (then they +/// start over), and adding a server leaves the others' colours. +pub fn tints(bookmarks: &[Bookmark]) -> Vec { + let n = SERVER_TINTS.len(); + let mut taken = [false; SERVER_TINTS.len()]; + bookmarks + .iter() + .enumerate() + .map(|(i, bookmark)| { + if i % n == 0 { + taken = [false; SERVER_TINTS.len()]; + } + let start = avatar::name_hash(&bookmark.name) as usize % n; + let slot = (0..n).map(|k| (start + k) % n).find(|&s| !taken[s]).unwrap_or(start); + taken[slot] = true; + avatar::rgb(SERVER_TINTS[slot]) + }) + .collect() +} + /// "offline", "connecting", "observing" or "connected". "connecting" is /// voice only: observing that is not there yet (a gateway that is away and /// tried again) is "offline", as users never hear of the gateway. @@ -29,7 +66,9 @@ pub fn status(state: &SessionState) -> &'static str { /// A server of the rail and the home page. `unread`: messages in its /// chats; `live`: streams on it; `detail`: who is there ("9 online · 7 /// channels"), empty for its address; `flavor`: "TeamSpeak 6" once -/// reached; `icon`: the server's icon (empty: its initials). +/// reached; `icon`: the server's icon (empty: its initials) on `tint` +/// ([`tints`]). +#[allow(clippy::too_many_arguments)] pub fn item( bookmark: &Bookmark, state: &SessionState, @@ -38,6 +77,7 @@ pub fn item( detail: String, flavor: String, icon: slint::Image, + tint: Color, ) -> ServerItem { ServerItem { id: bookmark.id as i32, @@ -45,7 +85,7 @@ pub fn item( address: bookmark.address.clone().into(), status: status(state).into(), initials: avatar::initials(&bookmark.name).into(), - tint: avatar::tint(&bookmark.name), + tint, icon, unread, live, @@ -262,6 +302,7 @@ mod tests { String::new(), String::new(), cached_icon(&bookmark, &cache), + Color::default(), ); assert_eq!(server.status.as_str(), "offline"); assert_eq!(server.icon.size().width, 4); @@ -273,6 +314,44 @@ mod tests { std::fs::remove_dir_all(dir).unwrap(); } + fn named(names: &[&str]) -> Vec { + names.iter().map(|n| Bookmark { name: (*n).into(), ..Default::default() }).collect() + } + + /// The colour a name picks. + fn own_tint(name: &str, step: usize) -> Color { + let n = SERVER_TINTS.len(); + avatar::rgb(SERVER_TINTS[(avatar::name_hash(name) as usize + step) % n]) + } + + #[test] + fn tints_are_distinct_up_to_the_palette_size() { + let names: Vec = (0..SERVER_TINTS.len()).map(|i| format!("Server {i}")).collect(); + let mut bookmarks = named(&names.iter().map(String::as_str).collect::>()); + let distinct: std::collections::HashSet<_> = + tints(&bookmarks).iter().map(|t| t.as_argb_encoded()).collect(); + assert_eq!(distinct.len(), SERVER_TINTS.len()); + // One more starts over with its name's colour. + bookmarks.extend(named(&["One more"])); + assert_eq!(tints(&bookmarks)[SERVER_TINTS.len()], own_tint("One more", 0)); + // The sample servers, two of which shared a blue. + let sample = tints(&named(&["Nightfall Guild", "Pixel Lounge", "Dev TS3"])); + assert!(sample[0] != sample[1] && sample[1] != sample[2] && sample[0] != sample[2]); + } + + #[test] + fn tints_follow_the_name_and_stay_when_a_server_is_added() { + let names = ["Nightfall Guild", "Pixel Lounge", "Dev TS3", "Home", "Raid"]; + let before = tints(&named(&names)); + let mut more = named(&names); + more.extend(named(&["New one"])); + assert_eq!(tints(&more)[..names.len()], before[..]); + // Alone, a server has its name's colour, in any case. + assert_eq!(tints(&named(&["pixel lounge"])), [own_tint("Pixel Lounge", 0)]); + // A second server with the name takes the next colour. + assert_eq!(tints(&named(&["Raid", "Raid"])), [own_tint("Raid", 0), own_tint("Raid", 1)]); + } + #[test] fn connect_shows_only_without_voice() { let b = Bookmark { diff --git a/crates/voelin-ui/src/vm/tree.rs b/crates/voelin-ui/src/vm/tree.rs index 7b1051c..06f23e0 100644 --- a/crates/voelin-ui/src/vm/tree.rs +++ b/crates/voelin-ui/src/vm/tree.rs @@ -318,6 +318,14 @@ fn is_moderator_group(name: &str) -> bool { name.to_lowercase().contains("mod") } +/// Whether a client cannot speak in its channel: the channel needs more +/// talk power than it has, and it was not made a talker. +pub fn cannot_talk(channel: Option<&ChannelInfo>, client: &ClientInfo) -> bool { + channel.is_some_and(|c| { + c.needed_talk_power > 0 && client.talk_power < c.needed_talk_power && !client.talker + }) +} + impl TreeInput<'_> { /// The position of a client's group in display order (no group last). fn group_rank(&self, client: &ClientInfo) -> usize { @@ -335,7 +343,8 @@ impl TreeInput<'_> { && !talking && c.streaming != Some(true) && c.away.is_none(); - let status = match self.presence.channels.get(&c.channel) { + let channel = self.presence.channels.get(&c.channel); + let status = match channel { Some(channel) if elsewhere => format!("In {}", channel_title(channel).0), _ => status_of(c, talking), }; @@ -363,7 +372,7 @@ impl TreeInput<'_> { priority: c.priority_speaker, commander: c.channel_commander, recording: c.recording, - talk_power: c.talk_power, + cannot_talk: cannot_talk(channel, c), badge, badge_2, badge_3, @@ -786,6 +795,43 @@ mod tests { assert!(members[0].admin && !members[1].admin); } + #[test] + fn members_who_cannot_talk() { + let channel = |needed| ChannelInfo { needed_talk_power: needed, ..Default::default() }; + let client = |talk_power, talker| ClientInfo { talk_power, talker, ..Default::default() }; + for (needed, power, talker, cannot) in [ + (50, 75, false, false), + (50, 50, false, false), + (50, 0, false, true), + (50, 49, false, true), + // A talker speaks without talk power. + (50, 0, true, false), + // The channel needs none. + (0, 0, false, false), + ] { + let case = format!("needed {needed}, power {power}, talker {talker}"); + assert_eq!( + cannot_talk(Some(&channel(needed)), &client(power, talker)), + cannot, + "{case}" + ); + } + assert!(!cannot_talk(None, &client(0, false))); + // In the members panel: bob (talk power 75) speaks in Games, which + // needs 50; Carol (none) cannot. + let mut p = presence(); + p.channels.get_mut(&2).unwrap().needed_talk_power = 50; + p.clients.get_mut(&11).unwrap().talk_power = 75; + p.clients.get_mut(&12).unwrap().channel = 2; + let (t, c, pb) = (HashSet::new(), HashSet::new(), ClientPlaybackMap::new()); + let e = Extras::default(); + let rows: Vec<_> = members(&input(&p, &t, &c, &pb, "", &e)) + .iter() + .map(|m| (m.name.to_string(), m.cannot_talk)) + .collect(); + assert_eq!(rows, [("bob".to_owned(), false), ("Carol".to_owned(), true)]); + } + #[test] fn everyone_in_sections() { let mut p = presence(); diff --git a/crates/voelin-ui/ui/bridge.slint b/crates/voelin-ui/ui/bridge.slint index 1b7d745..1f5d87b 100644 --- a/crates/voelin-ui/ui/bridge.slint +++ b/crates/voelin-ui/ui/bridge.slint @@ -106,8 +106,9 @@ export struct MemberItem { priority: bool, commander: bool, recording: bool, - // `client_talk_power`; shown when the channel needs it. - talk-power: int, + // Its channel needs more talk power than it has (and it is no + // talker): it cannot speak. + cannot-talk: bool, // myTeamSpeak badges, as in `TreeItem`. badge: image, badge-2: image, @@ -151,7 +152,7 @@ export struct MemberCard { } export struct ChatTab { - // "#Lobby", "@alice", "Server" + // "Lobby", "@alice", "Server" title: string, // The name alone ("Lobby"). name: string, @@ -429,7 +430,7 @@ export struct ContactItem { muted: bool, // "Contact since 14 Jan 2022". since: string, - // Every session that sees them: "Nightfall Guild · #Chill Zone". + // Every session that sees them: "Nightfall Guild · Chill Zone". spots: [string], // A voice connection sees them: they can be messaged, poked, joined. reachable: bool, @@ -550,7 +551,7 @@ export struct EventItem { month: string, // "Sat 26 Apr, 19:00 – 21:00" when: string, - // "#Raid Night" or "Server-wide". + // "Raid Night" or "Server-wide". place: string, // A scheduled stream: "Exploring the Lands Between · Elden Ring". stream: string, @@ -605,7 +606,7 @@ export struct DmPeer { tint: color, avatar: image, online: bool, - // "Online · Nightfall Guild · #Chill Zone", "Offline · last seen 2 h ago". + // "Online · Nightfall Guild · Chill Zone", "Offline · last seen 2 h ago". status: string, description: string, groups: [string], @@ -1330,6 +1331,9 @@ export global Images { pure callback emoji(string) -> image; // The characters of a Twemoji key, to react with or to insert. pure callback emoji-text(string) -> string; + // The first letter of initials, for small avatars (Slint cannot cut + // strings). + pure callback first-letter(string) -> string; } // One emoji of the picker. `text` is what picking it inserts. diff --git a/crates/voelin-ui/ui/components/avatar.slint b/crates/voelin-ui/ui/components/avatar.slint index c6c8162..cb468b7 100644 --- a/crates/voelin-ui/ui/components/avatar.slint +++ b/crates/voelin-ui/ui/components/avatar.slint @@ -1,5 +1,6 @@ import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; +import { Images } from "../bridge.slint"; import { Icon } from "icon.slint"; // Presence shown in the avatar's status dot. @@ -13,8 +14,11 @@ export enum Status { info, } -// A round avatar: a picture, or initials on a colour; a status dot, a crown -// badge, and a green ring while speaking. +// A round avatar: a picture, or initials on a colour (one letter under +// 28 px); a status dot, a crown badge, and a green ring while speaking. A +// server icon (`square`) at most half as wide as the avatar (TeamSpeak's +// are often 16 px) is drawn at twice its size, sharp, on the colour; a +// person's picture always fills the circle. export component Avatar inherits Rectangle { in property image; in property initials; @@ -26,6 +30,8 @@ export component Avatar inherits Rectangle { // Squircle instead of a circle (server icons). in property square; in property label; + property small: root.size < 28px; + property small-picture: root.square && root.image.width > 0 && root.image.width * 2px <= root.size; width: size; height: size; @@ -44,18 +50,21 @@ export component Avatar inherits Rectangle { } face := Rectangle { border-radius: root.square ? Theme.radius-lg : root.size / 2; - background: root.image.width > 0 ? Theme.surface-3 : root.tint; + background: root.image.width > 0 && !root.small-picture ? Theme.surface-3 : root.tint; clip: true; if root.image.width > 0: Image { - width: 100%; - height: 100%; + x: (parent.width - self.width) / 2; + y: (parent.height - self.height) / 2; + width: root.small-picture ? root.image.width * 2px : parent.width; + height: root.small-picture ? root.image.height * 2px : parent.height; source: root.image; - image-fit: cover; + image-fit: root.small-picture ? ImageFit.fill : ImageFit.cover; + image-rendering: root.small-picture ? ImageRendering.pixelated : ImageRendering.smooth; } if root.image.width == 0: Text { - text: root.initials; + text: root.small ? Images.first-letter(root.initials) : root.initials; color: #ffffff; - font-size: root.size * 0.38; + font-size: root.size * (root.small ? 0.5 : 0.38); font-weight: Theme.weight-semibold; horizontal-alignment: center; vertical-alignment: center; diff --git a/crates/voelin-ui/ui/screens/channels.slint b/crates/voelin-ui/ui/screens/channels.slint index 242dfef..21f9907 100644 --- a/crates/voelin-ui/ui/screens/channels.slint +++ b/crates/voelin-ui/ui/screens/channels.slint @@ -186,7 +186,7 @@ component TreeRow inherits Rectangle { source: item.icon; } if item.spacer == 0 && item.icon.width == 0: Icon { - source: item.locked ? Icons.lock : Icons.volume-2; + source: item.locked ? Icons.lock : Icons.channel; size: 18px; tint: item.banner.width > 0 || item.own ? Theme.text : Theme.icon; y: (parent.height - self.height) / 2; @@ -353,7 +353,7 @@ export component ChannelTree inherits VerticalLayout { spacing: Theme.space-2; SectionHeader { text: @tr("Channels"); - icon: Icons.volume-2; + icon: Icons.channel; small: true; } if Bridge.tree.length == 0: Text { diff --git a/crates/voelin-ui/ui/screens/chat.slint b/crates/voelin-ui/ui/screens/chat.slint index ed17695..976f98e 100644 --- a/crates/voelin-ui/ui/screens/chat.slint +++ b/crates/voelin-ui/ui/screens/chat.slint @@ -10,7 +10,7 @@ import { Icon, IconButton, Avatar, Chip, TabItem, TextField, MessageText, Banner // A compact title and actions over the optional channel background. export component PageHeader inherits Rectangle { - in property icon: Icons.hash; + in property icon: Icons.channel; in property banner; in property title; in property description; @@ -834,7 +834,7 @@ export component ChatView inherits VerticalLayout { if root.header: PageHeader { banner: root.tab-banner; - icon: root.tab-kind == 1 ? Icons.hash : root.tab-kind == 2 ? Icons.at-sign : Icons.message-square; + icon: root.tab-kind == 1 ? Icons.channel : root.tab-kind == 2 ? Icons.at-sign : Icons.message-square; title: root.tab-name; description: root.tab-topic != "" ? root.tab-topic : Bridge.server-title; // Only when the chat does not come through our voice connection @@ -861,7 +861,7 @@ export component ChatView inherits VerticalLayout { } // The voice channel we are in, with the people and the streams. if Bridge.voice-connected: IconButton { - icon: Icons.volume-2; + icon: Icons.channel; label: @tr("Voice channel"); y: (parent.height - self.height) / 2; clicked => { Nav.show-voice(true); } diff --git a/crates/voelin-ui/ui/screens/events.slint b/crates/voelin-ui/ui/screens/events.slint index d9933e6..65924cd 100644 --- a/crates/voelin-ui/ui/screens/events.slint +++ b/crates/voelin-ui/ui/screens/events.slint @@ -167,7 +167,7 @@ component EventCard inherits Rectangle { HorizontalLayout { spacing: Theme.space-2; Icon { - source: Icons.hash; + source: Icons.channel; size: 14px; tint: Theme.text-muted; y: (parent.height - self.height) / 2; @@ -384,7 +384,7 @@ export component EventDialog inherits Modal { Select { model: Bridge.event-channels; current-index <=> form.channel; - icon: Icons.hash; + icon: Icons.channel; label: @tr("Channel"); } } diff --git a/crates/voelin-ui/ui/screens/members.slint b/crates/voelin-ui/ui/screens/members.slint index 28e3c33..c905187 100644 --- a/crates/voelin-ui/ui/screens/members.slint +++ b/crates/voelin-ui/ui/screens/members.slint @@ -174,12 +174,19 @@ export component MemberRow inherits Rectangle { tint: Theme.danger; y: (parent.height - self.height) / 2; } - if member.talk-power > 0: Text { - text: member.talk-power; - color: Theme.text-disabled; - font-size: Theme.font-xs; - vertical-alignment: center; - accessible-label: @tr("talk power {}", member.talk-power); + // A hand, as TeamSpeak asks for talk power; the card has the number. + if member.cannot-talk: Tooltip { + text: @tr("Needs talk power to speak"); + width: hand.width; + height: hand.height; + y: (parent.height - self.height) / 2; + hand := Icon { + source: Icons.hand; + size: 16px; + tint: Theme.text-muted; + accessible-role: AccessibleRole.image; + accessible-label: @tr("Needs talk power to speak"); + } } } } diff --git a/crates/voelin-ui/ui/screens/overlays.slint b/crates/voelin-ui/ui/screens/overlays.slint index 7e2a97f..e0d1061 100644 --- a/crates/voelin-ui/ui/screens/overlays.slint +++ b/crates/voelin-ui/ui/screens/overlays.slint @@ -297,7 +297,7 @@ component ResultRow inherits VerticalLayout { border-radius: Theme.radius-md; background: Theme.surface-4; Icon { - source: root.item.kind == "channel" ? Icons.hash : Icons.settings; + source: root.item.kind == "channel" ? Icons.channel : Icons.settings; size: Theme.icon-sm; tint: Theme.accent-text; } diff --git a/crates/voelin-ui/ui/screens/streams.slint b/crates/voelin-ui/ui/screens/streams.slint index f0d23a5..08d9e7c 100644 --- a/crates/voelin-ui/ui/screens/streams.slint +++ b/crates/voelin-ui/ui/screens/streams.slint @@ -455,7 +455,7 @@ export component StreamViewer inherits Rectangle { if !root.alone: VerticalLayout { PageHeader { banner: Bridge.own-channel-banner; - icon: Icons.volume-2; + icon: Icons.channel; title: Bridge.own-channel != "" ? Bridge.own-channel : Bridge.viewer-title; description: Bridge.own-channel-topic; if Bridge.members.length > 0: Button { diff --git a/crates/voelin-ui/ui/screens/voice.slint b/crates/voelin-ui/ui/screens/voice.slint index 1106fd9..31245f7 100644 --- a/crates/voelin-ui/ui/screens/voice.slint +++ b/crates/voelin-ui/ui/screens/voice.slint @@ -225,7 +225,7 @@ export component VoiceView inherits VerticalLayout { padding-bottom: Theme.space-3; spacing: Theme.space-5; Icon { - source: Icons.volume-2; + source: Icons.channel; size: 40px; tint: Theme.text-secondary; y: Theme.space-1; diff --git a/crates/voelin-ui/ui/shells/mobile.slint b/crates/voelin-ui/ui/shells/mobile.slint index e46d89e..d5608a4 100644 --- a/crates/voelin-ui/ui/shells/mobile.slint +++ b/crates/voelin-ui/ui/shells/mobile.slint @@ -171,7 +171,7 @@ export component MobileShell inherits Rectangle { } // The voice channel we are in, from any page. if !root.voice && Bridge.voice-connected: IconButton { - icon: Icons.volume-2; + icon: Icons.channel; label: @tr("Voice channel"); round: true; filled: true; diff --git a/docs/ui.md b/docs/ui.md index fb84ab0..a1cb08e 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -108,7 +108,7 @@ puts them on an inner `face`). | `Slider` | slider.slint | `value`, `minimum`, `maximum`, `step`, `label`; `changed(float)` while dragging, `released(float)` | | `SegmentedTabs` | tabs.slint | `model`, `current-index`, `label`; `selected(int)` | | `TabItem` | tabs.slint | underlined tab: `text`, `selected`, `badge`, `closable`; `clicked`, `close` | -| `Avatar` | avatar.slint | `image` or `initials` + `tint`, `size`, `status` (`Status.online/idle/dnd/offline/info`), `speaking` (green ring), `crown`, `square` (server icons) | +| `Avatar` | avatar.slint | `image` or `initials` + `tint` (one letter under 28 px, through `Images.first-letter`), `size`, `status` (`Status.online/idle/dnd/offline/info`), `speaking` (green ring), `crown`, `square` (server icons); a server icon at most half as wide (TeamSpeak's 16 px ones) is drawn at twice its size, sharp, on the tint (a person's picture always fills it) | | `CountBadge` | badge.slint | count bubble: `count`, `fill` (red), `ink` (the number) | | `LiveBadge` | badge.slint | `text` (LIVE), `large` | | `Chip` | badge.slint | tag: `text`, `icon`, `picture` (in its own colours, a badge's), `tint`, `fill`, `outlined` | @@ -136,7 +136,9 @@ puts them on an inner `face`). Shell pieces (ui/shells/): `DesktopShell` (rail + top bar + panels as @children), `Sidebar` (page navigation above the voice card and user card), -`Panel`, `ServerRail` (Home, the servers, Add a server, the settings), +`Panel`, `ServerRail` (Home, the servers, Add a server, the settings; each +server shows its icon or its initials, on a colour no other server has while +there are at most ten, kept when a server is added), `TopBar` (the search, starting over the main panel, opens the search like Ctrl+K; the bell at the right), `MobileShell` (top bar, page, bottom navigation), `VoiceCard`, `VoiceButtons` (mute, deafen, share; `gear` adds @@ -152,7 +154,7 @@ comes from the engine's events; what a gateway adds is hidden without it. | Part | `VOELIN_OPEN` | What it shows | Engine data | |---|---|---|---| | Chat | `server` (`server:chat`: the server chat), `actions`, `link-confirm[:]`, `unread[:end]` | Header with Pinned Messages, Topics, the voice channel and the members button; chat tabs; messages grouped by author ("Today at 10:14"), avatars, BBCode formatting (see Formatting below), emoji, reactions with an add button, pin and topic marks, file cards with download; composer with attach, emoji and send. A link opens in the browser; one whose text is not its address (a masked link) first shows where it goes in `LinkDialog` (the host, the whole address; Open, Copy link, Cancel); a TeamSpeak link opens in Voelin (Adding a server: Links, below); a right-click on a link offers Open link and Copy link. Every message has actions on hover (`MessageActions`; `actions` shows the last one's): Quote (`> Author: …` lines at the start of the composer, which takes the focus to write below them and grows to show up to about eight lines) and Copy text, and with a gateway quick reactions, pin and Start a topic; a right-click on a message shows Copy text, Copy link (its first web address), Quote, and with a gateway React… and Pin. The server chat starts with the server's welcome message (and its host message when the server puts it in the chat log). Opens at the newest message and follows new ones while at the end. Scrolling up to within a screen of the top loads the page before, above the rows on screen, which stay in place (a spinner above the oldest message while it loads). The Older messages button there is for a chat too short to scroll, and for after a page that brought nothing (scrolling loads again once the list was a screen away). The voice view, the phone's voice screen and private chats load the same way. Messages count as read while their chat is on screen in the focused window; the chat tabs and the server rail count the others (not our own). A chat that comes on screen with new messages, or that is on screen when messages that came while away arrive (a stored or gateway page), shows a red line with New above the first (`NewDivider`) until the chat is left; while that line is above the view, a bar over the list says how many are new and since when (`UnreadBar`: "5 new messages since 10:14", Jump, and × to mark them read). Where each chat was read is kept on this device (the store's `chat_reads`), so the counts survive a restart: messages that came while away (a gateway's history) count as new | `ChatHistory` (and `Chat` for servers without history), `Presence` (welcome and host message), `AvatarReady`, `Transfer`, `Gateway` (pins; reactions arrive as stored messages); `Command::LoadOlderHistory`, `DownloadChatFile`, `UploadFile`, `GatewayRequest::React`, `Unreact`, `Pin`, `Unpin` | -| Members panel | `server` (`panel`, `no-panel`) | "Members — N" and a search; those streaming first (the people in our channel while the voice channel or a stream is shown), then each server group in the server's order with its icon, then those without a group. Rows: avatar with status, name, crown (admin groups), priority speaker, channel commander, recording, up to three myTeamSpeak badges, moderator role, talk power, what they do or the channel they are in. Resizable: the width is `ui.members_width` | `Presence`, `Groups`, `Talking`, `IconReady`, `PictureReady` | +| Members panel | `server` (`panel`, `no-panel`) | "Members — N" and a search; those streaming first (the people in our channel while the voice channel or a stream is shown), then each server group in the server's order with its icon, then those without a group. Rows: avatar with status, name, crown (admin groups), priority speaker, channel commander, recording, up to three myTeamSpeak badges, moderator role, a hand when their channel needs more talk power than they have ("Needs talk power to speak"; the member card has the number), what they do or the channel they are in. Resizable: the width is `ui.members_width` | `Presence`, `Groups`, `Talking`, `IconReady`, `PictureReady` | | Member card | `member` | Description, groups, badges (up to three chips in the client's order, what each is for on hover; "Badge" for one the app does not know), talk power, country; private message, poke, friend, block; volume and mute for us | `ContactsChanged`, `PictureReady` (badges); `Command::SetContact`, `SetClientVolume`, `SetClientMuted`, `Poke` | | Poke | `poke` (the first other member's, card open; after `friends` a contact's) | `PokeDialog`, from the member card, a friend's row and the direct message header: an optional message with a "12/100" count, Send off above 100 characters, Enter sends, Escape cancels | `Command::Poke` (trimmed, cut to 100 characters; the engine cuts too) | | Channel password | `channel-password`, `channel-password:wrong` | Joining a channel (a double-click in the tree, joining a friend) moves there with voice, or connects into it (by its id) without; when the server puts us elsewhere on connecting, as it does for a wrong password, it is joined again, which says why. A locked channel first asks for its password in `ChannelPasswordDialog`, unless one was given since voice connected; a refused one asks again under "Wrong password". A full channel or another refusal is a toast | `Presence` (`has_password`), `JoinFailed`; `Command::MoveToChannel`, `ConnectVoice` (`channel_password`) | @@ -579,6 +581,13 @@ gradient (74% to 66% opacity) keeps primary text above 4.5:1 contrast even on all-white or all-black artwork, while leaving the image visible. Missing pictures retain the normal background. +A channel has one icon everywhere, a speaker (`Icons.channel`, a lock for a +locked one in the tree), and chat tabs, notifications and search results name +it without a `#` (private chats keep their `@`). A server icon at most half +as wide as its avatar (TeamSpeak's are often 16 pixels) is drawn at twice its +size, sharp, on the server's colour instead of stretched. Avatars under 28 +pixels, as the tree's clients, show one letter. + Bookmarks remember the server icon ID and the address that supplied it. The server list, search results and server header load its cached bytes before connecting, including after restarting the app. Editing a server address