32 lines
756 B
Plaintext
32 lines
756 B
Plaintext
#module "selectable"
|
|
#import "drawing_props"
|
|
#import "style"
|
|
|
|
SelectableSpec :: struct {
|
|
bounds: Rectangle
|
|
selected: bool
|
|
hovered: bool
|
|
pressed: bool
|
|
disabled: bool
|
|
face: StyleFrame
|
|
label_inset: float
|
|
}
|
|
|
|
SelectablePaint :: struct {
|
|
bounds: Rectangle
|
|
fill_color: u32
|
|
text_color: u32
|
|
label_x: float
|
|
draw_fill: bool
|
|
}
|
|
|
|
SelectablePaintFor :: (spec: SelectableSpec) -> SelectablePaint #export {
|
|
paint: SelectablePaint
|
|
paint.bounds = spec.bounds
|
|
paint.label_x = spec.bounds.x + spec.label_inset
|
|
paint.text_color = spec.face.value.foreground
|
|
paint.draw_fill = !spec.disabled && (spec.selected || spec.hovered || spec.pressed)
|
|
paint.fill_color = spec.face.value.background
|
|
return paint
|
|
}
|