Graphics Library for D
Adam D. Ruppe
destructionator at gmail.com
Mon Jan 6 11:44:05 PST 2014
One of the things I did with my files was to have a separate
event loop module which could be used by anything, in addition to
their own event loop things (especially since I never implemented
the other module on Windows or even other Poxixes yet; it is
Linux only, but that's just due to my implementation.)
The separate event loop is nice because integrating loops is a
bit of a pain. What mine does is pass type info for a single
argument to a central thing:
import ev = arsd.eventloop;
// two separate libraries that can use the same loop
import simpledisplay;
import terminal;
struct MyEvent { } // a custom event
void main() {
auto window = new SimpleWindow();
auto terminal = Terminal(ConsoleOutputMode.linear);
auto terminalInput = RealTimeconsoleInput(&terminal,
ConsoleInputFlags.raw | ConsoleInputFlags.allInputEvents);
addListener((InputEvent event) {
// input from the terminal
});
addListener((KeyEvent event) {
// key info from the gui window
send(MyEvent()); // send the custom event
});
addListener(MyEvent event) {
// a custom event
});
ev.loop();
}
and so on. Then the higher level things can build on this to do
whatever - minigui.d for example uses a javascript style
item.addEventListener thingy.
More information about the Digitalmars-d
mailing list