PERFORCE change 217887 for review
Brooks Davis
brooks at FreeBSD.org
Fri Sep 28 22:06:48 UTC 2012
http://p4web.freebsd.org/@@217887?ac=10
Change 217887 by brooks at brooks_zenith on 2012/09/28 22:05:58
Introduce a new dialog function that allows the gesture to close
the dialog to be specified with flags. Reimplement the current
fb_dialog() using it.
Add a pair of utility functions to convert between gesture codes
and their bitflag versions.
Affected files ...
.. //depot/projects/ctsrd/beribsd/src/ctsrd-lib/libde4tc/de4tc.c#14 edit
.. //depot/projects/ctsrd/beribsd/src/ctsrd-lib/libde4tc/de4tc.h#12 edit
Differences ...
==== //depot/projects/ctsrd/beribsd/src/ctsrd-lib/libde4tc/de4tc.c#14 (text+ko) ====
@@ -151,6 +151,72 @@
* Revised touch screen polling interface
*****************************************************************************/
+int
+tsg2tsgf(int g)
+{
+
+ switch (g) {
+ case TSG_NONE: return (TSGF_NONE);
+ case TSG_NORTH: return (TSGF_NORTH);
+ case TSG_NORTHEAST: return (TSGF_NORTHEAST);
+ case TSG_EAST: return (TSGF_EAST);
+ case TSG_SOUTHEAST: return (TSGF_SOUTHEAST);
+ case TSG_SOUTH: return (TSGF_SOUTH);
+ case TSG_SOUTHWEST: return (TSGF_SOUTHWEST);
+ case TSG_WEST: return (TSGF_WEST);
+ case TSG_NORTHWEST: return (TSGF_NORTHWEST);
+ case TSG_ROTATE_CW: return (TSGF_ROTATE_CW);
+ case TSG_ROTATE_CCW: return (TSGF_ROTATE_CCW);
+ case TSG_CLICK: return (TSGF_CLICK);
+ case TSG_DCLICK: return (TSGF_DCLICK);
+ case TSG2_NORTH: return (TSGF_NORTH);
+ case TSG2_NORTHEAST: return (TSGF_NORTHEAST);
+ case TSG2_EAST: return (TSGF_EAST);
+ case TSG2_SOUTHEAST: return (TSGF_SOUTHEAST);
+ case TSG2_SOUTH: return (TSGF_SOUTH);
+ case TSG2_SOUTHWEST: return (TSGF_SOUTHWEST);
+ case TSG2_WEST: return (TSGF_WEST);
+ case TSG2_NORTHWEST: return (TSGF_NORTHWEST);
+ case TSG2_CLICK: return (TSGF_CLICK);
+ case TSG2_ZOOM_IN: return (TSGF_ZOOM_IN);
+ case TSG2_ZOOM_OUT: return (TSGF_ZOOM_OUT);
+ }
+ errx(1, "tsg2tsgf called with invalid gesture 0x%x", g);
+}
+
+int
+tsgf2tsg(int f)
+{
+
+ switch (f) {
+ case TSGF_NONE: return (TSG_NONE);
+ case TSGF_NORTH: return (TSG_NORTH);
+ case TSGF_NORTHEAST: return (TSG_NORTHEAST);
+ case TSGF_EAST: return (TSG_EAST);
+ case TSGF_SOUTHEAST: return (TSG_SOUTHEAST);
+ case TSGF_SOUTH: return (TSG_SOUTH);
+ case TSGF_SOUTHWEST: return (TSG_SOUTHWEST);
+ case TSGF_WEST: return (TSG_WEST);
+ case TSGF_NORTHWEST: return (TSG_NORTHWEST);
+ case TSGF_ROTATE_CW: return (TSG_ROTATE_CW);
+ case TSGF_ROTATE_CCW: return (TSG_ROTATE_CCW);
+ case TSGF_CLICK: return (TSG_CLICK);
+ case TSGF_DCLICK: return (TSG_DCLICK);
+ case TSGF_2NORTH: return (TSG2_NORTH);
+ case TSGF_2NORTHEAST: return (TSG2_NORTHEAST);
+ case TSGF_2EAST: return (TSG2_EAST);
+ case TSGF_2SOUTHEAST: return (TSG2_SOUTHEAST);
+ case TSGF_2SOUTH: return (TSG2_SOUTH);
+ case TSGF_2SOUTHWEST: return (TSG2_SOUTHWEST);
+ case TSGF_2WEST: return (TSG2_WEST);
+ case TSGF_2NORTHWEST: return (TSG2_NORTHWEST);
+ case TSGF_2CLICK: return (TSG2_CLICK);
+ case TSGF_ZOOM_IN: return (TSG2_ZOOM_IN);
+ case TSGF_ZOOM_OUT: return (TSG2_ZOOM_OUT);
+ }
+ errx(1, "tsg2tsgf called with invalid flag 0x%x", f);
+}
+
struct tsstate*
ts_poll(void)
{
@@ -623,11 +689,11 @@
#define FBD_BORDER_LWIDTH 2
#define FBD_BORDER_SPACE 3
#define FBD_BORDER_WIDTH (FBD_BORDER_LWIDTH + FBD_BORDER_SPACE * 2)
-fb_dialog_action
-fb_dialog(fb_dialog_type type, u_int32_t bcolor, u_int32_t bgcolor,
+int
+fb_dialog_gestures(int cgestures, u_int32_t bcolor, u_int32_t bgcolor,
u_int32_t tcolor, const char *title, const char *text)
{
- int dheight, dwidth, x0, y0, x, y;
+ int dheight, dwidth, gesture, x0, y0, x, y;
int i, textlines, linewidth, maxwidth;
int textheight, textwidth, titleheight, titlewidth;
char **lines;
@@ -737,53 +803,42 @@
nanosleep(&stime, NULL);
ts_drain();
+ for (;;) {
+ ts = ts_poll();
+ gesture = tsg2tsgf(ts->ts_gesture);
+ if (cgestures & gesture)
+ return (gesture);
+ }
+}
+
+fb_dialog_action
+fb_dialog(fb_dialog_type type, u_int32_t bcolor, u_int32_t bgcolor,
+ u_int32_t tcolor, const char *title, const char *text)
+{
+ int gesture;
+
switch (type) {
case FBDT_EAST2CLOSE:
- for (;;) {
- ts = ts_poll();
- if (ts->ts_gesture == TSG_EAST) {
- if (ts_poll()->ts_count != 0)
- ts_drain();
- return(FBDA_OK);
- }
- }
+ fb_dialog_gestures(TSGF_EAST, bcolor, bgcolor, tcolor,
+ title, text);
+ return(FBDA_OK);
case FBDT_PINCH2CLOSE:
- for (;;) {
- ts = ts_poll();
- if (ts->ts_gesture == TSG2_ZOOM_OUT) {
- if (ts_poll()->ts_count != 0)
- ts_drain();
- return(FBDA_OK);
- }
- }
+ fb_dialog_gestures(TSGF_ZOOM_OUT, bcolor, bgcolor, tcolor,
+ title, text);
+ return(FBDA_OK);
case FBDT_PINCH_OR_VSCROLL:
- for (;;) {
- ts = ts_poll();
- switch (ts->ts_gesture) {
- case TSG2_ZOOM_OUT:
- if (ts_poll()->ts_count != 0)
- ts_drain();
- return(FBDA_OK);
- case TSG_NORTH:
- case TSG2_NORTH:
- if (ts_poll()->ts_count != 0)
- ts_drain();
- return(FBDA_DOWN);
- case TSG_SOUTH:
- case TSG2_SOUTH:
- if (ts_poll()->ts_count != 0)
- ts_drain();
- return(FBDA_UP);
- }
- }
- case FBDT_WEST2CLOSE:
- for (;;) {
- ts = ts_poll();
- if (ts->ts_gesture == TSG_WEST) {
- if (ts_poll()->ts_count != 0)
- ts_drain();
- return(FBDA_OK);
- }
+ gesture = fb_dialog_gestures(TSGF_ZOOM_OUT | TSGF_NORTH |
+ TSGF_2NORTH | TSGF_SOUTH | TSGF_2SOUTH, bcolor,
+ bgcolor, tcolor, title, text);
+ switch (gesture) {
+ case TSGF_ZOOM_OUT:
+ return(FBDA_OK);
+ case TSGF_NORTH:
+ case TSGF_2NORTH:
+ return(FBDA_DOWN);
+ case TSGF_SOUTH:
+ case TSGF_2SOUTH:
+ return(FBDA_UP);
}
default:
err(1, "Unhandled dialog type");
==== //depot/projects/ctsrd/beribsd/src/ctsrd-lib/libde4tc/de4tc.h#12 (text+ko) ====
@@ -57,6 +57,31 @@
#define TSG2_ZOOM_IN 0x48
#define TSG2_ZOOM_OUT 0x49
+#define TSGF_NONE 0x00000001
+#define TSGF_NORTH 0x00000002
+#define TSGF_NORTHEAST 0x00000004
+#define TSGF_EAST 0x00000008
+#define TSGF_SOUTHEAST 0x00000010
+#define TSGF_SOUTH 0x00000020
+#define TSGF_SOUTHWEST 0x00000040
+#define TSGF_WEST 0x00000080
+#define TSGF_NORTHWEST 0x00000100
+#define TSGF_ROTATE_CW 0x00000200
+#define TSGF_ROTATE_CCW 0x00000400
+#define TSGF_CLICK 0x00000800
+#define TSGF_DCLICK 0x00001000
+#define TSGF_2NORTH 0x00002000
+#define TSGF_2NORTHEAST 0x00004000
+#define TSGF_2EAST 0x00008000
+#define TSGF_2SOUTHEAST 0x00010000
+#define TSGF_2SOUTH 0x00020000
+#define TSGF_2SOUTHWEST 0x00040000
+#define TSGF_2WEST 0x00080000
+#define TSGF_2NORTHWEST 0x00100000
+#define TSGF_2CLICK 0x00200000
+#define TSGF_ZOOM_IN 0x00400000
+#define TSGF_ZOOM_OUT 0x00800000
+
typedef enum {
FBDA_CANCEL,
FBDA_OK,
@@ -70,7 +95,6 @@
FBDT_EAST2CLOSE,
FBDT_PINCH2CLOSE,
FBDT_PINCH_OR_VSCROLL,
- FBDT_WEST2CLOSE,
#ifdef NOTYET
FBDT_OK,
FBDT_OKCANCEL,
@@ -105,6 +129,8 @@
void multitouch_release_event(void);
struct tsstate* ts_poll(void);
void ts_drain(void);
+int tsg2tsgf(int g);
+int tsgf2tsg(int f);
void fb_init(void);
void fb_fini(void);
u_int32_t fb_colour(int r, int g, int b);
@@ -134,5 +160,7 @@
u_int32_t *buffer, int w, int h);
fb_dialog_action fb_dialog(fb_dialog_type type, u_int32_t bcolor,
u_int32_t bgcolor, u_int32_t tcolor, const char *title, const char *text);
+int fb_dialog_gestures(int gestures, u_int32_t bcolor, u_int32_t bgcolor,
+ u_int32_t tcolor, const char *title, const char *text);
#endif /* !_DE4TC_H_ */
More information about the p4-projects
mailing list