Files
VoelinClient/crates/voelin-ui/ui/components/tooltip.slint
Claude 3c47bc682f ui: a clearer edge on pop-ups, and a light scrim behind them
Pop-ups, menus and tooltips had the border-strong edge, which barely
shows against the panels under them. They get a new border-popup token;
the Select and Stream Studio drop-downs too, being the same kind of menu.
The member card, the emoji picker and the bell's panel now dim the
window behind them with a new scrim-light, lighter than the modals'
scrim; a click on it still closes them. The toast moves above them, so
that scrim does not dim it (a poke from the member card is confirmed
there).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
2026-10-06 07:34:00 +00:00

71 lines
2.5 KiB
Plaintext

// 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-popup;
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;
}
}
}