Scale matrix add
This commit is contained in:
parent
baf7dcc52c
commit
3920dfd39a
2 changed files with 60 additions and 27 deletions
|
|
@ -62,16 +62,7 @@ ElementType :: enum {
|
|||
InputFloat,
|
||||
Dropdown,
|
||||
Label,
|
||||
Custom0,
|
||||
Custom1,
|
||||
Custom2,
|
||||
Custom3,
|
||||
Custom4,
|
||||
Custom5,
|
||||
Custom6,
|
||||
Custom7,
|
||||
Custom8,
|
||||
Custom9,
|
||||
Custom0, Custom1, Custom2, Custom3, Custom4, Custom5, Custom6, Custom7, Custom8, Custom9,
|
||||
}
|
||||
|
||||
@rodata element_type_input := bit_set[ElementType] {.InputFloat}
|
||||
|
|
@ -92,6 +83,11 @@ Dimensions :: struct {
|
|||
width, height: Size,
|
||||
}
|
||||
|
||||
dimensions_pixels :: proc(v: [2]f32) -> Dimensions {return {Size_Pixels(v.x), Size_Pixels(v.y)}}
|
||||
dimensions_percentage :: proc(v: [2]f32) -> Dimensions {return {Size_Percentage(v.x), Size_Percentage(v.y)}}
|
||||
dimensions_percentage_remainder :: proc(v: [2]f32) -> Dimensions {return {Size_PercentageRemainder(v.x), Size_PercentageRemainder(v.y)}}
|
||||
dimensions_auto :: proc() -> Dimensions {return {SIZE_AUTO, SIZE_AUTO}}
|
||||
|
||||
Axis :: enum {X, Y}
|
||||
|
||||
init :: proc(ctx: ^Context, element_capacity: int, measure_text_callback: MeasureTextProc, measure_text_callback_data: rawptr, allocator := context.allocator) {
|
||||
|
|
@ -165,16 +161,16 @@ container_end :: proc() {
|
|||
br = {max(br.x, element_br.x), max(br.y, element_br.y)}
|
||||
}
|
||||
if width_is_auto {
|
||||
container.area.width = br.x - container.area.x
|
||||
container.area.width = br.x - container.area.x + container.padding.x
|
||||
}
|
||||
if height_is_auto {
|
||||
container.area.height = br.y - container.area.y
|
||||
container.area.height = br.y - container.area.y + container.padding.y
|
||||
}
|
||||
}
|
||||
ctx.same_line = false
|
||||
}
|
||||
|
||||
assert_auto_with_pixels :: proc(dimensions: Dimensions) {
|
||||
assert_auto_dimension_with_pixels :: proc(dimensions: Dimensions) {
|
||||
container := _container_current()
|
||||
if _, is_auto := container.dimensions.width.(Size_Auto); is_auto {
|
||||
_, is_pixels := dimensions.width.(Size_Pixels)
|
||||
|
|
@ -188,7 +184,7 @@ assert_auto_with_pixels :: proc(dimensions: Dimensions) {
|
|||
|
||||
element :: proc(element_type: ElementType, dimensions: Dimensions, config: ElementConfiguration, data: rawptr = nil) -> ^Element {
|
||||
assert(element_type != .Container)
|
||||
assert_auto_with_pixels(dimensions)
|
||||
assert_auto_dimension_with_pixels(dimensions)
|
||||
element := Element{config = config, type = element_type, dimensions = dimensions, data = data}
|
||||
element.area = _resolve_element_area(element, is_text = (element.type == .Label))
|
||||
return _append_element(element)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue