Setup spall profiling, did first optimizations!

This commit is contained in:
2024-03-11 02:05:18 -04:00
parent 304e710c16
commit 1656dffb67
23 changed files with 357 additions and 120 deletions

View File

@ -7,6 +7,8 @@ UI_Widget :: struct {
ui_widget :: proc( label : string, flags : UI_BoxFlags ) -> (widget : UI_Widget)
{
// profile(#procedure)
widget.box = ui_box_make( flags, label )
widget.signal = ui_signal_from_box( widget.box )
return
@ -14,6 +16,8 @@ ui_widget :: proc( label : string, flags : UI_BoxFlags ) -> (widget : UI_Widget)
ui_button :: proc( label : string, flags : UI_BoxFlags = {} ) -> (btn : UI_Widget)
{
// profile(#procedure)
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 )
@ -22,20 +26,22 @@ ui_button :: proc( label : string, flags : UI_BoxFlags = {} ) -> (btn : UI_Widge
ui_text :: proc( label : string, content : StringCached, flags : UI_BoxFlags = {} ) -> UI_Widget
{
// profile(#procedure)
state := get_state(); using state
box := ui_box_make( flags, label )
signal := ui_signal_from_box( box )
text_size := measure_text_size( content.str, box.style.font, box.style.font_size, 0 )
box.text = content
box.style.layout.size = text_size
box.text = content
box.style.layout.size_to_text = true
return { box, signal }
}
ui_space :: proc( label : string, flags : UI_BoxFlags = {} ) -> UI_Widget
{
// profile(#procedure)
space_str := str_intern( " " )
state := get_state(); using state
@ -43,14 +49,15 @@ ui_space :: proc( label : string, flags : UI_BoxFlags = {} ) -> UI_Widget
box := ui_box_make( flags, label )
signal := ui_signal_from_box( box )
text_size := measure_text_size( space_str.str, box.style.font, box.style.font_size, 0 )
box.text = space_str
box.style.layout.size = text_size
box.text = space_str
box.style.layout.size_to_text = true
return { box, signal }
}
ui_tab :: proc( label : string, flags : UI_BoxFlags = {} ) -> UI_Widget
{
// profile(#procedure)
tab_str := str_intern( "\t" )
state := get_state(); using state
@ -58,8 +65,8 @@ ui_tab :: proc( label : string, flags : UI_BoxFlags = {} ) -> UI_Widget
box := ui_box_make( flags, label )
signal := ui_signal_from_box( box )
text_size := measure_text_size( tab_str.str, box.style.font, box.style.font_size, 0 )
box.text = tab_str
box.style.layout.size = text_size
box.text = tab_str
box.style.layout.size_to_text = true
return { box, signal }
}