TileView icon indicating copy to clipboard operation
TileView copied to clipboard

Zoom out to show whole image

Open mkv123 opened this issue 10 years ago • 17 comments

It would be very useful to add a feature to the widget which allows zooming out enough to show the entire image.

Currently the minimum zoom (zoom out) is capped to never show areas outside the specified image. However this also makes it impossible to zoom out far enough to see the whole image (well unless your image aspect ratio perfectly matches the views aspect ratio, which is rare).

mkv123 avatar Jan 14 '16 09:01 mkv123

The UX would be dramatically worsened in my opinion if we show whitespace, which would be required to show the entire map.

You can achieve this same effect by placing a TileView instance in your own layout (e.g., put a TileView in a RelativeLayout, have it match the largest dimension and center across the smaller dimension).

moagrius avatar Jan 14 '16 14:01 moagrius

If I implement this by adding setMinimumZoomMode(zoomMode) which would support the existing behaviours (fill and no minimum zoom) as well as the new one (fit), would you potentially accept it?

mkv123 avatar Jan 14 '16 15:01 mkv123

is what you're describing different from setShouldScaleToFit?

moagrius avatar Jan 14 '16 15:01 moagrius

Yes, it is. The setShouldScaleToFit is basically what is typically spoken of as "scale to fill while maintaining aspect ratio", even the documentation of that function speaks of fill, while fit is typically used meaning fit this image into this rectangle, i.e. show the whole image.

  • fill = current behaviour with setShouldScaleToFit(true)
  • off = current behaviour with setShouldScaleToFit(false)
  • fit = new behaviour where the image would be scaled to fit the viewport.

I would prefer to use the more widely used terminology as described above, but more importantly I just want this feature :)

mkv123 avatar Jan 14 '16 15:01 mkv123

So I'm not really clear on what the new feature would do. The original post said:

It would be very useful to add a feature to the widget which allows zooming out enough to show the entire image.

Currently, you can zoom out to see the entire image by setShouldScaleToFit(false).

That said, if you have a new feature that you think would be useful the user base at large, and is not a breaking change, conforms to code style, etc, then yes I'd potentially accept it.

moagrius avatar Jan 14 '16 15:01 moagrius

Ok, re-reading my initial post, I can see I wasn't clear enough. Sorry about that.

So I'd like a bounded minimum zoom, which would stop zooming out once the entire image is shown.

perhaps adding a new API called setMinimumZoomMode(MinimumZoomMode mode); where

public enum MinimumZoomMode {
    OFF,
    FILL,
    FIT
 }

Then the old api (deprecated I hope) would be implemented as

  public void setShouldScaleToFit( boolean shouldScaleToFit ) {
    if(shouldScaleToFit) {
      setMinimumZoomMode(MinimumZoomMode.FILL);
    } else {
      setMinimumZoomMode(MinimumZoomMode.OFF);
    }
  }

mkv123 avatar Jan 14 '16 16:01 mkv123

Would the visible area be centered? Top-left?

moagrius avatar Jan 14 '16 16:01 moagrius

Centered :)

mkv123 avatar Jan 14 '16 16:01 mkv123

centered horizontally or vertically, depending on which is needed.

mkv123 avatar Jan 14 '16 16:01 mkv123

I see potential value. I would not deprecate setScaleToFit, but what happens under the covers is not important to me (your example would be fine). Feel free to fork and PR. Please try to match code style (naming conventions, whitespace, etc). Include javadoc where appropriate. Bump versions in gradle and readme. Etc.

Thanks for pitching in.

moagrius avatar Jan 14 '16 16:01 moagrius

Ok. I'll take a stab at implementing this.

mkv123 avatar Jan 14 '16 16:01 mkv123

Cool, looking forward to seeing it. Thanks again.

moagrius avatar Jan 14 '16 16:01 moagrius

@mkv123 Are you needing something like this? This is TileView in what I would call "scaled to fit" instead of "scaled to cover" (this is currently called "scaled to fit" however in the current implementation). I have also got it centered in screen. See screenshot below (this image is TileView)

screenshot_20160404-145650 . screenshot_20160404-145720

I've said to Mike previously, I've been meaning to fork TileView and add these changes in. Ill try see if I get some time tonight.

mkmckenna avatar Apr 04 '16 14:04 mkmckenna

Yup, exactly that. Actually I implemented it as well, but ran into some issues where I wasn't able to get it to work unless the mode was set as the default. Something to do with the initial scaling calculations, but I also ran out of time trying to debug the issue. Since the hacked version delivered what was needed (without support for the original mode) I needed to move to other things.

mkv123 avatar Apr 04 '16 14:04 mkv123

I added a PR to allow different scale modes and added centering: https://github.com/moagrius/TileView/pull/318

tsuijten avatar Jun 14 '16 06:06 tsuijten

this should be fixed in 2.1.8, re-open if your issue is not resolved

moagrius avatar Jul 25 '16 01:07 moagrius

ref https://github.com/moagrius/TileView#scaling

moagrius avatar Jul 25 '16 01:07 moagrius