Participant and StreamCard move into screens/voice-parts.slint with a `compact` look that replaces the phone's VoiceMember and StreamPrompt, so the compact stage and the phone's voice screen can share them. The phone's VoiceControl goes: IconButton and ActionButton get `alarm`, the filled red Leave, and `edge`; ActionButton also gets `icon-size` and `checkable`. The screenshots are unchanged. The phone's voice-bar buttons now behave like the You page's: hover, keyboard focus, surface-4 while pressed, and an accent caption while Sharing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
278 lines
9.8 KiB
Plaintext
278 lines
9.8 KiB
Plaintext
import { Theme } from "../theme.slint";
|
|
import { Icon } from "icon.slint";
|
|
import { CountBadge } from "badge.slint";
|
|
import { HoverTooltip } from "tooltip.slint";
|
|
|
|
export enum ButtonKind {
|
|
// Filled accent: the main action.
|
|
primary,
|
|
// Surface with a border.
|
|
secondary,
|
|
// Destructive: leave, end stream, delete.
|
|
danger,
|
|
// No background until hovered.
|
|
ghost,
|
|
}
|
|
|
|
// The focus ring shared by controls.
|
|
export component FocusRing inherits Rectangle {
|
|
in property <bool> shown;
|
|
in property <length> radius: Theme.radius-md;
|
|
// The size of the ringed element.
|
|
in property <length> w;
|
|
in property <length> h;
|
|
x: -Theme.glow-width;
|
|
y: -Theme.glow-width;
|
|
width: w + 2 * Theme.glow-width;
|
|
height: h + 2 * Theme.glow-width;
|
|
border-radius: radius + Theme.glow-width;
|
|
border-width: shown ? Theme.glow-width : 0px;
|
|
border-color: Theme.glow;
|
|
}
|
|
|
|
// A button with a label, an icon or both.
|
|
export component Button inherits Rectangle {
|
|
in property <string> text;
|
|
in property <image> icon;
|
|
in property <ButtonKind> kind: ButtonKind.secondary;
|
|
in property <bool> enabled: true;
|
|
// Toggled on: drawn as selected (e.g. an open panel).
|
|
in property <bool> checked;
|
|
// Smaller height and padding.
|
|
in property <bool> small;
|
|
// Stretch the label to the full width.
|
|
in property <bool> centered: true;
|
|
callback clicked();
|
|
|
|
property <bool> active: touch.pressed || checked;
|
|
property <color> fill: kind == ButtonKind.primary ? (active ? Theme.accent-pressed : touch.has-hover ? Theme.accent-hover : Theme.accent)
|
|
: kind == ButtonKind.danger ? (active ? Theme.danger : touch.has-hover ? Theme.danger-soft.brighter(0.3) : Theme.danger-soft)
|
|
: kind == ButtonKind.ghost ? (active ? Theme.surface-4 : touch.has-hover ? Theme.surface-3 : transparent)
|
|
: checked ? (touch.has-hover ? Theme.accent-soft-hover : Theme.accent-soft)
|
|
: (active ? Theme.surface-4 : touch.has-hover ? Theme.surface-3 : Theme.surface-2);
|
|
property <color> ink: kind == ButtonKind.primary ? Theme.on-accent
|
|
: !enabled ? Theme.text-disabled
|
|
: kind == ButtonKind.danger ? (active ? Theme.on-accent : Theme.danger)
|
|
: Theme.text;
|
|
|
|
min-width: self.min-height;
|
|
min-height: small ? Theme.control-height-sm : Theme.control-height;
|
|
max-height: self.min-height;
|
|
horizontal-stretch: 0;
|
|
vertical-stretch: 0;
|
|
border-radius: Theme.radius-md;
|
|
background: fill;
|
|
border-width: kind == ButtonKind.secondary || kind == ButtonKind.danger || checked ? 1px : 0px;
|
|
border-color: checked ? Theme.accent : kind == ButtonKind.danger ? Theme.danger.transparentize(55%) : Theme.border-strong;
|
|
opacity: enabled ? 1.0 : 0.5;
|
|
animate background { duration: Theme.fast; }
|
|
|
|
accessible-role: AccessibleRole.button;
|
|
accessible-label: text;
|
|
accessible-enabled: enabled;
|
|
accessible-checkable: checked;
|
|
accessible-checked: checked;
|
|
accessible-action-default => { if enabled { clicked(); } }
|
|
|
|
FocusRing {
|
|
shown: focus.has-focus;
|
|
w: root.width;
|
|
h: root.height;
|
|
}
|
|
focus := FocusScope {
|
|
enabled: root.enabled;
|
|
key-pressed(event) => {
|
|
if event.text == " " || event.text == "\n" {
|
|
root.clicked();
|
|
return accept;
|
|
}
|
|
reject
|
|
}
|
|
touch := TouchArea {
|
|
enabled: root.enabled;
|
|
mouse-cursor: MouseCursor.pointer;
|
|
clicked => {
|
|
focus.focus();
|
|
root.clicked();
|
|
}
|
|
}
|
|
}
|
|
HorizontalLayout {
|
|
padding-left: text == "" ? 0px : small ? Theme.space-4 : Theme.space-5;
|
|
padding-right: self.padding-left;
|
|
spacing: Theme.space-3;
|
|
alignment: centered ? center : start;
|
|
if icon.width > 0: Icon {
|
|
source: icon;
|
|
size: small ? Theme.icon-sm : Theme.icon-md;
|
|
tint: ink;
|
|
y: (parent.height - self.height) / 2;
|
|
}
|
|
if text != "": Text {
|
|
text: root.text;
|
|
color: ink;
|
|
font-size: small ? Theme.font-sm : Theme.font-body;
|
|
font-weight: Theme.weight-medium;
|
|
vertical-alignment: center;
|
|
overflow: elide;
|
|
}
|
|
}
|
|
}
|
|
|
|
// A square (or round) button with only an icon. `label` names it for
|
|
// screen readers and, on the desktop, in a tooltip.
|
|
//
|
|
// The look is on `face`, not on the root: an opacity or an animation on a
|
|
// component's root makes Slint inline the component where it is used, and
|
|
// there are over a hundred IconButtons. Shared, their code stays small (and
|
|
// so does the compiler's memory).
|
|
export component IconButton inherits Rectangle {
|
|
in property <image> icon;
|
|
in property <string> label;
|
|
// Shown when the pointer rests on the button (desktop only, also while
|
|
// disabled); "" for none.
|
|
in property <string> tooltip: label;
|
|
in property <bool> enabled: true;
|
|
in property <bool> checked;
|
|
in property <bool> round;
|
|
// Drawn on a surface instead of transparent.
|
|
in property <bool> filled;
|
|
// Red while checked (muted microphone).
|
|
in property <bool> danger;
|
|
// Filled red, with a white icon (Leave).
|
|
in property <bool> alarm;
|
|
// The edge while filled and not checked.
|
|
in property <color> edge: Theme.border;
|
|
in property <length> size: Theme.control-height;
|
|
in property <length> icon-size: Theme.icon-md;
|
|
in property <brush> tint: alarm ? Theme.on-accent : checked ? (danger ? Theme.danger : Theme.accent-text) : Theme.icon;
|
|
// A small dot at the top right (unread, live).
|
|
in property <bool> dot;
|
|
in property <color> dot-color: Theme.live;
|
|
// A neutral count at the top right (pins, topics); hidden at 0 or less.
|
|
in property <int> count;
|
|
callback clicked();
|
|
|
|
width: size;
|
|
height: size;
|
|
|
|
accessible-role: AccessibleRole.button;
|
|
accessible-label: label;
|
|
accessible-enabled: enabled;
|
|
accessible-action-default => { if enabled { clicked(); } }
|
|
|
|
face := Rectangle {
|
|
border-radius: root.round ? root.size / 2 : Theme.radius-md;
|
|
background: root.alarm ? (touch.pressed ? Theme.danger.darker(0.2) : touch.has-hover ? Theme.danger.brighter(0.1) : Theme.danger)
|
|
: touch.pressed ? Theme.surface-4
|
|
: root.checked ? (root.danger ? Theme.danger-soft : Theme.accent-soft)
|
|
: touch.has-hover ? Theme.surface-3
|
|
: root.filled ? Theme.surface-2 : transparent;
|
|
border-width: !root.alarm && (root.filled || root.checked) ? 1px : 0px;
|
|
border-color: root.checked ? (root.danger ? Theme.danger.transparentize(50%) : Theme.accent) : root.edge;
|
|
opacity: root.enabled ? 1.0 : 0.45;
|
|
animate background { duration: Theme.fast; }
|
|
|
|
FocusRing {
|
|
shown: focus.has-focus;
|
|
radius: face.border-radius;
|
|
w: root.width;
|
|
h: root.height;
|
|
}
|
|
focus := FocusScope {
|
|
enabled: root.enabled;
|
|
key-pressed(event) => {
|
|
if event.text == " " || event.text == "\n" {
|
|
root.clicked();
|
|
return accept;
|
|
}
|
|
reject
|
|
}
|
|
touch := TouchArea {
|
|
enabled: root.enabled;
|
|
mouse-cursor: MouseCursor.pointer;
|
|
clicked => {
|
|
focus.focus();
|
|
root.clicked();
|
|
}
|
|
}
|
|
}
|
|
Icon {
|
|
source: root.icon;
|
|
size: root.icon-size;
|
|
tint: root.tint;
|
|
}
|
|
if root.dot: Rectangle {
|
|
x: parent.width - self.width - root.size * 0.18;
|
|
y: root.size * 0.16;
|
|
width: 9px;
|
|
height: 9px;
|
|
border-radius: 4.5px;
|
|
background: root.dot-color;
|
|
border-width: 2px;
|
|
border-color: Theme.surface;
|
|
}
|
|
if root.count > 0: CountBadge {
|
|
x: parent.width - self.width + 4px;
|
|
y: -4px;
|
|
count: root.count;
|
|
fill: Theme.icon;
|
|
ink: Theme.surface;
|
|
}
|
|
HoverTooltip {
|
|
text: root.tooltip;
|
|
pressed: touch.pressed;
|
|
hovered: touch.has-hover;
|
|
}
|
|
}
|
|
}
|
|
|
|
// A round control with a caption below (the phone's voice bar and You page:
|
|
// Mute, Deafen, Go Live, Leave).
|
|
export component ActionButton inherits VerticalLayout {
|
|
in property <image> icon;
|
|
in property <string> text;
|
|
in property <bool> checked;
|
|
in property <bool> danger;
|
|
// Filled red (Leave).
|
|
in property <bool> alarm;
|
|
// A toggle for screen readers, which are told `checked`.
|
|
in property <bool> checkable;
|
|
in property <bool> enabled: true;
|
|
in property <length> size: 40px;
|
|
in property <length> icon-size: Theme.icon-md;
|
|
// The circle's edge while not checked.
|
|
in property <color> edge: Theme.border;
|
|
callback clicked();
|
|
spacing: Theme.space-1;
|
|
alignment: center;
|
|
HorizontalLayout {
|
|
alignment: center;
|
|
IconButton {
|
|
icon: root.icon;
|
|
label: root.text;
|
|
// The caption already names it.
|
|
tooltip: "";
|
|
checked: root.checked;
|
|
danger: root.danger;
|
|
alarm: root.alarm;
|
|
enabled: root.enabled;
|
|
round: true;
|
|
filled: true;
|
|
size: root.size;
|
|
icon-size: root.icon-size;
|
|
edge: root.edge;
|
|
accessible-checkable: root.checkable;
|
|
accessible-checked: root.checked;
|
|
clicked => { root.clicked(); }
|
|
}
|
|
}
|
|
Text {
|
|
text: root.text;
|
|
font-size: Theme.font-xs;
|
|
color: root.checked ? (root.danger ? Theme.danger : Theme.accent-text) : Theme.text-secondary;
|
|
horizontal-alignment: center;
|
|
accessible-role: AccessibleRole.none;
|
|
}
|
|
}
|