Fix firing panel scrollbar layout jitter and strike reorder lock-in

Scrollbar: the ScrolledWindow left horizontal policy on AUTOMATIC (the
default), so a vertical scrollbar's own width could shrink the
content area enough to trigger a horizontal scrollbar too, perturbing
card heights and tripping vertical scrolling that wasn't actually
needed. Pinned horizontal off outright, this is a fixed-width sidebar,
never wanted anyway.

Reorder: the card sort key forced every Strike above every non-Strike
on *every* refresh, not just at creation, silently undoing any manual
drag-reorder that moved a strike below other targets. The 'new
strikes go first' behavior only needs to happen once, at creation
(already handled by _add_strike_at's reorder_target(target, 0)); the
sort key was redundant with that and actively fighting the user
afterward. Removed it.
This commit is contained in:
Dominik Moritz Roth 2026-08-09 15:46:22 +02:00
parent c5bcbd3bce
commit 19e9ffdd68

View File

@ -91,6 +91,12 @@ class FiringPanel(Gtk.Box):
self._list_box.set_margin_start(10)
self._list_box.set_margin_end(10)
scroller = Gtk.ScrolledWindow(child=self._list_box, vexpand=True)
# Horizontal scrolling is never wanted here (fixed-width sidebar),
# leaving it on AUTOMATIC (the default) lets a vertical scrollbar's
# own width shrink the content area enough to trigger a horizontal
# one too, which then perturbs card heights and can trip vertical
# scrolling that wasn't actually needed. Pin it off outright.
scroller.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
self.append(scroller)
self.refresh()
@ -173,11 +179,13 @@ class FiringPanel(Gtk.Box):
def sort_key(t: Target):
dead_last = 1 if (self.show_dead == "sort_later" and not t.alive) else 0
strike_first = 0 if t.type is TargetType.STRIKE else 1
return (dead_last, strike_first)
return dead_last
# Stable sort: ties keep board order, which is exactly what drag
# reordering (Board.reorder_target) manipulates.
# reordering (Board.reorder_target) manipulates. A new strike goes
# to the front once, at creation (see app.py's _add_strike_at),
# not forced back there on every refresh, that would fight any
# later manual reorder.
targets.sort(key=sort_key)
if not targets: