I have been working on a set of GUI tools that incorporate one or more axes for image viewing. One frustration has always been the inefficient view control behavior of IMSHOW when zooming. If my axes and image have contrary aspect ratios (one is short and wide and the other is tall and narrow), zooming in on an image doesn't allow the user any better use of the space defined by the parent axes. The effective viewport aspect ratio (abs(diff(xlim))/abs(diff(ylim)) remains the same no matter the zoom level. In any other image editing application, zooming such an image will fill the unused space in the axes until the displayed region and axes have the same aspect ratio.
So far, my approach has been to use a callback function (actionpostcallback) on each zoom event. If there is a mismatch of aspect ratios between the viewport and axes, i can scale the viewport in accordingly. This only changes anything when zooming in the first time. After this, the two aspect ratios are the same, and the ability to zoom out to the initial zoom level is unpredictable.
In R2009b, the normal gui zoom tools (zoom in/out or scroll wheel) can't zoom out further than the initial zoom level. In normal use, this works fine because the viewport aspect ratio never changes. Whichever dimension it's using to limit the scaling doesn't matter. But since I'm changing the viewport and i can never seem to predict whether it's Xlim or Ylim which will be clamped by the plot/zoom/graphics routines, I often can't zoom back out.
I can see a couple of ways which I could solve this issue:
1: If my callback function were able to know what zoom level was attempted but disallowed, I could make it zoom out manually. I don't know how I'd get that information in a callback that occurs after the zoom event. All I can hope to detect is that geometry stops changing between calls.
2: If I were able to find a way to change the "can't zoom further out" behavior, this could all be managed easily. I'm pretty sure that's not a trivial thing. In R2015b, one can easily zoom out further than the initial zoom factor, but I imagine that's a consequence of a lot of changes to the graphics handling routines.
3: Pad every image such that it has the same aspect ratio as the axes.
4: Do something entirely different.
I'm not sure this has been a clear problem description. I feel I almost need a video to show what happens, and I didn't want to post a mess of code. If anyone has any insight, it would be appreciated. If anyone wants further details, I can add them.