tools: draw some grids for positioning testing in the event-gui
authorPeter Hutterer <peter.hutterer@who-t.net>
Tue, 19 Apr 2016 01:04:26 +0000 (11:04 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Tue, 19 Apr 2016 05:19:34 +0000 (15:19 +1000)
Having a grid makes it easier to detect pointer jumps

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools/event-gui.c

index 791a1ea182830aaa087de7400d98405f68e74670..605f00a34d9d4354a528f0a3f7abc00ec5ae5485 100644 (file)
@@ -315,6 +315,46 @@ draw_pointer(struct window *w, cairo_t *cr)
        cairo_restore(cr);
 }
 
+static inline void
+draw_background(struct window *w, cairo_t *cr)
+{
+       int x1, x2, y1, y2, x3, y3, x4, y4;
+       int cols;
+
+       /* 10px and 5px grids */
+       cairo_save(cr);
+       cairo_set_source_rgb(cr, 0.8, 0.8, 0.8);
+       x1 = w->width/2 - 200;
+       y1 = w->height/2 - 200;
+       x2 = w->width/2 + 200;
+       y2 = w->height/2 - 200;
+       for (cols = 1; cols < 10; cols++) {
+               cairo_move_to(cr, x1 + 10 * cols, y1);
+               cairo_rel_line_to(cr, 0, 100);
+               cairo_move_to(cr, x1, y1 + 10 * cols);
+               cairo_rel_line_to(cr, 100, 0);
+
+               cairo_move_to(cr, x2 + 5 * cols, y2);
+               cairo_rel_line_to(cr, 0, 50);
+               cairo_move_to(cr, x2, y2 + 5 * cols);
+               cairo_rel_line_to(cr, 50, 0);
+       }
+
+       /* 3px horiz/vert bar codes */
+       x3 = w->width/2 - 200;
+       y3 = w->height/2 + 200;
+       x4 = w->width/2 + 200;
+       y4 = w->height/2 + 100;
+       for (cols = 0; cols < 50; cols++) {
+               cairo_move_to(cr, x3 + 3 * cols, y3);
+               cairo_rel_line_to(cr, 0, 20);
+
+               cairo_move_to(cr, x4, y4 + 3 * cols);
+               cairo_rel_line_to(cr, 20, 0);
+       }
+       cairo_stroke(cr);
+}
+
 static gboolean
 draw(GtkWidget *widget, cairo_t *cr, gpointer data)
 {
@@ -324,6 +364,8 @@ draw(GtkWidget *widget, cairo_t *cr, gpointer data)
        cairo_rectangle(cr, 0, 0, w->width, w->height);
        cairo_fill(cr);
 
+       draw_background(w, cr);
+
        draw_gestures(w, cr);
        draw_scrollbars(w, cr);
        draw_touchpoints(w, cr);