Hi,
I've had a look at the code and have come comments.
General comments:
1. Coding style should conform to:
https://inkscape.org/en/develop/coding-style/
2. Loads of compiler errors of the type:
src/display.sp-canvas.cpp:1556:43: error: invalid conversion from 'gpointer {aka void*}' to 'GdkWindow* {aka _GdkWindow*}; [-fpermissive]
These are mostly in copying event data to bevent. Why is bevent necessary? Can't the function just return 'FALSE' to get gtk_widget_real_touch_event() to do the translation?
On Sat, 2017-04-22 at 04:27 -0700, Yale Zhang wrote:
Rotate should be useful. I think most people find it easier to draw vertical lines than horizontal since there's less wrist motion.
I've updated my touchscreen code to support canvas rotation. Anyone want to use it?
transform math: https://1drv.ms/u/s!AngRQgSreBCehTiw0R_rGV7gxQIP
A couple of notes: *awkward coordinate system - Why is the canvas completely off the screen when rotation=0, offset=0? It seems the window's Y axis points down while the document's Y axis points up?
Inkscape uses an inverted coordinate system as compared to SVG. This is a long standing "bug" which we hope to fix some day but it is so embedded inside Inkscape so that fixing every occurrence is a nightmare.
- why is a positive rotation counter clockwise? In a left handed
coordinate system, it should be clockwise.
It depends on where the rotation is taking place. Desktop uses right- handed, SVG uses left-handed. See above.
*I couldn't figure out how to set the rotation, zoom, and offset using the functions in the desktop class (scroll_to_point(), zoom_absolute_keep_point() and had to access the private affine matrix directly. Calling those functions in sequence seems to add unwanted offsets on top of each other instead of letting me set the offset directly.
I can help with this. One shouldn't need to access the private affine matrix. You probably want:
SPDesktop::rotate_relative_keep_point (Geom::Point const &c, double rotate);
and
SPDesktop::zoom_relative_keep_point (Geom::Point const &c, double zoom);
where 'c' is the point halfway between the two touch points in desktop coordinates:
Geom::Point const event_w(ave.x, ave.y); Geom::Point const event_dt(desktop->w2d(event_w));
c = event_dt;
Note also that rotation and scaling are handled independently of offset.
*had to roll back r15548 or else touch screen events get lost somehow.
This should be investigated as using gtk_device_grab (which you have reverted to) is deprecated.
- I couldn't figure out how to use the GTK gesture classes (which are
probably more robust), so wrote my own code for detecting zoom, rotate, and scroll gestures. When I tried, the gesture classes weren't receiving any events. 2nd, it seems only 2 finger rotation and zoom gestures are recognized, but not 2 finger scrolling. There is a 1 finger scroll gesture.
How important is it to be able to scroll using two fingers? I imagine it would be useful to be able to rotate and scroll at the same time. One finger scroll might work by ignoring the second finger.... (one would need to experiment with a gesture group containing zooming, rotating, and scrolling).
Tav
-Yale