Change the way the %Tl() (touch region) tag is done to remove dodgey 1-char settings.

check the manual...
%Tl(..., &action) -> %Tl(..., action, repeat_press)
%Tl(..., *action) -> %Tl(..., action, long_press)
%Tl(..., !action) -> %Tl(..., action, reverse_bar)
and a new allow_while_lock to make the region fire when softlocked

these options must all be after the action name, but otherwise the order doesnt matter. And for the setting_inc/dec/set action the setting name must follow the action name, *then* the options

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30219 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2011-07-28 12:53:22 +00:00
parent bb618dbd84
commit 969903b5fe
7 changed files with 105 additions and 106 deletions

View file

@ -1071,6 +1071,68 @@ static const struct touchaction touchactions[] = {
#endif
};
static int touchregion_setup_setting(struct skin_element *element, int param_no,
struct touchregion *region)
{
int p = param_no;
char *name = element->params[p++].data.text;
int j;
/* Find the setting */
for (j=0; j<nb_settings; j++)
if (settings[j].cfg_name &&
!strcmp(settings[j].cfg_name, name))
break;
if (j==nb_settings)
return WPS_ERROR_INVALID_PARAM;
region->setting_data.setting = (void*)&settings[j];
if (region->action == ACTION_SETTINGS_SET)
{
char* text;
int temp;
struct touchsetting *setting =
&region->setting_data;
if (element->params_count < p+1)
return -1;
#ifndef __PCTOOL__
text = element->params[p++].data.text;
switch (settings[j].flags&F_T_MASK)
{
case F_T_CUSTOM:
setting->value.text = text;
break;
case F_T_INT:
case F_T_UINT:
if (settings[j].cfg_vals == NULL)
{
setting->value.number = atoi(text);
}
else if (cfg_string_to_int(j, &temp, text))
{
if (settings[j].flags&F_TABLE_SETTING)
setting->value.number =
settings[j].table_setting->values[temp];
else
setting->value.number = temp;
}
else
return -1;
break;
case F_T_BOOL:
if (cfg_string_to_int(j, &temp, text))
{
setting->value.number = temp;
}
else
return -1;
break;
default:
return -1;
}
#endif /* __PCTOOL__ */
}
return p-param_no;
}
static int parse_touchregion(struct skin_element *element,
struct wps_token *token,
struct wps_data *wps_data)
@ -1082,7 +1144,6 @@ static int parse_touchregion(struct skin_element *element,
const char *action;
const char pb_string[] = "progressbar";
const char vol_string[] = "volume";
char temp[20];
/* format: %T([label,], x,y,width,height,action[, ...])
* if action starts with & the area must be held to happen
@ -1125,39 +1186,13 @@ static int parse_touchregion(struct skin_element *element,
region->allow_while_locked = false;
action = element->params[p++].data.text;
strcpy(temp, action);
action = temp;
switch (*action)
{
case '!':
region->reverse_bar = true;
action++;
break;
case '^':
action++;
region->allow_while_locked = true;
break;
}
/* figure out the action */
if(!strcmp(pb_string, action))
region->action = ACTION_TOUCH_SCROLLBAR;
else if(!strcmp(vol_string, action))
region->action = ACTION_TOUCH_VOLUME;
else
{
if (*action == '*')
{
action++;
region->press_length = LONG_PRESS;
}
else if(*action == '&')
{
action++;
region->press_length = REPEAT;
}
else
region->press_length = PRESS;
imax = ARRAYLEN(touchactions);
for (i = 0; i < imax; i++)
{
@ -1169,68 +1204,13 @@ static int parse_touchregion(struct skin_element *element,
region->action == ACTION_SETTINGS_DEC ||
region->action == ACTION_SETTINGS_SET)
{
int val;
if (element->params_count < p+1)
{
return WPS_ERROR_INVALID_PARAM;
}
else
{
char *name = element->params[p].data.text;
int j;
/* Find the setting */
for (j=0; j<nb_settings; j++)
if (settings[j].cfg_name &&
!strcmp(settings[j].cfg_name, name))
break;
if (j==nb_settings)
return WPS_ERROR_INVALID_PARAM;
region->setting_data.setting = (void*)&settings[j];
if (region->action == ACTION_SETTINGS_SET)
{
char* text;
int temp;
struct touchsetting *setting =
&region->setting_data;
if (element->params_count < p+2)
return WPS_ERROR_INVALID_PARAM;
#ifndef __PCTOOL__
text = element->params[p+1].data.text;
switch (settings[j].flags&F_T_MASK)
{
case F_T_CUSTOM:
setting->value.text = text;
break;
case F_T_INT:
case F_T_UINT:
if (settings[j].cfg_vals == NULL)
{
setting->value.number = atoi(text);
}
else if (cfg_string_to_int(j, &temp, text))
{
if (settings[j].flags&F_TABLE_SETTING)
setting->value.number =
settings[j].table_setting->values[temp];
else
setting->value.number = temp;
}
else
return WPS_ERROR_INVALID_PARAM;
break;
case F_T_BOOL:
if (cfg_string_to_int(j, &temp, text))
{
setting->value.number = temp;
}
else
return WPS_ERROR_INVALID_PARAM;
break;
default:
return WPS_ERROR_INVALID_PARAM;
}
#endif /* __PCTOOL__ */
}
}
val = touchregion_setup_setting(element, p, region);
if (val < 0)
return WPS_ERROR_INVALID_PARAM;
p += val;
}
break;
}
@ -1238,6 +1218,18 @@ static int parse_touchregion(struct skin_element *element,
if (region->action == ACTION_NONE)
return WPS_ERROR_INVALID_PARAM;
}
while (p < element->params_count)
{
char* param = element->params[p++].data.text;
if (!strcmp(param, "allow_while_locked"))
region->allow_while_locked = true;
else if (!strcmp(param, "reverse_bar"))
region->reverse_bar = true;
else if (!strcmp(param, "repeat_press"))
region->press_length = REPEAT;
else if (!strcmp(param, "long_press"))
region->press_length = LONG_PRESS;
}
struct skin_token_list *item = new_skin_token_list_item(NULL, region);
if (!item)
return WPS_ERROR_INVALID_PARAM;

View file

@ -600,13 +600,11 @@ display cycling round the defined sublines. See
\opt{touchscreen}{
\section{Touchscreen Areas}
\begin{tagmap}
\config{\%T(x,y,width,\tabnlindent{}height,action)}
\config{\%T(x,y,width,\tabnlindent{}height, action, [options])}
& Invoke the action specified when the user presses in the defined
touchscreen area.\\
\end{tagmap}
If the action starts with \& then the area must be held and allows repeat presses (e.g. for seeking).
If the action starts with * then the area must be held but the press only triggers once
(e.g. for switching a setting on a long press).
Possible actions are:
\begin{description}
@ -636,6 +634,15 @@ display cycling round the defined sublines. See
\item[setting\_dec] -- Decrement the subsequently specified setting (e.g
\config{\%T(0,0, setting\_dec, volume)} decreases the volume by one step).
\end{description}
Any (or muliple) of the following options can be used after the action is specified
\subsection{Options}
\begin{description}
\item[repeat_press] -- This region will trigger mulitple times when held (i.e for seeking)
\item[long_press] -- This region will trigger once after it is held for a long press
\item[reverse_bar] -- Reverse the bars touch direction (i.e seek right to left)
\item[allow_while_locked] -- Allows the region to be pressable when the
skin is locked by the lock touch action
\end{description}
\section{Last Touchscreen Press}
\begin{tagmap}

View file

@ -50,7 +50,7 @@
%?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)>
%T(206,0,24,24,play)
%T(206,0,24,24,&stop)
%T(206,0,24,24,stop, repeat)
%T(182,0,18,92,repmode)
%T(139,0,37,23,shuffle)
%T(98,0,33,23,volume)
@ -69,8 +69,8 @@
%T(39,5,24,24,pitch)
%T(58,0,24,24,contextmenu)
%T(86,0,24,24,quickscreen)
%T(115,0,24,23,&rwd)
%T(144,0,24,23,&ffwd)
%T(115,0,24,23,rwd, repeat)
%T(144,0,24,23,ffwd, repeat)
%T(115,0,24,23,prev)
%T(144,0,24,23,next)

View file

@ -68,8 +68,8 @@
%T(50,5,24,24,pitch)
%T(80,5,24,24,contextmenu)
%T(110,5,24,24,quickscreen)
%T(150,5,24,24,&rwd)
%T(175,5,24,24,&ffwd)
%T(150,5,24,24,rwd, repeat)
%T(175,5,24,24,ffwd, repeat)
%T(150,5,24,24,prev)
%T(175,5,24,24,next)
%Vl(u,0,74,-,30,1)

View file

@ -80,7 +80,7 @@
# playmode
%?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)>
%T(273,66,45,50,play)
%T(273,66,45,50,&stop)
%T(273,66,45,50,stop, repeat)
#
# popup osd menu
@ -96,7 +96,7 @@
#
%V(0,420,90,58,-)
%xd(H)%xd(I)
%T(0,0,40,58,&rwd)
%T(0,0,40,58,rwd, repeat)
%T(0,0,40,58,prev)
%T(50,0,40,58,&ffwd)
%T(50,0,40,58,ffwd, repeat)
%T(50,0,40,58,next)

View file

@ -81,7 +81,7 @@
# playmode
%?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)>
%T(400,119,70,75,play)
%T(400,119,70,75,&stop)
%T(400,119,70,75,stop, repeat)
#
# popup osd menu
@ -97,7 +97,7 @@
#
%V(0,720,150,75,-)
%xd(H)%xd(I)
%T(0,0,70,75,&rwd)
%T(0,0,70,75,rwd, repeat)
%T(0,0,70,75,prev)
%T(70,0,70,75,&ffwd)
%T(70,0,70,75,ffwd, repeat)
%T(70,0,70,75,next)

View file

@ -77,7 +77,7 @@
%xl(F,playmode-800x480x16.bmp,0,0,5)
%?Tp<%?mp<%xd(F, 1)|%xd(F, 3)|%xd(F, 2)|%xd(F, 4)|%xd(F, 5)||||>|%xd(F, %mp)>
%T(0,0,70,70,play)
%T(0,0,70,70,&stop)
%T(0,0,70,70,stop, repeat)
#
# popup osd menu
@ -96,7 +96,7 @@
%xl(H,rew-800x480x16.bmp,0,5)
%xl(I,ff-800x480x16.bmp,80,5)
%xd(H)%xd(I)
%T(0,0,70,75,&rwd)
%T(0,0,70,75,rwd, repeat)
%T(0,0,70,75,prev)
%T(80,0,70,75,&ffwd)
%T(80,0,70,75,ffwd, repeat)
%T(80,0,70,75,next)