aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-09-29 15:46:34 +1000
committerinmarket <andrewh@inmarket.com.au>2014-09-29 15:46:34 +1000
commite2f3a68c3b9b97799ac446fa5c0bc8bfdf9d9012 (patch)
tree55b727183b6fc67821dc9256cfbdc4308da2d0a8 /src
parent3abbf8e1b2bac9ca02ab22d00fad828e5ff54898 (diff)
downloaduGFX-e2f3a68c3b9b97799ac446fa5c0bc8bfdf9d9012.tar.gz
uGFX-e2f3a68c3b9b97799ac446fa5c0bc8bfdf9d9012.tar.bz2
uGFX-e2f3a68c3b9b97799ac446fa5c0bc8bfdf9d9012.zip
Progress bar optimisation.
Diffstat (limited to 'src')
-rw-r--r--src/gwin/gwin_progressbar.c41
-rw-r--r--src/gwin/gwin_progressbar.h7
2 files changed, 22 insertions, 26 deletions
diff --git a/src/gwin/gwin_progressbar.c b/src/gwin/gwin_progressbar.c
index ef28e8dc..d5b8721a 100644
--- a/src/gwin/gwin_progressbar.c
+++ b/src/gwin/gwin_progressbar.c
@@ -79,13 +79,12 @@ GHandle gwinGProgressbarCreate(GDisplay *g, GProgressbarObject *gs, const GWidge
gs->pos = 0;
#if GWIN_PROGRESSBAR_AUTO
- gs->delay = 0;
gtimerInit(&gs->gt);
#endif
ResetDisplayPos(gs);
gwinSetVisible((GHandle)gs, pInit->g.show);
-
+
return (GHandle)gs;
}
@@ -183,39 +182,37 @@ void gwinProgressbarDecrement(GHandle gh) {
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
+
+ if (gsw->pos >= gsw->max)
+ gtimerStop(&gsw->gt);
+
+ #undef gsw
}
-
+
void gwinProgressbarStart(GHandle gh, delaytime_t delay) {
#define gsw ((GProgressbarObject *)gh)
-
+
if (gh->vmt != (gwinVMT *)&progressbarVMT)
return;
-
- gsw->delay = delay;
-
- gtimerStart(&(gsw->gt), _progressbarCallback, gh, FALSE, gsw->delay);
-
+
+ gtimerStart(&gsw->gt, _progressbarCallback, gh, TRUE, delay);
+
#undef gsw
}
-
+
void gwinProgressbarStop(GHandle gh) {
#define gsw ((GProgressbarObject *)gh)
-
+
if (gh->vmt != (gwinVMT *)&progressbarVMT)
return;
-
- gtimerStop(&(gsw->gt));
-
+
+ gtimerStop(&gsw->gt);
+
#undef gsw
}
#endif /* GWIN_PROGRESSBAR_AUTO */
@@ -226,7 +223,7 @@ void gwinProgressbarDecrement(GHandle gh) {
void gwinProgressbarDraw_Std(GWidgetObject *gw, void *param) {
#define gsw ((GProgressbarObject *)gw)
-
+
const GColorSet * pcol;
(void) param;
diff --git a/src/gwin/gwin_progressbar.h b/src/gwin/gwin_progressbar.h
index 49c11a98..dae9d40a 100644
--- a/src/gwin/gwin_progressbar.h
+++ b/src/gwin/gwin_progressbar.h
@@ -33,7 +33,6 @@ typedef struct GProgressbarObject {
int pos;
#if GWIN_PROGRESSBAR_AUTO
GTimer gt;
- delaytime_t delay;
#endif
} GProgressbarObject;
@@ -59,7 +58,7 @@ extern "C" {
* @note A progressbar does not take any GINPUT inputs.
*
* @api
- */
+ */
GHandle gwinGProgressbarCreate(GDisplay *g, GProgressbarObject *gb, const GWidgetInit *pInit);
#define gwinProgressbarCreate(w, pInit) gwinGProgressbarCreate(GDISP, w, pInit)
@@ -165,14 +164,14 @@ void gwinProgressbarDecrement(GHandle gh);
* @api
*/
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);
#endif /* GWIN_PROGRESSBAR_AUTO */