Created
July 21, 2010 06:33
-
-
Save eagsalazar/484149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Clutter; | |
using Mx; | |
class ButtonBar : Mx.BoxLayout { | |
public signal void play(); | |
public signal void spin1(); | |
public signal void spin2(); | |
delegate void ClickResponder(); | |
private void create_button(string tooltip, string label, ClickResponder callback) { | |
var button = new Mx.Button.with_label(label); | |
button.tooltip_text = tooltip; | |
button.clicked.connect(callback); | |
add((Clutter.Actor)button); | |
} | |
public ButtonBar() { | |
create_button("Click to play/pause", "Play", (() => { play(); })); | |
create_button("Click to animate 1", "Animate 1", (() => { spin1(); })); | |
create_button("Click to animate 2", "Animate 2", (() => { spin2(); })); | |
} | |
} | |
bool on_keypress_event(KeyEvent e) { | |
Clutter.main_quit(); | |
return true; | |
} | |
void main(string[] args) { | |
Clutter.init(ref args); | |
// Each window by default has a stage associated with it | |
var stage = Stage.get_default(); | |
stage.color = Color.from_string("black"); | |
stage.width = 800; | |
stage.height = 600; | |
var buttonBar = new ButtonBar(); | |
stage.add_actor(buttonBar); | |
buttonBar.anchor_gravity = Gravity.CENTER; | |
buttonBar.y = stage.height - 40; | |
buttonBar.x = stage.width/2; | |
buttonBar.play.connect(() => { stdout.printf("play!\n"); }); | |
buttonBar.spin1.connect(() => { stdout.printf("spin1!\n"); }); | |
buttonBar.spin2.connect(() => { stdout.printf("spin2!\n"); }); | |
stage.show_all(); | |
Clutter.main(); | |
stage.hide.connect(Clutter.main_quit); | |
stage.key_press_event.connect(on_keypress_event); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment