Mercurial > mplayer.hg
changeset 36861:bade5683ca70
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.
author | ib |
---|---|
date | Fri, 28 Feb 2014 14:38:45 +0000 |
parents | d66aef85ae31 |
children | f1da7af6fc9b |
files | gui/app/app.c gui/app/app.h gui/app/gui.h |
diffstat | 3 files changed, 23 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/app/app.c Fri Feb 28 14:30:20 2014 +0000 +++ b/gui/app/app.c Fri Feb 28 14:38:45 2014 +0000 @@ -179,60 +179,36 @@ } /** - * @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; + 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; - case itPotmeter: - case itVPotmeter: - case itHPotmeter: - - if (state < 0.0f) - state = 0.0f; - if (state > 100.0f) - state = 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; + 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; - case itPotmeter: - case itVPotmeter: - case itHPotmeter: - - if (state < 0.0f) - state = 0.0f; - if (state > 100.0f) - state = 100.0f; - - guiApp.playbarItems[i].value = state; - break; + guiApp.playbarItems[i].value = value; } - } - } } /**
--- a/gui/app/app.h Fri Feb 28 14:30:20 2014 +0000 +++ b/gui/app/app.h Fri Feb 28 14:38:45 2014 +0000 @@ -178,7 +178,7 @@ 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 */
--- a/gui/app/gui.h Fri Feb 28 14:30:20 2014 +0000 +++ b/gui/app/gui.h Fri Feb 28 14:38:45 2014 +0000 @@ -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 */