Scaling at runtime

I am looking at scaling a grid in a canvas which I use to do by grabbing the new window width and height and dividing by the old width and height. I was grabbing the old window size in Resizing and then calculating in resized. This seems to have stopped working so after poking around to see if there was anything new that might have been added to help I saw graphic.ScaleX and ScaleY and also window.scalefactor and window scalefactorchanged.

When I try and see what these values are returning it always returns 1.00000. I can’t see any examples to work from

EF.Text = canvas1.graphics.ScaleX.ToText

graphics.ScaleX & graphics.ScaleY are used for High Resolution displays, such as Retina or HiDPI on Windows.

You may want to store the old values in xojo.core.size, then when it resizes, use those values to compare with and scale, then update the xojo.core.size to match the new sizes.

Thanks Sam, any idea how window.scalefactor and window.scalefactorchanged work?

Window.ScaleFactor detrmines whether this runs on a Retina screen (result=2) or standard screen (result=1).

The only line in window.scalefactorchanged is

me.invalidate

to re-draw the graphics according to the scalefactor in case the window has been dragged from one to another.

Just to point out another way to skin this cat, you could take a look at the piDog DataView grid control. It has a zoom factor you can adjust. I often tie it to a slider control to let the user zoom in or out.

I started using the control because of some other features I needed. But started adding sliders to adjust the zoom factor just because it already had inherent support for it too.

[quote=404024:@Detlef Kahner]Window.ScaleFactor detrmines whether this runs on a Retina screen (result=2) or standard screen (result=1).

The only line in window.scalefactorchanged is

me.invalidate

to re-draw the graphics according to the scalefactor in case the window has been dragged from one to another.[/quote]
If you were caching any graphics, you probably would also use this event to clear the cache of the resolution specific ones.

Thanks for notifying.