v0.84.1: automatic buttons ending the second toolbar row line up under the buttons ending the first

This commit is contained in:
2026-10-29 18:15:27 -07:00
parent 2deacdadca
commit b26b0da54b
4 changed files with 97 additions and 2 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
"""LinTunes — iTunes-style music library manager and player for Linux."""
__version__ = "0.84.0"
__version__ = "0.84.1"
+42
View File
@@ -113,6 +113,48 @@ def shown_ids(rows) -> set[str]:
return {e["id"] for row in rows for e in row}
def _fills(entry) -> bool:
size, base = entry.get("size", "auto"), base_id(entry["id"])
return size == "fill" or (size == "auto" and (base in AUTO_FILL or base == "seek"))
def column_partners(rows) -> dict[str, str]:
"""{row-1 item: row-0 item} it sits exactly under. ``ANCHORED_UNDER``
first; then the buttons ending row 1 pair off, right to left, with the
buttons ending row 0, so a theme box over a speakers box lines up like
DJ over bpm. Only "auto" buttons in row 1 join (an exact width is the
user's call); a spacer or anything that fills ends either run."""
top, bottom = rows
shown = {e["id"] for e in top}
partners = {e["id"]: ANCHORED_UNDER[base_id(e["id"])] for e in bottom
if base_id(e["id"]) in ANCHORED_UNDER
and e.get("size", "auto") == "auto"
and ANCHORED_UNDER[base_id(e["id"])] in shown}
def run(row, ok):
out = []
for entry in reversed(row):
if base_id(entry["id"]) in SPACERS or _fills(entry) or not ok(entry):
break
out.append(entry["id"])
return out
below = run(bottom, lambda e: e.get("size", "auto") == "auto"
and base_id(e["id"]) not in ("library", "view"))
above = run(top, lambda e: True)
for low, high in zip(below, above):
partners[low] = high
# The pairs must keep row 0's order, or the anchors would cross.
order = {e["id"]: i for i, e in enumerate(top)}
last, kept = -1, {}
for entry in bottom:
high = partners.get(entry["id"])
if high is not None and order[high] > last and high not in kept.values():
kept[entry["id"]] = high
last = order[high]
return kept
def palette_ids(rows) -> list[str]:
"""What the palette offers: everything not shown, and always both
spacers (dragging one in makes a new instance)."""
+2 -1
View File
@@ -874,6 +874,7 @@ class TransportBar(QWidget):
"""The layout engine's slots for ``row``. Row 1's automatic items
follow what they belong under: the sidebar, the view, row 0."""
split = self._split()
partners = toolbar.column_partners(self._rows)
slots = []
for entry in self._rows[row]:
item, size = entry["id"], entry.get("size", "auto")
@@ -885,7 +886,7 @@ class TransportBar(QWidget):
if size == "fill":
slots.append(Slot(item, fill=True, min_width=least))
continue
above = self._rects[0].get(toolbar.ANCHORED_UNDER.get(base, ""))
above = self._rects[0].get(partners.get(item, ""))
if row == 1 and base == "library" and split is not None:
slots.append(Slot(item, anchor=(split[0], split[1]), min_width=least))
elif row == 1 and above is not None: