Saving projects
This commit is contained in:
parent
4261f07762
commit
64735fe60e
3 changed files with 182 additions and 63 deletions
|
|
@ -60,9 +60,19 @@ ElementType :: enum {
|
|||
Button,
|
||||
Slider,
|
||||
InputFloat,
|
||||
InputText,
|
||||
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}
|
||||
|
|
@ -83,10 +93,25 @@ 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}}
|
||||
dimensions_pixels :: proc {
|
||||
dimensions_pixels_size,
|
||||
dimensions_pixels_v,
|
||||
dimensions_pixels_width_height,
|
||||
}
|
||||
dimensions_pixels_width_height :: proc(w, h: Size_Pixels) -> Dimensions {return {w, h}}
|
||||
dimensions_pixels_v :: proc(v: v2) -> Dimensions {return {Size_Pixels(v.x), Size_Pixels(v.y)}}
|
||||
dimensions_pixels_size :: proc(s: Size_Pixels) -> Dimensions {return {s, s}}
|
||||
|
||||
dimensions_percentage :: proc {
|
||||
dimensions_percentage_size,
|
||||
dimensions_percentage_v,
|
||||
dimensions_percentage_width_height,
|
||||
}
|
||||
dimensions_percentage_width_height :: proc(w, h: Size_Percentage) -> Dimensions {return {w, h}}
|
||||
dimensions_percentage_v :: proc(v: v2) -> Dimensions {return {Size_Percentage(v.x), Size_Percentage(v.y)}}
|
||||
dimensions_percentage_size :: proc(s: Size_Percentage) -> Dimensions {return {s, s}}
|
||||
|
||||
dimensions_auto :: proc() -> Dimensions {return {Size_Auto(true), Size_Auto(true)}}
|
||||
|
||||
Axis :: enum {X, Y}
|
||||
|
||||
|
|
@ -161,16 +186,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.padding.x
|
||||
container.area.width = br.x - container.area.x
|
||||
}
|
||||
if height_is_auto {
|
||||
container.area.height = br.y - container.area.y + container.padding.y
|
||||
container.area.height = br.y - container.area.y
|
||||
}
|
||||
}
|
||||
ctx.same_line = false
|
||||
}
|
||||
|
||||
assert_auto_dimension_with_pixels :: proc(dimensions: Dimensions) {
|
||||
assert_auto_with_pixels :: proc(dimensions: Dimensions) {
|
||||
container := _container_current()
|
||||
if _, is_auto := container.dimensions.width.(Size_Auto); is_auto {
|
||||
_, is_pixels := dimensions.width.(Size_Pixels)
|
||||
|
|
@ -184,7 +209,7 @@ assert_auto_dimension_with_pixels :: proc(dimensions: Dimensions) {
|
|||
|
||||
element :: proc(element_type: ElementType, dimensions: Dimensions, config: ElementConfiguration, data: rawptr = nil) -> ^Element {
|
||||
assert(element_type != .Container)
|
||||
assert_auto_dimension_with_pixels(dimensions)
|
||||
assert_auto_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