pharo-graphics / Toplo

A widget framework on top of Bloc
MIT License
17 stars 8 forks source link

Enhancement ToLabel with automatic multi lines #135

Closed LANDAISB closed 2 months ago

LANDAISB commented 2 months ago

We have a need of a multi-lines label widget who can display text using the whole space, like a read-only TextArea.

Basically, a ToLabel multiLine but without explicit carrier return, automatically adapting to widget size.

labordep commented 2 months ago

Use case example:

image

labordep commented 2 months ago

With less size:

image

labordep commented 2 months ago

May be this is not a ToLabel but another widget as ToText ?

plantec commented 2 months ago

Is is ok with a ToTextField ?

example: ToTextField new withLineWrapping; text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur varius felis finibus congue porttitor. Integer vehicula risus at odio porttitor semper. Aliquam erat volutpat. Curabitur feugiat tellus vitae massa interdum, ac ultrices dui scelerisque. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nulla facilisi. In pulvinar dui lectus, vel auctor purus fermentum id.'; beReadonlyWithoutSelection; openInInnerWindow

LANDAISB commented 2 months ago

Thanks ! I test and it works ! But i still have a question: I don't know how to set font name, size and color for textField. I used this for ToLabel:

            self when: ToInstallLookEvent write: (self property: #'text-attributes-with-builder') with: [:e |
                e textAttributesBuilder fontSize: (self getFontSize: 5).
                e textAttributesBuilder defaultFontName: fontName.
                e textAttributesBuilder light.
                e textAttributesBuilder foreground: (Color quantumWhite100).
            ].

-> Which property should I use ?

plantec commented 2 months ago
initializeToTextFieldStyleRules

    | fontName |
    fontName := 'American Typewriter'.

    self select: ToTextField asTypeSelector style: [

        self select: #description asStampSelector style: [
            self when: ToInstallLookEvent write: (self property: #'text-attributes-with-builder') with: [:e |
                e textAttributesBuilder fontSize: (self getFontSize: 25).
                e textAttributesBuilder defaultFontName: fontName.
                e textAttributesBuilder light.
                e textAttributesBuilder foreground: (Color red).
            ].
        ].
    ]
plantec commented 2 months ago

this should work now with my last commit (Toplo:dev)

LANDAISB commented 2 months ago

Yes, it works on Toplo:dev. Thank you !