From 709879ee56d31fe543a0ad882713bd4e3d17d2d2 Mon Sep 17 00:00:00 2001 From: dam Date: Thu, 17 Aug 2023 20:28:47 +0100 Subject: Added kscurses and testing program. --- kscurses/ui/button.jai | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 kscurses/ui/button.jai (limited to 'kscurses/ui/button.jai') diff --git a/kscurses/ui/button.jai b/kscurses/ui/button.jai new file mode 100644 index 0000000..3866e03 --- /dev/null +++ b/kscurses/ui/button.jai @@ -0,0 +1,25 @@ +UI_Button :: struct { + #as using base : UI_Elem = .{type = .BUTTON}; + text := ""; + on_click : struct { + proc := (data : *void){}; + data : *void; + }; +} + +handle_key_button :: (ui_elem : *UI_Elem, key : Key) -> handled:bool { + using cast(*UI_Button) ui_elem; + assert(cursor_state == .ON); + assert(!links.inner); + if key == .ENTER { + on_click.proc(on_click.data); + return true; + } + return false; +} +c_draw_button :: (canvas : *Canvas, ui_elem : *UI_Elem, zone : Ibox2, style : *UI_Style) -> bool { + using cast(*UI_Button) ui_elem; + mode := ifx cursor_state == .ON && box_type == .NONE then style.text.cursor else style.text.default; + c_draw_line_ascii(canvas, text, zone, .{(zone.width - xx text.count) / 2, xx ((zone.height - 1) / 2)}, mode); + return true; +} -- cgit v1.2.3