Skip to content

Show dialog messages with a wrapping label - #2007

Merged
jecisc merged 3 commits into
pharo-spec:Pharo15from
jordanmontt:use-wrapping-label-in-dialogs
Nov 30, 2026
Merged

jecisc merged 3 commits into
pharo-spec:Pharo15from
jordanmontt:use-wrapping-label-in-dialogs

Conversation

@jordanmontt

Copy link
Copy Markdown
Contributor

Message dialogs now show their message with a wrapping label instead of a read-only text, and request dialogs no longer cut it off.

This PR fixes two things. First, dialogs now use multiline labels (wrapping labels), so they no longer need to calculate the height of the label. It simplifies the dialogs' code.

For this, a fix in the box layout was needed. Now, the box adapter lets a nested layout added with expand: false to a vertical box take the height of its content. Before, it kept the height it had when it was built: a wrapping label in such a row (the dialog's icon and message) was first laid out at about one word per line, and the row kept that height, pushing the rest of the dialog out of the window.

Goal

Spec labels can wrap (SpLabelPresenter>>#beWrap, #1993). A dialog message is text to read, not to edit, but message dialogs showed it in a read-only SpTextPresenter without scroll bars, and request and select dialogs estimated its height from font metrics, one line short.

  • Dialogs show their message with a wrapping label that takes the height of its lines.
  • Box layouts: in a vertical box, a nested layout that does not expand now follows the height of its content, so a wrapping label inside it can grow and shrink. Before, it kept its first height (3000 pixels in the new test).

Main changes

  • SpAbstractMessageDialog>>#newDialogLabel answers a wrapping label, for inform, alert, confirm, request and select dialogs.
  • Request and select dialogs add their message with expand: false instead of a height estimated from font metrics (calculateLabelHeight, removed with labelMargin). The estimate was one line short: a three-line message in a request dialog lost its last line behind the text input.
  • In a vertical box, a nested layout added with expand: false now takes the height of its content (vResizing: #shrinkWrap) instead of keeping the height it had when it was built (#rigid). SpMorphicBoxAdapter>>#basicAdd:constraints:to: makes the switch; horizontal boxes keep #rigid.
  • SpWrappingLabelMorph>>#minExtent answers at least its height, so a row that shrink-wraps keeps all its lines.

🤖 Generated with Claude Code but reviewed thoroughly by jordanmontt ❤️

jordanmontt and others added 3 commits November 27, 2026 16:50
Inform, alert and confirm dialogs show their message with a wrapping label instead of a read-only text. Request and select dialogs keep the text for now: their layout estimates the message height.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In a vertical box, a nested layout added with expand: false shrink-wraps instead of keeping the height it had when built, and a wrapping label reports its height as its minimum. Request and select dialogs then show their whole message with a wrapping label, without the font-metric height estimate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
repository_commit rewrote it in 382574a although nothing in it changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jordanmontt

Copy link
Copy Markdown
Contributor Author

Now it looks like this

Capture d’écran 2026-11-27 à 17 34 10

@Ducasse

Ducasse commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Looks good to me.

@Ducasse

Ducasse commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Seb did you check with topple? @tinchodias

@jordanmontt

Copy link
Copy Markdown
Contributor Author

Seb did you check with topple? @tinchodias

I will!

@tinchodias

tinchodias commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

For the record, this project must be loaded on a Pharo 15: https://github.com/pharo-graphics/Spec-Toplo

This way:

Metacello new
    mvs;
    dev: 'Alexandrie' repository: 'github://pharo-graphics/Alexandrie:dev/src';
    dev: 'XMLParser' repository: 'github://pharo-contributions/XML-XMLParser:master/src';
    dev: 'Bloc' repository: 'github://pharo-graphics/Bloc:dev/src';
    dev: 'Album' repository: 'github://pharo-graphics/Album:dev/src';
    dev: 'Toplo' repository: 'github://pharo-graphics/Toplo:dev/src';
    dev: 'SpecToplo' repository: 'github://pharo-graphics/Spec-Toplo:dev/src';
    load.

then try:

app := StPharoApplication new.
app useBackend: #Toplo.
		
presenter := SpLabelPresenter newApplication: app.
presenter beWrap.
presenter label: 'Multi
Line'.
presenter open.

the adapter implements it

@tinchodias

Copy link
Copy Markdown
Contributor

I'm adding support for multiline; right now:

Screenshot 2026-11-30 at 13 47 47

@jecisc
jecisc merged commit cdbaffa into pharo-spec:Pharo15 Nov 30, 2026
1 of 2 checks passed
@jordanmontt
jordanmontt deleted the use-wrapping-label-in-dialogs branch November 30, 2026 20:40
@jordanmontt

Copy link
Copy Markdown
Contributor Author

Great, I will open an issue in Spec Toplo to not forget!

@jordanmontt

Copy link
Copy Markdown
Contributor Author

Actually I see that you have already opened a PR

jecisc pushed a commit to pharo-vcs/iceberg that referenced this pull request Dec 1, 2026
The warning row is added with expand: false, so it takes only the height of its text. Needs pharo-spec/Spec#2007 to fit the wrapped text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tinchodias

Copy link
Copy Markdown
Contributor

For the record: pharo-graphics/Spec-Toplo#167

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.

4 participants