pharo-graphics / Toplo

A widget framework on top of Bloc
MIT License
19 stars 9 forks source link

Get a form directly from ToImage #30

Closed LouisePla closed 1 year ago

LouisePla commented 1 year ago

It would be nice to get directly the form given to ToImage innerImage: with a form message.

Example:

|toImage form|
toImage := ToImage new innerImage: (Smalltalk ui icons iconNamed: #delete).
form := toImage form 

instead of:

|toImage background form  |
toImage := ToImage new innerImage: (Smalltalk ui icons iconNamed: #delete).
toImage innerImage ifNil: [ ^self ].
background := toImage innerImage background ifNil: [ ^self ].
(background isKindOf: BlImageBackground) ifFalse: [ ^self ].
form := background image ifNil: [ ^self ]
plantec commented 1 year ago

at a ToImage level, the inner element can be whatever BlElement.

tinchodias commented 1 year ago

In a Spec backend we started to write, we did the same as @LouisePla to retrieve the Form

plantec commented 1 year ago

added ToImage>>innerForm

plantec commented 1 year ago

ToImage>>InnerForm returns nil if the request makes no sense or if there is no form. ToImage>>withInnerFormDo: aBlock runs aBlock with the form as argument if the result of sending #form is not nil

plantec commented 1 year ago

added withInnerFormDo: aBlock ifNone: aNoneBlock " aBlock is evaluated with the form as arguments if the result of #innerForm is not nil, else, aNoneBlock is evaluated " to ensure one can manage error cases