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