Skip to content

Responsive SizedPanel: report the narrow layout's minimum width - #19

Merged
ctoth merged 1 commit into
masterfrom
fix/narrow-min-size
Nov 5, 2026
Merged

ctoth merged 1 commit into
masterfrom
fix/narrow-min-size

Conversation

@ctoth

@ctoth ctoth commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #14, needed by accessibleapps/wx_utils#2.

Once a responsive SizedPanel has been laid out, it sets its minimum width to its narrow layout's minimum, while its best size stays the wide one. It then sends the top-level window a size event. A window that takes its minimum from its sizer (wx_utils AutoFittingMixin) can now be narrowed far enough for the panel to switch layouts.

Verified on Windows (wx 4.3.2 msw, private desktop). A form panel (sizer_type "form", narrow "vertical") inside an AutoFittingMixin + SizedFrame, with fit():

  • With this branch and wx_utils fix/fit-minsize-2: the window opens at 273 px wide, and its drag minimum (WM_GETMINMAXINFO ptMinTrackSize) becomes 157. SetSize(150) narrows it to 157 and switches the panel to narrow.
  • With wx_utils master, the window stays at a 273 px minimum, so the wx_utils change is needed too.
  • The Responsive layouts: switch a SizedPanel to a narrow arrangement when the wide one doesn't fit #14 width sweep (form panel plus a wrapping button row, 900 → 200 → 900) gives the same results as on master. One switch each way, child order unchanged, hidden_when_narrow fields and labels hidden only while narrow, and all four wrapped buttons inside the panel and in UIA.

A responsive SizedPanel reported only its wide layout's minimum size, so
a window that takes its minimum from its sizer (wx_utils
AutoFittingMixin.fit) could never be made narrow enough for the panel to
switch: SetSize(150) was refused at the wide minimum.

After render, deferred with wx.CallAfter so the window first takes the
wide layout's size, the panel measures the narrow layout's minimum width
once and sets it as its minimum width (keeping an app-declared min_size
where larger). Its best size stays the wide layout's, so the window still
opens wide. It then sends its top-level window a size event so a window
that re-reads its sizer's minimum on resize picks up the new one.

The wrap row's minimum-height pin keeps this width, and leaving wrap mode
restores it instead of clearing the minimum. The switch itself is
unchanged: it compares the client width with the wide layout's CalcMin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SeWnvjMTaHf6iZhDbaJpDE
@ctoth
ctoth merged commit 0c19860 into master Nov 5, 2026
3 checks passed
@ctoth
ctoth deleted the fix/narrow-min-size branch November 5, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants