Stop the rail destinations sliding to the middle when it collapses

The scroll body holds [nav, RECENTS header, RECENTS], and RECENTS carries the
only stretch factor. Collapsing hides it, which leaves a fixed-height nav tree
(app.py sets one per row count) and nothing that can expand — so the box layout
centred what was left and the destinations dropped 297px down a 1048px window,
with the same gap opening below them.

A stretch spacer at the foot of the body takes the slack instead. It takes none
of it while RECENTS is visible, because RECENTS carries stretch 1 against its 0,
so the open rail is byte-for-byte what it was.

This is what "thu gọn menu lại ra giữa" meant, reported three times. I read it
as horizontal each time and measured x — which was 4px and correct throughout.
The report was about the vertical axis and I never checked it.

check_rail_align now measures the gap between the + button and the first
destination in both states: 6px/6px now, 6px/223px with the spacer removed.

15/15 checkers pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nam Pham Dinh Thanh
2026-08-18 11:11:55 +09:00
co-authored by Claude Opus 5
parent cb03bc1494
commit ac29f519cc
2 changed files with 36 additions and 0 deletions
+30
View File
@@ -140,6 +140,7 @@ def main() -> int:
app.processEvents()
fails += compare(theme_name, rail, opened, closed)
fails += column_widths_do_not_move_icons(win, app, theme_name)
fails += rows_stay_under_the_header(win, app, theme_name)
print()
for f in fails:
@@ -150,6 +151,35 @@ def main() -> int:
os._exit(1 if fails else 0)
def rows_stay_under_the_header(win, app, theme_name):
"""The destinations start just below the + button in both states.
Collapsing hides RECENTS, the one item in the scroll body with a stretch
factor. With nothing left to expand, a box layout centres what remains, and
the whole group slid ~300px down the rail.
"""
from PySide6.QtCore import QPoint
rail = win._nav_wrap
gaps = {}
for state in ("open", "collapsed"):
if (state == "collapsed") != win._nav_collapsed:
win._toggle_nav()
app.processEvents()
btn = win.nav_new_chat
below = btn.mapTo(rail, QPoint(0, btn.height())).y()
top = win.nav.mapTo(rail, QPoint(0, 0)).y() + win.nav.visualItemRect(win.nav.topLevelItem(0)).top()
gaps[state] = top - below
if win._nav_collapsed:
win._toggle_nav()
app.processEvents()
print(f" gap under +: open={gaps['open']}px collapsed={gaps['collapsed']}px")
if abs(gaps["collapsed"] - gaps["open"]) > 4:
return [f"{theme_name}: the destinations sit {gaps['collapsed']}px below "
f"the + button when collapsed but {gaps['open']}px when open"]
return []
def column_widths_do_not_move_icons(win, app, theme_name):
"""The icon must not care how wide the column is.