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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
96 lines
3.5 KiB
Plaintext
96 lines
3.5 KiB
Plaintext
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.
|
|
export enum Status {
|
|
none,
|
|
online,
|
|
idle,
|
|
dnd,
|
|
offline,
|
|
// A blue dot: observed invisibly, streaming...
|
|
info,
|
|
}
|
|
|
|
// 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> image;
|
|
in property <string> initials;
|
|
in property <color> tint: Theme.accent-soft;
|
|
in property <length> size: 36px;
|
|
in property <Status> status: Status.none;
|
|
in property <bool> speaking;
|
|
in property <bool> crown;
|
|
// Squircle instead of a circle (server icons).
|
|
in property <bool> square;
|
|
in property <string> label;
|
|
property <bool> small: root.size < 28px;
|
|
property <bool> small-picture: root.square && root.image.width > 0 && root.image.width * 2px <= root.size;
|
|
|
|
width: size;
|
|
height: size;
|
|
accessible-role: AccessibleRole.image;
|
|
accessible-label: label;
|
|
|
|
// Speaking ring (outside the picture).
|
|
if speaking: Rectangle {
|
|
x: -3px;
|
|
y: -3px;
|
|
width: root.size + 6px;
|
|
height: root.size + 6px;
|
|
border-radius: root.square ? Theme.radius-lg + 3px : self.width / 2;
|
|
border-width: 2px;
|
|
border-color: Theme.success;
|
|
}
|
|
face := Rectangle {
|
|
border-radius: root.square ? Theme.radius-lg : root.size / 2;
|
|
background: root.image.width > 0 && !root.small-picture ? Theme.surface-3 : root.tint;
|
|
clip: true;
|
|
if root.image.width > 0: Image {
|
|
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: root.small-picture ? ImageFit.fill : ImageFit.cover;
|
|
image-rendering: root.small-picture ? ImageRendering.pixelated : ImageRendering.smooth;
|
|
}
|
|
if root.image.width == 0: Text {
|
|
text: root.small ? Images.first-letter(root.initials) : root.initials;
|
|
color: #ffffff;
|
|
font-size: root.size * (root.small ? 0.5 : 0.38);
|
|
font-weight: Theme.weight-semibold;
|
|
horizontal-alignment: center;
|
|
vertical-alignment: center;
|
|
}
|
|
}
|
|
if root.status != Status.none: Rectangle {
|
|
property <length> dot: max(10px, root.size * 0.3);
|
|
x: root.size - dot + 1px;
|
|
y: root.size - dot + 1px;
|
|
width: dot;
|
|
height: dot;
|
|
border-radius: dot / 2;
|
|
background: root.status == Status.online ? Theme.success
|
|
: root.status == Status.idle ? Theme.idle
|
|
: root.status == Status.dnd ? Theme.dnd
|
|
: root.status == Status.info ? Theme.info
|
|
: Theme.offline;
|
|
border-width: 2px;
|
|
border-color: Theme.surface;
|
|
}
|
|
if root.crown: Icon {
|
|
x: root.size - self.width * 0.7;
|
|
y: -self.height * 0.35;
|
|
source: Icons.crown;
|
|
size: max(12px, root.size * 0.34);
|
|
tint: Theme.gold;
|
|
}
|
|
}
|