Skip to content

[GUI] Fix truncated Help, Cancel and OK buttons - #966

Merged
arnodelorme merged 2 commits into
developfrom
fix/inputgui-button-width
Sep 12, 2026
Merged

arnodelorme merged 2 commits into
developfrom
fix/inputgui-button-width

Conversation

@arnodelorme

Copy link
Copy Markdown
Collaborator

The bottom buttons were sized in normalized units, so their pixel width followed the figure scaling factor and their labels were clipped in narrow dialogs (28 px wide buttons on a 3440 px display, 56 px on a 560 px default figure). They are now sized in pixels from the rendered label, and the figure is widened only when the row does not fit.

Checked on pop_resample and on the single help, double help, no help, wide, geomvert and geom layouts, plus a full pop_resample round trip on sample data.

Set the Help/Cancel/OK width in pixels from the rendered label instead of
letting supergui scale it with the figure, which truncated the labels in
narrow dialogs on high resolution displays.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@claude

claude Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@arnodelorme

arnodelorme commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

Code review

  • Overall assessment: Fixes the clipping in every layout tested; the wide-dialog margin regression raised in the first pass is now addressed in 7ab34de.
  • Highest-risk area: adjustbuttons in functions/guifunc/inputgui.m.
  • Merge recommendation: Safe to merge.

Layouts, develop vs this branch

MATLAB R2025b, macOS, 3440x1440 display. Six inputgui layouts rendered in 'mode','plot', once with develop's inputgui.m shadowed in and once with this branch.

inputgui bottom buttons, develop versus this branch, six layouts

Each pushbutton's pixel position(3) measured against its text extent(3):

layout develop (px) this branch (px) text needs (px)
pop_resample / inputdlg2 27 / 27 / 27 80 / 80 / 80 (figure 256 -> 281) 39 / 55 / 25
no help button 27 / 27 80 / 80 55 / 25
two help buttons 27 / 27 / 27 / 27 84 / 96 / 80 / 80 (256 -> 389) 64 / 76 / 55 / 25
geomvert listbox dialog 23 / 23 / 23 80 / 80 / 80 (200 -> 277) 39 / 55 / 25
long okbut / cancel labels 22 / 22 / 22 80 / 144 / 160 (200 -> 421) 39 / 124 / 140
wide dialog (1774 px) 94 / 94 / 94 80 / 80 / 80 39 / 55 / 25

Every clipped label now fits, and no layout is clipped on either side.

Margin fix (7ab34de)

The first commit used a fixed margin = 10, which ignored the proportional g.borders supergui applies to everything else. On the 1774 px wide dialog that pulled Help from x = 88 to x = 10 and OK from 85 px off the right edge to 10 px, so the button row no longer lined up with the column above it. adjustbuttons now reads the margins supergui had already used, and falls back to 10 px only when they are smaller than that.

wide dialog left and right edges across develop, the first commit, and the margin fix

wide dialog left margin (px) right margin (px)
develop 88 85
first commit 10 10
with 7ab34de 88 85

Narrow dialogs are unchanged by the second commit beyond a few pixels (pop_resample: Help x 10 -> 14, figure 276 -> 281), because the two borders nearly coincide there.

Other checks

  • 'addbuttons','off' skips adjustbuttons entirely.
  • 'mode', <figure> re-entry (the pop_headplot pattern) does not re-run adjustbuttons, so the pixel layout from the first call survives.
  • 'geom' path, minwidth (700 -> figure width 700), and a uilist reduced to {} all behave.
  • Full GUI round trip on sample_data/eeglab_data.set: pop_resample(EEG) returns srate 128, pnts 30504, history EEG = pop_resample( EEG, 128);, eeg_checkset clean.

Blocking

None.

Important

None remaining. The wide-dialog margin finding from the first review pass is fixed in 7ab34de.

Nits

  1. Manual resize re-clips the labels. adjustbuttons ends with set(butobj, 'units', 'normalized'), so the pixel widths only hold at the size the dialog opens at; halving the figure width by hand takes the buttons back to 40 px. Keeping 'pixels' would fix that but would unpin the right-aligned buttons from the right edge, so this is a genuine trade-off rather than an oversight. Worth a one-line comment saying the normalized units are deliberate.
  2. Figure widening clamps only the left edge. figpos(1) = max(0, figpos(1)-(rowwidth-figpos(3))/2) keeps the dialog on screen on the left but can push the right edge past the screen when rowwidth is large on a small display. Clamping against get(0,'screensize') on the right too would cost one line.
  3. curext(3)+20 and minwidth = 80 are magic numbers; the 80 duplicates the 'width' 80 already given to each button at lines 182-193. A shared local would keep them in sync.

Test gaps

No automated check, which matches the repo (no central test suite). The regression is cheap to pin down if you want a snippet in the PR body or in AGENTS.md:

inputgui('geometry', {[2 1]}, 'uilist', { {'style' 'text' 'string' 'Rate'} {'style' 'edit' 'string' '128'} }, ...
         'helpcom', 'disp(1)', 'mode', 'plot');
h = findobj(gcf, 'style', 'pushbutton'); set(h, 'units', 'pixels');
p = get(h, 'position'); e = get(h, 'extent');
assert(all(cellfun(@(a,b) a(3) >= b(3), p, e)), 'button labels are clipped');

EEGLAB notes

  1. allobj(end-3:end) and alignleft = [ true true false false ] are tied to the four g.uilist entries appended at inputgui.m:180-193 (help / help-or-empty / cancel / ok). That coupling is correct today but invisible from adjustbuttons. A comment at line 193 ("the last four uilist entries are consumed by adjustbuttons") would keep the two in sync.
  2. The isbutton guard handles the {} slots, the nan values supergui writes for panel/uitable/link2lines, and the empty-cell case, so the no-help and single-help paths degrade cleanly. marginleft falls back to marginright when there is no left-aligned button, which is what keeps the no-help dialog symmetric (Cancel/OK unchanged at an 11 px right margin).
  3. Not exercised: Octave. get(uicontrol,'extent') on a pushbutton is the only property used here that is not uniformly implemented across Octave versions; worth a quick check if Octave support still matters for guifunc.

Keep the left and right margins supergui used for the bottom row
instead of a fixed 10 px, so the buttons stay aligned with the
columns above them in wide dialogs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@arnodelorme
arnodelorme merged commit 9e35579 into develop Sep 12, 2026
2 checks passed
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.

1 participant