diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-02-19 08:00:52 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-02-19 08:00:52 +1000 |
commit | b82448c3e23663a25a423402343fbca78253b80c (patch) | |
tree | 57a03e35b88f6e434b6c4d084695fc5ce1061932 /demos/modules/gwin/button | |
parent | dcedf414136e55e6dacbe736babe748e1374e19e (diff) | |
parent | 37966ff16d923bbca53c9464815cb49cbd7fc3be (diff) | |
download | uGFX-b82448c3e23663a25a423402343fbca78253b80c.tar.gz uGFX-b82448c3e23663a25a423402343fbca78253b80c.tar.bz2 uGFX-b82448c3e23663a25a423402343fbca78253b80c.zip |
Merge branch 'master' into gwin
Diffstat (limited to 'demos/modules/gwin/button')
-rw-r--r-- | demos/modules/gwin/button/demo.mk | 3 | ||||
-rw-r--r-- | demos/modules/gwin/button/gfxconf.h | 1 | ||||
-rw-r--r-- | demos/modules/gwin/button/main.c | 16 |
3 files changed, 19 insertions, 1 deletions
diff --git a/demos/modules/gwin/button/demo.mk b/demos/modules/gwin/button/demo.mk new file mode 100644 index 00000000..5b8cd2a5 --- /dev/null +++ b/demos/modules/gwin/button/demo.mk @@ -0,0 +1,3 @@ +DEMODIR = $(GFXLIB)/demos/modules/gwin/button +GFXINC += $(DEMODIR) +GFXSRC += $(DEMODIR)/main.c diff --git a/demos/modules/gwin/button/gfxconf.h b/demos/modules/gwin/button/gfxconf.h index 5376bd52..eba3f4ef 100644 --- a/demos/modules/gwin/button/gfxconf.h +++ b/demos/modules/gwin/button/gfxconf.h @@ -48,6 +48,7 @@ #define GDISP_NEED_CLIP TRUE #define GDISP_NEED_CIRCLE TRUE #define GDISP_NEED_TEXT TRUE +#define GDISP_NEED_CONTROL TRUE /* GDISP fonts to include */ #define GDISP_INCLUDE_FONT_UI2 TRUE diff --git a/demos/modules/gwin/button/main.c b/demos/modules/gwin/button/main.c index 6ec8a287..6349ca09 100644 --- a/demos/modules/gwin/button/main.c +++ b/demos/modules/gwin/button/main.c @@ -54,10 +54,16 @@ static void createWidgets(void) { int main(void) { GEvent* pe; + static const orientation_t orients[] = { GDISP_ROTATE_0, GDISP_ROTATE_90, GDISP_ROTATE_180, GDISP_ROTATE_270 }; + unsigned which; // Initialize the display gfxInit(); + // We are currently at GDISP_ROTATE_0 + which = 0; + gdispSetOrientation(orients[which]); + // Set the widget defaults gwinSetDefaultFont(gdispOpenFont("UI2")); gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE); @@ -81,7 +87,15 @@ int main(void) { case GEVENT_GWIN_BUTTON: if (((GEventGWinButton*)pe)->button == ghButton1) { // Our button has been pressed - printf("Button clicked\r\n"); + if (++which >= sizeof(orients)/sizeof(orients[0])) + which = 0; + + // Setting the orientation during run-time is a bit naughty particularly with + // GWIN windows. In this case however we know that the button is in the top-left + // corner which should translate safely into any orientation. + gdispSetOrientation(orients[which]); + gdispClear(White); + gwinRedrawDisplay(GDISP, FALSE); } break; |