Efficient Drawing / Scrolling in a Canvas

I tried employing most of those, the biggest problem I have when it’s in the scroll view is fighting the scrollview caching mechanism. If I only update the areas (like I should) scrolling is smooth, but big chunks don’t get cached (even though the logged co-ords align). So you’ll be scrolling and then get huge gaps in the map.

Since I am currently unemployed :frowning: and have some time on my hands (in between online interviews and applicaitions) I decided to tackle this “problem”, as I have a larger project that might also benefit from it.

Its still a work in progress (just started it at lunchtime today)… but it is a control with horzontal and vertical scrollbars, that accepts a picture as a property, then scrolls that picture based on how the user interacts. It also supports ZOOM in/out, automatically attempting to keep the center of the view in place.

All the MouseEvents work, and the X,Y coordinates returned by these events are the coordinates relative to the ACTUAL size of the image, not the zoomed size. So you can blow it up really huge and select the coordinates of a specific pixel

The image is currently an external picture which is attached to the control. This allows you to draw on the image, and when you invalidate the control, the view shows whatever changes you just made to the image. Sounds strange, but its actually quite straight forward in how it works.

myCanvas.Image=aPictureObject  // sets the custom control (myCanvas) to be the viewer for aPictureObject
myCanvas.Zoom=5  // magnifies the view of the image to 500% (adjusting scrollbars automatically)
myCanvas.LiveScroll=true // moves the viewport in realtime synched with the scrollbars
myCanvas.LineStep=x // sets the scrollbar linestep to X PERCENTAGE of the image (applied to both Horz and Vert)
myCanvas.PageStep=x // also a PERCENTAGE value .... this is DIFFERENT than a normal scrollbar would work
//
// to draw you need to manipulate the attached picture object directly
//
aPictureObject.Graphics.Drawline 0,0,100,100
myCanvas.Invalidate
//
// As I polish this up... some of this might change slightly

Right now the ZOOM is under program control, meaning you would attach it to an exteral slider or buttons.
But I am thinking about adding an INTERNAL overlaid control (think Mapquest)… but that won’t be until the base control is done.

[quote=254482:@Rob Egal]+ compatibility to windows
https://www.dropbox.com/s/a2obhttzm4y41kh/scrollContainer_demo_1_11.xojo_binary_project?dl=0[/quote]

friend can you share the example please

the link does not work

I think that’s the point :slight_smile: