Introducing GWIN_PROGRESSBAR_AUTO for the automatic incremental function of the progressbar widget
This commit is contained in:
parent
15baf7a5c7
commit
5979acc7f6
7 changed files with 88 additions and 73 deletions
|
@ -82,6 +82,7 @@
|
||||||
#define GWIN_NEED_IMAGE_ANIMATION FALSE
|
#define GWIN_NEED_IMAGE_ANIMATION FALSE
|
||||||
#define GWIN_NEED_LIST_IMAGES FALSE
|
#define GWIN_NEED_LIST_IMAGES FALSE
|
||||||
#define GWIN_NEED_PROGRESSBAR TRUE
|
#define GWIN_NEED_PROGRESSBAR TRUE
|
||||||
|
#define GWIN_PROGRESSBAR_AUTO TRUE
|
||||||
|
|
||||||
/* Features for the GINPUT sub-system. */
|
/* Features for the GINPUT sub-system. */
|
||||||
#define GINPUT_NEED_MOUSE TRUE
|
#define GINPUT_NEED_MOUSE TRUE
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
#define GWIN_NEED_LIST TRUE
|
#define GWIN_NEED_LIST TRUE
|
||||||
#define GWIN_NEED_LIST_IMAGES TRUE
|
#define GWIN_NEED_LIST_IMAGES TRUE
|
||||||
#define GWIN_NEED_PROGRESSBAR TRUE
|
#define GWIN_NEED_PROGRESSBAR TRUE
|
||||||
|
#define GWIN_PROGRESSBAR_AUTO TRUE
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// GEVENT //
|
// GEVENT //
|
||||||
|
|
|
@ -148,6 +148,7 @@
|
||||||
#define GWIN_NEED_LIST FALSE
|
#define GWIN_NEED_LIST FALSE
|
||||||
#define GWIN_NEED_LIST_IMAGES FALSE
|
#define GWIN_NEED_LIST_IMAGES FALSE
|
||||||
#define GWIN_NEED_PROGRESSBAR FALSE
|
#define GWIN_NEED_PROGRESSBAR FALSE
|
||||||
|
#define GWIN_PROGRESSBAR_AUTO FALSE
|
||||||
#define GWIN_NEED_FRAME FALSE
|
#define GWIN_NEED_FRAME FALSE
|
||||||
#define GWIN_FLAT_STYLING FALSE
|
#define GWIN_FLAT_STYLING FALSE
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,10 @@ GHandle gwinGProgressbarCreate(GDisplay *g, GProgressbarObject *gs, const GWidge
|
||||||
gs->pos = 0;
|
gs->pos = 0;
|
||||||
gs->delay = 0;
|
gs->delay = 0;
|
||||||
|
|
||||||
|
#if GWIN_PROGRESSBAR_AUTO
|
||||||
|
gtimerInit(&gs->gt);
|
||||||
|
#endif
|
||||||
|
|
||||||
ResetDisplayPos(gs);
|
ResetDisplayPos(gs);
|
||||||
gwinSetVisible((GHandle)gs, pInit->g.show);
|
gwinSetVisible((GHandle)gs, pInit->g.show);
|
||||||
|
|
||||||
|
@ -179,54 +183,48 @@ void gwinProgressbarDecrement(GHandle gh) {
|
||||||
#undef gsw
|
#undef gsw
|
||||||
}
|
}
|
||||||
|
|
||||||
// used by gwinProgressbarStart();
|
#if GWIN_PROGRESSBAR_AUTO
|
||||||
static void _progressbarCallback(void *param) {
|
// used by gwinProgressbarStart();
|
||||||
#define gsw ((GProgressbarObject *)gh)
|
static void _progressbarCallback(void *param) {
|
||||||
GHandle gh = (GHandle)param;
|
#define gsw ((GProgressbarObject *)gh)
|
||||||
|
GHandle gh = (GHandle)param;
|
||||||
|
|
||||||
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gwinProgressbarIncrement(gh);
|
gwinProgressbarIncrement(gh);
|
||||||
|
|
||||||
if (gsw->pos < gsw->max)
|
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);
|
gtimerStart(&(gsw->gt), _progressbarCallback, gh, FALSE, gsw->delay);
|
||||||
|
|
||||||
#undef gsw
|
#undef gsw
|
||||||
}
|
}
|
||||||
|
|
||||||
void gwinProgressbarStart(GHandle gh, delaytime_t delay) {
|
void gwinProgressbarStop(GHandle gh) {
|
||||||
#define gsw ((GProgressbarObject *)gh)
|
#define gsw ((GProgressbarObject *)gh)
|
||||||
|
|
||||||
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
if (gh->vmt != (gwinVMT *)&progressbarVMT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gsw->delay = delay;
|
gtimerStop(&(gsw->gt));
|
||||||
|
|
||||||
gtimerInit(&(gsw->gt));
|
#undef gsw
|
||||||
gtimerStart(&(gsw->gt), _progressbarCallback, gh, FALSE, gsw->delay);
|
}
|
||||||
|
#endif /* GWIN_PROGRESSBAR_AUTO */
|
||||||
#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
|
|
||||||
}
|
|
||||||
|
|
||||||
/*----------------------------------------------------------
|
/*----------------------------------------------------------
|
||||||
* Custom Draw Routines
|
* Custom Draw Routines
|
||||||
|
|
|
@ -30,7 +30,7 @@ typedef struct GProgressbarObject {
|
||||||
int max;
|
int max;
|
||||||
int res;
|
int res;
|
||||||
int pos;
|
int pos;
|
||||||
#if GFX_USE_GTIMER
|
#if GWIN_PROGRESSBAR_AUTO
|
||||||
GTimer gt;
|
GTimer gt;
|
||||||
delaytime_t delay;
|
delaytime_t delay;
|
||||||
#endif
|
#endif
|
||||||
|
@ -147,31 +147,33 @@ void gwinProgressbarDecrement(GHandle gh);
|
||||||
*/
|
*/
|
||||||
#define gwinProgressbarReset(gh) gwinProgressbarSetPosition(gh, ((GProgressbarObject *)(gh))->min)
|
#define gwinProgressbarReset(gh) gwinProgressbarSetPosition(gh, ((GProgressbarObject *)(gh))->min)
|
||||||
|
|
||||||
/**
|
#if GWIN_PROGRESSBAR_AUTO
|
||||||
* @brief Automatically increments the progress bar
|
/**
|
||||||
*
|
* @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 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 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)
|
*
|
||||||
*
|
* @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)
|
* @param[in] gh The window handle (must be a progressbar window)
|
||||||
*
|
* @param[in] delay The incrementation delay (in milliseconds)
|
||||||
* @api
|
*
|
||||||
*/
|
* @api
|
||||||
void gwinProgressbarStart(GHandle gh, delaytime_t delay);
|
*/
|
||||||
|
void gwinProgressbarStart(GHandle gh, delaytime_t delay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stop the timer which is started by @p gwinProgressbarStart()
|
* @brief Stop the timer which is started by @p gwinProgressbarStart()
|
||||||
*
|
*
|
||||||
* @param[in] gh The window handle (must be a progressbar window)
|
* @param[in] gh The window handle (must be a progressbar window)
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
void gwinProgressbarStop(GHandle gh);
|
void gwinProgressbarStop(GHandle gh);
|
||||||
|
#endif /* GWIN_PROGRESSBAR_AUTO */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Some custom progressbar drawing routines
|
* @brief Some custom progressbar drawing routines
|
||||||
|
|
|
@ -214,6 +214,13 @@
|
||||||
#ifndef GWIN_NEED_IMAGE_ANIMATION
|
#ifndef GWIN_NEED_IMAGE_ANIMATION
|
||||||
#define GWIN_NEED_IMAGE_ANIMATION FALSE
|
#define GWIN_NEED_IMAGE_ANIMATION FALSE
|
||||||
#endif
|
#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 */
|
#endif /* _GWIN_OPTIONS_H */
|
||||||
|
|
|
@ -93,6 +93,11 @@
|
||||||
#endif
|
#endif
|
||||||
#if GWIN_NEED_GRAPH
|
#if GWIN_NEED_GRAPH
|
||||||
#endif
|
#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
|
||||||
|
|
||||||
#endif /* _GWIN_RULES_H */
|
#endif /* _GWIN_RULES_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue