First text box!!!

This commit is contained in:
2024-03-09 10:21:48 -05:00
parent f1edf1c43e
commit 635ce91a9d
13 changed files with 149 additions and 41 deletions

View File

@ -200,18 +200,30 @@ update :: proc( delta_time : f64 ) -> b32
frame_style_default := UI_Style {
flags = frame_style_flags,
bg_color = Color_BG_TextBox,
font = default_font,
font_size = 30,
text_color = Color_White,
}
frame_style_disabled := UI_Style {
flags = frame_style_flags,
bg_color = Color_Frame_Disabled,
font = default_font,
font_size = 30,
text_color = Color_White,
}
frame_style_hovered := UI_Style {
flags = frame_style_flags,
bg_color = Color_Frame_Hover,
font = default_font,
font_size = 30,
text_color = Color_White,
}
frame_style_select := UI_Style {
flags = frame_style_flags,
bg_color = Color_Frame_Select,
font = default_font,
font_size = 30,
text_color = Color_White,
}
frame_theme := UI_StyleTheme { styles = {
frame_style_default,
@ -223,9 +235,11 @@ update :: proc( delta_time : f64 ) -> b32
default_layout := UI_Layout {
anchor = {},
// alignment = { 0.0, 0.0 },
// alignment = { 0.0, 0.5 },
alignment = { 0.5, 0.5 },
text_alignment = { 1.0, 1.0 },
// alignment = { 1.0, 1.0 },
corner_radii = { 0.3, 0.3, 0.3, 0.3 },
pos = { 0, 0 },
size = { 200, 200 },
}
@ -234,7 +248,44 @@ update :: proc( delta_time : f64 ) -> b32
// test_hover_n_click()
// test_draggable()
config.ui_resize_border_width = 2
// First box with text!!!!
{
@static pos : Vec2
text := str_intern( "Lorem ipsum dolor sit amet")
text_size := measure_text_size( text.str, default_font, 30, 0 )
ui_style_theme( { styles = {
frame_style_default,
frame_style_default,
frame_style_default,
frame_style_default,
}})
layout := default_layout
layout.size = cast(Vec2) text_size
layout.size.y *= 4
layout.size.x *= 1.5
// layout.size.y *= 3.248
// layout.size.x *= 1.348
// layout.size.x *= 1.348
layout.padding = ui_layout_padding( 30 )
ui_set_layout( layout )
text_box := ui_widget( "TEXT BOX!", UI_BoxFlags { .Mouse_Clickable, .Focusable, .Click_To_Focus } )
if text_box.first_frame {
pos = text_box.style.layout.pos
text_box.text = text
}
if text_box.dragging {
pos += mouse_world_delta()
}
text_box.style.layout.pos = pos
}
}
//endregion Imgui Tick