Add "elfzip" target to make which creates a zip of all elf files, as mapzip does...
[maemo-rb.git] / apps / gui / skin_engine / skin_touchsupport.c
blob850c1c0647162a52c77e9a994c197804b3e02622
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2009 - Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "config.h"
23 #include <stdio.h>
24 #include "action.h"
25 #include "skin_engine.h"
26 #include "wps_internals.h"
28 /** Disarms all touchregions. */
29 void skin_disarm_touchregions(struct wps_data *data)
31 struct skin_token_list *regions = data->touchregions;
32 while (regions)
34 ((struct touchregion *)regions->token->value.data)->armed = false;
35 regions = regions->next;
39 /* Get the touched action.
40 * egde_offset is a percentage value for the position of the touch
41 * inside the bar for regions which arnt WPS_TOUCHREGION_ACTION type.
43 int skin_get_touchaction(struct wps_data *data, int* edge_offset,
44 struct touchregion **retregion)
46 int returncode = ACTION_NONE;
47 short x,y;
48 short vx, vy;
49 int type = action_get_touchscreen_press(&x, &y);
50 static int last_action = ACTION_NONE;
51 struct touchregion *r;
52 bool repeated = (type == BUTTON_REPEAT);
53 bool released = (type == BUTTON_REL);
54 bool pressed = (type == BUTTON_TOUCHSCREEN);
55 struct skin_token_list *regions = data->touchregions;
57 while (regions)
59 r = (struct touchregion *)regions->token->value.data;
60 /* make sure this region's viewport is visible */
61 if (r->wvp->hidden_flags&VP_DRAW_HIDDEN)
63 regions = regions->next;
64 continue;
66 /* check if it's inside this viewport */
67 if (viewport_point_within_vp(&(r->wvp->vp), x, y))
68 { /* reposition the touch inside the viewport since touchregions
69 * are relative to a preceding viewport */
70 vx = x - r->wvp->vp.x;
71 vy = y - r->wvp->vp.y;
72 /* now see if the point is inside this region */
73 if (vx >= r->x && vx < r->x+r->width &&
74 vy >= r->y && vy < r->y+r->height)
76 /* reposition the touch within the area */
77 vx -= r->x;
78 vy -= r->y;
81 switch(r->type)
83 case WPS_TOUCHREGION_ACTION:
84 if (r->armed && ((repeated && r->repeat) || (released && !r->repeat)))
86 last_action = r->action;
87 returncode = r->action;
88 if (retregion)
89 *retregion = r;
91 if (pressed)
92 r->armed = true;
93 break;
94 default:
95 if (edge_offset)
97 if(r->width > r->height)
98 *edge_offset = vx*100/r->width;
99 else
100 *edge_offset = vy*100/r->height;
101 if (r->reverse_bar)
102 *edge_offset = 100 - *edge_offset;
104 returncode = r->type;
105 if (retregion)
106 *retregion = r;
107 break;
111 regions = regions->next;
114 /* On release, all regions are disarmed. */
115 if (released)
116 skin_disarm_touchregions(data);
118 if (returncode != ACTION_NONE)
119 return returncode;
121 last_action = ACTION_TOUCHSCREEN;
122 return ACTION_TOUCHSCREEN;