changeset 36858:bb067298265a

Fix bug with btnSet(). Only change the pressed state if the item actually has a button. Additionally, change variable name.
author ib
date Fri, 28 Feb 2014 14:11:25 +0000
parents e8d545fe74ac
children 9bc711c42ea6
files gui/app/app.c gui/app/app.h gui/app/gui.h
diffstat 3 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gui/app/app.c	Fri Feb 28 13:30:06 2014 +0000
+++ b/gui/app/app.c	Fri Feb 28 14:11:25 2014 +0000
@@ -241,15 +241,17 @@
  * @param event event
  * @param set new value
  */
-void btnSet(int event, int set)
+void btnSet(int event, int state)
 {
     int i;
 
     for (i = 0; i <= guiApp.IndexOfMainItems; i++)
         if (guiApp.mainItems[i].message == event)
-            guiApp.mainItems[i].pressed = set;
+            if (hasButton(guiApp.mainItems[i]))
+                guiApp.mainItems[i].pressed = state;
 
     for (i = 0; i <= guiApp.IndexOfPlaybarItems; i++)
         if (guiApp.playbarItems[i].message == event)
-            guiApp.playbarItems[i].pressed = set;
+            if (hasButton(guiApp.mainItems[i]))
+                guiApp.playbarItems[i].pressed = state;
 }
--- a/gui/app/app.h	Fri Feb 28 13:30:06 2014 +0000
+++ b/gui/app/app.h	Fri Feb 28 14:11:25 2014 +0000
@@ -179,6 +179,6 @@
 int appFindMessage(const char *name);
 void appFreeStruct(void);
 void btnModify(int event, float state);
-void btnSet(int event, int set);
+void btnSet(int event, int state);
 
 #endif /* MPLAYER_GUI_APP_H */
--- a/gui/app/gui.h	Fri Feb 28 13:30:06 2014 +0000
+++ b/gui/app/gui.h	Fri Feb 28 14:11:25 2014 +0000
@@ -24,6 +24,8 @@
 #ifndef MPLAYER_GUI_GUI_H
 #define MPLAYER_GUI_GUI_H
 
+#include "gui/app/app.h"
+
 #include "stream/stream.h"
 
 /// Name of the program the GUI utilizes
@@ -49,4 +51,7 @@
 /// Check whether @a x/y is inside the rectangle given by @a top @a x/y and @a bottom @a x/y.
 #define isInside(x, y, tx, ty, bx, by) ((x) > (tx) && (y) > (ty) && (x) < (bx) && (y) < (by))
 
+/// 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)
+
 #endif /* MPLAYER_GUI_GUI_H */