A generic touchscreen calibration program for X.Org
Revision | 8a56f723d2c806481ee1b24461a3391986ae1728 (tree) |
---|---|
Time | 2010-01-09 19:13:24 |
Author | Tias Guns <tias@ulys...> |
Commiter | Tias Guns |
make the touch points more visuals: draw a cross through them
@@ -33,6 +33,8 @@ const int time_step = 100; // in milliseconds | ||
33 | 33 | const int max_time = 15000; // 5000 = 5 sec |
34 | 34 | |
35 | 35 | // Clock appereance |
36 | +const int cross_lines = 25; | |
37 | +const int cross_circle = 4; | |
36 | 38 | const int clock_radius = 50; |
37 | 39 | const int clock_line_width = 10; |
38 | 40 |
@@ -92,7 +94,6 @@ CalibrationArea::CalibrationArea(Calibrator* calibrator0) | ||
92 | 94 | |
93 | 95 | bool CalibrationArea::on_expose_event(GdkEventExpose *event) |
94 | 96 | { |
95 | - const double radius = 4; | |
96 | 97 | Glib::RefPtr<Gdk::Window> window = get_window(); |
97 | 98 | if (window) { |
98 | 99 | Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context(); |
@@ -110,19 +111,23 @@ bool CalibrationArea::on_expose_event(GdkEventExpose *event) | ||
110 | 111 | cr->stroke(); |
111 | 112 | |
112 | 113 | // Draw the points |
113 | - int i = 0; | |
114 | - for (; i < calibrator->get_numclicks(); i++) { | |
115 | - cr->arc(X[i], Y[i], radius, 0.0, 2.0 * M_PI); | |
116 | - cr->set_source_rgb(1.0, 1.0, 1.0); | |
117 | - cr->fill_preserve(); | |
114 | + for (int i = 0; i <= calibrator->get_numclicks(); i++) { | |
115 | + // set color: already clicked or not | |
116 | + if (i < calibrator->get_numclicks()) | |
117 | + cr->set_source_rgb(1.0, 1.0, 1.0); | |
118 | + else | |
119 | + cr->set_source_rgb(0.8, 0.0, 0.0); | |
120 | + | |
121 | + cr->set_line_width(1); | |
122 | + cr->move_to(X[i] - cross_lines, Y[i]); | |
123 | + cr->rel_line_to(cross_lines*2, 0); | |
124 | + cr->move_to(X[i], Y[i] - cross_lines); | |
125 | + cr->rel_line_to(0, cross_lines*2); | |
118 | 126 | cr->stroke(); |
119 | - } | |
120 | 127 | |
121 | - cr->set_line_width(2); | |
122 | - cr->arc(X[i], Y[i], radius, 0.0, 2.0 * M_PI); | |
123 | - cr->set_source_rgb(0.8, 0.0, 0.0); | |
124 | - //cr->fill_preserve(); | |
125 | - cr->stroke(); | |
128 | + cr->arc(X[i], Y[i], cross_circle, 0.0, 2.0 * M_PI); | |
129 | + cr->stroke(); | |
130 | + } | |
126 | 131 | |
127 | 132 | // Draw the clock background |
128 | 133 | cr->arc(display_width/2, display_height/2, clock_radius/2, 0.0, 2.0 * M_PI); |
@@ -132,7 +137,7 @@ bool CalibrationArea::on_expose_event(GdkEventExpose *event) | ||
132 | 137 | |
133 | 138 | cr->set_line_width(clock_line_width); |
134 | 139 | cr->arc(display_width/2, display_height/2, (clock_radius - clock_line_width)/2, |
135 | - 0.0, 2.0 * M_PI * (double)time_elapsed/(double)max_time); | |
140 | + 3/2.0*M_PI, (3/2.0*M_PI) + ((double)time_elapsed/(double)max_time) * 2*M_PI); | |
136 | 141 | cr->set_source_rgb(0.0, 0.0, 0.0); |
137 | 142 | cr->stroke(); |
138 | 143 |