package panel
import "git.teletypegames.org/engines/inkwell/inkbase/panel"
Package panel is an inkbase widget: Panel, a coloured rectangle with an optional border, used as a backdrop for grouping other widgets. With Blocks set it is opaque to clicks (see widget.ClickBlocker) — what a plate the HUD is mounted on wants; a rule drawn on top of one does not need it.
The widget reads its default colours from a game that implements Host (PanelColors() Colors) on the UICtx's Game, and draws with its own colours, or black, on one that does not. inkwell's *Game is a Host, with the theme's PanelBG and DialogBorder, and the root package re-exports Panel.
Index
Types
type Colors
type Colors struct { BG color.Color Border color.Color }
Colors is the fallback palette a Panel reads from its host when its own BG or BorderColor is nil.
type Host
type Host interface { // PanelColors is the fallback palette. PanelColors() Colors }
Host is the optional part of the game a Panel reads its fallback colours from, the UICtx's Game. A Panel on a Game that does not implement it still draws, with its own colours only.
type Panel
type Panel struct { // Name is the key the widget is registered under. Name string // When gates the widget; nil shows it always. When inkbase.Condition // Bounds is the rectangle filled. Bounds inkbase.Rectangle // BG fills it; nil takes the host's [Colors].BG (in inkwell the active // theme's PanelBG), and black without one. BG color.Color // Border is the outline's thickness in pixels; 0 draws none. Border int // BorderColor is the outline's colour; nil takes the host's // [Colors].Border (in inkwell the theme's DialogBorder), and no outline // without one. BorderColor color.Color // Blocks makes the panel opaque to clicks, so a widget that pops up // where the pointer is — the verb coin — does not open over it. A // plate the HUD is mounted on wants this; a rule drawn on top of one // does not, since the plate underneath has already said so. Blocks bool }
Panel is a generic background widget — a colored rectangle. Useful as a backdrop for grouping other widgets or as a chat/notebook frame.
func (*Panel) BlocksClickAt
func (p *Panel) BlocksClickAt(ctx *widget.UICtx, pt inkbase.Point) bool
BlocksClickAt reports whether pt falls inside Bounds of a panel that has Blocks set; such a panel keeps clicks off the scene behind it.
func (*Panel) Draw
func (p *Panel) Draw(dst *ebiten.Image, ctx *widget.UICtx)
Draw fills Bounds with BG and, when Border is positive, outlines it in BorderColor.
func (*Panel) GetName
func (p *Panel) GetName() string
GetName returns the name the panel is registered under.
func (*Panel) Layer
func (p *Panel) Layer() widget.Layer
Layer puts the panel on widget.LayerPanel, under the HUD mounted on it.
func (*Panel) Tick
func (p *Panel) Tick(ctx *widget.UICtx)
Tick does nothing; the panel only displays.
func (*Panel) VisibleWhen
func (p *Panel) VisibleWhen() inkbase.Condition
VisibleWhen returns the condition that switches the panel on; nil means always.