From 8169a0453b77364a0ef804f43762cc5675f450bf Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 23 Apr 2014 23:29:50 +0200 Subject: Added gwinProgressbarStop() --- src/gwin/progressbar.c | 11 +++++++++++ src/gwin/progressbar.h | 9 +++++++++ 2 files changed, 20 insertions(+) (limited to 'src/gwin') diff --git a/src/gwin/progressbar.c b/src/gwin/progressbar.c index 37bad3c8..671c0971 100644 --- a/src/gwin/progressbar.c +++ b/src/gwin/progressbar.c @@ -200,6 +200,17 @@ void gwinProgressbarStart(GHandle gh, delaytime_t delay) { #undef gsw } +void gwinProgressbarStop(GHandle gh) { + #define gsw ((GProgressbarObject *)gh) + + if (gh->vmt != (gwinVMT *)&progressbarVMT) + return; + + gtimerStop(&(gsw->gt)); + + #undef gsw +} + /*---------------------------------------------------------- * Custom Draw Routines *----------------------------------------------------------*/ diff --git a/src/gwin/progressbar.h b/src/gwin/progressbar.h index de10783f..1b7e4424 100644 --- a/src/gwin/progressbar.h +++ b/src/gwin/progressbar.h @@ -155,6 +155,15 @@ void gwinProgressbarDecrement(GHandle gh); */ void gwinProgressbarStart(GHandle gh, delaytime_t delay); +/** + * @brief Stop the timer which is started by @p gwinProgressbarStart() + * + * @param[in] gh The window handle (must be a progressbar window) + * + * @api + */ +void gwinProgressbarStop(GHandle gh); + /** * @brief Some custom progressbar drawing routines * @details These function may be passed to @p gwinSetCustomDraw() to get different progressbar drawing styles -- cgit v1.2.3 From 5c3779cf79616539840baae000797a731ed43127 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 23 Apr 2014 23:39:12 +0200 Subject: Added gwinProgressbarReset() --- src/gwin/progressbar.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/gwin') diff --git a/src/gwin/progressbar.h b/src/gwin/progressbar.h index 1b7e4424..fcf76b12 100644 --- a/src/gwin/progressbar.h +++ b/src/gwin/progressbar.h @@ -138,6 +138,15 @@ void gwinProgressbarDecrement(GHandle gh); */ #define gwinProgressbarGetPosition(gh) (((GProgressbarObject *)(gh))->pos) + /** + * @brief Reset the progressbar to the minimum position + * + * @param[in] gh The window handle (must be a progressbar window) + * + * @api + */ +#define gwinProgressbarReset(gh) gwinProgressbarSetPosition(gh, ((GProgressbarObject *)(gh))->min) + /** * @brief Automatically increments the progress bar * -- cgit v1.2.3 From c3b17604ee456a725328f924a8a3ec339629eb7b Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Wed, 23 Apr 2014 23:55:35 +0200 Subject: Fixing gwin progressbar destroying process --- src/gwin/progressbar.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/gwin') diff --git a/src/gwin/progressbar.c b/src/gwin/progressbar.c index 671c0971..a7acc0ed 100644 --- a/src/gwin/progressbar.c +++ b/src/gwin/progressbar.c @@ -29,12 +29,21 @@ static void ResetDisplayPos(GProgressbarObject *gsw) { gsw->dpos = ((gsw->w.g.width-1)*(gsw->pos-gsw->min))/(gsw->max-gsw->min); } +// We have to deinitialize the timer which auto updates the progressbar if any +static void _destroy(GHandle gh) { + #if GFX_USE_GTIMER + gtimerDeinit( &((GProgressbarObject *)gh)->gt ); + #endif + + _gwidgetDestroy(gh); +} + // The progressbar VMT table static const gwidgetVMT progressbarVMT = { { "Progressbar", // The classname sizeof(GProgressbarObject), // The object size - _gwidgetDestroy, // The destroy routine + _destroy, // The destroy routine _gwidgetRedraw, // The redraw routine 0, // The after-clear routine }, -- cgit v1.2.3