tmpkus / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

Add zoom event handler that responds to mouse wheel events #236

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Feature request, add a zoom event handler that responds to mouse wheel events.

Original issue reported on code.google.com by heue...@gmail.com on 25 Jan 2012 at 10:35

GoogleCodeExporter commented 9 years ago
Patch to svn trunk attached.

Original comment by heue...@gmail.com on 25 Jan 2012 at 10:37

Attachments:

GoogleCodeExporter commented 9 years ago
Looks good.

PZoomEventHandler uses a viewZoomPoint (where the user clicked) to anchor the 
zoom. Consider anchoring zoom where the mouse is pointing when the wheel is 
rotated. (This is how Google Maps works, for example.)

Something like:

...
final Point2D anchor = e.getCanvasPosition();
camera.localToView(anchor);
camera.scaleViewAboutPoint(scale, anchor.getX(), anchor.getY());
...

Original comment by atdi...@gmail.com on 12 Feb 2012 at 12:06

GoogleCodeExporter commented 9 years ago
Thank you for the comments.

I was thinking of adding the viewZoomPoint feature, but I don't actually like 
that behavior.  Would you be ok with making that configurable with a boolean 
bound property?  The same might be added to PZoomEventHandler while I'm at it.

And one minor fix to the patch above,

-    PMouseWheelZoomEventHandler() {
+    public PMouseWheelZoomEventHandler() {

Original comment by heue...@gmail.com on 12 Feb 2012 at 2:18

GoogleCodeExporter commented 9 years ago
Yep, I like making it configurable with a boolean option.

Original comment by atdi...@gmail.com on 12 Feb 2012 at 7:25

GoogleCodeExporter commented 9 years ago
Input event handlers don't have property change support, so I just went with a 
ZoomMode enum instead.  Let me know what you think; updated patch attached.

Original comment by heue...@gmail.com on 15 Feb 2012 at 11:05

Attachments:

GoogleCodeExporter commented 9 years ago
I like it.

Original comment by atdi...@gmail.com on 18 Feb 2012 at 3:31

GoogleCodeExporter commented 9 years ago
Turns out another zoom mode was what I was actually after, zoom about canvas 
center.  I added that and made it the default.

There is also a new MouseWheelZoomExample that demonstrates the different modes.

$ svn commit -m "Issue 236 ; adding zoom event handler that responds to mouse 
wheel events" core/ examples/
Adding         
core/src/main/java/org/piccolo2d/event/PMouseWheelZoomEventHandler.java
Adding         
core/src/test/java/org/piccolo2d/event/PMouseWheelZoomEventHandlerTest.java
Sending        examples/src/main/java/org/piccolo2d/examples/ExampleRunner.java
Adding         
examples/src/main/java/org/piccolo2d/examples/MouseWheelZoomExample.java
Transmitting file data ....
Committed revision 1163.

Original comment by heue...@gmail.com on 23 Feb 2012 at 10:05

GoogleCodeExporter commented 9 years ago

Original comment by atdi...@gmail.com on 25 Feb 2012 at 1:29