comparison mde/events.d @ 31:baa87e68d7dc

GUI now supports basic interactible widgets, widget colour and border are more unified, and some code cleanup. Removed some circular dependencies which slipped in. As a result, the OpenGL code got separated into different files. Enabled widgets to recieve events. New IParentWidget interface allowing widgets to interact with their parents. New Widget base class. New WidgetDecoration class. New ButtonWidget class responding to events (in a basic way). committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 29 Apr 2008 18:10:58 +0100
parents 467c74d4804d
children 316b0230a849
comparison
equal deleted inserted replaced
30:467c74d4804d 31:baa87e68d7dc
18 18
19 import global = mde.global; 19 import global = mde.global;
20 import sdl = mde.SDL; // resizeWindow 20 import sdl = mde.SDL; // resizeWindow
21 21
22 import mde.input.input; 22 import mde.input.input;
23 import mde.input.exception;
24
25 import mde.scheduler.InitFunctions;
26 23
27 import derelict.sdl.events; 24 import derelict.sdl.events;
28 25
29 import tango.time.Time; 26 import tango.time.Time;
30 import tango.util.log.Log : Log, Logger; 27 import tango.util.log.Log : Log, Logger;
31 28
32 private Logger logger; 29 private Logger logger;
33 static this() { 30 static this() {
34 logger = Log.getLogger ("mde.events"); 31 logger = Log.getLogger ("mde.events");
35
36 init.addFunc (&initInput, "initInput");
37 }
38
39 void initInput () { // init func
40 try {
41 global.input = new Input();
42 global.input.loadConfig (); // (may also create instance)
43
44 global.input.addButtonCallback (cast(Input.inputID) 0x0u, delegate void(Input.inputID i, bool b) {
45 if (b) {
46 logger.info ("Quiting...");
47 global.run = false;
48 }
49 } );
50 } catch (Exception) {
51 setInitFailure;
52 }
53 } 32 }
54 33
55 void pollEvents (TimeSpan) { 34 void pollEvents (TimeSpan) {
56 SDL_Event event; 35 SDL_Event event;
57 while (SDL_PollEvent (&event)) { 36 while (SDL_PollEvent (&event)) {
69 //global.scheduler.request(global.SCHEDULE.DRAW); 48 //global.scheduler.request(global.SCHEDULE.DRAW);
70 break;+/ 49 break;+/
71 default: 50 default:
72 try { 51 try {
73 global.input (event); 52 global.input (event);
74 } catch (InputClassException e) { 53 } catch (Exception e) {
75 logger.error ("Caught input exception; event will be ignored. Exception was:"); 54 logger.error ("Caught input exception; event will be ignored. Exception was:");
76 logger.error (e.msg); 55 logger.error (e.msg);
77 } 56 }
78 } 57 }
79 } 58 }