Files
qbz/crates/qbz-slint/ui/primitives/ToggleButton.slint
T
vicrodh 1d4b5c7868 style(slint): match toolbar selects to genre button + sharp toggle + grouped list rows
- QbzSelect sm now matches the favorites genre button: no outline, 6px
  corners (was Radius.sm 8px), 12px label (was body). Standard size
  (Settings) unchanged.
- ToggleButton snaps its icon to whole pixels (the HeaderBar/QueueSidebar
  treatment) so the grid/list glyphs render crisp instead of blurry.
- AlbumCollectionView grouped sections now follow the view mode: in list
  mode each group renders AlbumListRow rows (column header once on top)
  instead of always a card grid, so group + list no longer conflict.

cc
2026-05-27 11:45:52 -06:00

40 lines
1.4 KiB
Plaintext

// One half of a segmented toggle (grid/list) or a standalone toolbar
// toggle (group-by / Hi-Res / filter). Shared by every album-toolbar
// view (Discover Browse, Label Releases, Favorites). 34px square icon
// button: highlighted when active, surface-elevated on hover.
import { Theme } from "../foundation/semantic-colors.slint";
import { QbzIcon } from "QbzIcon.slint";
export component ToggleButton inherits Rectangle {
in property <image> icon;
in property <bool> active: false;
// Bootstrap-style small variant. Default is the standard size.
in property <bool> sm: false;
callback clicked();
width: root.sm ? 30px : 34px;
height: root.sm ? 30px : 34px;
background: root.active
? Theme.surface-hover
: (ta.has-hover ? Theme.surface-elevated : transparent);
QbzIcon {
source: root.icon;
width: root.sm ? 15px : 17px;
height: root.sm ? 15px : 17px;
// Snap the centered position to whole pixels so the icon stays
// crisp (same treatment as the HeaderBar / QueueSidebar icons).
x: Math.round((parent.width - self.width) / 2 / 1px) * 1px;
y: Math.round((parent.height - self.height) / 2 / 1px) * 1px;
tint: root.active ? Theme.text-primary : Theme.text-muted;
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => {
root.clicked();
}
}
}