v0.47.1: the no-art panel sits on the window, shaded like the visualizer

With no art, the sidebar's art widget moves out of the playlist list's
frame onto the window below it, so the panel is set into the gray like the
visualizer rather than into a white box. A tall debossed panel is now
shaded along its top and bottom exactly as the 62 px visualizer is, flat
in the visualizer's color between, instead of one gradient stretched over
its whole height, which read as gray. The scrollbar thumb is shaded the
same way, like a button.
This commit is contained in:
2026-10-10 23:03:47 -07:00
parent fbb439b7ee
commit d4cf3f95c2
6 changed files with 134 additions and 73 deletions
+3 -2
View File
@@ -52,8 +52,9 @@ def test_library_button_spans_the_playlist_list(qapp, tmp_path):
window = _window(qapp, tmp_path)
header = window.sidebar.header
lists = window.sidebar.list_area
# The frame around the playlists takes in the album art too.
assert window.sidebar.art.parentWidget() is lists
# With nothing playing the art is the empty panel, below the frame on
# the window (Round 80); the frame takes in real art (test_round80).
assert window.sidebar.art.parentWidget() is window.sidebar
assert header.parentWidget() is not window.sidebar
assert _gx(header) == _gx(lists) > _gx(window)
assert header.width() == lists.width()
+63 -30
View File
@@ -78,13 +78,12 @@ def test_thickness_follows_ui_scale(qapp):
ClickToJumpScrollStyle.extent = before
def test_thumb_rims_match_a_real_button(qapp):
def test_thumb_is_shaded_like_a_real_button(qapp):
qapp.setStyleSheet(theme.button_emboss_qss(QColor("#d0d0d0")))
try:
button = QPushButton("OK")
height = button.sizeHint().height()
assert abs(theme.button_rim_px(button.fontMetrics())
- theme.EMBOSS_RIM_WIDTH * height) < 1
assert abs(theme.button_height_px(button.fontMetrics())
- button.sizeHint().height()) <= 2
finally:
qapp.setStyleSheet("")
@@ -101,43 +100,77 @@ def test_thumb_paints(qapp):
# --------------------------------------------------------------------------
# no album art: a debossed panel, not a flat square
# no album art: a debossed panel on the window, not a box in the list
# --------------------------------------------------------------------------
def test_no_art_is_a_debossed_panel(qapp):
from PyQt6.QtCore import QObject, pyqtSignal
from lintunes.gui.sidebar import NO_ART_MARGIN, SidebarArt
def _sidebar(qapp, tmp_path):
from lintunes.gui.main_window import MainWindow
from lintunes.library_manager import LibraryManager
from lintunes.models.library import Library
from lintunes.models.track import Track
from lintunes.preferences import Preferences
library = Library(tracks={1: Track(track_id=1, name="One")})
window = MainWindow(LibraryManager(library, tmp_path), Preferences(tmp_path))
window.resize(1000, 700)
window.show()
qapp.processEvents()
return window, window.sidebar
class Player(QObject):
track_changed = pyqtSignal(object)
art = SidebarArt(Player())
art.resize(200, 200)
def test_no_art_panel_sits_below_the_frame(qapp, tmp_path):
from lintunes.gui.sidebar import NO_ART_GAP
window, sidebar = _sidebar(qapp, tmp_path)
art = sidebar.art
assert not art.has_art()
assert art.parentWidget() is sidebar
assert art.y() >= sidebar.list_area.geometry().bottom()
assert art.height() == art.width() + NO_ART_GAP
image = art.grab().toImage()
base = art.palette().base().color()
# the margin around the panel is the list's own background...
assert image.pixelColor(1, 100) == base
# ...the corner is rounded off, so it's background too...
assert image.pixelColor(NO_ART_MARGIN + 1, NO_ART_MARGIN + 1) == base
# ...and the panel is shaded darker at the top than in the middle
top = image.pixelColor(100, NO_ART_MARGIN + 2).lightness()
middle = image.pixelColor(100, 100).lightness()
assert top < middle
window_bg = art.palette().window().color()
# the gap above is bare window; the panel's middle is the visualizer's
# color, flat, not shaded gray over its whole height
assert image.pixelColor(art.width() // 2, 1) == window_bg
panel = art.palette().alternateBase().color()
for y in (art.height() // 3, art.height() // 2, 2 * art.height() // 3):
assert image.pixelColor(art.width() // 2, y) == panel
window.close()
def test_deboss_rims_can_be_fixed_in_pixels(qapp):
"""On a 400 px panel the default rims are 32 px deep; 3 px rims leave
row 10 already on the face, a good deal lighter."""
def test_real_art_goes_inside_the_frame(qapp, tmp_path):
from PyQt6.QtGui import QPixmap
window, sidebar = _sidebar(qapp, tmp_path)
art = sidebar.art
pixmap = QPixmap(10, 10)
pixmap.fill(QColor("red"))
art._pixmap = pixmap
art.has_art_changed.emit(True)
art._fit_height()
assert art.parentWidget() is sidebar.list_area
assert art.height() == art.width()
art._pixmap = None
art.set_track(None)
assert art.parentWidget() is sidebar
window.close()
def test_tall_deboss_copies_a_short_panels_edges(qapp):
"""Shaded ``like`` a 62 px panel, a 400 px one matches it row for row
along the top, and is flat in the middle."""
from PyQt6.QtCore import QRectF
from PyQt6.QtGui import QImage, QPainter
color = QColor("#e0e0e0")
color = QColor("#f2f2f2")
def row10(**kw):
image = QImage(100, 400, QImage.Format.Format_ARGB32)
def paint(height, **kw):
image = QImage(100, height, QImage.Format.Format_ARGB32)
image.fill(0)
painter = QPainter(image)
theme.paint_deboss(painter, QRectF(0.5, 0.5, 99, 399), color, 8, **kw)
theme.paint_deboss(painter, QRectF(0.5, 0.5, 99, height - 1),
color, 8, **kw)
painter.end()
return image.pixelColor(50, 10).lightness()
return image
assert row10(rim=3) > row10() + 5
short, tall = paint(62), paint(400, like=62)
for y in (3, 10, 20):
assert abs(short.pixelColor(50, y).lightness()
- tall.pixelColor(50, y).lightness()) <= 1
assert tall.pixelColor(50, 200) == color