ci/woodpecker/push/woodpecker Pipeline was successful
Registration order was the only thing deciding what a widget was drawn over, which forced a domain to keep one ordered list of every widget it owns — the one shape that cannot be split into a file per widget. A widget now says where it belongs: Layer, the eight LayerScene..LayerCursor constants, the optional Layered interface and LayerOf for wrappers. Draw runs from the bottom layer up, Tick from the top down, and registration order only breaks ties inside a layer. Every built-in declares its own; anything that stays quiet sits on LayerHUD, so existing HUDs come out where they were. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package inkwell
|
|
|
|
import (
|
|
"image/color"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
"github.com/hajimehoshi/ebiten/v2/vector"
|
|
)
|
|
|
|
// Panel is a generic background widget — a colored rectangle. Useful as a
|
|
// backdrop for grouping other widgets or as a chat/notebook frame.
|
|
type Panel struct {
|
|
Name string
|
|
Bounds Rectangle
|
|
// BG, if nil, falls back to the active Theme.PanelBG.
|
|
BG color.Color
|
|
// Border thickness in pixels (0 = no border).
|
|
Border int
|
|
// BorderColor, if nil, falls back to Theme.DialogBorder.
|
|
BorderColor color.Color
|
|
}
|
|
|
|
func (p *Panel) GetName() string { return p.Name }
|
|
func (p *Panel) Layer() Layer { return LayerPanel }
|
|
func (p *Panel) Tick(ctx *UICtx) {}
|
|
|
|
func (p *Panel) Draw(dst *ebiten.Image, ctx *UICtx) {
|
|
bg := p.BG
|
|
if bg == nil {
|
|
bg = ctx.Game.Theme().PanelBG
|
|
}
|
|
vector.DrawFilledRect(dst,
|
|
float32(p.Bounds.X), float32(p.Bounds.Y),
|
|
float32(p.Bounds.W), float32(p.Bounds.H), bg, false)
|
|
if p.Border > 0 {
|
|
bc := p.BorderColor
|
|
if bc == nil {
|
|
bc = ctx.Game.Theme().DialogBorder
|
|
}
|
|
vector.StrokeRect(dst,
|
|
float32(p.Bounds.X), float32(p.Bounds.Y),
|
|
float32(p.Bounds.W), float32(p.Bounds.H),
|
|
float32(p.Border), bc, false)
|
|
}
|
|
}
|