Add another simple clutter example, showing actors and Container i/f.
[girtod.git] / example_clutter1.d
blobbd5323271fc92282bd75d3eb762b60eae9fdc250
1 // D version of example from
2 // http://www.openismus.com/documents/clutter_tutorial/1.0/docs/tutorial/html/sec-stage.html
3 //
4 // Link with: "gtk2/glib2.o gtk2/gobject2.o gtk2/clutter.o `pkg-config --libs clutter-1.0`"
6 import std.stdio;
7 import clut = gtk2.clutter;
9 int on_stage_button_press(clut.Actor* stage, clut.Event* event, void* data)
11 float x = 0, y = 0;
12 event.get_coords(&x, &y);
13 writef("Stage clicked at (%f, %f)\n", x, y);
14 return true; /* Stop further handling of this event. */
17 int main(string argv[]) {
18 clut.Color stage_color = { 0x00, 0x00, 0x00, 0xff }; /* Black */
20 argv = clut.init(argv);
22 /* Get the stage and set its size and color: */
23 auto stage = clut.Stage.get_default();
24 stage.set_size(200, 200);
25 stage.set_color(&stage_color);
27 /* Show the stage: */
28 stage.show();
30 /* Connect a signal handler to handle mouse clicks and key presses on the stage: */
31 stage.signal_connect!"button-press-event"(&on_stage_button_press);
33 /* Start the main loop, so we can respond to events: */
34 clut.main_();
36 return 0;