feat(ui): per-side borders (border-top/right/bottom/left)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0a7525b125
commit
584e455f2d
8 changed files with 50 additions and 16 deletions
|
|
@ -16,7 +16,7 @@ function fr_draw_in(n: UiNode) -> void {
|
|||
fr_background(n)
|
||||
fr_border(n)
|
||||
if n.kind == UI_TEXT { fr_text(n) }
|
||||
if n.kind == UI_IMAGE and ui_be.image != null { ui_be.image(n.src, n.x + n.pl + n.border, n.y + n.pt + n.border, n.cw - ly_hin(n), n.ch - ly_vin(n), n.rfg, fr_ga * n.rfg_a) }
|
||||
if n.kind == UI_IMAGE and ui_be.image != null { ui_be.image(n.src, n.x + n.pl + n.bl, n.y + n.pt + n.bt, n.cw - ly_hin(n), n.ch - ly_vin(n), n.rfg, fr_ga * n.rfg_a) }
|
||||
let clipped = n.kind == UI_SCROLL and ui_be.clip != null
|
||||
if clipped { fr_clip_push(n.x, n.y, n.cw, n.ch) }
|
||||
if n.children != null { fr_children(n) }
|
||||
|
|
@ -50,14 +50,17 @@ function fr_box(x: float, y: float, w: float, h: float, r: float, c: int, a: flo
|
|||
if r > 0.0 and ui_be.round != null { ui_be.round(x, y, w, h, r, c, a) } else if ui_be.rect != null { ui_be.rect(x, y, w, h, c, a) }
|
||||
}
|
||||
function fr_border(n: UiNode) -> void {
|
||||
if n.border <= 0.0 or ui_be.rect == null { return }
|
||||
if n.bt + n.br + n.bb + n.bl <= 0.0 or ui_be.rect == null { return }
|
||||
var c = n.border_c
|
||||
var ca = fr_ga * n.border_a
|
||||
if c < 0 {
|
||||
c = n.rfg
|
||||
ca = fr_ga * n.rfg_a
|
||||
}
|
||||
fr_frame(n.x, n.y, n.cw, n.ch, n.border, c, ca)
|
||||
if n.bt > 0.0 { ui_be.rect(n.x, n.y, n.cw, n.bt, c, ca) }
|
||||
if n.bb > 0.0 { ui_be.rect(n.x, n.y + n.ch - n.bb, n.cw, n.bb, c, ca) }
|
||||
if n.bl > 0.0 { ui_be.rect(n.x, n.y + n.bt, n.bl, n.ch - n.bt - n.bb, c, ca) }
|
||||
if n.br > 0.0 { ui_be.rect(n.x + n.cw - n.br, n.y + n.bt, n.br, n.ch - n.bt - n.bb, c, ca) }
|
||||
}
|
||||
function fr_frame(x: float, y: float, w: float, h: float, b: float, c: int, a: float) -> void {
|
||||
ui_be.rect(x, y, w, b, c, a)
|
||||
|
|
@ -79,7 +82,7 @@ function fr_outline(n: UiNode) -> void {
|
|||
}
|
||||
# a text's lines (one, or the wrapped ones), each placed by text-align, the last cut by an ellipsis
|
||||
function fr_text(n: UiNode) -> void {
|
||||
let y = n.y + n.pt + n.border
|
||||
let y = n.y + n.pt + n.bt
|
||||
let a = n.rfg_a * fr_ga
|
||||
if n.lines == null {
|
||||
var s = n.text
|
||||
|
|
@ -91,7 +94,7 @@ function fr_text(n: UiNode) -> void {
|
|||
}
|
||||
# where a line starts: text-align within the room the box gives it
|
||||
function fr_line_x(n: UiNode, s: string) -> float {
|
||||
let x = n.x + n.pl + n.border
|
||||
let x = n.x + n.pl + n.bl
|
||||
if n.talign == UI_START { return x }
|
||||
let spare = n.cw - ly_hin(n) - ly_text_w(s, n.rsize)
|
||||
if n.talign == UI_CENTER { return x + spare / 2.0 }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue