0.61: Mouse zooming, selection and zoomed area jumps around

*** Please report new bugs here! ***

Moderators: XnTriq, helmut, xnview, Dreamer

User avatar
CreativeWorld
Posts: 141
Joined: Fri Dec 30, 2011 7:08 pm

0.61: Mouse zooming, selection and zoomed area jumps around

Post by CreativeWorld »

[Update]
The zoomed area also jumps to the top-left or bottom-right when mouse zooming in and out,
in XnView v2.03 and v2.04 running through Wine.
[/Update]

I have tested this in xnview mp v0.61, v0.6 and v0.56 on linux mint 15 cinnamon 32bit.

When holding down the left mouse button and scrolling up or down to zoom in and out on a selection,
the selection jumps to the bottom-right or top-left.

The same thing happens to the zoomed in area but in the reverse direction when
zooming in and out with the right mouse button held down and scrolling up or down.


To reproduce the selection jumping around do the following:

Draw a selection on an image,
put the cursor in the middle of the selection

Image

Hold down the left mouse button,
scroll up to zoom in,
then move the mouse, 1 pixel is enough

the selection jumps to the bottom-right when zooming in,
(for me it jumped around 50x50px)

Image

and to the top-left when scrolling down to zooming out,
(for me it jumped around 100,100 px)

Image


To reproduce the zoomed area jumping around do the following:

Set the right mousebutton to "Move picture",
Tools > Settings > Keyboard/Mouse > Mouse > Right button

Make sure "show pan tool" is checked,
settings > view > show pan tool
to see the zoomed in area jump around.

Open a large image so there is room to zoom in and out,
make the window slightly smaller than the image,
so there is room to pan with the right mousebutton.

If i try to zoom in on the right dot,
i place the cursor on the dot,
hold down the right mousebutton and
scroll up to zoom in,
if i move the cursor even slightly (it's difficult not to)

Image

the zoomed area jumps towards the top-left

Image


If i start at 200% again,
hold down the right mousebutton and
scroll down to zoom out,
and move the cursor again,

the zoomed area jumps towards the bottom-left

Image


If i start mouse zooming when the image is smaller than the window,
then it works fine.


on a related note,
When zooming in with the left mousebutton held down but not on a selection,
a new tiny selection gets started even if one doesn't move the cursor.

When holding down the right mousebutton and scrolling to zoom in or out,
if one doesn't move the mouse before releasing the right button the context menu pops up.

thanks for making a great image viewer/manipulator,
keep up the good work
User avatar
CreativeWorld
Posts: 141
Joined: Fri Dec 30, 2011 7:08 pm

Re: Mouse zooming, the selection and zoomed area jumps aroun

Post by CreativeWorld »

update #2, Possible Solution

The same thing happens in xnview 2.05.


While i was trying to code my own zoom function,
i encountered this same problem.

When the (move picture) mouse button is pressed down,
i calculated the x and y offset between the x and y coordinates
between the mouse pointer and the image (top left corner).

When the (move picture) button is held down,
and i scrolled the mouse wheel to zoom in or out,
i change the coordinates of the image,
if the i then moved the mouse pointer even
1 pixel (it is difficult not to),
the image snaps back to the same distance (offset)
from the mouse pointer as it had when the
(move picture) mouse button was first pressed.

Solution:
This can be fixed by calculating the x and y offset again
in the code for the mouse wheel event,
after the code for zooming in and out.

It's probably a good idea to only calculate the offset in the
mouse wheel code, when the "move picture" mouse button
is held down, otherwise it is calculated everytime
the mouse wheel is scrolled.

Here's a video showing what happens with and without
setting the offset after the code for zooming in and out.

http://videobin.org/+6wj/8jp.html

and here's a video of it happening in in xnview mp v0.61.

http://videobin.org/+6wk/8jq.html
User avatar
helmut
Posts: 8705
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: Mouse zooming, the selection and zoomed area jumps aroun

Post by helmut »

Thanks for your good description, CreativeWorld. I could reproduce your problem both in XnView MP 0.61 and XnView Classic 2.00. :bugconfirmed:

The steps to reproduce in short:
1. Open an image
2. Select an area of the image
3. Move mouse cursor into the selected area and left click on the image. Keep left mouse button pressed.
4. Use mouse wheel to zoom out (left mouse button still pressed)
5. Move the mouse a bit (left mouse button still pressed)
-> The selection will jump randomly.

Two actions are mixed (Zooming and dragging the selected area) and therefore internal coordinates are not updated properly.
User avatar
xnview
Author of XnView
Posts: 45271
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Mouse zooming, the selection and zoomed area jumps aroun

Post by xnview »

I can't reproduce, which settings do you have in mouse options?
Pierre.
User avatar
CreativeWorld
Posts: 141
Joined: Fri Dec 30, 2011 7:08 pm

Re: 0.61: Mouse zooming, selection and zoomed area jumps aro

Post by CreativeWorld »

To reproduce the selection getting shifted around,
leave the left mouse button with it's default setting "Make selection"

then just follow helmuts 5 steps above.


To reproduce the whole image shifting around when one moves the mouse after "mouse zooming",
the right mouse button is set to "Move Picture".

then follow these steps.

1. open a large image
2. make sure the settings > view > Show Pan tool, is Checked
3. set the right mouse button to Move Picture
4. make sure the window is smaller than the image so that the pan tool shows up in the bottom right corner.
5. hold down the right mouse button on the image (here is where the offset between the image and the mouse cursor is set)
6. scroll forward on the mouse wheel to zoom in one step, try not to move the mouse,
look at the pan tool, the red and white dotted rectangle shows the zoomed in area of the image, keep holding down the right mouse button
7. now move the mouse (1px is enough), (the image jumps to the same distance that was set when the mouse button was pressed)
look at the pan tool again, the red and white dotted rectangle jumped up and to the left.

if one zooms in all the way to the center off the image,
holds down the right mouse button,
scrolls backwards on the mouse wheel to zoom out,
and then moves the mouse the zoomed in area jumps to the bottom and to the right.
(again it matches the distance between the mouse and the image that was set when one pressed the mouse button)


Im pretty sure the reason is because the offset between the image and the mouse coordinates only
gets calculated when the "move picture" mouse button is pressed,

the offset should also be calculated when the mouse wheel is scrolled,
and it's probably a good idea to just calculate the distance in the scroll function
if the "move picture" mousebutton is pressed, then it won't calculate it unnecessarily
if someone sets up the scrollwheel to zoom in and out.

i made an example program here:
https://www.khanacademy.org/cs/object-t ... 2347326957
User avatar
xnview
Author of XnView
Posts: 45271
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: 0.61: Mouse zooming, selection and zoomed area jumps aro

Post by xnview »

Pierre.