# HG changeset patch # User ib # Date 1393596685 0 # Node ID bb067298265a210f1f40c409e3674d4da8228d76 # Parent e8d545fe74ac5a0ed6f7010874f7f2b403c71ab0 Fix bug with btnSet(). Only change the pressed state if the item actually has a button. Additionally, change variable name. diff -r e8d545fe74ac -r bb067298265a gui/app/app.c --- 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; } diff -r e8d545fe74ac -r bb067298265a gui/app/app.h --- 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 */ diff -r e8d545fe74ac -r bb067298265a gui/app/gui.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 */