zoom scrolledwindow whilst keepPointInPlace

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

zoom scrolledwindow whilst keepPointInPlace

tcab
I want to improve my zoom function on a scrolled window so that it stays viewing the same object as I zoom.

It's presumably something like the ZoomWithMouseWheel 'keepPointInPlace' feature of floatcanvas, but I'm not using floatwindow - just a plain old OGL canvas (ScrolledWindow) and setting the virtualcanvas with a call to ScrolledWindow.SetScrollbars(...noUnitsX, noUnitsY...) where I multiply noUnitsX and noUnitsY by my ScrolledWindow.scalex and scaley values to achieve the proper virtualcanvas size in response to the zoom. The zoom and virtual canvas setting all works fine.

Can anyone suggest a suitable algorithm to achieve a more 'keepPointInPlace' zoom?  I tried setting the scrollbar positions in the call to SetScrollbars(...xPos, yPos...) to retain the same relative scrollbar positions before and after the zoom, which helps - but OGL shape objects in the scrolled window are still drifting slowly out of view after a few zoom increments.  

I suspect I need to do something with GetViewStart() or something?  I can create a short code sample if needed, but some initial ideas would be helpful.

Andy
PyNSource - Python UML tool

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: zoom scrolledwindow whilst keepPointInPlace

Chris Barker - NOAA Federal
well, you could take a look at the FloatCanvas code
-- though it's pretty simple, due to features that FloatCanvas already has, like:

self.MoveImage(-delta, 'world')

that "world" is pretty handy :-)

I'm not familiar with OGL, but you may be able to do something similar. The trick is to figure out where the mouse is relative to the main coordinates, (or the center point of the window) and then call SetScrollbars to make sure it's in the same place.

-CHB



On Wed, Jan 30, 2019 at 3:44 AM Andy Bulka <[hidden email]> wrote:
I want to improve my zoom function on a scrolled window so that it stays viewing the same object as I zoom.

It's presumably something like the ZoomWithMouseWheel 'keepPointInPlace' feature of floatcanvas, but I'm not using floatwindow - just a plain old OGL canvas (ScrolledWindow) and setting the virtualcanvas with a call to ScrolledWindow.SetScrollbars(...noUnitsX, noUnitsY...) where I multiply noUnitsX and noUnitsY by my ScrolledWindow.scalex and scaley values to achieve the proper virtualcanvas size in response to the zoom. The zoom and virtual canvas setting all works fine.

Can anyone suggest a suitable algorithm to achieve a more 'keepPointInPlace' zoom?  I tried setting the scrollbar positions in the call to SetScrollbars(...xPos, yPos...) to retain the same relative scrollbar positions before and after the zoom, which helps - but OGL shape objects in the scrolled window are still drifting slowly out of view after a few zoom increments.  

I suspect I need to do something with GetViewStart() or something?  I can create a short code sample if needed, but some initial ideas would be helpful.

Andy
PyNSource - Python UML tool

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.


--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.