diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-02-24 06:19:25 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-02-24 06:19:25 +0000 |
commit | 31fb4f6ff65db32a23217c097d4848fd9292973b (patch) | |
tree | e5bb4dba9d6f81880a4494b91425b82178d8477c | |
parent | 6c4b80c67bcfb9593852bde584b1e2e6ee3c5c82 (diff) | |
download | rockbox-31fb4f6ff65db32a23217c097d4848fd9292973b.tar.gz rockbox-31fb4f6ff65db32a23217c097d4848fd9292973b.zip |
Change how touchscreen regions work slightly... "It modifies the behaviour of touch buttons to be more similar to the way gui buttons operate in desktop applications. Upon a touch press event, the button at the touch position is armed. Upon a touch repeat or release, the button at the touch position is triggered only if it is armed. Upon release (and wps entry), all buttons are disarmed. E.g. when you touch press on an empty area, then while pressing drag your finger on a button, then release the button, the button is not triggered."
Author: Jens Theeß
Flyspray: FS#10982
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24876 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 1 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 2 | ||||
-rw-r--r-- | apps/gui/wps.c | 37 | ||||
-rw-r--r-- | docs/CREDITS | 1 |
4 files changed, 38 insertions, 3 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index cf790c3796..844fe5f120 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -1477,6 +1477,7 @@ static int parse_touchregion(const char *wps_bufptr, | |||
1477 | region->width = w; | 1477 | region->width = w; |
1478 | region->height = h; | 1478 | region->height = h; |
1479 | region->wvp = curr_vp; | 1479 | region->wvp = curr_vp; |
1480 | region->armed = false; | ||
1480 | 1481 | ||
1481 | if(!strncmp(pb_string, action, sizeof(pb_string)-1) | 1482 | if(!strncmp(pb_string, action, sizeof(pb_string)-1) |
1482 | && *(action + sizeof(pb_string)-1) == '|') | 1483 | && *(action + sizeof(pb_string)-1) == '|') |
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 04a295a449..f6c7463804 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -222,6 +222,8 @@ struct touchregion { | |||
222 | } type; /* type of touch region */ | 222 | } type; /* type of touch region */ |
223 | bool repeat; /* requires the area be held for the action */ | 223 | bool repeat; /* requires the area be held for the action */ |
224 | int action; /* action this button will return */ | 224 | int action; /* action this button will return */ |
225 | bool armed; /* A region is armed on press. Only armed regions are triggered | ||
226 | on repeat or release. */ | ||
225 | }; | 227 | }; |
226 | #endif | 228 | #endif |
227 | 229 | ||
diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 6afed43213..c58181ed36 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c | |||
@@ -86,6 +86,10 @@ static void wps_state_init(void); | |||
86 | static void track_changed_callback(void *param); | 86 | static void track_changed_callback(void *param); |
87 | static void nextid3available_callback(void* param); | 87 | static void nextid3available_callback(void* param); |
88 | 88 | ||
89 | #ifdef HAVE_TOUCHSCREEN | ||
90 | static void wps_disarm_touchregions(struct wps_data *data); | ||
91 | #endif | ||
92 | |||
89 | #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" | 93 | #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" |
90 | #ifdef HAVE_REMOTE_LCD | 94 | #ifdef HAVE_REMOTE_LCD |
91 | #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps" | 95 | #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps" |
@@ -623,14 +627,30 @@ static void gwps_enter_wps(void) | |||
623 | #endif | 627 | #endif |
624 | display->clear_display(); | 628 | display->clear_display(); |
625 | skin_update(gwps, WPS_REFRESH_ALL); | 629 | skin_update(gwps, WPS_REFRESH_ALL); |
630 | |||
631 | #ifdef HAVE_TOUCHSCREEN | ||
632 | wps_disarm_touchregions(gui_wps[i].data); | ||
633 | #endif | ||
626 | } | 634 | } |
627 | /* force statusbar/skin update since we just cleared the whole screen */ | 635 | /* force statusbar/skin update since we just cleared the whole screen */ |
628 | send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); | 636 | send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); |
629 | } | 637 | } |
630 | 638 | ||
631 | #ifdef HAVE_TOUCHSCREEN | 639 | #ifdef HAVE_TOUCHSCREEN |
640 | /** Disarms all touchregions. */ | ||
641 | static void wps_disarm_touchregions(struct wps_data *data) | ||
642 | { | ||
643 | struct skin_token_list *regions = data->touchregions; | ||
644 | while (regions) | ||
645 | { | ||
646 | ((struct touchregion *)regions->token->value.data)->armed = false; | ||
647 | regions = regions->next; | ||
648 | } | ||
649 | } | ||
650 | |||
632 | int wps_get_touchaction(struct wps_data *data) | 651 | int wps_get_touchaction(struct wps_data *data) |
633 | { | 652 | { |
653 | int returncode = ACTION_NONE; | ||
634 | short x,y; | 654 | short x,y; |
635 | short vx, vy; | 655 | short vx, vy; |
636 | int type = action_get_touchscreen_press(&x, &y); | 656 | int type = action_get_touchscreen_press(&x, &y); |
@@ -638,7 +658,9 @@ int wps_get_touchaction(struct wps_data *data) | |||
638 | struct touchregion *r; | 658 | struct touchregion *r; |
639 | bool repeated = (type == BUTTON_REPEAT); | 659 | bool repeated = (type == BUTTON_REPEAT); |
640 | bool released = (type == BUTTON_REL); | 660 | bool released = (type == BUTTON_REL); |
661 | bool pressed = (type == BUTTON_TOUCHSCREEN); | ||
641 | struct skin_token_list *regions = data->touchregions; | 662 | struct skin_token_list *regions = data->touchregions; |
663 | |||
642 | while (regions) | 664 | while (regions) |
643 | { | 665 | { |
644 | r = (struct touchregion *)regions->token->value.data; | 666 | r = (struct touchregion *)regions->token->value.data; |
@@ -665,11 +687,13 @@ int wps_get_touchaction(struct wps_data *data) | |||
665 | switch(r->type) | 687 | switch(r->type) |
666 | { | 688 | { |
667 | case WPS_TOUCHREGION_ACTION: | 689 | case WPS_TOUCHREGION_ACTION: |
668 | if ((repeated && r->repeat) || (released && !r->repeat)) | 690 | if (r->armed && ((repeated && r->repeat) || (released && !r->repeat))) |
669 | { | 691 | { |
670 | last_action = r->action; | 692 | last_action = r->action; |
671 | return r->action; | 693 | returncode = r->action; |
672 | } | 694 | } |
695 | if (pressed) | ||
696 | r->armed = true; | ||
673 | break; | 697 | break; |
674 | case WPS_TOUCHREGION_SCROLLBAR: | 698 | case WPS_TOUCHREGION_SCROLLBAR: |
675 | if(r->width > r->height) | 699 | if(r->width > r->height) |
@@ -708,7 +732,7 @@ int wps_get_touchaction(struct wps_data *data) | |||
708 | 732 | ||
709 | global_settings.volume += min_vol; | 733 | global_settings.volume += min_vol; |
710 | setvol(); | 734 | setvol(); |
711 | return ACTION_REDRAW; | 735 | returncode = ACTION_REDRAW; |
712 | } | 736 | } |
713 | } | 737 | } |
714 | } | 738 | } |
@@ -716,6 +740,13 @@ int wps_get_touchaction(struct wps_data *data) | |||
716 | regions = regions->next; | 740 | regions = regions->next; |
717 | } | 741 | } |
718 | 742 | ||
743 | /* On release, all regions are disarmed. */ | ||
744 | if (released) | ||
745 | wps_disarm_touchregions(data); | ||
746 | |||
747 | if (returncode != ACTION_NONE) | ||
748 | return returncode; | ||
749 | |||
719 | if ((last_action == ACTION_WPS_SEEKBACK || last_action == ACTION_WPS_SEEKFWD)) | 750 | if ((last_action == ACTION_WPS_SEEKBACK || last_action == ACTION_WPS_SEEKFWD)) |
720 | return ACTION_WPS_STOPSEEK; | 751 | return ACTION_WPS_STOPSEEK; |
721 | last_action = ACTION_TOUCHSCREEN; | 752 | last_action = ACTION_TOUCHSCREEN; |
diff --git a/docs/CREDITS b/docs/CREDITS index d077595b4e..0da7d49367 100644 --- a/docs/CREDITS +++ b/docs/CREDITS | |||
@@ -530,6 +530,7 @@ Mark Borgerding | |||
530 | Tobias Diedrich | 530 | Tobias Diedrich |
531 | Andrew Engelbrecht | 531 | Andrew Engelbrecht |
532 | Kevin Schoedel | 532 | Kevin Schoedel |
533 | Jens Theeß | ||
533 | 534 | ||
534 | The libmad team | 535 | The libmad team |
535 | The wavpack team | 536 | The wavpack team |