v0.31.5: Library button edge to edge with the playlists; one floor; floating top row

The sidebar gets 8px of bare window on its left, and the Library button
spans exactly the playlist list below it, scrollbar included. The Library
button, search box, playlist name, times and playhead all stand on one
floor 5px above the lists (text by its baseline). The top row floats:
equal space before, between and after the controls, with the now-playing
panel a fixed share of the width (700px at 1920). The header row grows if
the app font makes the Library button taller than the strip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-28 23:04:12 -07:00
co-authored by Claude Opus 5.5
parent d5cdddee33
commit 6f50248202
9 changed files with 167 additions and 85 deletions
+39 -13
View File
@@ -11,7 +11,7 @@ from PyQt6.QtCore import QPoint
from lintunes.gui.fit_label import FitLabel
from lintunes.gui.main_window import MainWindow
from lintunes.gui.transport import NOW_PLAYING_MAX, NOW_PLAYING_MIN
from lintunes.gui.transport import NOW_PLAYING_MIN
from lintunes.library_manager import LibraryManager
from lintunes.models.library import Library
from lintunes.models.playlist import Playlist
@@ -46,12 +46,37 @@ def test_startup_still_opens_on_the_library(qapp, tmp_path):
assert window._sidebar.library_button.isChecked()
def test_library_button_spans_the_sidebar(qapp, tmp_path):
def test_library_button_spans_the_playlist_list(qapp, tmp_path):
# Edge to edge with the list below it, scrollbar included, with bare
# window to the left of both.
window = _window(qapp, tmp_path)
header = window.sidebar.header
lists = window.sidebar.list_area
assert header.parentWidget() is not window.sidebar
assert _gx(header) == _gx(window.sidebar)
assert header.width() == window.sidebar.width()
assert _gx(header) == _gx(lists) > _gx(window)
assert header.width() == lists.width()
button = window.sidebar.library_button
assert _gx(button) == _gx(lists)
assert _gx(button, button.width()) == _gx(lists, lists.width())
def test_header_row_items_share_one_floor(qapp, tmp_path):
from lintunes.gui.transport import HeaderRow
window = _window(qapp, tmp_path)
row = window._transport._header_row
floor = row.height() - HeaderRow.BOTTOM
def bottom(widget):
return widget.mapTo(row, QPoint(0, widget.height())).y()
assert bottom(window.sidebar.library_button) == floor
assert bottom(window._library_view._search) == floor
assert bottom(window._transport._slider) == floor
window._show_playlist("abcd1234")
qapp.processEvents()
label = window._playlist_view.header
baseline = bottom(label) - label.fontMetrics().descent()
assert abs(baseline - floor) <= 1
def test_search_then_title_sit_where_the_view_starts(qapp, tmp_path):
@@ -84,13 +109,13 @@ def test_header_row_shares_the_seek_band(qapp, tmp_path):
assert library.mapTo(bar, QPoint()).y() >= row.geometry().top()
def test_panel_caps_and_gaps_take_the_rest(qapp, tmp_path):
window = _window(qapp, tmp_path, width=1600)
def test_panel_scales_with_the_window(qapp, tmp_path):
window = _window(qapp, tmp_path, width=1920)
bar = window._transport
assert bar._now_playing.width() == NOW_PLAYING_MAX
assert abs(bar._now_playing.width() - 700) <= 1
window.resize(800, 500)
qapp.processEvents()
assert NOW_PLAYING_MIN <= bar._now_playing.width() < NOW_PLAYING_MAX
assert NOW_PLAYING_MIN <= bar._now_playing.width() < 700
bpm = bar._bpm_button.parentWidget()
assert bar._now_playing.geometry().right() < bpm.geometry().left()
assert bpm.geometry().right() < bar.width()
@@ -116,10 +141,10 @@ def test_long_name_shrinks_then_elides(qapp):
def test_row_is_knolled_with_equal_gaps_and_ends(qapp, tmp_path):
from lintunes.gui.transport import MAX_GAP, MIN_GAP
from lintunes.gui.transport import MIN_GAP
window = _window(qapp, tmp_path)
bar = window._transport
for width in (900, 1280, 1800):
for width in (900, 1280, 1920):
window.resize(width, 500)
qapp.processEvents()
row = [bar._prev_btn.parentWidget(), bar._shuffle_btn.parentWidget(),
@@ -128,7 +153,8 @@ def test_row_is_knolled_with_equal_gaps_and_ends(qapp, tmp_path):
edges = [(w.geometry().left(), w.geometry().right()) for w in row]
gaps = [b[0] - a[1] - 1 for a, b in zip(edges, edges[1:])]
assert max(gaps) - min(gaps) <= 1
assert MIN_GAP <= gaps[0] <= MAX_GAP
assert gaps[0] >= MIN_GAP
# The ends get the same space as the gaps: the row floats.
left_end, right_end = edges[0][0], bar.width() - 1 - edges[-1][1]
assert abs(left_end - right_end) <= 1
assert left_end >= gaps[0] - 1
for end in (left_end, right_end):
assert abs(end - gaps[0]) <= 7