v0.31.1: one button look — crisper emboss, darken on hover

- The emboss hugs the edges: thin lit and shaded rims, a defined outline
  that's a touch darker along the bottom, and a nearly flat face — shape
  without depth.
- Hover darkens the whole button slightly instead of Qt's pale panel on
  top of it.
- One face for every button (theme.button_face_qss): regular buttons,
  Library and its ▾, the purple friend-mode buttons, and the transport
  boxes. Shuffle and bpm are boxes that are one button, so the whole box
  darkens (bpm's whole box is now its tap target); the play box's three
  tiles each darken on their own.
This commit is contained in:
2026-09-28 22:17:05 -07:00
parent f1f5f450ff
commit 2d0f077af0
6 changed files with 145 additions and 73 deletions
+35 -12
View File
@@ -31,13 +31,32 @@ CONTROL_HEIGHT = 62
# panel (the seek row sits below the panel, not beside the boxes).
TOP = Qt.AlignmentFlag.AlignTop
def _box_style(bg: QColor) -> str:
return f"""
QFrame#transportBox {{
border: 1px solid palette(mid);
border-radius: 8px;
background: {theme.emboss_gradient(bg)};
}}
def _box_style(bg: QColor, button: bool = False) -> str:
"""A transport box. A box that *is* one button (shuffle, bpm) gets the
shared button face — emboss, outline, whole-box darkening on hover; the
three-tile play box gets the same face, and each tile darkens on its own
(see TILE_STYLE)."""
face = theme.button_face_qss("QFrame#transportBox", bg, radius=8)
if not button:
# Hover belongs to the tiles here, not the whole box.
face += (f"QFrame#transportBox:hover {{ background:"
f" {theme.emboss_gradient(bg)}; }}")
return face + TILE_STYLE
# Tool buttons inside a box: no light panel of their own. A tile in the play
# box darkens slightly under the cursor — the same "whole button, a little
# darker" as every other button — and a lone button leaves that to its box.
TILE_STYLE = """
QFrame#transportBox QToolButton, QFrame#transportBox QPushButton {
border: none; background: transparent; border-radius: 6px;
}
QFrame#transportBox[tiles="true"] QToolButton:hover {
background: rgba(0, 0, 0, 22);
}
QFrame#transportBox[tiles="true"] QToolButton:pressed {
background: rgba(0, 0, 0, 38);
}
"""
@@ -105,7 +124,10 @@ def _box(*widgets, bg: QColor, margins=(10, 3, 10, 3), hug=False,
a full-bleed tap target with its content centered in its share."""
frame = QFrame()
frame.setObjectName("transportBox")
frame.setStyleSheet(_box_style(bg))
# A box holding one control is that control: it darkens as a whole.
frame.setProperty("tiles", len(widgets) > 1)
frame.setAttribute(Qt.WidgetAttribute.WA_Hover)
frame.setStyleSheet(_box_style(bg, button=len(widgets) == 1))
inner = QHBoxLayout(frame)
inner.setContentsMargins(*margins)
if split:
@@ -180,7 +202,7 @@ class BpmButton(QPushButton):
self._manager = manager
self._tempo = TapTempo()
self._target_track_id: int | None = None
self.setFixedWidth(64)
self.setFixedWidth(74) # + the box's 3 px margins = its old footprint
self.setFlat(True) # flat text inside its box, like the transport icons
self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
self.setEnabled(False)
@@ -356,8 +378,9 @@ class TransportBar(QWidget):
# with the now-playing panel like the transport boxes — kept out of
# the seek row so it doesn't drive the timeline row's height.
self._bpm_button = BpmButton(player, manager)
bpm_box = _box(self._bpm_button, bg=box_bg, margins=(8, 8, 8, 8),
hug=True, height=CONTROL_HEIGHT)
# The whole box is the tap target, so it darkens (and taps) as one.
bpm_box = _box(self._bpm_button, bg=box_bg, margins=(3, 3, 3, 3),
hug=True, height=CONTROL_HEIGHT, split=True)
self._boxes.append(bpm_box)
layout.addWidget(bpm_box, alignment=TOP)
@@ -388,7 +411,7 @@ class TransportBar(QWidget):
button.refresh_icons()
box_bg = theme.gray(theme.gray_value(self._prefs, "color_button"))
for box in self._boxes:
box.setStyleSheet(_box_style(box_bg))
box.setStyleSheet(_box_style(box_bg, button=not box.property("tiles")))
self._apply_now_playing_bg()
self._apply_now_playing_font()
self._visualizer.update() # dim-mode bar color may have changed