Languages

[Genie] Test Mx Widget

No votes yet
[indent=4]
 
uses
    Mx
 
progressbar : ProgressBar
slider : Slider
 
def static main_content () : Clutter.Actor
    var table = new Table ()
    table.column_spacing = 24
    table.row_spacing = 24
 
    var mylabel = new Label.with_text ("Hello World")
    mylabel.tooltip_text = "I'm a label"
    table.add_actor_with_properties (mylabel, 0, 0, "y-fill", false)
 
    var combo = new ComboBox ()
    combo.active_text = "Hello World"
    combo.append_text ("Hello")
    combo.append_text ("Word")
    table.add_actor_with_properties (combo, 0, 1, "y-fill", false)
 
    progressbar = new ProgressBar ()
    progressbar.progress = 0.4
    progressbar.tooltip_text = "Move the slider to change my value"
    table.add_actor_with_properties (progressbar, 1, 0, "y-fill", false)
 
    slider = new Slider ()
    table.add_actor_with_properties (slider, 1, 1, "y-fill", false)
    slider.notify["value"].connect (change_progress_value)
 
    var toggle = new Toggle ()
    table.add_actor_with_properties (toggle, 2, 0, "y-fill", false)
 
    var entry = new Entry.with_text ("Put your text...")
    table.add_actor_with_properties (entry, 2, 1, "y-fill", false)
 
    var button = new Button.with_label ("Simple Button")
    table.add_actor_with_properties (button, 3, 0, "y-fill", false)
 
    var togglebutton = new Button.with_label ("Toggle Button")
    togglebutton.is_toggle = true
    table.add_actor_with_properties (togglebutton, 3, 1, "y-fill", false)
 
    var pathbar = new PathBar ()
    pathbar.push ("/usr")
    pathbar.push ("/home")
    pathbar.push ("/me")
    table.add_actor_with_properties (pathbar, 4, 0, "y-fill", false)
 
    var checkbutton = new Button ()
    checkbutton.set_style_class ("check-box")
    checkbutton.is_toggle = true
    table.add_actor_with_properties (checkbutton, 4, 1, "y-fill", false, "x-fill", false)
 
    var expander = new Expander ()
    table.add_actor_with_properties (expander, 5, 0, "y-fill", false)
    expander.label = "Expander"
    expander.add_actor (new Label.with_text ("Genie"))
 
    var adjustment = new Adjustment.with_values (0, 0, 10, 1, 1, 1)
    var scrollbar = new ScrollBar.with_adjustment (adjustment)
    scrollbar.height = 22.0f
    table.add_actor_with_properties (scrollbar, 5, 1, "y-fill", false)
 
    var frame = new Frame ()
    frame.child = table
    return frame
 
def static change_progress_value ()
    progressbar.progress = slider.get_value ()
 
init
    var app = new Application (ref args, "Genie Mx Widget", 0)
    var window = app.create_window ()
    window.clutter_stage.set_size (600, 400)
 
    var toolbar = window.get_toolbar ()
    var label = new Label.with_text ("Test mx widget")
    toolbar.add_actor (label)
 
    window.child = main_content ()
    window.clutter_stage.show ()
    app.run ()