rawptr for everything
This commit is contained in:
parent
55d122de0c
commit
f923e07fbf
2 changed files with 69 additions and 29 deletions
19
ui.odin
19
ui.odin
|
|
@ -11,6 +11,9 @@ rect_get_tr :: #force_inline proc(rect: rect2) -> v2 {return {rect.x + rect.widt
|
|||
rect_get_br :: #force_inline proc(rect: rect2) -> v2 {return {rect.x + rect.width, rect.y + rect.height}}
|
||||
rect_get_bl :: #force_inline proc(rect: rect2) -> v2 {return {rect.x, rect.y + rect.height}}
|
||||
rect_get_size :: #force_inline proc(rect: rect2) -> v2 {return {rect.width, rect.height}}
|
||||
rect_get_corners :: #force_inline proc(rect: rect2) -> (tl, tr, br, bl: v2) {
|
||||
return rect_get_tl(rect), rect_get_tr(rect), rect_get_br(rect), rect_get_bl(rect)
|
||||
}
|
||||
rect_grow :: proc(rect: rect2, amount: v2) -> rect2 {return {rect.x - amount.x / 2.0, rect.y - amount.y / 2.0, rect.width + amount.x, rect.height + amount.y}}
|
||||
|
||||
ctx: ^Context
|
||||
|
|
@ -127,9 +130,9 @@ focus_next_element :: proc(ctx: ^Context, allowed_focus := element_type_input) {
|
|||
ctx.element_focus_id = -1
|
||||
}
|
||||
|
||||
container_begin :: proc(dimensions: Dimensions, config: ElementConfiguration) -> ^Element {
|
||||
container_begin :: proc(dimensions: Dimensions, config: ElementConfiguration, data: rawptr = nil) -> ^Element {
|
||||
area := _resolve_element_area(dimensions, config.margin)
|
||||
element := _append_element({area = area, config = config, type = .Container, dimensions = dimensions})
|
||||
element := _append_element({area = area, config = config, type = .Container, dimensions = dimensions, data = data})
|
||||
container_index := len(ctx.elements) - 1
|
||||
append(&ctx.containers, container_index)
|
||||
append(&ctx.container_last_element, -1)
|
||||
|
|
@ -171,22 +174,22 @@ assert_no_dimensions_percentage_in_auto_container :: proc(dimensions: Dimensions
|
|||
}
|
||||
}
|
||||
|
||||
button :: proc(dimensions: Dimensions, config: ElementConfiguration) -> ^Element {
|
||||
button :: proc(dimensions: Dimensions, config: ElementConfiguration, data: rawptr = nil) -> ^Element {
|
||||
assert_no_dimensions_percentage_in_auto_container(dimensions)
|
||||
area := _resolve_element_area(dimensions, config.margin)
|
||||
return _append_element({area = area, config = config, type = .Button, dimensions = dimensions})
|
||||
return _append_element({area = area, config = config, type = .Button, dimensions = dimensions, data = data})
|
||||
}
|
||||
|
||||
slider :: proc(dimensions: Dimensions, config: ElementConfiguration, data: rawptr) -> ^Element {
|
||||
slider :: proc(dimensions: Dimensions, config: ElementConfiguration, data: rawptr = nil) -> ^Element {
|
||||
assert_no_dimensions_percentage_in_auto_container(dimensions)
|
||||
area := _resolve_element_area(dimensions, config.margin)
|
||||
return _append_element({area = area, config = config, type = .Slider, data = data, dimensions = dimensions})
|
||||
return _append_element({area = area, config = config, type = .Slider, dimensions = dimensions, data = data})
|
||||
}
|
||||
|
||||
input_float :: proc(dimensions: Dimensions, config: ElementConfiguration, data: rawptr) -> ^Element {
|
||||
input_float :: proc(dimensions: Dimensions, config: ElementConfiguration, data: rawptr = nil) -> ^Element {
|
||||
assert_no_dimensions_percentage_in_auto_container(dimensions)
|
||||
area := _resolve_element_area(dimensions, config.margin)
|
||||
return _append_element({area = area, config = config, type = .InputFloat, data = data, dimensions = dimensions})
|
||||
return _append_element({area = area, config = config, type = .InputFloat, dimensions = dimensions, data = data})
|
||||
}
|
||||
|
||||
get_element_outer_area :: proc(element: Element) -> rect2 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue