Skip to content

Add ScalingCanvas and #canvasScaleFactor for OSWorldRenderer#15647

Merged
Ducasse merged 53 commits intopharo-project:Pharo12from
Rinzwind:scaling-canvas-tryout-15
Dec 2, 2023
Merged

Add ScalingCanvas and #canvasScaleFactor for OSWorldRenderer#15647
Ducasse merged 53 commits intopharo-project:Pharo12from
Rinzwind:scaling-canvas-tryout-15

Conversation

@Rinzwind
Copy link
Copy Markdown
Contributor

@Rinzwind Rinzwind commented Dec 1, 2023

This pull request:

  • Adds ScalingCanvas as a subclass of PluggableCanvas. A ScalingCanvas provides scaling on an underlying FormCanvas. The class is taken from the ‘Retina display’ scaling experiment mentioned in previous pull requests.
  • Introduces a setting #canvasScaleFactor for OSWorldRenderer which determines the scale of the Form used to draw a WorldMorph. The world is drawn on a ScalingCanvas, instead of directly on a FormCanvas, when the setting is set to a value other than 1.

The screenshots listed in pull request #15561 show the effect of setting the #canvasScaleFactor to 2 on Macs with a ‘Retina display’.

The #canvasScaleFactor can be set through the Settings Browser so that it can also be saved to disk:

Note that pull request #15561 mentions doing World scaleFactor: 0.5 as a way to use ScalingCanvas, but this no longer applies as the #canvasScaleFactor has been separated from the world #scaleFactor. The two factors can be set independently. Though on Macs with a ‘Retina display’, it seems best to set them so that the multiplication of the #canvasScaleFactor by the reciprocal of the #scaleFactor is 2. The following cycles through such combinations:

OSWorldRenderer canvasScaleFactor: OSWorldRenderer canvasScaleFactor \\ 5 + 1.
World scaleFactor: OSWorldRenderer canvasScaleFactor / 2; changed.

A few methods are refactored on FormCanvas to offer a ‘scale’ parameter for use by a ScalingCanvas. As previously mentioned, it might be better to turn ScalingCanvas into a subclass of FormCanvas. The FormMapping that is used in ScalingCanvas needs to be removed but is still needed because icons are not yet consistently represented as a FormSet with a Form for more than one scale. The #canvasScaleFactor is global while it might be better to have a separate factor per world. These and any other necessary improvements can however be left to ‘future work’; merging this now will make it easier for others to give it a try.

I will update the Pharo 11 backport when this pull request is merged.

…ethrough:strikethroughColor: on ScalingCanvas delegate to a corresponding method on FormCanvas that takes the ‘scale’ as an additional parameter.
…s passed to the block is another ScalingCanvas.
…nding method on FormCanvas that takes the ‘scale’ as an additional parameter.
…ngCanvas so that the canvas passed to the block is another ScalingCanvas if the transform is a pure translation.
…uring: on ScalingCanvas so that in each the canvas passed to the block is another ScalingCanvas.
…ITheme and ThemeIcons to the corresponding scale 2 form.
…graph, but not the surrounding decorators, by delegating to a corresponding method on FormCanvas that takes the ‘scale’ as an additional parameter.
…rColor: on ScalingCanvas so that, when the border width is 0, the use of #apply: is avoided as it affects translucent colors (note: Pharo issue pharo-project#14654 is taken into account here to prevent a VM crash for the large rectangles derived from the value of #defaultMaxExtent in RubAbstractTextArea).
…hes used by HandMorph so that the patches are no longer scaled down when saved and scaled back up when restored.
…ners, #drawImageOn:at: and #paintImageOn:at: on ScalingCanvas.
…direct transformations of the corresponding values from the FormCanvas.
…Color and #shadowColor: on ScalingCanvas as direct delegations to the FormCanvas.
…fillColor:scale:drawBlock:do: from the #example for ScalingCanvas.
…:fillColor:borderWidth:borderColor: on ScalingCanvas to take into account that the rectangle can have nonintegral coordinates.
… there is no mapping in ‘FormMapping’ by scaling the form so as to avoid the use of #apply: as that affects translucent colors, made the method also take into account that the point can be nonintegral, and extended the class with the implementations from Canvas for #paintImage:at: and #paintImage:at:sourceRect: to cancel out the overrides of PluggableCanvas.
…ceRect:rule: to its #stencil:at:sourceRect:color: as well.
…ont:color:underline:underlineColor:strikethrough:strikethroughColor: on ScalingCanvas to take into account that the given bounds rectangle can have nonintegral coordinates.
…n:font:color:underline:underlineColor:strikethrough:strikethroughColor:scale: and #paragraph:bounds:color:scale: on FormCanvas to a protocol ‘scaled drawing’.
…erer so that, when set to a value other than 1, the world is drawn on a scaled form using a ScalingCanvas.
@Rinzwind Rinzwind force-pushed the scaling-canvas-tryout-15 branch from de42f45 to ded8b0b Compare December 1, 2023 09:48
…cCoreDependencies on SystemDependenciesTest to changes in commit c2f51fe (“Merged ScalingCanvas, and […]”).
@Ducasse Ducasse merged commit f048494 into pharo-project:Pharo12 Dec 2, 2023
@Ducasse
Copy link
Copy Markdown
Member

Ducasse commented Dec 2, 2023

Thanks Kris we really appreciate all your work this is really cool.
We are so busy that this is cool to get you on our sides.

@Rinzwind
Copy link
Copy Markdown
Contributor Author

Rinzwind commented Dec 2, 2023

Thanks! 😄

Rinzwind added a commit to Rinzwind/pharo that referenced this pull request Dec 3, 2023
…nvas and #canvasScaleFactor for OSWorldRenderer”) to Pharo 11.
@Rinzwind
Copy link
Copy Markdown
Contributor Author

Rinzwind commented Dec 3, 2023

I updated the Pharo 11 backport: branch ‘scaling-canvas-tryout-15-pharo11’ (commit 8803946). I could open a pull request for that as well if desired.

@Rinzwind Rinzwind deleted the scaling-canvas-tryout-15 branch March 29, 2024 11:40
Rinzwind added a commit to Rinzwind/pharo that referenced this pull request Aug 31, 2024
…mmit f048494 (“Merge pull request pharo-project#15647 […] Add ScalingCanvas and #canvasScaleFactor for OSWorldRenderer”): the extent of the form passed to the renderer needs to be scaled by the factor used by the canvas in #getCanvas on OSWindowFormRenderer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants