v0.61.0: buttons darken clearly while held; the play box is three touching buttons; taller scrubber; crisp art border

Held is now PRESSED_DARKER 125 (between Material 3 and GNOME), sunk, on
every button. Transport boxes no longer carry the face themselves (a
QFrame has no pressed state): each button does, so shuffle, repeat and
bpm sink while held and the play box's tiles act as separate buttons with
no grey hover patch. Scrollbar thumbs darken further while dragged. The
seek bar's groove and knob are twice as tall. The album art meets a 1 px
line in the lists' grey, without the pale blend that doubled it.
This commit is contained in:
2026-10-17 00:39:46 -07:00
parent 293d253258
commit 42114f252b
8 changed files with 178 additions and 41 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
"""LinTunes — iTunes-style music library manager and player for Linux."""
__version__ = "0.60.0"
__version__ = "0.61.0"
+15 -8
View File
@@ -441,24 +441,31 @@ class SidebarArt(QWidget):
face.darker(theme.HOVER_DARKER),
NO_ART_RADIUS, like=CONTROL_HEIGHT)
return
theme.paint_deboss(painter, rect,
self.palette().alternateBase().color(),
NO_ART_RADIUS, like=CONTROL_HEIGHT)
if self._pixmap is None or self._pixmap.isNull():
theme.paint_deboss(painter, rect,
self.palette().alternateBase().color(),
NO_ART_RADIUS, like=CONTROL_HEIGHT)
return
# The cover fills the panel inside its border, so the border and its
# darker top edge stay where they are with or without art.
inside = rect.adjusted(1, 1, -1, -1)
# The cover reaches the outline's centre and the line is drawn over
# it, so the art meets a crisp 1 px line — inset half a pixel, the
# antialiased clip left a pale blend of panel and art inside the
# line that read as a second pixel of border. The line is the lists'
# uniform frame grey (Round 92).
clip = QPainterPath()
clip.addRoundedRect(inside, NO_ART_RADIUS - 1, NO_ART_RADIUS - 1)
clip.addRoundedRect(rect, NO_ART_RADIUS, NO_ART_RADIUS)
painter.save()
painter.setClipPath(clip)
area = inside.toAlignedRect()
area = self.rect().adjusted(0, NO_ART_GAP, 0, 0)
scaled = self._pixmap.scaled(
area.size(), Qt.AspectRatioMode.KeepAspectRatioByExpanding,
Qt.TransformationMode.SmoothTransformation)
x = area.left() + (area.width() - scaled.width()) // 2
y = area.top() + (area.height() - scaled.height()) // 2
painter.drawPixmap(x, y, scaled)
painter.restore()
from PyQt6.QtGui import QPen
painter.setPen(QPen(frame_color(self.palette()), 1))
painter.drawPath(clip)
class PlaylistTree(QTreeWidget):
+35 -1
View File
@@ -44,6 +44,14 @@ class ClickToJumpScrollStyle(QProxyStyle):
extent = 14
# A slider whose `tall` property is set (the seek bar) has its groove
# and handle this many times Fusion's height; the handle keeps its width.
TALL = 2
@staticmethod
def _tall(widget) -> bool:
return widget is not None and bool(widget.property("tall"))
def styleHint(self, hint, option=None, widget=None, returnData=None):
if hint == QStyle.StyleHint.SH_ScrollBar_LeftClickAbsolutePosition:
return 1
@@ -54,9 +62,31 @@ class ClickToJumpScrollStyle(QProxyStyle):
return self.extent
if metric == QStyle.PixelMetric.PM_ScrollBarSliderMin:
return self.extent * 2
if metric in (QStyle.PixelMetric.PM_SliderThickness,
QStyle.PixelMetric.PM_SliderControlThickness) \
and self._tall(widget):
return super().pixelMetric(metric, option, widget) * self.TALL
return super().pixelMetric(metric, option, widget)
def subControlRect(self, control, option, sub, widget=None):
if control == QStyle.ComplexControl.CC_Slider and self._tall(widget) \
and sub == QStyle.SubControl.SC_SliderGroove:
groove = super().subControlRect(control, option, sub, widget)
center = groove.center()
if option.orientation == Qt.Orientation.Horizontal:
groove.setHeight(groove.height() * self.TALL)
else:
groove.setWidth(groove.width() * self.TALL)
groove.moveCenter(center)
return groove
if control == QStyle.ComplexControl.CC_Slider and self._tall(widget) \
and sub == QStyle.SubControl.SC_SliderHandle:
handle = super().subControlRect(control, option, sub, widget)
if option.orientation == Qt.Orientation.Horizontal:
handle.moveTop(max(option.rect.top(), handle.top()))
else:
handle.moveLeft(max(option.rect.left(), handle.left()))
return handle
if control != QStyle.ComplexControl.CC_ScrollBar:
return super().subControlRect(control, option, sub, widget)
SC = QStyle.SubControl
@@ -109,7 +139,11 @@ class ClickToJumpScrollStyle(QProxyStyle):
and option.state & (QStyle.StateFlag.State_MouseOver
| QStyle.StateFlag.State_Sunken))
if hot:
color = color.darker(theme.HOVER_DARKER)
# A thumb is a button: darker under the cursor, darker
# still while it's held and dragged.
held = option.state & QStyle.StateFlag.State_Sunken
color = color.darker(theme.PRESSED_DARKER if held
else theme.HOVER_DARKER)
theme.paint_emboss(painter, thumb, color, theme.BUTTON_RADIUS,
like=theme.button_height_px(option.fontMetrics))
painter.restore()
+28 -28
View File
@@ -41,35 +41,31 @@ TOP = Qt.AlignmentFlag.AlignTop
# (Library button · search or playlist name · seek) at the medium UI scale.
BAR_HEIGHT = TOP_MARGIN + CONTROL_HEIGHT + ROW_GAP + 34
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)}; }}")
def _box_style(bg: QColor) -> str:
"""A transport box is its buttons: each one carries the shared button
face (emboss, outline, darker on hover, sunk and darker while held), and
the box itself draws nothing. The play box's three are separate buttons
that touch — square where they meet, sharing one line (TILE_STYLE)."""
face = "QFrame#transportBox { border: none; background: transparent; }"
for kind in ("QToolButton", "QPushButton"):
face += theme.button_face_qss(f"QFrame#transportBox > {kind}", bg,
radius=8)
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;
}
# Where tiles meet: square corners, and one shared line (the later tile
# drops its left border), as the Library button and its ▾ do.
TILE_STYLE = "".join(
f"QFrame#transportBox > {kind}[tile=\"{tile}\"] {{ {rule} }}"
for kind in ("QToolButton", "QPushButton")
for tile, rule in (
("first", "border-top-right-radius: 0; border-bottom-right-radius: 0;"),
("middle", "border-radius: 0; border-left: none;"),
("last", "border-top-left-radius: 0; border-bottom-left-radius: 0;"
" border-left: none;"))) + """
QFrame#transportBox QPushButton, QFrame#transportBox QPushButton:disabled {
color: black;
}
QFrame#transportBox[tiles="true"] QToolButton:hover {
background: rgba(0, 0, 0, 22);
}
QFrame#transportBox[tiles="true"] QToolButton:pressed {
background: rgba(0, 0, 0, 38);
}
"""
@@ -133,12 +129,15 @@ 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")
# 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))
if len(widgets) > 1:
for i, widget in enumerate(widgets):
widget.setProperty("tile", "first" if i == 0 else
"last" if i == len(widgets) - 1 else "middle")
frame.setStyleSheet(_box_style(bg))
inner = QHBoxLayout(frame)
inner.setContentsMargins(*margins)
# A split box is all button, edge to edge: the face is the buttons'.
inner.setContentsMargins(*((0, 0, 0, 0) if split else margins))
if split:
inner.setSpacing(0)
for widget in widgets:
@@ -492,6 +491,7 @@ class TransportBar(QWidget):
self._remaining_label.setAlignment(Qt.AlignmentFlag.AlignRight
| Qt.AlignmentFlag.AlignBottom)
self._slider = SeekSlider()
self._slider.setProperty("tall", True) # twice Fusion's height
self._slider.setRange(0, 0)
self._slider.setFocusPolicy(Qt.FocusPolicy.NoFocus)
# The row reaches below the floor by the text's descent (so the
@@ -670,7 +670,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, button=not box.property("tiles")))
box.setStyleSheet(_box_style(box_bg))
self._apply_now_playing_bg()
self._apply_now_playing_font()
self._visualizer.update() # dim-mode bar color may have changed
+5 -2
View File
@@ -208,7 +208,10 @@ EMBOSS_RIM = 116
EMBOSS_RIM_WIDTH = 0.08 # fraction of the height each rim takes
BUTTON_RADIUS = 4 # every button's corners, and the scrollbar thumb's
HOVER_DARKER = 107 # hover: the whole button, slightly darker
PRESSED_DARKER = 112
# Held down: clearly darker again (Round 92) — between Material 3's state
# layers (hover 8 %, pressed 10 %) and GNOME's buttons (15 % → 30 %).
PRESSED_DARKER = 125
CHECKED_DARKER = 112 # a toggle that is on (checked), not held
def emboss_edges(color: QColor) -> str:
@@ -332,7 +335,7 @@ def button_emboss_qss(button: QColor) -> str:
return button_face_qss(
"QPushButton:!flat", button,
extra="padding: 3px 12px; min-height: 1.3em;",
checked_color=button.darker(PRESSED_DARKER)) + \
checked_color=button.darker(CHECKED_DARKER)) + \
"QPushButton:!flat:default { border-color: palette(highlight); }" \
"QPushButton:!flat:disabled { color: palette(mid); }"