aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-12-06 15:48:47 +1000
committerinmarket <andrewh@inmarket.com.au>2014-12-06 15:48:47 +1000
commit5bf2b8678a5a58059baffe780d00cd570781cea7 (patch)
tree001a4d387ecfb39b79c1863a643e36966fd39638 /demos
parent4931f39a0d26f53a03834cfdc65d5e365a928652 (diff)
downloaduGFX-5bf2b8678a5a58059baffe780d00cd570781cea7.tar.gz
uGFX-5bf2b8678a5a58059baffe780d00cd570781cea7.tar.bz2
uGFX-5bf2b8678a5a58059baffe780d00cd570781cea7.zip
Extended slider events. Updated the demo to match.
Actually reduced code size :)
Diffstat (limited to 'demos')
-rw-r--r--demos/modules/gwin/slider/gfxconf.h1
-rw-r--r--demos/modules/gwin/slider/main.c33
2 files changed, 27 insertions, 7 deletions
diff --git a/demos/modules/gwin/slider/gfxconf.h b/demos/modules/gwin/slider/gfxconf.h
index fc8d356e..cb9fc1db 100644
--- a/demos/modules/gwin/slider/gfxconf.h
+++ b/demos/modules/gwin/slider/gfxconf.h
@@ -56,6 +56,7 @@
#define GWIN_NEED_WINDOWMANAGER TRUE
#define GWIN_NEED_WIDGET TRUE
#define GWIN_NEED_SLIDER TRUE
+#define GWIN_NEED_CONSOLE TRUE
/* Features for the GINPUT subsystem. */
#define GINPUT_NEED_MOUSE TRUE
diff --git a/demos/modules/gwin/slider/main.c b/demos/modules/gwin/slider/main.c
index bf0aacfc..781447b6 100644
--- a/demos/modules/gwin/slider/main.c
+++ b/demos/modules/gwin/slider/main.c
@@ -30,7 +30,7 @@
#include "gfx.h"
static GListener gl;
-static GHandle ghSlider1, ghSlider2;
+static GHandle ghSlider1, ghSlider2, ghConsole;
static void createWidgets(void) {
GWidgetInit wi;
@@ -40,16 +40,24 @@ static void createWidgets(void) {
wi.g.show = TRUE;
// create Slider1
- wi.g.y = 10; wi.g.x = 10; wi.g.width = 200; wi.g.height = 20; wi.text = "S1";
+ wi.g.y = 10; wi.g.x = 10; wi.g.width = gdispGetWidth()-20; wi.g.height = 20; wi.text = "S1";
ghSlider1 = gwinSliderCreate(0, &wi);
// create Slider2
- wi.g.y = 40; wi.g.x = 10; wi.g.width = 20; wi.g.height = 200; wi.text = "S2";
+ wi.g.y = 40; wi.g.x = 10; wi.g.width = 20; wi.g.height = gdispGetHeight() - 50; wi.text = "S2";
ghSlider2 = gwinSliderCreate(0, &wi);
+
+ // Set slider 2 to return extended events
+ gwinSliderSendExtendedEvents(ghSlider2, TRUE);
+
+ // Console to display slider events
+ wi.g.y = 40; wi.g.x = 40; wi.g.width = gdispGetWidth()-50; wi.g.height = gdispGetHeight()-50;
+ ghConsole = gwinConsoleCreate(0, &wi.g);
}
int main(void) {
- GEvent* pe;
+ GEventGWinSlider * pe;
+ const char * sAction;
// Initialize the display
gfxInit();
@@ -61,21 +69,32 @@ int main(void) {
// create the widget
createWidgets();
+ gwinSetColor(ghConsole, Green);
+ gwinSetBgColor(ghConsole, White);
+ gwinClear(ghConsole);
// We want to listen for widget events
geventListenerInit(&gl);
gwinAttachListener(&gl);
while(1) {
- // Get an Event
- pe = geventEventWait(&gl, TIME_INFINITE);
+ // Get an Event (assume it is a slider event)
+ pe = (GEventGWinSlider *)geventEventWait(&gl, TIME_INFINITE);
switch(pe->type) {
case GEVENT_GWIN_SLIDER:
- //printf("Slider %s = %d\n", gwinGetText(((GEventGWinSlider *)pe)->gwin), ((GEventGWinSlider *)pe)->position);
+ switch(pe->action) {
+ case GSLIDER_EVENT_SET: sAction = "SET"; break;
+ case GSLIDER_EVENT_CANCEL: sAction = "CANCEL"; break;
+ case GSLIDER_EVENT_MOVE: sAction = "MOVE"; break;
+ case GSLIDER_EVENT_START: sAction = "START"; break;
+ default: sAction = "????"; break;
+ }
+ gwinPrintf(ghConsole, "Slider %s = %d%% %s\n", gwinGetText(pe->gwin), pe->position, sAction);
break;
default:
+ // Oops - not a slider event.
break;
}
}