Scroll-zoom with modifier key

Issue #18 closed
Robert Leach created an issue

Allow zooming/unzooming toward/away-from cursor position (or center if cursor is not over the matrix) when a modifier key is held down. Another modifier key could indicate zoom toward/away-from selection.

Comments (10)

  1. Robert Leach reporter

    Scroll zooming already works for when you scroll sideways (on my magic mouse) and it looks OK, but it fixes the top-left corner instead of where the cursor is.

  2. Christopher Keil repo owner

    I know. The issue here is adjusting the view to where the cursor is. I have tried it and implemented it (had working code for #10, #14 and #25) and it just looks plain terrible in my opinion. I really like the idea though and I do think it's super important. But to make it smooth looking you'd have to change everything related to GlobalView and how the tiles are drawn. The scrollbars are tied to the tile number and you can only adjust the view by moving whole tile steps.

    When you do scroll-zoom now, you're not actually moving the view as it normally should be. All of our zooming code is just increasing the scale of the tiles (changing the side lengths of the tiles). The increments/ decrements in side length are such that the side length in pixels divided by the number of available pixels on screen is a whole number.

    For smooth zooming and cursor following (in essence adjusting the scrollbars) you'd need to be able to display partial tiles. All of the issues I put on hold in relation to this would be very few lines of code to implement if we drew to a panel on a JScrollPane. I tried this and there's a lot of refactoring needed to achieve this.

    If you want to, I can upload a JAR later today or tomorrow with the double-click to zoom on cursor code working.

  3. Robert Leach reporter

    I was thinking about this, and I think we may not have to change the way globalview works. Instead of zooming one row/col at a time, zoom 2 rows/cols at a time (one row on the top and one row on the bottom for example). If there are an odd number of rows/cols, then yeah, there would be an image shift at the end.

  4. Log in to comment