21 lines
1.3 KiB
Text
21 lines
1.3 KiB
Text
# attr_place.ludic - position and its insets, z-index, overflow, white-space and text-overflow
|
|
const EL_KEYS_PLACE_PROP: string = " bottom inset left overflow overflow-y position right text-overflow top white-space z-index "
|
|
function el_place_prop(ui_st: mut UiState, n: UiNode, key: string, v: Val) -> bool {
|
|
if not lk_in(EL_KEYS_PLACE_PROP, key) { return false } # not one of its keys: no text made for it
|
|
let s = vl_text_u(ui_st, v)
|
|
if key == "position" {
|
|
n.pos = 0
|
|
if s == "relative" { n.pos = 1 }
|
|
if s == "absolute" { n.pos = 2 }
|
|
if s == "fixed" { n.pos = 3 }
|
|
} else if key == "top" { n.top = el_inset(ui_st, n, 0, v) } else if key == "right" { n.right = el_inset(ui_st, n, 1, v) } else if key == "bottom" { n.bottom = el_inset(ui_st, n, 2, v) } else if key == "left" { n.left = el_inset(ui_st, n, 3, v) } else if key == "inset" {
|
|
el_sides(ui_st, v)
|
|
n.top = ui_st.el_s0
|
|
n.right = ui_st.el_s1
|
|
n.bottom = ui_st.el_s2
|
|
n.left = ui_st.el_s3
|
|
} else if key == "z-index" { n.z = int(el_num(s)) } else if key == "overflow" or key == "overflow-y" {
|
|
if (s == "auto" or s == "scroll" or s == "hidden") and n.kind == UI_BOX { n.kind = UI_SCROLL }
|
|
} else if key == "white-space" { n.nowrap = s == "nowrap" or s == "pre" } else if key == "text-overflow" { n.ellipsis = s == "ellipsis" } else { return false }
|
|
return true
|
|
}
|