[MPlayer-cvslog] r36957 - in trunk/gui/app: app.c app.h gui.h

ib subversion at mplayerhq.hu
Fri Feb 28 15:38:45 CET 2014


Author: ib
Date: Fri Feb 28 15:38:45 2014
New Revision: 36957

Log:
Fix bug with btnModify().

Don't change a button's pressed state with this function.
Only change an item's value.

Additionally, update documentation and change variable name.

Modified:
   trunk/gui/app/app.c
   trunk/gui/app/app.h
   trunk/gui/app/gui.h

Modified: trunk/gui/app/app.c
==============================================================================
--- trunk/gui/app/app.c	Fri Feb 28 15:30:20 2014	(r36956)
+++ trunk/gui/app/app.c	Fri Feb 28 15:38:45 2014	(r36957)
@@ -179,60 +179,36 @@ guiItem *appFindItem(int event)
 }
 
 /**
- * @brief Modify the state (i.e. set a new value) to the item belonging to an event.
+ * @brief Modify the value of the item belonging to an event.
  *
  * @param event event
- * @param state new value
+ * @param value new value
  */
-void btnModify(int event, float state)
+void btnModify(int event, float value)
 {
     int i;
 
-    for (i = 0; i <= guiApp.IndexOfMainItems; i++) {
-        if (guiApp.mainItems[i].message == event) {
-            switch (guiApp.mainItems[i].type) {
-            case itButton:
-
-                guiApp.mainItems[i].pressed = (int)state;
-                break;
-
-            case itPotmeter:
-            case itVPotmeter:
-            case itHPotmeter:
-
-                if (state < 0.0f)
-                    state = 0.0f;
-                if (state > 100.0f)
-                    state = 100.0f;
+    for (i = 0; i <= guiApp.IndexOfMainItems; i++)
+        if (guiApp.mainItems[i].message == event)
+            if (hasValue(guiApp.mainItems[i])) {
+                if (value < 0.0f)
+                    value = 0.0f;
+                if (value > 100.0f)
+                    value = 100.0f;
 
-                guiApp.mainItems[i].value = state;
-                break;
+                guiApp.mainItems[i].value = value;
             }
-        }
-    }
-
-    for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++) {
-        if (guiApp.playbarItems[i].message == event) {
-            switch (guiApp.playbarItems[i].type) {
-            case itButton:
 
-                guiApp.playbarItems[i].pressed = (int)state;
-                break;
-
-            case itPotmeter:
-            case itVPotmeter:
-            case itHPotmeter:
-
-                if (state < 0.0f)
-                    state = 0.0f;
-                if (state > 100.0f)
-                    state = 100.0f;
+    for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++)
+        if (guiApp.playbarItems[i].message == event)
+            if (hasValue(guiApp.playbarItems[i])) {
+                if (value < 0.0f)
+                    value = 0.0f;
+                if (value > 100.0f)
+                    value = 100.0f;
 
-                guiApp.playbarItems[i].value = state;
-                break;
+                guiApp.playbarItems[i].value = value;
             }
-        }
-    }
 }
 
 /**

Modified: trunk/gui/app/app.h
==============================================================================
--- trunk/gui/app/app.h	Fri Feb 28 15:30:20 2014	(r36956)
+++ trunk/gui/app/app.h	Fri Feb 28 15:38:45 2014	(r36957)
@@ -178,7 +178,7 @@ extern guiItems guiApp;
 guiItem *appFindItem(int event);
 int appFindMessage(const char *name);
 void appFreeStruct(void);
-void btnModify(int event, float state);
+void btnModify(int event, float value);
 void btnSet(int event, int state);
 
 #endif /* MPLAYER_GUI_APP_H */

Modified: trunk/gui/app/gui.h
==============================================================================
--- trunk/gui/app/gui.h	Fri Feb 28 15:30:20 2014	(r36956)
+++ trunk/gui/app/gui.h	Fri Feb 28 15:38:45 2014	(r36957)
@@ -54,4 +54,7 @@
 /// Check whether #guiItem @a item has a button (and thus a pressed state).
 #define hasButton(item) (item.type == itButton || item.type == itHPotmeter || item.type == itVPotmeter)
 
+/// Check whether #guiItem @a item utilizes member 'value'
+#define hasValue(item) (item.type == itHPotmeter || item.type == itVPotmeter || item.type == itPotmeter)
+
 #endif /* MPLAYER_GUI_GUI_H */


More information about the MPlayer-cvslog mailing list