From 5979acc7f6f1b2d2c76ff80c651b78516335b567 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Thu, 8 May 2014 14:37:13 +0200 Subject: Introducing GWIN_PROGRESSBAR_AUTO for the automatic incremental function of the progressbar widget --- src/gwin/progressbar.c | 92 ++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 47 deletions(-) (limited to 'src/gwin/progressbar.c') diff --git a/src/gwin/progressbar.c b/src/gwin/progressbar.c index c64e2119..0ad7a230 100644 --- a/src/gwin/progressbar.c +++ b/src/gwin/progressbar.c @@ -84,6 +84,10 @@ GHandle gwinGProgressbarCreate(GDisplay *g, GProgressbarObject *gs, const GWidge gs->pos = 0; gs->delay = 0; + #if GWIN_PROGRESSBAR_AUTO + gtimerInit(&gs->gt); + #endif + ResetDisplayPos(gs); gwinSetVisible((GHandle)gs, pInit->g.show); @@ -179,54 +183,48 @@ void gwinProgressbarDecrement(GHandle gh) { #undef gsw } -// used by gwinProgressbarStart(); -static void _progressbarCallback(void *param) { - #define gsw ((GProgressbarObject *)gh) - GHandle gh = (GHandle)param; - - if (gh->vmt != (gwinVMT *)&progressbarVMT) - return; - - gwinProgressbarIncrement(gh); - - if (gsw->pos < gsw->max) +#if GWIN_PROGRESSBAR_AUTO + // used by gwinProgressbarStart(); + static void _progressbarCallback(void *param) { + #define gsw ((GProgressbarObject *)gh) + GHandle gh = (GHandle)param; + + if (gh->vmt != (gwinVMT *)&progressbarVMT) + return; + + gwinProgressbarIncrement(gh); + + if (gsw->pos < gsw->max) + gtimerStart(&(gsw->gt), _progressbarCallback, gh, FALSE, gsw->delay); + + #undef gsw + } + + void gwinProgressbarStart(GHandle gh, delaytime_t delay) { + #define gsw ((GProgressbarObject *)gh) + + if (gh->vmt != (gwinVMT *)&progressbarVMT) + return; + + gsw->delay = delay; + + gtimerInit(&(gsw->gt)); gtimerStart(&(gsw->gt), _progressbarCallback, gh, FALSE, gsw->delay); - - #undef gsw -} - -void gwinProgressbarStart(GHandle gh, delaytime_t delay) { - #define gsw ((GProgressbarObject *)gh) - - if (gh->vmt != (gwinVMT *)&progressbarVMT) - return; - - gsw->delay = delay; - - gtimerInit(&(gsw->gt)); - gtimerStart(&(gsw->gt), _progressbarCallback, gh, FALSE, gsw->delay); - - #if 0 - // if this is not made, the progressbar will not start when it's already visible - if (gsw->w.g.flags & GWIN_FLG_VISIBLE) { - gwinSetVisible(gh, FALSE); - gwinSetVisible(gh, TRUE); - } - #endif - - #undef gsw -} - -void gwinProgressbarStop(GHandle gh) { - #define gsw ((GProgressbarObject *)gh) - - if (gh->vmt != (gwinVMT *)&progressbarVMT) - return; - - gtimerStop(&(gsw->gt)); - - #undef gsw -} + + #undef gsw + } + + void gwinProgressbarStop(GHandle gh) { + #define gsw ((GProgressbarObject *)gh) + + if (gh->vmt != (gwinVMT *)&progressbarVMT) + return; + + gtimerStop(&(gsw->gt)); + + #undef gsw + } +#endif /* GWIN_PROGRESSBAR_AUTO */ /*---------------------------------------------------------- * Custom Draw Routines -- cgit v1.2.3