Pan on mouse wheel zoom implemented.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Pan on mouse wheel zoom implemented.

johnfound
Well, as I already somewhere wrote, this is a feature that I badly miss in LibreCad and here it is:

pan-on-zoom.diff

It is controlled from two options in the Application Preferences dialog:



The first enables and disables the pan-on-zoom feature. If it is checked, on mouse wheel, the point where the mouse cursor is located will be scrolled at the center of the window, together with the mouse cursor. This way, you can pan only with the wheel, without pressing it and dragging.

The second option, if checked, will inhibit the zoom if the mouse cursor is far from the center of the screen. This way, the first wheel event will not zoom, and only pan the view to the center. Pretty useful for browsing big drawings without zoom-in-out all the time.

I am not very good in explanations - simply patch and try yourself.

I am not a good C++ programmer, so the quality of the code might be low. I even can't estimate it...

Any suggestions, notes and critic are welcome.
Reply | Threaded
Open this post in threaded view
|

Re: Pan on mouse wheel zoom implemented.

dxli
Hi John found,

No problem, I will add your changes ASAP.

Zooming is a source of complaints for LibreCAD. Mostly, due to accidental large zooming changes.

It helps to speed up, if you could push to your own fork, and send in pull requests.

Coding expertise is not a concern here, since we can tweak the code together in a PR before merging.


johnfound wrote
Well, as I already somewhere wrote, this is a feature that I badly miss in LibreCad and here it is:

pan-on-zoom.diff

It is controlled from two options in the Application Preferences dialog:



The first enables and disables the pan-on-zoom feature. If it is checked, on mouse wheel, the point where the mouse cursor is located will be scrolled at the center of the window, together with the mouse cursor. This way, you can pan only with the wheel, without pressing it and dragging.

The second option, if checked, will inhibit the zoom if the mouse cursor is far from the center of the screen. This way, the first wheel event will not zoom, and only pan the view to the center. Pretty useful for browsing big drawings without zoom-in-out all the time.

I am not very good in explanations - simply patch and try yourself.

I am not a good C++ programmer, so the quality of the code might be low. I even can't estimate it...

Any suggestions, notes and critic are welcome.
Reply | Threaded
Open this post in threaded view
|

Re: Pan on mouse wheel zoom implemented.

johnfound
Sorry, but I can't login in github anymore, because of the 2fa. That is why I am posting my changes here.

In addition, besides C++, I am not very good with git workflow as well.

Actually, I have exported the repository to fossil in order to have comfortable version control. Anyway, feel free to use and edit my code as you wish.
Reply | Threaded
Open this post in threaded view
|

Re: Pan on mouse wheel zoom implemented.

dxli
Hi Johnfound,

I tested your changes, the only thing I am thinking about improving is to avoid the hard-coded vale 32 in skipping the first zooming.

Conceptually, we should get the value by a ratio of the viewport, or anything intuitive to the end users who have no idea about the implementation details


johnfound wrote
Sorry, but I can't login in github anymore, because of the 2fa. That is why I am posting my changes here.

In addition, besides C++, I am not very good with git workflow as well.

Actually, I have exported the repository to fossil in order to have comfortable version control. Anyway, feel free to use and edit my code as you wish.
Reply | Threaded
Open this post in threaded view
|

Re: Pan on mouse wheel zoom implemented.

johnfound
Yes, I am fully agree. The hardcoded value was simply for a test. But unfortunately I am not very sure what is the proper solution of this problem. That is why I wanted to test it in practice in hope that will notice some misbehavior or something...

From general considerations follows, that this value should be a slightly (or not slightly) larger than the distance of the unintended/unconscious mouse moves around the center of the screen... But I am still not sure what this value is.

If there are another such distances in librecad, the same value can be used. In general, the snap distance is something similar, but it is usually much smaller...

Any ideas and considerations are welcome.

P.S. BTW, I have checked the source of the FreePCB (where the idea is taken from) (Click here for the source) and they also use hardcoded constants == 30.
Reply | Threaded
Open this post in threaded view
|

Re: Pan on mouse wheel zoom implemented.

dxli
Hi Johnfound,

I have pushed your changes to the master branch.

I am changing the option unchecked by default. Will push it soon after done test. Your fix for the nullptr graphic is also included in this commit.

Regards!
Reply | Threaded
Open this post in threaded view
|

Re: Pan on mouse wheel zoom implemented.

johnfound
It's great my effort is appreciated, even when I am not able to work with the standard workflow.