diff options
author | Alex Auvolat <alex@adnab.me> | 2017-05-08 16:43:31 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2017-05-08 16:43:31 +0200 |
commit | 287a579f65e6e5e3c4610cbf134123691ee3e64c (patch) | |
tree | 1774e1ec804fa712d3d87547ef5c7e45998b2f12 /src/sysapp | |
parent | e72e5e87497744410fb62843ef852d26bf5277d2 (diff) | |
download | kogata-287a579f65e6e5e3c4610cbf134123691ee3e64c.tar.gz kogata-287a579f65e6e5e3c4610cbf134123691ee3e64c.zip |
Implement tk.box
Diffstat (limited to 'src/sysapp')
-rw-r--r-- | src/sysapp/login/main.lua | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/src/sysapp/login/main.lua b/src/sysapp/login/main.lua index a0297f8..c3788a2 100644 --- a/src/sysapp/login/main.lua +++ b/src/sysapp/login/main.lua @@ -12,6 +12,7 @@ print("Hello, world!") gui.open() gui.load_cursor('sys:/cursors/left_ptr.png') +gui.show_cursor() for x = 0, 255, 16 do for y = 0, 255, 16 do @@ -20,42 +21,28 @@ for x = 0, 255, 16 do end local f = draw.load_image('root:/logo.png') -local wm = tk.wm_widget() +local wm = tk.window_manager() tk.init(gui, wm) -local img = tk.image_widget(f) +local img = tk.image(f) wm:add(img, "Window 1", 100, 16) -local img2 = tk.image_widget(f) +local img2 = tk.box({ + center_content = true, + vscroll = true, + hscroll = true, + vresize = true, + hresize = true, + }, tk.image(f)) wm:add(img2, "Window 2", 16, 100) +local img3 = tk.box({ + constrain_size = true, + vresize = true, + hresize = true, + }, tk.image(f)) +wm:add(img3, "Window 3", 300, 150) +local txt = tk.text({color = tk.rgb(0, 255, 0), width=200}, "Hello, world!\nThis is a long text") +wm:add(txt, "Text example", 32, 32) -gui.show_cursor() - ---[[ -local fnt = draw.load_ttf_font('sys:/fonts/vera.ttf') -if fnt == nil then - print("Could not load vera.ttf!") - os.exit() -end - -local txt_x, txt_y = 0, 0 - -gui.on_mouse_down = function (lb, rb, mb) - if lb then - gui.hide_cursor() - gui.surface:write(gui.mouse_x, gui.mouse_y, string.format("Click at %d, %d", gui.mouse_x, gui.mouse_y), fnt, 16, gui.surface:rgb(0, 0, 255)) - txt_x = gui.mouse_x - txt_y = gui.mouse_y + 16 - gui.show_cursor() - end -end - -gui.on_text_input = function(chr) - gui.hide_cursor() - gui.surface:write(txt_x, txt_y, chr, fnt, 16, gui.surface:rgb(0, 0, 255)) - txt_x = txt_x + fnt:text_width(chr, 16) - gui.show_cursor() -end ---]] mainloop.run() |