diff options
author | inmarket <andrewh@inmarket.com.au> | 2013-06-10 17:18:01 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2013-06-10 17:18:01 +1000 |
commit | 2cb35d6815a0a12035f4792c266b688c77085620 (patch) | |
tree | 292ebc4760767d67b41f7f0e0022185afcf05067 /demos | |
parent | 777ec6af7c1b594f7b7a9cbaaf7ead90d8fb7e8f (diff) | |
download | uGFX-2cb35d6815a0a12035f4792c266b688c77085620.tar.gz uGFX-2cb35d6815a0a12035f4792c266b688c77085620.tar.bz2 uGFX-2cb35d6815a0a12035f4792c266b688c77085620.zip |
Clean up GWIN Event assignment. Optimise event efficiency.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/modules/gadc/gwinosc.c | 2 | ||||
-rw-r--r-- | demos/modules/gaudin/gwinosc.c | 2 | ||||
-rw-r--r-- | demos/modules/gwin/widgets/gfxconf.h | 4 | ||||
-rw-r--r-- | demos/modules/gwin/widgets/main.c | 70 |
4 files changed, 34 insertions, 44 deletions
diff --git a/demos/modules/gadc/gwinosc.c b/demos/modules/gadc/gwinosc.c index 88e61334..60a08686 100644 --- a/demos/modules/gadc/gwinosc.c +++ b/demos/modules/gadc/gwinosc.c @@ -47,7 +47,7 @@ GHandle gwinCreateScope(GScopeObject *gs, coord_t x, coord_t y, coord_t cx, coord_t cy, uint32_t physdev, uint32_t frequency) { /* Initialise the base class GWIN */ - if (!(gs = (GScopeObject *)_gwindowInit((GWindowObject *)gs, x, y, cx, cy, sizeof(GScopeObject)))) + if (!(gs = (GScopeObject *)_gwindowCreate((GWindowObject *)gs, x, y, cx, cy, sizeof(GScopeObject)))) return 0; /* Initialise the scope object members and allocate memory for buffers */ diff --git a/demos/modules/gaudin/gwinosc.c b/demos/modules/gaudin/gwinosc.c index e90430d3..975c2c06 100644 --- a/demos/modules/gaudin/gwinosc.c +++ b/demos/modules/gaudin/gwinosc.c @@ -54,7 +54,7 @@ GHandle gwinCreateScope(GScopeObject *gs, coord_t x, coord_t y, coord_t cx, coord_t cy, uint16_t channel, uint32_t frequency) { /* Initialise the base class GWIN */ - if (!(gs = (GScopeObject *)_gwindowInit((GWindowObject *)gs, x, y, cx, cy, sizeof(GScopeObject)))) + if (!(gs = (GScopeObject *)_gwindowCreate((GWindowObject *)gs, x, y, cx, cy, sizeof(GScopeObject)))) return 0; /* Initialise the scope object members and allocate memory for buffers */ diff --git a/demos/modules/gwin/widgets/gfxconf.h b/demos/modules/gwin/widgets/gfxconf.h index b4574149..411d829e 100644 --- a/demos/modules/gwin/widgets/gfxconf.h +++ b/demos/modules/gwin/widgets/gfxconf.h @@ -51,15 +51,17 @@ #define GDISP_NEED_IMAGE_PNG FALSE /* Features for the GWIN sub-system. */ +#define GWIN_NEED_WINDOWMANAGER TRUE #define GWIN_NEED_CONSOLE TRUE #define GWIN_NEED_GRAPH FALSE +#define GWIN_NEED_WIDGET TRUE #define GWIN_NEED_BUTTON TRUE #define GWIN_NEED_SLIDER TRUE #define GWIN_NEED_CHECKBOX TRUE /* Features for the GINPUT sub-system. */ #define GINPUT_NEED_MOUSE TRUE -#define GINPUT_NEED_TOGGLE FALSE +#define GINPUT_NEED_TOGGLE TRUE #define GINPUT_NEED_DIAL FALSE #endif /* _GFXCONF_H */ diff --git a/demos/modules/gwin/widgets/main.c b/demos/modules/gwin/widgets/main.c index 2102d3a2..1c34b9fa 100644 --- a/demos/modules/gwin/widgets/main.c +++ b/demos/modules/gwin/widgets/main.c @@ -49,11 +49,20 @@ int main(void) { gfxInit(); gdispClear(White); - // Set the font and defalt colors + // Set the widget defaults gwinSetDefaultFont(gdispOpenFont("UI2")); gwinSetDefaultColor(Black); gwinSetDefaultBgColor(White); + // We want to listen for widget events + geventListenerInit(&gl); + gwinAttachListener(&gl); + + // Connect the mouse + #if GINPUT_NEED_MOUSE + gwinAttachMouse(0); + #endif + // Create out gwin windows/widgets ghConsole = gwinCreateConsole(NULL, ScrWidth/2+1, ScrHeight/2+1, ScrWidth/2-1, ScrHeight/2-1); ghButton1 = gwinCreateButton(NULL, 0+0*(BUTTON_WIDTH+1), 0, BUTTON_WIDTH, BUTTON_HEIGHT); @@ -84,49 +93,28 @@ int main(void) { gwinSetText(ghCheckbox1, "C1", FALSE); gwinSetText(ghCheckbox2, "C2", FALSE); - // Assign the mouse and dials to the buttons & sliders etc. -#if GINPUT_NEED_MOUSE - gwinAttachMouse(ghButton1, 0); - gwinAttachMouse(ghButton2, 0); - gwinAttachMouse(ghButton3, 0); - gwinAttachMouse(ghButton4, 0); - gwinAttachMouse(ghSlider1, 0); - gwinAttachMouse(ghSlider2, 0); - gwinAttachMouse(ghSlider3, 0); - gwinAttachMouse(ghSlider4, 0); - gwinAttachMouse(ghCheckbox1, 0); - gwinAttachMouse(ghCheckbox2, 0); -#endif -#if GINPUT_NEED_DIAL - gwinAttachSliderDial(ghSlider1, 0); - gwinAttachSliderDial(ghSlider3, 1); -#endif - - // We want to listen for widget events - geventListenerInit(&gl); - gwinAttachListener(ghButton1, &gl, 0); - gwinAttachListener(ghButton2, &gl, 0); - gwinAttachListener(ghButton3, &gl, 0); - gwinAttachListener(ghButton4, &gl, 0); - gwinAttachListener(ghSlider1, &gl, 0); - gwinAttachListener(ghSlider2, &gl, 0); - gwinAttachListener(ghSlider3, &gl, 0); - gwinAttachListener(ghSlider4, &gl, 0); - gwinAttachListener(ghCheckbox1, &gl, 0); - gwinAttachListener(ghCheckbox2, &gl, 0); + // Assign toggles and dials to the buttons & sliders etc. + #if GINPUT_NEED_TOGGLE + gwinAttachToggle(ghButton1, 0, 0); + gwinAttachToggle(ghButton2, 0, 1); + #endif + #if GINPUT_NEED_DIAL + gwinAttachDial(ghSlider1, 0, 0); + gwinAttachDial(ghSlider3, 0, 1); + #endif // Draw everything on the screen gwinClear(ghConsole); - gwinDraw(ghButton1); - gwinDraw(ghButton2); - gwinDraw(ghButton3); - gwinDraw(ghButton4); - gwinDraw(ghSlider1); - gwinDraw(ghSlider2); - gwinDraw(ghSlider3); - gwinDraw(ghSlider4); - gwinDraw(ghCheckbox1); - gwinDraw(ghCheckbox2); + gwinSetVisible(ghButton1, TRUE); + gwinSetVisible(ghButton2, TRUE); + gwinSetVisible(ghButton3, TRUE); + gwinSetVisible(ghButton4, TRUE); + gwinSetVisible(ghSlider1, TRUE); + gwinSetVisible(ghSlider2, TRUE); + gwinSetVisible(ghSlider3, TRUE); + gwinSetVisible(ghSlider4, TRUE); + gwinSetVisible(ghCheckbox1, TRUE); + gwinSetVisible(ghCheckbox2, TRUE); while(1) { // Get an Event |