CabinGame/Luxe/blocks/ui/box.wren
2020-10-25 18:55:33 +01:00

33 lines
No EOL
889 B
Text

import "luxe: ui/control" for Control
import "luxe: world" for UI, World, UIEvent
import "luxe: draw" for PathStyle
import "luxe: assets" for Assets
import "luxe: render" for Image
import "luxe: math" for Math
import "globals" for Globals
import "math/rect" for AABB
import "math/math" for M
import "blocks/debug" for DrawDebug
class UIBox{
static create(ent){
var box = Control.create(ent)
var style = PathStyle.new()
style.color = [1,1,1,1]
style.thickness = 1
Control.set_state_data(box, {"style": style})
Control.set_render(box) {|control, state, x, y, w, h|
var depth = UI.draw_depth_of(control, 0)
UI.draw_rect(control, x+0.5, y+0.5, depth, w-1, h-1, 0, state["style"])
}
return box
}
static set_color(box, color){
var data = Control.get_state_data(box)
data["style"].color = color
}
}