From a695f5337df66cc09964f84f94a6ed113dcc8100 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Tue, 6 May 2014 20:18:05 +0200 Subject: [PATCH 01/20] typo fix --- src/gaudio/sys_options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gaudio/sys_options.h b/src/gaudio/sys_options.h index 1363d703..eb903424 100644 --- a/src/gaudio/sys_options.h +++ b/src/gaudio/sys_options.h @@ -14,7 +14,7 @@ */ #ifndef _GAUDIO_OPTIONS_H -#define _GAUDOUT_OPTIONS_H +#define _GAUDIO_OPTIONS_H /** * @name GAUDIO Functionality to be included From 15baf7a5c72cace67403e939c90140a4f35f9f22 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Thu, 8 May 2014 13:20:12 +0200 Subject: [PATCH 02/20] Bug fix - GWIN_NEED_PROGRESSBAR not set to FALSE by default --- src/gwin/sys_options.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gwin/sys_options.h b/src/gwin/sys_options.h index aa296026..34c4f074 100644 --- a/src/gwin/sys_options.h +++ b/src/gwin/sys_options.h @@ -57,6 +57,13 @@ #ifndef GWIN_NEED_BUTTON #define GWIN_NEED_BUTTON FALSE #endif + /** + * @brief Should progressbar functions be included. + * @details Defaults to FALSE + */ + #ifndef GWIN_NEED_PROGRESSBAR + #define GWIN_NEED_PROGRESSBAR FALSE + #endif /** * @brief Should slider functions be included. * @details Defaults to FALSE From 5979acc7f6f1b2d2c76ff80c651b78516335b567 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Thu, 8 May 2014 14:37:13 +0200 Subject: [PATCH 03/20] Introducing GWIN_PROGRESSBAR_AUTO for the automatic incremental function of the progressbar widget --- demos/modules/gwin/progressbar/gfxconf.h | 1 + demos/modules/gwin/widgets/gfxconf.h | 1 + gfxconf.example.h | 1 + src/gwin/progressbar.c | 92 ++++++++++++------------ src/gwin/progressbar.h | 54 +++++++------- src/gwin/sys_options.h | 7 ++ src/gwin/sys_rules.h | 5 ++ 7 files changed, 88 insertions(+), 73 deletions(-) diff --git a/demos/modules/gwin/progressbar/gfxconf.h b/demos/modules/gwin/progressbar/gfxconf.h index 4ea487b9..6af70faf 100644 --- a/demos/modules/gwin/progressbar/gfxconf.h +++ b/demos/modules/gwin/progressbar/gfxconf.h @@ -82,6 +82,7 @@ #define GWIN_NEED_IMAGE_ANIMATION FALSE #define GWIN_NEED_LIST_IMAGES FALSE #define GWIN_NEED_PROGRESSBAR TRUE +#define GWIN_PROGRESSBAR_AUTO TRUE /* Features for the GINPUT sub-system. */ #define GINPUT_NEED_MOUSE TRUE diff --git a/demos/modules/gwin/widgets/gfxconf.h b/demos/modules/gwin/widgets/gfxconf.h index c5673367..25065b27 100644 --- a/demos/modules/gwin/widgets/gfxconf.h +++ b/demos/modules/gwin/widgets/gfxconf.h @@ -65,6 +65,7 @@ #define GWIN_NEED_LIST TRUE #define GWIN_NEED_LIST_IMAGES TRUE #define GWIN_NEED_PROGRESSBAR TRUE + #define GWIN_PROGRESSBAR_AUTO TRUE /////////////////////////////////////////////////////////////////////////// // GEVENT // diff --git a/gfxconf.example.h b/gfxconf.example.h index 5be67335..8881208c 100644 --- a/gfxconf.example.h +++ b/gfxconf.example.h @@ -148,6 +148,7 @@ #define GWIN_NEED_LIST FALSE #define GWIN_NEED_LIST_IMAGES FALSE #define GWIN_NEED_PROGRESSBAR FALSE + #define GWIN_PROGRESSBAR_AUTO FALSE #define GWIN_NEED_FRAME FALSE #define GWIN_FLAT_STYLING FALSE 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 */ From a9ead70e09ab3cc227b72f3dcd56d03b24f3b53d Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 9 May 2014 10:39:10 +0200 Subject: [PATCH 04/20] Imagebox widget bug fix that could cause gwinImageOpenFile() to crash --- docs/releases.txt | 1 + src/gwin/gimage.c | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/releases.txt b/docs/releases.txt index 859c7edd..511208f9 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -33,6 +33,7 @@ FEATURE: Added vs1053 audio play driver FEATURE: Added GAUDIO wave-play demo FEATURE: Added many GWIN simple demo's and updated the combined widget demo FEATURE: Added gwinEnable() and gwinDisable() +FIX: Imagebox widget bugfix that could cause gwinImageOpenFile() to crash *** changes after 1.9 *** diff --git a/src/gwin/gimage.c b/src/gwin/gimage.c index fdc6df84..44ba785a 100644 --- a/src/gwin/gimage.c +++ b/src/gwin/gimage.c @@ -128,6 +128,7 @@ GHandle gwinGImageCreate(GDisplay *g, GImageObject *gobj, GWindowInit *pInit) { // Ensure the gdispImageIsOpen() gives valid results gobj->image.type = 0; + gobj->image.fns = 0; // Initialise the timer #if GWIN_NEED_IMAGE_ANIMATION From 81517afc37520093ffeb832be0946bb1cbddebc9 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 9 May 2014 10:39:27 +0200 Subject: [PATCH 05/20] Imagebox widget demo compiler warning fix --- demos/modules/gwin/imagebox/gfxconf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/modules/gwin/imagebox/gfxconf.h b/demos/modules/gwin/imagebox/gfxconf.h index 7ff4dece..4db8be39 100644 --- a/demos/modules/gwin/imagebox/gfxconf.h +++ b/demos/modules/gwin/imagebox/gfxconf.h @@ -42,7 +42,7 @@ #define GDISP_NEED_PIXELREAD FALSE #define GDISP_NEED_CONTROL FALSE #define GDISP_NEED_QUERY FALSE -#define GDISP_NEED_MULTITHREAD FALSE +#define GDISP_NEED_MULTITHREAD TRUE #define GDISP_NEED_STREAMING FALSE #define GDISP_NEED_TEXT TRUE #define GDISP_NEED_ANTIALIAS FALSE From a3d1e05566c3deddfe5014322bbce14b2e46c2cd Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 9 May 2014 10:40:53 +0200 Subject: [PATCH 06/20] added missing entry in releases.txt --- docs/releases.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/releases.txt b/docs/releases.txt index 511208f9..e5be2311 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -33,7 +33,8 @@ FEATURE: Added vs1053 audio play driver FEATURE: Added GAUDIO wave-play demo FEATURE: Added many GWIN simple demo's and updated the combined widget demo FEATURE: Added gwinEnable() and gwinDisable() -FIX: Imagebox widget bugfix that could cause gwinImageOpenFile() to crash +FIX: Progressbar widget bug fix that could gwinProgressbarStop() to crash +FIX: Imagebox widget bug fix that could cause gwinImageOpenFile() to crash *** changes after 1.9 *** From 52262dbafe3709528a0832f159f6f2bd55105cc1 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 9 May 2014 10:58:23 +0200 Subject: [PATCH 07/20] progressbar widget cleanup --- src/gwin/progressbar.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gwin/progressbar.c b/src/gwin/progressbar.c index 0ad7a230..524a5346 100644 --- a/src/gwin/progressbar.c +++ b/src/gwin/progressbar.c @@ -208,7 +208,6 @@ void gwinProgressbarDecrement(GHandle gh) { gsw->delay = delay; - gtimerInit(&(gsw->gt)); gtimerStart(&(gsw->gt), _progressbarCallback, gh, FALSE, gsw->delay); #undef gsw From 82a3f8491f6ec3b6bbb161167fc435acbfacc3a1 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 9 May 2014 12:07:08 +0200 Subject: [PATCH 08/20] Renaming image widget files to appropriate name --- src/gwin/{gimage.c => imagebox.c} | 0 src/gwin/{image.h => imagebox.h} | 0 src/gwin/sys_defs.h | 2 +- src/gwin/sys_make.mk | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename src/gwin/{gimage.c => imagebox.c} (100%) rename src/gwin/{image.h => imagebox.h} (100%) diff --git a/src/gwin/gimage.c b/src/gwin/imagebox.c similarity index 100% rename from src/gwin/gimage.c rename to src/gwin/imagebox.c diff --git a/src/gwin/image.h b/src/gwin/imagebox.h similarity index 100% rename from src/gwin/image.h rename to src/gwin/imagebox.h diff --git a/src/gwin/sys_defs.h b/src/gwin/sys_defs.h index f4e1c2f7..53ed016b 100644 --- a/src/gwin/sys_defs.h +++ b/src/gwin/sys_defs.h @@ -874,7 +874,7 @@ extern "C" { #endif #if GWIN_NEED_IMAGE || defined(__DOXYGEN__) - #include "src/gwin/image.h" + #include "src/gwin/imagebox.h" #endif #endif /* GFX_USE_GWIN */ diff --git a/src/gwin/sys_make.mk b/src/gwin/sys_make.mk index 4c670ea2..1e2404e6 100644 --- a/src/gwin/sys_make.mk +++ b/src/gwin/sys_make.mk @@ -6,7 +6,7 @@ GFXSRC += $(GFXLIB)/src/gwin/gwin.c \ $(GFXLIB)/src/gwin/button.c \ $(GFXLIB)/src/gwin/slider.c \ $(GFXLIB)/src/gwin/checkbox.c \ - $(GFXLIB)/src/gwin/gimage.c \ + $(GFXLIB)/src/gwin/imagebox.c \ $(GFXLIB)/src/gwin/label.c \ $(GFXLIB)/src/gwin/radio.c \ $(GFXLIB)/src/gwin/list.c \ From ec09292542874ee8290f460413afef0adf789039 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Fri, 9 May 2014 12:20:32 +0200 Subject: [PATCH 09/20] Revert "Renaming image widget files to appropriate name" This reverts commit 82a3f8491f6ec3b6bbb161167fc435acbfacc3a1. --- src/gwin/{imagebox.c => gimage.c} | 0 src/gwin/{imagebox.h => image.h} | 0 src/gwin/sys_defs.h | 2 +- src/gwin/sys_make.mk | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename src/gwin/{imagebox.c => gimage.c} (100%) rename src/gwin/{imagebox.h => image.h} (100%) diff --git a/src/gwin/imagebox.c b/src/gwin/gimage.c similarity index 100% rename from src/gwin/imagebox.c rename to src/gwin/gimage.c diff --git a/src/gwin/imagebox.h b/src/gwin/image.h similarity index 100% rename from src/gwin/imagebox.h rename to src/gwin/image.h diff --git a/src/gwin/sys_defs.h b/src/gwin/sys_defs.h index 53ed016b..f4e1c2f7 100644 --- a/src/gwin/sys_defs.h +++ b/src/gwin/sys_defs.h @@ -874,7 +874,7 @@ extern "C" { #endif #if GWIN_NEED_IMAGE || defined(__DOXYGEN__) - #include "src/gwin/imagebox.h" + #include "src/gwin/image.h" #endif #endif /* GFX_USE_GWIN */ diff --git a/src/gwin/sys_make.mk b/src/gwin/sys_make.mk index 1e2404e6..4c670ea2 100644 --- a/src/gwin/sys_make.mk +++ b/src/gwin/sys_make.mk @@ -6,7 +6,7 @@ GFXSRC += $(GFXLIB)/src/gwin/gwin.c \ $(GFXLIB)/src/gwin/button.c \ $(GFXLIB)/src/gwin/slider.c \ $(GFXLIB)/src/gwin/checkbox.c \ - $(GFXLIB)/src/gwin/imagebox.c \ + $(GFXLIB)/src/gwin/gimage.c \ $(GFXLIB)/src/gwin/label.c \ $(GFXLIB)/src/gwin/radio.c \ $(GFXLIB)/src/gwin/list.c \ From ca1a83abca9ecc159ff6f0d9e27ab133fb947997 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:17:22 +1000 Subject: [PATCH 10/20] Use the more generic file mask for gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5611e0ab..b16e2726 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,9 @@ build .dep .cproject .project +*.sublime* *.stackdump *.lst *.o *.map -*.sublime-* src/gdisp/fonts/*.dat From 9e8b38ba943b339b966b1011bab899720d6305fc Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:25:31 +1000 Subject: [PATCH 11/20] Add gwinClearInit() and gwinWidgetClearInit() to clear gwin initialisation structures. Incorporate into demo's --- demos/modules/gadc/main.c | 4 ++++ demos/modules/gaudio/oscilloscope/main.c | 1 + demos/modules/gwin/basic/main.c | 1 + demos/modules/gwin/button/main.c | 4 +--- demos/modules/gwin/checkbox/main.c | 4 +--- demos/modules/gwin/console/main.c | 1 + demos/modules/gwin/graph/main.c | 1 + demos/modules/gwin/list/main.c | 4 +--- demos/modules/gwin/progressbar/main.c | 4 +--- demos/modules/gwin/radio/main.c | 4 +--- demos/modules/gwin/slider/main.c | 4 +--- demos/modules/gwin/widgets/main.c | 2 +- src/gwin/gwidget.c | 8 ++++++++ src/gwin/gwidget.h | 16 ++++++++++++++++ src/gwin/gwin.c | 8 ++++++++ src/gwin/sys_defs.h | 18 +++++++++++++++++- tools/touch_driver_test/main.c | 1 + 17 files changed, 65 insertions(+), 20 deletions(-) diff --git a/demos/modules/gadc/main.c b/demos/modules/gadc/main.c index 7db14c82..ae508278 100644 --- a/demos/modules/gadc/main.c +++ b/demos/modules/gadc/main.c @@ -152,6 +152,8 @@ int main(void) { gwinSetDefaultFont(font); { GWindowInit wi; + + gwinClearInit(&wi); wi.show = TRUE; wi.x = wi.y = 0; wi.width = swidth-SCOPE_CX; @@ -184,6 +186,8 @@ int main(void) { /* Set up the scope window in the top right on the screen */ { GWindowInit wi; + + gwinClearInit(&wi); wi.show = TRUE; wi.x = swidth-SCOPE_CX; wi.y = 0; diff --git a/demos/modules/gaudio/oscilloscope/main.c b/demos/modules/gaudio/oscilloscope/main.c index 3636e8f9..b544016e 100644 --- a/demos/modules/gaudio/oscilloscope/main.c +++ b/demos/modules/gaudio/oscilloscope/main.c @@ -73,6 +73,7 @@ int main(void) { { GWindowInit wi; + gwinClearInit(&wi); wi.show = TRUE; wi.x = wi.y = 0; wi.width = swidth; wi.height = sheight; diff --git a/demos/modules/gwin/basic/main.c b/demos/modules/gwin/basic/main.c index 4d8fa33c..fca150c9 100644 --- a/demos/modules/gwin/basic/main.c +++ b/demos/modules/gwin/basic/main.c @@ -43,6 +43,7 @@ int main(void) { { GWindowInit wi; + gwinClearInit(&wi); wi.show = TRUE; wi.x = 20; wi.y = 10; wi.width = 200; wi.height = 150; GW1 = gwinWindowCreate(0, &wi); wi.show = TRUE; wi.x = 50; wi.y = 190; wi.width = 150; wi.height = 100; diff --git a/demos/modules/gwin/button/main.c b/demos/modules/gwin/button/main.c index 6349ca09..156e929e 100644 --- a/demos/modules/gwin/button/main.c +++ b/demos/modules/gwin/button/main.c @@ -36,9 +36,7 @@ static void createWidgets(void) { GWidgetInit wi; // Apply some default values for GWIN - wi.customDraw = 0; - wi.customParam = 0; - wi.customStyle = 0; + gwinWidgetClearInit(&wi); wi.g.show = TRUE; // Apply the button parameters diff --git a/demos/modules/gwin/checkbox/main.c b/demos/modules/gwin/checkbox/main.c index b6cef40b..2a2df2fb 100644 --- a/demos/modules/gwin/checkbox/main.c +++ b/demos/modules/gwin/checkbox/main.c @@ -36,9 +36,7 @@ static void createWidgets(void) { GWidgetInit wi; // Apply some default values for GWIN - wi.customDraw = 0; - wi.customParam = 0; - wi.customStyle = 0; + gwinWidgetClearInit(&wi); wi.g.show = TRUE; // Apply the checkbox parameters diff --git a/demos/modules/gwin/console/main.c b/demos/modules/gwin/console/main.c index 14f68cd4..0e9000b5 100644 --- a/demos/modules/gwin/console/main.c +++ b/demos/modules/gwin/console/main.c @@ -48,6 +48,7 @@ int main(void) { { GWindowInit wi; + gwinClearInit(&wi); wi.show = TRUE; wi.x = 0; wi.y = 0; wi.width = gdispGetWidth(); wi.height = gdispGetHeight()/2; GW1 = gwinConsoleCreate(0, &wi); diff --git a/demos/modules/gwin/graph/main.c b/demos/modules/gwin/graph/main.c index 4dd67ae8..7a496fae 100644 --- a/demos/modules/gwin/graph/main.c +++ b/demos/modules/gwin/graph/main.c @@ -69,6 +69,7 @@ int main(void) { { GWindowInit wi; + gwinClearInit(&wi); wi.show = TRUE; wi.x = wi.y = 0; wi.width = gdispGetWidth(); diff --git a/demos/modules/gwin/list/main.c b/demos/modules/gwin/list/main.c index 3811c36f..6d469626 100644 --- a/demos/modules/gwin/list/main.c +++ b/demos/modules/gwin/list/main.c @@ -37,9 +37,7 @@ static void createWidgets(void) { GWidgetInit wi; // Apply some default values for GWIN - wi.customDraw = 0; - wi.customParam = 0; - wi.customStyle = 0; + gwinWidgetClearInit(&wi); wi.g.show = TRUE; // Create the label for the first list diff --git a/demos/modules/gwin/progressbar/main.c b/demos/modules/gwin/progressbar/main.c index 960a3293..6fb53c2e 100644 --- a/demos/modules/gwin/progressbar/main.c +++ b/demos/modules/gwin/progressbar/main.c @@ -5,9 +5,7 @@ GHandle ghProgressbar; static void _createWidget(void) { GWidgetInit wi; - wi.customDraw = 0; - wi.customParam = 0; - wi.customStyle = 0; + gwinWidgetClearInit(&wi); wi.g.show = TRUE; wi.g.y = 10; wi.g.x = 10; wi.g.width = 200; wi.g.height = 20; wi.text = "Progress 1"; diff --git a/demos/modules/gwin/radio/main.c b/demos/modules/gwin/radio/main.c index a3c493c3..60bf206f 100644 --- a/demos/modules/gwin/radio/main.c +++ b/demos/modules/gwin/radio/main.c @@ -40,9 +40,7 @@ static void createWidgets(void) { GWidgetInit wi; // Apply some default values for GWIN - wi.customDraw = 0; - wi.customParam = 0; - wi.customStyle = 0; + gwinWidgetClearInit(&wi); wi.g.show = TRUE; // create Radio11 diff --git a/demos/modules/gwin/slider/main.c b/demos/modules/gwin/slider/main.c index 0897f1f3..475f68cf 100644 --- a/demos/modules/gwin/slider/main.c +++ b/demos/modules/gwin/slider/main.c @@ -36,9 +36,7 @@ static void createWidgets(void) { GWidgetInit wi; // Apply some default values for GWIN - wi.customDraw = 0; - wi.customParam = 0; - wi.customStyle = 0; + gwinWidgetClearInit(&wi); wi.g.show = TRUE; // create Slider1 diff --git a/demos/modules/gwin/widgets/main.c b/demos/modules/gwin/widgets/main.c index 17f87d46..9742a027 100644 --- a/demos/modules/gwin/widgets/main.c +++ b/demos/modules/gwin/widgets/main.c @@ -113,7 +113,7 @@ static gdispImage imgYesNo; static void createWidgets(void) { GWidgetInit wi; - wi.customDraw = 0; wi.customParam = 0; wi.customStyle = 0; + gwinWidgetClearInit(&wi); // Create the Tabs wi.g.show = TRUE; wi.customDraw = gwinRadioDraw_Tab; diff --git a/src/gwin/gwidget.c b/src/gwin/gwidget.c index 181b7425..c46520ea 100644 --- a/src/gwin/gwidget.c +++ b/src/gwin/gwidget.c @@ -297,6 +297,14 @@ void _gwidgetRedraw(GHandle gh) { gw->fnDraw(gw, gw->fnParam); } +void gwinWidgetClearInit(GWidgetInit *pwi) { + char *p; + unsigned len; + + for(p = (char *)pwi, len = sizeof(GWidgetInit); len; len--) + *p++ = 0; +} + void gwinSetDefaultStyle(const GWidgetStyle *pstyle, bool_t updateAll) { if (!pstyle) pstyle = &BlackWidgetStyle; diff --git a/src/gwin/gwidget.h b/src/gwin/gwidget.h index 96832fe3..8373e2d0 100644 --- a/src/gwin/gwidget.h +++ b/src/gwin/gwidget.h @@ -78,6 +78,10 @@ typedef void (*CustomWidgetDrawFunction)(struct GWidgetObject *gw, void *param); * @brief The structure to initialise a widget. * * @note Some widgets may have extra parameters. + * @note If you create this structure on the stack, you should always memset + * it to all zero's first in case a future version of the software + * add's extra fields. Alternatively you can use @p gwinWidgetClearInit() + * to clear it. * @note The text element must be static string (not stack allocated). If you want to use * a dynamic string (eg a stack allocated string) use NULL for this member and then call * @p gwinSetText() with useAlloc set to TRUE. @@ -126,6 +130,18 @@ typedef struct GWidgetObject { extern "C" { #endif +/** + * @brief Clear a GWidgetInit structure to all zero's + * @note This function is provided just to prevent problems + * on operating systems where using memset() causes issues + * in the users application. + * + * @param[in] pwi The GWidgetInit structure to clear + * + * @api + */ +void gwinWidgetClearInit(GWidgetInit *pwi); + /** * @brief Set the default style for widgets created hereafter. * diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c index 54f42077..93c17f3a 100644 --- a/src/gwin/gwin.c +++ b/src/gwin/gwin.c @@ -149,6 +149,14 @@ GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit * Routines that affect all windows *-----------------------------------------------*/ +void gwinClearInit(GWindowInit *pwi) { + char *p; + unsigned len; + + for(p = (char *)pwi, len = sizeof(GWindowInit); len; len--) + *p++ = 0; +} + void gwinSetDefaultColor(color_t clr) { defaultFgColor = clr; } diff --git a/src/gwin/sys_defs.h b/src/gwin/sys_defs.h index f4e1c2f7..fa5084a3 100644 --- a/src/gwin/sys_defs.h +++ b/src/gwin/sys_defs.h @@ -34,7 +34,7 @@ */ typedef struct GWindowObject { #if GWIN_NEED_WINDOWMANAGER - // This MUST be the first member of the struct + // This MUST be the first member of the structure gfxQueueASyncItem wmq; // @< The next window (for the window manager) #endif const struct gwinVMT *vmt; // @< The VMT for this GWIN @@ -54,6 +54,10 @@ typedef struct GWindowObject { * * @note Some gwin's will need extra parameters. * @note The dimensions and position may be changed to fit on the real screen. + * @note If you create this structure on the stack, you should always memset + * it to all zero's first in case a future version of the software + * add's extra fields. Alternatively you can use @p gwinClearInit() + * to clear it. * * @{ */ @@ -102,6 +106,18 @@ extern "C" { * Functions that affect all windows *-------------------------------------------------*/ + /** + * @brief Clear a GWindowInit structure to all zero's + * @note This function is provided just to prevent problems + * on operating systems where using memset() causes issues + * in the users application. + * + * @param[in] pwi The GWindowInit structure to clear + * + * @api + */ + void gwinClearInit(GWindowInit *pwi); + /** * @brief Set the default foreground color for all new GWIN windows * diff --git a/tools/touch_driver_test/main.c b/tools/touch_driver_test/main.c index adfafa0f..a8318edd 100644 --- a/tools/touch_driver_test/main.c +++ b/tools/touch_driver_test/main.c @@ -66,6 +66,7 @@ int main(void) { { GWindowInit wi; + gwinClearInit(&wi); wi.show = TRUE; wi.x = 0; wi.y = bHeight; wi.width = swidth; wi.height = sheight-bHeight; ghc = gwinConsoleCreate(&gc, &wi); } From 7c2b2555f879264ccece4afe688e85bd2201baff Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:26:42 +1000 Subject: [PATCH 12/20] Remove superfluous entries in gfxconf.example.h --- gfxconf.example.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/gfxconf.example.h b/gfxconf.example.h index 8881208c..113b05d5 100644 --- a/gfxconf.example.h +++ b/gfxconf.example.h @@ -135,7 +135,6 @@ #define GWIN_NEED_GRAPH FALSE #define GWIN_NEED_WIDGET FALSE - #define GWIN_NEED_HIERARCHY FALSE #define GWIN_NEED_LABEL FALSE #define GWIN_LABEL_ATTRIBUTE FALSE #define GWIN_NEED_BUTTON FALSE @@ -149,7 +148,6 @@ #define GWIN_NEED_LIST_IMAGES FALSE #define GWIN_NEED_PROGRESSBAR FALSE #define GWIN_PROGRESSBAR_AUTO FALSE - #define GWIN_NEED_FRAME FALSE #define GWIN_FLAT_STYLING FALSE From cf5867b33d76d775782412d74733d221136af556 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:30:00 +1000 Subject: [PATCH 13/20] New gdispImageInit() call to initialise a gdispImage structure Use in gwinImage --- src/gdisp/image.c | 4 ++++ src/gdisp/image.h | 8 ++++++++ src/gwin/gimage.c | 3 +-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/gdisp/image.c b/src/gdisp/image.c index 5a743905..e2b7d758 100644 --- a/src/gdisp/image.c +++ b/src/gdisp/image.c @@ -130,6 +130,10 @@ gdispImageError } #endif +void gdispImageInit(gdispImage *img) { + img->type = GDISP_IMAGE_TYPE_UNKNOWN; +} + gdispImageError gdispImageOpenGFile(gdispImage *img, GFILE *f) { gdispImageError err; diff --git a/src/gdisp/image.h b/src/gdisp/image.h index 1bf378f1..76e8bdea 100644 --- a/src/gdisp/image.h +++ b/src/gdisp/image.h @@ -130,6 +130,14 @@ extern "C" { #define gdispImageSetSimulFileReader(img, fname) gdispImageSetFileReader(img, fname) #endif + /** + * @brief Initialise a gdispImage object + * + * @param[in] img The image structure to initialise + * + */ + void gdispImageInit(gdispImage *img); + /** * @brief Open an image using an open GFILE and get it ready for drawing * @details Determine the image format and get ready to decode the first image frame diff --git a/src/gwin/gimage.c b/src/gwin/gimage.c index 44ba785a..07d27dd0 100644 --- a/src/gwin/gimage.c +++ b/src/gwin/gimage.c @@ -127,8 +127,7 @@ GHandle gwinGImageCreate(GDisplay *g, GImageObject *gobj, GWindowInit *pInit) { return 0; // Ensure the gdispImageIsOpen() gives valid results - gobj->image.type = 0; - gobj->image.fns = 0; + gdispImageInit(&gobj->image); // Initialise the timer #if GWIN_NEED_IMAGE_ANIMATION From c475d69a9cbf8d2796904140dbf0f2d9d1d1220f Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:31:16 +1000 Subject: [PATCH 14/20] New gqueue calls to allow inserting an object into the queue at an arbitrary location. --- src/gqueue/gqueue.c | 75 +++++++++++++++++++++++++++++++++++++++++++ src/gqueue/sys_defs.h | 25 +++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/src/gqueue/gqueue.c b/src/gqueue/gqueue.c index 8540bcea..45ca6fce 100644 --- a/src/gqueue/gqueue.c +++ b/src/gqueue/gqueue.c @@ -87,6 +87,30 @@ void _gqueueDeinit(void) pqueue->tail = pitem; } + void gfxQueueASyncInsert(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQueueASyncItem *pafter) { + gfxSystemLock(); + gfxQueueASyncInsertI(pqueue, pitem, pafter); + gfxSystemUnlock(); + } + void gfxQueueASyncInsertI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQueueASyncItem *pafter) { + if (!pitem) return; // Safety + + if (pafter && gfxQueueASyncIsInI(pqueue, pafter)) { + pitem->next = pafter->next; + pafter->next = pitem; + if (pqueue->tail == pafter) + pqueue->tail = pitem; + } else { + pitem->next = 0; + if (!pqueue->head) { + pqueue->head = pqueue->tail = pitem; + } else { + pqueue->tail->next = pitem; + pqueue->tail = pitem; + } + } + } + void gfxQueueASyncRemove(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem) { gfxSystemLock(); gfxQueueASyncRemoveI(pqueue, pitem); @@ -201,6 +225,30 @@ void _gqueueDeinit(void) gfxSemSignalI(&pqueue->sem); } + void gfxQueueGSyncInsert(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem, gfxQueueASyncItem *pafter) { + gfxSystemLock(); + gfxQueueGSyncInsertI(pqueue, pitem, pafter); + gfxSystemUnlock(); + } + void gfxQueueGSyncInsertI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem, gfxQueueASyncItem *pafter) { + if (!pitem) return; // Safety + + if (pafter && gfxQueueGSyncIsInI(pqueue, pafter)) { + pitem->next = pafter->next; + pafter->next = pitem; + if (pqueue->tail == pafter) + pqueue->tail = pitem; + } else { + pitem->next = 0; + if (!pqueue->head) { + pqueue->head = pqueue->tail = pitem; + } else { + pqueue->tail->next = pitem; + pqueue->tail = pitem; + } + } + } + void gfxQueueGSyncRemove(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem) { gfxSystemLock(); gfxQueueGSyncRemoveI(pqueue, pitem); @@ -312,6 +360,33 @@ void _gqueueDeinit(void) return gfxSemWait(&pitem->sem, ms); } + bool_t gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, delaytime_t ms) { + if (!pitem) return; // Safety + gfxSemInit(&pitem->sem, 0, 1); + + gfxSystemLock(); + if (pafter && gfxQueueGSyncIsInI(pqueue, pafter)) { + pitem->next = pafter->next; + pafter->next = pitem; + if (pqueue->tail == pafter) + pqueue->tail = pitem; + } else { + pitem->next = 0; + if (!pqueue->head) { + pqueue->head = pqueue->tail = pitem; + } else { + pqueue->tail->next = pitem; + pqueue->tail = pitem; + } + } + gfxSystemUnlock(); + + gfxSemSignal(&pqueue->sem); + + return gfxSemWait(&pitem->sem, ms); + + } + void gfxQueueFSyncRemove(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem) { gfxQueueFSyncItem *pi; diff --git a/src/gqueue/sys_defs.h b/src/gqueue/sys_defs.h index b97f2f4d..d0e46be1 100644 --- a/src/gqueue/sys_defs.h +++ b/src/gqueue/sys_defs.h @@ -198,6 +198,31 @@ void gfxQueueGSyncPushI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem); bool_t gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms); /* @} */ +/** + * @brief Insert an item on the queue after the specified item. + * @return none for ASync and GSync queues; For FSync queues - FALSE on timeout, otherwise TRUE + * + * @param[in] pqueue A pointer to the queue + * @param[in] pitem A pointer to the queue item + * @param[in] pafter A pointer to the queue item this new item must be inserted after. If NULL or + * pafter can't be found in the queue, it puts the new item at the end of the queue. + * @param[in] ms The maxmimum time to wait for an item to be removed from the queue (only for FSync queues) + * + * @note FSync: Use a delay time of TIME_IMMEDIATE if you don't want to wait until the + * item is removed from the queue. Note that even if the timeout occurs - the item + * remains in the queue. + * @note The routines ending in "I" are interrupt/system/iclass level routines. + * + * @api + * @{ + */ +void gfxQueueASyncInsert(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQueueASyncItem *pafter); +void gfxQueueASyncInsertI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQueueASyncItem *pafter); +void gfxQueueGSyncInsert(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem, gfxQueueASyncItem *pafter); +void gfxQueueGSyncInsertI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem, gfxQueueASyncItem *pafter); +bool_t gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, delaytime_t ms); +/* @} */ + /** * @brief Remove an item from the queue. * @note Removes the specified item from the queue where-ever it is in the queue From 6d2c8f0f509f2e66d4fea444ce220550a0df6da5 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:32:29 +1000 Subject: [PATCH 15/20] GWIN creation and destruction bug fixes --- src/gwin/class_gwin.h | 2 +- src/gwin/gwin.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gwin/class_gwin.h b/src/gwin/class_gwin.h index 49fc6084..50dd480e 100644 --- a/src/gwin/class_gwin.h +++ b/src/gwin/class_gwin.h @@ -170,7 +170,7 @@ extern "C" { * * @notapi */ -GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit, const gwinVMT *vmt, uint16_t flags); +GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit, const gwinVMT *vmt, uint32_t flags); #if GWIN_NEED_WIDGET || defined(__DOXYGEN__) /** diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c index 93c17f3a..84443f9f 100644 --- a/src/gwin/gwin.c +++ b/src/gwin/gwin.c @@ -114,7 +114,7 @@ void _gwinDeinit(void) // Internal routine for use by GWIN components only // Initialise a window creating it dynamically if required. -GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit, const gwinVMT *vmt, uint16_t flags) { +GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit, const gwinVMT *vmt, uint32_t flags) { // Allocate the structure if necessary if (!pgw) { if (!(pgw = gfxAlloc(vmt->size))) @@ -197,6 +197,9 @@ GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pI } void gwinDestroy(GHandle gh) { + if (!gh) + return; + // Make the window invisible gwinSetVisible(gh, FALSE); From 0f109512fde45684fe36e84101a84f7280b28394 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:33:33 +1000 Subject: [PATCH 16/20] gwinImage animated gif bug fix --- src/gwin/gimage.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gwin/gimage.c b/src/gwin/gimage.c index 07d27dd0..9d6363ba 100644 --- a/src/gwin/gimage.c +++ b/src/gwin/gimage.c @@ -26,10 +26,20 @@ static void _destroy(GWindowObject *gh) { #if GWIN_NEED_IMAGE_ANIMATION static void _redraw(GHandle gh); - static void _timer(void *gh) { + static void _timer(void *param) { + #define gh ((GHandle)param) + // We need to re-test the visibility in case it has been made invisible since the last frame. - if ((((GHandle)gh)->flags & GWIN_FLG_VISIBLE)) - _redraw((GHandle)gh); + if ((gh->flags & GWIN_FLG_VISIBLE)) { + // Setting the clip here shouldn't be necessary if the redraw doesn't overdraw + // but we put it in for safety anyway + #if GDISP_NEED_CLIP + gdispGSetClip(gh->display, gh->x, gh->y, gh->width, gh->height); + #endif + _redraw(gh); + } + + #undef gh } #endif From de5a9837773ebeadaae90b3bdf32df190f4192d8 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:34:12 +1000 Subject: [PATCH 17/20] GWIN window manager comment updates --- src/gwin/gwm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gwin/gwm.c b/src/gwin/gwm.c index 9c158f68..3140b03f 100644 --- a/src/gwin/gwm.c +++ b/src/gwin/gwm.c @@ -127,7 +127,7 @@ void gwinRedrawDisplay(GDisplay *g, bool_t preserve) { } /*----------------------------------------------- - * Window Manager Routines + * "Null" Window Manager Routines *-----------------------------------------------*/ static void WM_Init(void) { @@ -145,9 +145,9 @@ static void WM_DeInit(void) { } static bool_t WM_Add(GHandle gh, const GWindowInit *pInit) { - // Note the window will not be marked as visible yet + // Note the window will not currently be marked as visible - // Put it on the queue + // Put it on the end of the queue gfxQueueASyncPut(&_GWINList, &gh->wmq); // Make sure the size is valid @@ -156,7 +156,7 @@ static bool_t WM_Add(GHandle gh, const GWindowInit *pInit) { } static void WM_Delete(GHandle gh) { - // Remove it from the queue + // Remove it from the window list gfxQueueASyncRemove(&_GWINList, &gh->wmq); } From 28f10aaa3a67a288a051c841866f6c68a90e880f Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:35:30 +1000 Subject: [PATCH 18/20] Rename GWIN image header file to be consistent with all other controls and with its source file --- src/gwin/{image.h => gimage.h} | 0 src/gwin/sys_defs.h | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/gwin/{image.h => gimage.h} (100%) diff --git a/src/gwin/image.h b/src/gwin/gimage.h similarity index 100% rename from src/gwin/image.h rename to src/gwin/gimage.h diff --git a/src/gwin/sys_defs.h b/src/gwin/sys_defs.h index fa5084a3..c632b069 100644 --- a/src/gwin/sys_defs.h +++ b/src/gwin/sys_defs.h @@ -890,7 +890,7 @@ extern "C" { #endif #if GWIN_NEED_IMAGE || defined(__DOXYGEN__) - #include "src/gwin/image.h" + #include "src/gwin/gimage.h" #endif #endif /* GFX_USE_GWIN */ From f9b6b1697da42673ffe466edf9945ece0996ec1a Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:36:14 +1000 Subject: [PATCH 19/20] GWIN label bug fix and simplification --- src/gwin/label.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/gwin/label.c b/src/gwin/label.c index 8960300b..2aa0c860 100644 --- a/src/gwin/label.c +++ b/src/gwin/label.c @@ -138,6 +138,7 @@ void gwinLabelSetBorder(GHandle gh, bool_t border) { static void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) { coord_t w, h; + color_t c; (void) param; // is it a valid handle? @@ -146,6 +147,7 @@ static void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) { w = (gw->g.flags & GLABEL_FLG_WAUTO) ? getwidth(gw->text, gw->g.font, gdispGGetWidth(gw->g.display) - gw->g.x) : gw->g.width; h = (gw->g.flags & GLABEL_FLG_HAUTO) ? getheight(gw->text, gw->g.font, gdispGGetWidth(gw->g.display) - gw->g.x) : gw->g.height; + c = (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text; if (gw->g.width != w || gw->g.height != h) { gwinResize(&gw->g, w, h); @@ -154,29 +156,18 @@ static void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) { } #if GWIN_LABEL_ATTRIBUTE - if (gw2obj->attr != 0) { - gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw2obj->attr, gw->g.font, - (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background, - justifyLeft); - - gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font, - (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background, - justifyLeft); - } else { - gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font, - (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background, - justifyLeft); - - } + if (gw2obj->attr) { + gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw2obj->tab, h, gw2obj->attr, gw->g.font, c, gw->pstyle->background, justifyLeft); + gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, w-gw2obj->tab, h, gw->text, gw->g.font, c, gw->pstyle->background, justifyLeft); + } else + gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, justifyLeft); #else - gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font, - (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background, - justifyLeft); + gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, justifyLeft); #endif // render the border (if any) if (gw->g.flags & GLABEL_FLG_BORDER) - gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge); + gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, w, h, (gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge); } #endif // GFX_USE_GWIN && GFX_NEED_LABEL From 1478fdf41e3731cafacd22ff6f530fb724c02df3 Mon Sep 17 00:00:00 2001 From: inmarket Date: Fri, 9 May 2014 21:37:06 +1000 Subject: [PATCH 20/20] Re-order GWIN sys_rules to simplify ready for new functionality. --- src/gwin/sys_rules.h | 53 +++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/src/gwin/sys_rules.h b/src/gwin/sys_rules.h index 30dac1bb..f9f00a48 100644 --- a/src/gwin/sys_rules.h +++ b/src/gwin/sys_rules.h @@ -17,6 +17,7 @@ #define _GWIN_RULES_H #if GFX_USE_GWIN + // Sub-system rules #if !GFX_USE_GDISP #error "GWIN: GFX_USE_GDISP must be TRUE when using GWIN" #endif @@ -25,33 +26,20 @@ #warning "GWIN: Drawing can occur outside the defined windows as GDISP_NEED_CLIP is FALSE" #endif #endif - #if GWIN_NEED_IMAGE - #if !GDISP_NEED_IMAGE - #error "GWIN: GDISP_NEED_IMAGE is required when GWIN_NEED_IMAGE is TRUE." - #endif - #endif - #if GWIN_NEED_RADIO - #if !GDISP_NEED_CIRCLE - #if GFX_DISPLAY_RULE_WARNINGS - #warning "GWIN: GDISP_NEED_CIRCLE should be set to TRUE for much nicer radio button widgets." - #endif - #endif - #endif + + // Objects require their super-class #if GWIN_NEED_BUTTON || GWIN_NEED_SLIDER || GWIN_NEED_CHECKBOX || GWIN_NEED_LABEL || GWIN_NEED_RADIO || GWIN_NEED_LIST || \ GWIN_NEED_IMAGE || GWIN_NEED_CHECKBOX || GWIN_NEED_PROGRESSBAR #if !GWIN_NEED_WIDGET #if GFX_DISPLAY_RULE_WARNINGS - #warning "GWIN: GWIN_NEED_WIDGET is required when a Widget is used. It has been turned on for you." + #warning "GWIN: GWIN_NEED_WIDGET is required when a widget is used. It has been turned on for you." #endif #undef GWIN_NEED_WIDGET #define GWIN_NEED_WIDGET TRUE #endif #endif - #if GWIN_NEED_LIST - #if !GDISP_NEED_TEXT - #error "GWIN: GDISP_NEED_TEXT is required when GWIN_NEED_LIST is TRUE." - #endif - #endif + + // Rules for the super-classes #if GWIN_NEED_WIDGET #if !GDISP_NEED_TEXT #error "GWIN: GDISP_NEED_TEXT is required if GWIN_NEED_WIDGET is TRUE." @@ -86,16 +74,35 @@ #define GQUEUE_NEED_ASYNC TRUE #endif #endif + + // Rules for individual objects + #if GWIN_NEED_LIST + #if !GDISP_NEED_TEXT + #error "GWIN: GDISP_NEED_TEXT is required when GWIN_NEED_LIST is TRUE." + #endif + #endif + #if GWIN_NEED_RADIO + #if !GDISP_NEED_CIRCLE + #if GFX_DISPLAY_RULE_WARNINGS + #warning "GWIN: GDISP_NEED_CIRCLE should be set to TRUE for much nicer radio button widgets." + #endif + #endif + #endif + #if GWIN_NEED_IMAGE + #if !GDISP_NEED_IMAGE + #error "GWIN: GDISP_NEED_IMAGE is required when GWIN_NEED_IMAGE is TRUE." + #endif + #endif #if GWIN_NEED_CONSOLE #if !GDISP_NEED_TEXT #error "GWIN: GDISP_NEED_TEXT is required if GWIN_NEED_CONSOLE is TRUE." #endif #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." + #if GWIN_NEED_PROGRESSBAR + #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