Refactor ImageMorph to support more than one Form depicting the same image at different scales#14998
Conversation
…ToSize: in that it does not maintain the aspect ratio).
…more than one Form depicting the same image at different scales.
…ld a Form by ones that hold a FormSet (except for ‘cachedForm’ in AlphaImageMorph).
… for the corresponding arrow at scale 1 and 2.
|
I applied this to the ‘Retina display’ scaling experiment from earlier pull requests: commits 482bcd7 and a7e272b (these commits are not included in this pull request, the branch is ‘scaling-canvas-tryout-10’). In the extra world opened by ScalingCanvas still uses its ‘FormMapping’ for remapping other forms from the UITheme and ThemeIcons, that should be dropped by using FormSet for those as well. |
jecisc
left a comment
There was a problem hiding this comment.
This seems ok but it's the first time I see most of the code edited so if someone else wants to take a look I would prefer it
|
This is a nice design. |
|
I added FormSetTest and extended the comment on FormSet. |
|
Coool! |
…eMorph to support more than one Form depicting the same image at different scales”) to Pharo 11.

This pull request:
The distinction between FormSet and Form is akin to that between NSImage and NSImageRep in macOS’s AppKit. A similar concept is that of an
<img>element with a ‘srcset’ attribute in HTML.I initially used ‘Image’ as the name for the class but found that that got confusing as ‘image’ is already used in many selectors and variable names as a synonym for ‘form’. Once FormSet is used more and ‘image’ becomes more of a synonym for ‘form set’, the class could still be renamed to ‘Image’ as well.
The handling of the ‘none’ case in
FormSet>>#asFormWithExtent:could be improved by scaling the Form that most closely matches the given extent rather than just the first Form, and the result should perhaps be cached, but there’s no need for either of that at the moment.Note that loading these changes into an existing Pharo image probably requires using headless mode.