ui: tooltips on icon buttons, and a count

IconButton names itself in a tooltip after a moment of hover, also while
it is disabled (mute or deafen when not connected), and can show a
neutral count at its top right (for pins and topics later). Tooltips are
desktop only: the new Bridge.desktop is false in the Android app.

Tooltip showed once (its Timer turned off its own binding) and stayed
open after the pointer left. Both now use Slint's Tooltip element with
our TooltipBubble: it opens at the pointer, closes when the pointer
leaves, and lets clicks and hover through, which a PopupWindow of our own
does not while it is open. A press closes it until the pointer leaves.
The bubble sets its own preferred width, up to 400px, so long text wraps:
the tooltip's popup takes that width, and a max-width would not narrow it.

IconButton's look moves onto an inner rectangle: with an opacity and an
animation on its root, Slint inlined it at each of its 100-odd uses, and
the tooltip and count alone added 3.3 MB of generated code to a crate
whose compile already peaks near 14 GB. Now the generated code is 1.1 MB
smaller than before (70.7 MB).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
This commit is contained in:
Claude committed 2026-10-06 04:57:51 +00:00
1 parent d114444c04
commit cdedb86b9c
10 files changed
+175 -83

No files matched your search

+5
View File
@@ -21,6 +21,8 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows
decoders work without installing FFmpeg.
- AV1 decoding through dav1d in every desktop build.
- 122 more signed client versions (`Versions.csv`).
- Icon buttons show their name on hover (desktop), also while they are
disabled.
### Changed
@@ -53,6 +55,9 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows
- The account's avatar is downloaded from its own link; it was asked for
as an upload link and refused with HTTP 403.
- Hover help in the Stream Studio (a source's error, the status details)
shows each time and closes when the pointer leaves; it showed only once,
and stayed open until a click.
## [0.0.1-alpha] - 2026-10-04
+1
View File
@@ -643,6 +643,7 @@ pub fn run(options: RunOptions) -> Result<()> {
let bridge = ui.global::<Bridge>();
bridge.set_app_name(voelin_platform::APP_NAME.into());
bridge.set_app_version(env!("CARGO_PKG_VERSION").into());
bridge.set_desktop(cfg!(not(target_os = "android")));
let models = Models::new(&bridge);
// Wayland and X11 find the desktop file (and icon) by this id.
#[cfg(not(target_os = "android"))]
+3
View File
@@ -934,6 +934,9 @@ export global Bridge {
// The product name (voelin_platform::APP_NAME, not translated) and version.
in property <string> app-name: "Voelin";
in property <string> app-version;
// False in the Android app; the one platform flag (tooltips are desktop
// only). The studio's own window, desktop only, keeps the default.
in property <bool> desktop: true;
in-out property <ClientAudio> client-audio;
// Opt-in local crash reports, and a notice about reports on disk.
in-out property <bool> crash-reports;
+4 -2
View File
@@ -1,10 +1,12 @@
import { Theme } from "../theme.slint";
import { Icon } from "icon.slint";
// A red count bubble (unread, requests).
// A count bubble (unread, requests), red unless `fill` says otherwise.
export component CountBadge inherits Rectangle {
in property <int> count;
in property <color> fill: Theme.live;
// The number's colour.
in property <color> ink: Theme.on-accent;
width: max(18px, label.preferred-width + 10px);
height: 18px;
border-radius: 9px;
@@ -16,7 +18,7 @@ export component CountBadge inherits Rectangle {
padding-right: 5px;
label := Text {
text: root.count > 99 ? "99+" : root.count;
color: #ffffff;
color: root.ink;
font-size: Theme.font-xs;
font-weight: Theme.weight-bold;
horizontal-alignment: center;
+74 -45
View File
@@ -1,5 +1,7 @@
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.
@@ -117,11 +119,19 @@ export component Button inherits Rectangle {
}
}
// A square (or round) button with only an icon; `label` is for screen
// readers and the tooltip-less toolbar.
// 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;
@@ -135,63 +145,80 @@ export component IconButton inherits Rectangle {
// 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;
border-radius: round ? size / 2 : Theme.radius-md;
background: touch.pressed ? Theme.surface-4
: checked ? (danger ? Theme.danger-soft : Theme.accent-soft)
: touch.has-hover ? Theme.surface-3
: filled ? Theme.surface-2 : transparent;
border-width: filled || checked ? 1px : 0px;
border-color: checked ? (danger ? Theme.danger.transparentize(50%) : Theme.accent) : Theme.border;
opacity: enabled ? 1.0 : 0.45;
animate background { duration: Theme.fast; }
accessible-role: AccessibleRole.button;
accessible-label: label;
accessible-enabled: enabled;
accessible-action-default => { if enabled { clicked(); } }
FocusRing {
shown: focus.has-focus;
radius: root.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
face := Rectangle {
border-radius: root.round ? root.size / 2 : Theme.radius-md;
background: 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.filled || root.checked ? 1px : 0px;
border-color: root.checked ? (root.danger ? Theme.danger.transparentize(50%) : Theme.accent) : Theme.border;
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;
}
touch := TouchArea {
focus := FocusScope {
enabled: root.enabled;
mouse-cursor: MouseCursor.pointer;
clicked => {
focus.focus();
root.clicked();
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: icon;
size: icon-size;
tint: root.tint;
}
if 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: dot-color;
border-width: 2px;
border-color: Theme.surface;
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;
}
}
}
@@ -211,6 +238,8 @@ export component ActionButton inherits VerticalLayout {
IconButton {
icon: root.icon;
label: root.text;
// The caption already names it.
tooltip: "";
checked: root.checked;
danger: root.danger;
enabled: root.enabled;
@@ -15,6 +15,7 @@ export { SectionHeader, Card, Divider, Banner } from "card.slint";
export { Meter, SpeakingBars } from "meter.slint";
export { NavItem, ListItem } from "list-item.slint";
export { MenuEntry, PopupMenu, Tooltip, Modal, Toast, ResizeHandle } from "overlay.slint";
export { TooltipBubble, HoverTooltip } from "tooltip.slint";
export { RichText, EmojiPicker } from "emoji.slint";
// Virtualised lists and scrolling come from the standard widgets (styled by
// the fluent-dark style); ListView builds only the visible rows.
+6 -31
View File
@@ -5,6 +5,7 @@ import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Icon } from "icon.slint";
import { IconButton } from "button.slint";
import { HoverTooltip } from "tooltip.slint";
// An entry of a `PopupMenu`.
export struct MenuEntry {
@@ -102,39 +103,13 @@ export component PopupMenu inherits Rectangle {
}
}
// Hover help: wraps @children and shows `text` in a bubble after a moment.
// Hover help: wraps @children and shows `text` in a bubble near the
// pointer after a moment, until the pointer leaves (desktop only).
export component Tooltip inherits Rectangle {
in property <string> text;
// Above (default) or below the element.
in property <bool> below;
area := TouchArea {
@children
}
Timer {
interval: 600ms;
running: area.has-hover && root.text != "";
triggered => {
self.running = false;
bubble.show();
}
}
bubble := PopupWindow {
x: (root.width - self.width) / 2;
y: root.below ? root.height + 6px : -self.height - 6px;
width: label.preferred-width + 20px;
height: label.preferred-height + 12px;
close-policy: PopupClosePolicy.close-on-click-outside;
Rectangle {
border-radius: Theme.radius-sm;
background: Theme.surface-4;
border-width: 1px;
border-color: Theme.border-strong;
label := Text {
text: root.text;
color: Theme.text;
font-size: Theme.font-sm;
}
}
@children
HoverTooltip {
text: root.text;
}
}
@@ -0,0 +1,70 @@
// Tooltips: the bubble, and the hover area that shows it on the desktop.
// Kept apart from overlay.slint, which imports button.slint, so buttons can
// use them.
import { Theme } from "../theme.slint";
import { Bridge } from "../bridge.slint";
// The bubble of a tooltip: short text on a raised surface. Longer text
// wraps at `widest`.
export component TooltipBubble inherits Rectangle {
in property <string> text;
in property <length> widest: 400px;
// The tooltip's popup takes this preferred width (a max-width would not
// narrow it), and the text wraps inside it.
preferred-width: min(root.widest, label.preferred-width + 2 * Theme.space-3);
// Slint's own tooltip frame (4px corners) lies under the bubble, so the
// corners match it.
border-radius: Theme.radius-xs;
background: Theme.surface-4;
border-width: 1px;
border-color: Theme.border-strong;
HorizontalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-3;
padding-top: Theme.space-2;
padding-bottom: Theme.space-2;
label := Text {
text: root.text;
color: Theme.text;
font-size: Theme.font-sm;
vertical-alignment: center;
wrap: word-wrap;
}
}
}
// Put last in an element: it fills the element, and once the pointer rests
// on it for a moment, `text` shows in a bubble at the pointer until the
// pointer leaves. Desktop only (`Bridge.desktop`).
//
// It is Slint's `Tooltip`, whose bubble lets the pointer through: a
// PopupWindow of our own takes every click and move while it is open, so
// the element under it would lose the click and its hover. Being last, the
// hover area sees the pointer before the element's other children, also
// over a disabled button. Near the window's edges Slint moves the bubble
// inside.
export component HoverTooltip inherits Rectangle {
in property <string> text;
// The element's own TouchArea, if it has one: a press closes the bubble
// until the pointer leaves.
in property <bool> pressed;
in property <bool> hovered;
property <bool> clicked;
changed pressed => {
if self.pressed {
self.clicked = true;
}
}
changed hovered => {
if !self.hovered {
self.clicked = false;
}
}
// Removing the area closes an open bubble.
if Bridge.desktop && !root.clicked && root.text != "": Tooltip {
TooltipBubble {
text: root.text;
}
}
}
@@ -710,7 +710,6 @@ export component StudioHeader inherits HorizontalLayout {
}
Tooltip {
text: StudioBridge.status.details;
below: true;
width: 20px;
height: 20px;
Icon {
+11 -4
View File
@@ -84,13 +84,18 @@ The standard widgets (scroll bars, context menus) follow through
All in `ui/components/`, exported by `components/index.slint`.
A component used in many places keeps `opacity`, `visible`, shadows and
animations off its root element: Slint inlines such a component at every
use, which grows the generated code and the compiler's memory (IconButton
puts them on an inner `face`).
| Component | File | Key properties |
|---|---|---|
| `Icon` | icon.slint | `source` (an `Icons.*`), `size`, `tint` |
| `Spinner` | icon.slint | `size`, `tint`, `running` |
| `Button` | button.slint | `text`, `icon`, `kind` (`ButtonKind.primary/secondary/danger/ghost`), `enabled`, `checked`, `small`; `clicked` |
| `IconButton` | button.slint | `icon`, `label` (screen readers), `checked`, `danger`, `round`, `filled`, `size`, `icon-size`, `tint`, `dot`; `clicked` |
| `ActionButton` | button.slint | round button with a caption (Mute, Deafen, Go Live): `icon`, `text`, `checked`, `danger` |
| `IconButton` | button.slint | `icon`, `label` (screen readers), `tooltip` (default `label`, "" for none; on hover, also while disabled, desktop only), `checked`, `danger`, `round`, `filled`, `size`, `icon-size`, `tint`, `dot`, `count` (a neutral number at the top right, hidden at 0 or less); `clicked` |
| `ActionButton` | button.slint | round button with a caption (Mute, Deafen, Go Live), no tooltip: `icon`, `text`, `checked`, `danger` |
| `FocusRing` | button.slint | the accent ring of focused controls |
| `TextField` | text-field.slint | `text`, `placeholder`, `input-type`, `icon`, `label`, `bare`, `read-only`; `accepted`, `edited`, `key-pressed`; `clear()`, `select-all()` |
| `SearchBox` | text-field.slint | a TextField with a magnifier and the Ctrl K hint (`show-shortcut`) |
@@ -104,7 +109,7 @@ All in `ui/components/`, exported by `components/index.slint`.
| `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) |
| `CountBadge` | badge.slint | red count bubble: `count`, `fill` |
| `CountBadge` | badge.slint | count bubble: `count`, `fill` (red), `ink` (the number) |
| `LiveBadge` | badge.slint | `text` (LIVE), `large` |
| `Chip` | badge.slint | tag: `text`, `icon`, `tint`, `fill`, `outlined` |
| `Dot` | badge.slint | a status dot |
@@ -117,7 +122,9 @@ All in `ui/components/`, exported by `components/index.slint`.
| `NavItem` | list-item.slint | navigation entry: `icon`, `text`, `subtitle`, `selected`, `badge`, `chevron`; `clicked` |
| `ListItem` | list-item.slint | row with a leading slot (@children), `title`, `subtitle`, `trailing`, `selected` |
| `PopupMenu` | overlay.slint | themed menu: `entries` ([MenuEntry]), `show(x, y)`; `activated(int)` |
| `Tooltip` | overlay.slint | wraps @children, shows `text` on hover |
| `Tooltip` | overlay.slint | wraps @children; `text` shows at the pointer after a moment, until it leaves (desktop only: `Bridge.desktop`) |
| `HoverTooltip` | tooltip.slint | the same, put last in an element (as IconButton does): `text`; `pressed` and `hovered` of the element's TouchArea (a press closes it until the pointer leaves) |
| `TooltipBubble` | tooltip.slint | a tooltip's bubble: `text`, wrapping at `widest` (400px) |
| `Modal` | overlay.slint | dialog with backdrop: `title`, `subtitle`, `icon`, `card-width`, `card-height`; `dismissed` (backdrop, Escape, ×) |
| `Toast` | overlay.slint | `text`, `icon`, `timeout`, `shown` |
| `ResizeHandle` | overlay.slint | drag to resize a side panel: `size` (two-way), `minimum`, `maximum`, `left` |