Commit 97b3d97
Default touch screen events
Changed files (2)
Diff
@@ -13,11 +13,15 @@ */ using Cairo;+using Math; namespace BirdFont { public abstract class FontDisplay : GLib.Object { + private static double last_tap_y = -1;+ private static double last_tap_time = 0;+ /** Queue redraw area */ public signal void redraw_area (double x, double y, double w, double h); @@ -65,6 +69,49 @@ public abstract class FontDisplay : GLib.Object { public virtual void double_click (uint button, double ex, double ey) { } + public virtual void tap_down (int finger, int x, int y) {+ if (finger == 0) {+ if ((GLib.get_real_time () - last_tap_time) / 1000000.0 < 0.4) {+ double_click (1, x, y);+ } else {+ button_press (1, x, y);+ }+ + last_tap_time = GLib.get_real_time (); + }+ + last_tap_y = -1;+ }+ + public virtual void tap_up (int finger, int x, int y) {+ if (finger == 0) {+ button_release (1, x, y);+ }+ + last_tap_y = -1;+ }+ + public virtual void tap_move (int x, int y) {+ double d;+ + motion_notify (x, y);++ d = y - last_tap_y; + if (last_tap_y > -1 && fabs (d) > 15) { // FIXME: pixels, other units are better+ if (d > 0) {+ scroll_wheel_up (x, y);+ } else {+ scroll_wheel_down (x, y);+ }+ }+ + last_tap_y = y;+ }+ + /** Both fingers are moving. */+ public virtual void tap_move_delta (int x0, int y0, int x1, int y1) {+ }+ public virtual void zoom_in () { } @@ -144,6 +144,39 @@ public class TabContent : GLib.Object { GlyphCanvas.current_display.scroll_wheel_down (x, y); } + public static void tap_down (int finger, int x, int y) {+ if (MenuTab.suppress_event) {+ return;+ }+ + GlyphCanvas.current_display.tap_down (finger, x, y);+ }+ + public static void tap_up (int finger, int x, int y) {+ if (MenuTab.suppress_event) {+ return;+ }+ + GlyphCanvas.current_display.tap_up (finger, x, y);+ }+ + public static void tap_move (int x, int y) {+ if (MenuTab.suppress_event) {+ return;+ }+ + GlyphCanvas.current_display.tap_move (x, y);+ }+ + /** Both fingers are moving. */+ public static void tap_move_delta (int x0, int y0, int x1, int y1) {+ if (MenuTab.suppress_event) {+ return;+ }+ + GlyphCanvas.current_display.tap_move_delta (x0, y0, x1, y1);+ }+ public static void undo () { if (MenuTab.suppress_event) { return;