2024-03-08 15:45:27 -08:00
|
|
|
package sectr
|
|
|
|
|
2024-03-09 07:21:48 -08:00
|
|
|
UI_Widget :: struct {
|
|
|
|
using box : ^UI_Box,
|
|
|
|
using signal : UI_Signal,
|
|
|
|
}
|
|
|
|
|
2024-03-19 09:18:39 -07:00
|
|
|
|
2024-03-08 16:51:46 -08:00
|
|
|
ui_widget :: proc( label : string, flags : UI_BoxFlags ) -> (widget : UI_Widget)
|
|
|
|
{
|
2024-03-10 23:05:18 -07:00
|
|
|
// profile(#procedure)
|
|
|
|
|
2024-03-08 16:51:46 -08:00
|
|
|
widget.box = ui_box_make( flags, label )
|
|
|
|
widget.signal = ui_signal_from_box( widget.box )
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-03-19 09:18:39 -07:00
|
|
|
|
2024-03-08 16:51:46 -08:00
|
|
|
ui_button :: proc( label : string, flags : UI_BoxFlags = {} ) -> (btn : UI_Widget)
|
|
|
|
{
|
2024-03-10 23:05:18 -07:00
|
|
|
// profile(#procedure)
|
|
|
|
|
2024-03-08 16:51:46 -08:00
|
|
|
btn_flags := UI_BoxFlags { .Mouse_Clickable, .Focusable, .Click_To_Focus }
|
|
|
|
btn.box = ui_box_make( btn_flags | flags, label )
|
|
|
|
btn.signal = ui_signal_from_box( btn.box )
|
|
|
|
return
|
|
|
|
}
|
2024-03-08 15:45:27 -08:00
|
|
|
|
2024-03-19 09:18:39 -07:00
|
|
|
|
2024-03-10 17:09:04 -07:00
|
|
|
ui_text :: proc( label : string, content : StringCached, flags : UI_BoxFlags = {} ) -> UI_Widget
|
2024-03-09 10:55:47 -08:00
|
|
|
{
|
2024-03-10 23:05:18 -07:00
|
|
|
// profile(#procedure)
|
2024-03-09 10:55:47 -08:00
|
|
|
state := get_state(); using state
|
|
|
|
|
2024-03-10 07:31:21 -07:00
|
|
|
box := ui_box_make( flags, label )
|
2024-03-09 10:55:47 -08:00
|
|
|
signal := ui_signal_from_box( box )
|
|
|
|
|
2024-03-10 23:05:18 -07:00
|
|
|
box.text = content
|
2024-03-09 10:55:47 -08:00
|
|
|
return { box, signal }
|
|
|
|
}
|
2024-03-10 17:09:04 -07:00
|
|
|
|
2024-03-19 09:18:39 -07:00
|
|
|
|
2024-03-14 21:02:28 -07:00
|
|
|
ui_text_spaces :: proc( label : string, flags : UI_BoxFlags = {} ) -> UI_Widget
|
2024-03-10 17:09:04 -07:00
|
|
|
{
|
2024-03-10 23:05:18 -07:00
|
|
|
// profile(#procedure)
|
2024-03-13 21:00:22 -07:00
|
|
|
state := get_state(); using state
|
2024-03-10 23:05:18 -07:00
|
|
|
|
2024-03-13 21:00:22 -07:00
|
|
|
// TODO(Ed) : Move this somwhere in state.
|
2024-03-10 17:09:04 -07:00
|
|
|
space_str := str_intern( " " )
|
|
|
|
|
|
|
|
box := ui_box_make( flags, label )
|
|
|
|
signal := ui_signal_from_box( box )
|
|
|
|
|
2024-03-10 23:05:18 -07:00
|
|
|
box.text = space_str
|
2024-03-10 17:09:04 -07:00
|
|
|
return { box, signal }
|
|
|
|
}
|
|
|
|
|
2024-03-19 09:18:39 -07:00
|
|
|
|
2024-03-14 21:02:28 -07:00
|
|
|
ui_text_tabs :: proc( label : string, flags : UI_BoxFlags = {} ) -> UI_Widget
|
2024-03-10 17:09:04 -07:00
|
|
|
{
|
2024-03-10 23:05:18 -07:00
|
|
|
// profile(#procedure)
|
2024-03-13 21:00:22 -07:00
|
|
|
state := get_state(); using state
|
2024-03-10 23:05:18 -07:00
|
|
|
|
2024-03-13 21:00:22 -07:00
|
|
|
// TODO(Ed) : Move this somwhere in state.
|
2024-03-10 17:09:04 -07:00
|
|
|
tab_str := str_intern( "\t" )
|
|
|
|
|
|
|
|
box := ui_box_make( flags, label )
|
|
|
|
signal := ui_signal_from_box( box )
|
|
|
|
|
2024-03-10 23:05:18 -07:00
|
|
|
box.text = tab_str
|
2024-03-10 17:09:04 -07:00
|
|
|
return { box, signal }
|
|
|
|
}
|