aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2014-05-08 14:37:13 +0200
committerJoel Bodenmann <joel@unormal.org>2014-05-08 14:37:13 +0200
commit5979acc7f6f1b2d2c76ff80c651b78516335b567 (patch)
tree91d666b5682885c0c774dcc5548df1c1c7ef8e1c /src/gwin
parent15baf7a5c72cace67403e939c90140a4f35f9f22 (diff)
downloaduGFX-5979acc7f6f1b2d2c76ff80c651b78516335b567.tar.gz
uGFX-5979acc7f6f1b2d2c76ff80c651b78516335b567.tar.bz2
uGFX-5979acc7f6f1b2d2c76ff80c651b78516335b567.zip
Introducing GWIN_PROGRESSBAR_AUTO for the automatic incremental function of the progressbar widget
Diffstat (limited to 'src/gwin')
-rw-r--r--src/gwin/progressbar.c92
-rw-r--r--src/gwin/progressbar.h54
-rw-r--r--src/gwin/sys_options.h7
-rw-r--r--src/gwin/sys_rules.h5
4 files changed, 85 insertions, 73 deletions
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
diff --git a/src/gwin/progressbar.h b/src/gwin/progressbar.h
index fcf76b12..5253ba0c 100644
--- a/src/gwin/progressbar.h
+++ b/src/gwin/progressbar.h
@@ -30,7 +30,7 @@ typedef struct GProgressbarObject {
int max;
int res;
int pos;
- #if GFX_USE_GTIMER
+ #if GWIN_PROGRESSBAR_AUTO
GTimer gt;
delaytime_t delay;
#endif
@@ -147,31 +147,33 @@ void gwinProgressbarDecrement(GHandle gh);
*/
#define gwinProgressbarReset(gh) gwinProgressbarSetPosition(gh, ((GProgressbarObject *)(gh))->min)
-/**
- * @brief Automatically increments the progress bar
- *
- * @note The delay is generated using the GTIMER module which is based on software/virtual timer.
- * Therefore, the delay is totally unprecise.
- *
- * @note The progressbar incrementation starts at the current level. It is not reset to the minimum value.
- *
- * @note An event is generated once the maximum value has been reached (ToDo)
- *
- * @param[in] gh The window handle (must be a progressbar window)
- * @param[in] delay The incrementation delay (in milliseconds)
- *
- * @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);
+#if GWIN_PROGRESSBAR_AUTO
+ /**
+ * @brief Automatically increments the progress bar
+ *
+ * @note The delay is generated using the GTIMER module which is based on software/virtual timer.
+ * Therefore, the delay is totally unprecise.
+ *
+ * @note The progressbar incrementation starts at the current level. It is not reset to the minimum value.
+ *
+ * @note An event is generated once the maximum value has been reached (ToDo)
+ *
+ * @param[in] gh The window handle (must be a progressbar window)
+ * @param[in] delay The incrementation delay (in milliseconds)
+ *
+ * @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 */
/**
* @brief Some custom progressbar drawing routines
diff --git a/src/gwin/sys_options.h b/src/gwin/sys_options.h
index 34c4f074..41bc551f 100644
--- a/src/gwin/sys_options.h
+++ b/src/gwin/sys_options.h
@@ -214,6 +214,13 @@
#ifndef GWIN_NEED_IMAGE_ANIMATION
#define GWIN_NEED_IMAGE_ANIMATION FALSE
#endif
+ /**
+ * @brief Enable the API to automatically increment the progressbar over time
+ * @details Defaults to FALSE
+ */
+ #ifndef GWIN_PROGRESSBAR_AUTO
+ #define GWIN_PROGRESSBAR_AUTO FALSE
+ #endif
/** @} */
#endif /* _GWIN_OPTIONS_H */
diff --git a/src/gwin/sys_rules.h b/src/gwin/sys_rules.h
index 77f029f0..30dac1bb 100644
--- a/src/gwin/sys_rules.h
+++ b/src/gwin/sys_rules.h
@@ -93,6 +93,11 @@
#endif
#if GWIN_NEED_GRAPH
#endif
+ #if GWIN_PROGRESSBAR_AUTO
+ #if !GFX_USE_GTIMER
+ #error "GWIN: GFX_USE_GTIMER is required if GWIN_PROGRESSBAR_AUTO is TRUE."
+ #endif
+ #endif
#endif
#endif /* _GWIN_RULES_H */