New Touchscreen region type... 'mute' which un/mutes volume without pausing playback


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29046 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/action.h b/apps/action.h
index 260d868..e664c03 100644
--- a/apps/action.h
+++ b/apps/action.h
@@ -246,6 +246,7 @@
      * being used, but are nice additions if the touchscreen is used */
     ACTION_TOUCH_SHUFFLE,
     ACTION_TOUCH_REPMODE,
+    ACTION_TOUCH_MUTE,
 #endif    
 
     /* USB HID codes */
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 5a90873..e23f842 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -880,6 +880,7 @@
     { "resumeplayback", ACTION_TREE_WPS}, /* returns to previous music, WPS/FM */
     /* not really WPS specific, but no equivilant ACTION_STD_* */
     {"voldown", ACTION_WPS_VOLDOWN},    {"volup", ACTION_WPS_VOLUP},
+    {"mute", ACTION_TOUCH_MUTE },
     
     /* generic settings changers */
     {"setting_inc", ACTION_SETTINGS_INC}, {"setting_dec", ACTION_SETTINGS_DEC}, 
@@ -945,7 +946,7 @@
     region->wvp = curr_vp;
     region->armed = false;
     region->reverse_bar = false;
-    region->extradata = NULL;
+    region->data = NULL;
     action = element->params[4].data.text;
 
     strcpy(temp, action);
@@ -998,7 +999,7 @@
                                 break;
                         if (j==nb_settings)
                             return WPS_ERROR_INVALID_PARAM;
-                        region->extradata = (void*)&settings[j];
+                        region->data = (void*)&settings[j];
                     }
                 }
                 break;
@@ -1011,6 +1012,13 @@
     if (!item)
         return WPS_ERROR_INVALID_PARAM;
     add_to_ll_chain(&wps_data->touchregions, item);
+    
+    if (region->action == ACTION_TOUCH_MUTE)
+    {
+        region->value = global_settings.volume;
+    }
+        
+    
     return 0;
 }
 #endif
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 24edde7..02585f2 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -196,7 +196,10 @@
     int action;              /* action this button will return */
     bool armed;              /* A region is armed on press. Only armed regions are triggered
                                 on repeat or release. */
-    void* extradata;
+    union {                  /* Extra data, action dependant */
+        void* data;
+        int   value;
+    };
 };
 #endif
 
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index a5c751b..ad89f7a 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -39,6 +39,10 @@
 #include "font.h"
 #include "icon.h"
 #include "option_select.h"
+#ifdef HAVE_TOUCHSCREEN
+#include "sound.h"
+#include "misc.h"
+#endif
 
 /* initial setup of wps_data  */
 static int update_delay = DEFAULT_UPDATE_DELAY;
@@ -296,10 +300,23 @@
         case ACTION_SETTINGS_INC:
         case ACTION_SETTINGS_DEC:
         {
-            const struct settings_list *setting = region->extradata;
+            const struct settings_list *setting = region->data;
             option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true);
         }
         return ACTION_REDRAW;
+        case ACTION_TOUCH_MUTE:
+        {
+            const int min_vol = sound_min(SOUND_VOLUME);
+            if (global_settings.volume == min_vol)
+                global_settings.volume = region->value;
+            else
+            {
+                region->value = global_settings.volume;
+                global_settings.volume = min_vol;
+            }
+            setvol();
+        }
+        return ACTION_REDRAW;
         /* TODO */
     }
     return button;
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 7d633ad..e528380 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -242,10 +242,23 @@
         case ACTION_SETTINGS_INC:
         case ACTION_SETTINGS_DEC:
         {
-            const struct settings_list *setting = region->extradata;
+            const struct settings_list *setting = region->data;
             option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true);
         }
         return ACTION_REDRAW;
+        case ACTION_TOUCH_MUTE:
+        {
+            const int min_vol = sound_min(SOUND_VOLUME);
+            if (global_settings.volume == min_vol)
+                global_settings.volume = region->value;
+            else
+            {
+                region->value = global_settings.volume;
+                global_settings.volume = min_vol;
+            }
+            setvol();
+        }
+        return ACTION_REDRAW;
     }
     return button;
 }
diff --git a/apps/radio/radio_skin.c b/apps/radio/radio_skin.c
index 68314d6..2e32923 100644
--- a/apps/radio/radio_skin.c
+++ b/apps/radio/radio_skin.c
@@ -32,6 +32,10 @@
 #include "appevents.h"
 #include "statusbar-skinned.h"
 #include "option_select.h"
+#ifdef HAVE_TOUCHSCREEN
+#include "sound.h"
+#include "misc.h"
+#endif
 
 
 char* default_radio_skin(enum screen_type screen)
@@ -120,10 +124,23 @@
         case ACTION_SETTINGS_INC:
         case ACTION_SETTINGS_DEC:
         {
-            const struct settings_list *setting = region->extradata;
+            const struct settings_list *setting = region->data;
             option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true);
         }
         return ACTION_REDRAW;
+        case ACTION_TOUCH_MUTE:
+        {
+            const int min_vol = sound_min(SOUND_VOLUME);
+            if (global_settings.volume == min_vol)
+                global_settings.volume = region->value;
+            else
+            {
+                region->value = global_settings.volume;
+                global_settings.volume = min_vol;
+            }
+            setvol();
+        }
+        return ACTION_REDRAW;
     }   
 #endif
     return button;
diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex
index f6b348b..92bc209 100644
--- a/manual/appendix/wps_tags.tex
+++ b/manual/appendix/wps_tags.tex
@@ -615,6 +615,7 @@
     \item[pitch] -- Open the pitchscreen.
     \item[voldown] -- Decrease the volume by one step.
     \item[volup] -- Increase the volume by one step.
+    \item[mute] -- Un/Mute playback.
   \end{description}
 
   \section{Last Touchscreen Press}