-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ecs
62 lines (55 loc) · 2 KB
/
test.ecs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@require: 210606
@charset: utf8
import picasso as ui
import imgui, imgui_font
var app = new ui.application {
imgui.window_application(640, 400, "Picasso UI Test")
}
var font = imgui.add_font_extend_cn(imgui_font.source_han_sans, 18)
block
var win = app.add_activity(ui.activities.single_page, "main1")->window
win->add_view(app.make_view(ui.widgets.text, "text"))
win->add_view(app.make_view(ui.widgets.input, "input"))
win->add_view(app.make_view(ui.widgets.button, "btn", {"打开Activity 2"}))
app.views.main1->font = global.font
app.views.main1->on_focus.add_listener([](obj, txt){
imgui.style_color_dark()
obj.window->views.input->text += txt
})
win->views.input->on_render.add_listener([win](txt){
win->views.text->text = "输入:" + txt
})
win->views.btn->on_click.add_listener([win, app](obj){
app.push("main2", win->views.input->text)
})
end
block
var win = app.add_activity(ui.activities.single_page, "main2")->window
win->add_view(app.make_view(ui.widgets.text, "text"))
win->add_view(app.make_view(ui.widgets.input, "input"))
win->add_view(app.make_view(ui.widgets.button, "btn", {"关闭Activity 2"}))
app.views.main2->font = global.font
app.views.main2->on_focus.add_listener([win](obj, arg){
if arg is string
imgui.style_color_light()
win->views.text->text = "来自Activity 1:" + arg
win->views.input->text = new string
else if arg is boolean
if arg
app.pop(win->views.input->text)
end
end
})
win->views.btn->on_click.add_listener([app, win](obj){
app.push("main3")
})
end
block
var win = app.add_activity(ui.activities.single_page, "main3", {ui.windows.question_box, {"返回Activity 1?", "确定(Y)", "取消(N)"}})->window
app.views.main3->font = global.font
win->on_close.add_listener([](obj, val){
app.pop(val)
})
end
app.push("main1", "你好世界!")
app.start()