Made the ui_resize_border_width percent based instead of pixel based.
This commit is contained in:
parent
4a53a158e0
commit
7b69723f35
@ -102,7 +102,7 @@ startup :: proc( persistent_mem, frame_mem, transient_mem, files_buffer_mem : ^V
|
||||
|
||||
engine_refresh_hz = 30
|
||||
|
||||
ui_resize_border_width = 10
|
||||
ui_resize_border_width = 5
|
||||
}
|
||||
|
||||
Desired_OS_Scheduler_MS :: 1
|
||||
|
@ -128,7 +128,7 @@ AppConfig :: struct {
|
||||
|
||||
engine_refresh_hz : uint,
|
||||
|
||||
ui_resize_border_width : uint,
|
||||
ui_resize_border_width : f32,
|
||||
}
|
||||
|
||||
State :: struct {
|
||||
|
@ -160,10 +160,10 @@ render_mode_2d :: proc()
|
||||
|
||||
rl.DrawRectangleRoundedLines( rect_padding, style.layout.corner_radii[0], 9, line_thickness, Color_Debug_UI_Padding_Bounds )
|
||||
rl.DrawRectangleRoundedLines( rect_content, style.layout.corner_radii[0], 9, line_thickness, Color_Debug_UI_Content_Bounds )
|
||||
if .Mouse_Resizable in current.flags {
|
||||
resize_border_width := cast(f32) get_state().config.ui_resize_border_width
|
||||
|
||||
resize_percent_width := style.size * (1.0 / resize_border_width)
|
||||
if .Mouse_Resizable in current.flags
|
||||
{
|
||||
resize_border_width := cast(f32) get_state().config.ui_resize_border_width
|
||||
resize_percent_width := style.size * (resize_border_width * 1.0/ 200.0)
|
||||
resize_border_non_range := add(current.computed.bounds, range2(
|
||||
{ resize_percent_width.x, -resize_percent_width.x },
|
||||
{ -resize_percent_width.x, resize_percent_width.x }))
|
||||
@ -181,10 +181,9 @@ render_mode_2d :: proc()
|
||||
rl.DrawRectangleRoundedLines( rect_resize, style.layout.corner_radii[0], 9, line_thickness, Color_Red )
|
||||
}
|
||||
|
||||
// if current
|
||||
|
||||
// rl.DrawCircleV( render_bounds.p0, 5, Color_Red )
|
||||
// rl.DrawCircleV( render_bounds.p1, 5, Color_Blue )
|
||||
point_radius := 3 * (1 / cam.zoom)
|
||||
rl.DrawCircleV( render_bounds.p0, point_radius, Color_Red )
|
||||
rl.DrawCircleV( render_bounds.p1, point_radius, Color_Blue )
|
||||
|
||||
if len(current.text.str) > 0 {
|
||||
draw_text_string_cached( current.text, world_to_screen_pos(computed.text_pos), style.font_size, style.text_color )
|
||||
|
@ -228,34 +228,9 @@ update :: proc( delta_time : f64 ) -> b32
|
||||
frame_theme.focused.bg_color = Color_Frame_Select
|
||||
ui_style_theme( frame_theme )
|
||||
|
||||
// test_hover_n_click()
|
||||
|
||||
config.ui_resize_border_width = 2.5
|
||||
test_draggable()
|
||||
|
||||
config.ui_resize_border_width = 20
|
||||
// First box with text!!!!
|
||||
when true
|
||||
{
|
||||
@static pos : Vec2
|
||||
style := ui_style_peek( .Default )
|
||||
ui_style_theme( { styles = { style, style, style, style, }} )
|
||||
|
||||
text := str_intern( "Lorem ipsum dolor sit amet")
|
||||
font_size := 30
|
||||
|
||||
text_box := ui_text("TEXT BOX!", text, 30, flags = { .Mouse_Clickable })
|
||||
if text_box.first_frame {
|
||||
pos = text_box.style.layout.pos
|
||||
}
|
||||
|
||||
if text_box.dragging {
|
||||
pos += mouse_world_delta()
|
||||
}
|
||||
|
||||
text_box.style.layout.pos = pos
|
||||
}
|
||||
|
||||
// test_draggable()
|
||||
test_text_box()
|
||||
}
|
||||
//endregion Imgui Tick
|
||||
|
||||
|
@ -14,7 +14,7 @@ ui_signal_from_box :: proc ( box : ^ UI_Box ) -> UI_Signal
|
||||
signal.cursor_over = cast(b8) pos_within_range2( signal.cursor_pos, box.computed.bounds )
|
||||
|
||||
resize_border_width := cast(f32) get_state().config.ui_resize_border_width
|
||||
resize_percent_width := box.style.size * (1.0 / resize_border_width)
|
||||
resize_percent_width := box.style.size * (resize_border_width * 1.0/ 200.0)
|
||||
resize_border_non_range := add(box.computed.bounds, range2(
|
||||
{ resize_percent_width.x, -resize_percent_width.x },
|
||||
{ -resize_percent_width.x, resize_percent_width.x }))
|
||||
|
@ -54,3 +54,27 @@ test_draggable :: proc()
|
||||
draggable.style.layout.pos = debug.draggable_box_pos
|
||||
draggable.style.layout.size = debug.draggable_box_size
|
||||
}
|
||||
|
||||
test_text_box :: proc()
|
||||
{
|
||||
state := get_state(); using state
|
||||
ui := ui_context
|
||||
|
||||
@static pos : Vec2
|
||||
style := ui_style_peek( .Default )
|
||||
ui_style_theme( { styles = { style, style, style, style, }} )
|
||||
|
||||
text := str_intern( "Lorem ipsum dolor sit amet")
|
||||
font_size := 30
|
||||
|
||||
text_box := ui_text("TEXT BOX!", text, 30, flags = { .Mouse_Clickable })
|
||||
if text_box.first_frame {
|
||||
pos = text_box.style.layout.pos
|
||||
}
|
||||
|
||||
if text_box.dragging {
|
||||
pos += mouse_world_delta()
|
||||
}
|
||||
|
||||
text_box.style.layout.pos = pos
|
||||
}
|
Loading…
Reference in New Issue
Block a user