Panel
Panel management system for the Lilia framework.
Overview
liaListenForInventoryChanges(inventory)
Purpose
Registers the panel to mirror inventory events to its methods.
When Called
Use when a panel needs to react to changes in a specific inventory.
Parameters
Inventory inventory Inventory instance whose events should be listened to.
Example Usage
panel:liaListenForInventoryChanges(inv)
liaDeleteInventoryHooks(id)
Purpose
Removes inventory event hooks previously registered on the panel.
When Called
Call when tearing down a panel or when an inventory is no longer tracked.
Parameters
number id optional Optional inventory ID to target; nil clears all known hooks.
Example Usage
panel:liaDeleteInventoryHooks(invID)
On(name, fn)
SetupTransition(name, speed, fn)
Purpose
Creates a smoothly lerped state property driven by a predicate function.
When Called
Use when a panel needs an animated transition flag (e.g., hover fades).
Parameters
string name Property name to animate on the panel.
number speed Lerp speed multiplier.
function fn Predicate returning true when the property should approach 1.
Example Usage
panel:SetupTransition("HoverAlpha", 6, function(s) return s:IsHovered() end)
FadeHover(col, speed, rad)
Purpose
Draws a faded overlay that brightens when the panel is hovered.
When Called
Apply to panels that need a simple hover highlight.
Parameters
Color col Overlay color and base alpha.
number speed Transition speed toward hover state.
number rad optional Optional corner radius for rounded boxes.
Example Usage
panel:FadeHover(Color(255,255,255,40), 8, 4)
BarHover(col, height, speed)
Purpose
Animates a horizontal bar under the panel while hovered.
When Called
Use for button underlines or similar hover indicators.
Parameters
Color col Bar color.
number height Bar thickness in pixels.
number speed Transition speed toward hover state.
Example Usage
panel:BarHover(Color(0,150,255), 2, 10)
FillHover(col, dir, speed, mat)
Purpose
Fills the panel from one side while hovered, optionally using a material.
When Called
Use when a directional hover fill effect is desired.
Parameters
Color col Fill color.
number dir Direction constant (LEFT, RIGHT, TOP, BOTTOM).
number speed Transition speed toward hover state.
IMaterial mat optional Optional material to draw instead of a solid color.
Example Usage
panel:FillHover(Color(255,255,255,20), LEFT, 6)
TiledMaterial(mat, tw, th, col)
Purpose
Tiles a material over the panel at a fixed texture size.
When Called
Use when repeating patterns should fill the panel.
Parameters
IMaterial mat Material to tile.
number tw Tile width in texture units.
number th Tile height in texture units.
Color col Color tint for the material.
Example Usage
panel:TiledMaterial(myMat, 64, 64, Color(255,255,255))
Text(text, font, col, alignment, paint)
Purpose
Renders a single line of text within the panel or sets label properties directly.
When Called
Use to quickly add centered or aligned text to a panel.
Parameters
string text Text to display.
string font Font name to use.
Color col Text color.
number alignment TEXT_ALIGN_* constant controlling horizontal alignment.
boolean paint Force paint-based rendering even if label setters exist.
Example Usage
panel:Text("Hello", "Trebuchet24", color_white, TEXT_ALIGN_CENTER)
DualText(alignment, centerSpacing)
Purpose
Draws two stacked text lines with independent styling.
When Called
Use when a panel needs a title and subtitle aligned together.
Parameters
number alignment TEXT_ALIGN_* horizontal alignment.
number centerSpacing Offset to spread the two lines from the center point.
Example Usage
panel:DualText("Title", "Trebuchet24", lia.colors.primary, "Detail", "Trebuchet18", color_white)
Blur(amount)
Purpose
Draws a post-process blur behind the panel bounds.
When Called
Use to blur the world/UI behind a panel while it is painted.
Parameters
number amount Blur intensity multiplier.
Example Usage
panel:Blur(8)
CircleClick(col, speed, trad)
Purpose
Creates a ripple effect centered on the click position.
When Called
Use for buttons that need animated click feedback.
Parameters
Color col Ripple color and opacity.
number speed Lerp speed for expansion and fade.
number trad optional Target radius override; defaults to panel width.
Example Usage
panel:CircleClick(Color(255,255,255,40), 5)
CircleHover(col, speed, trad)
Purpose
Draws a circular highlight that follows the cursor while hovering.
When Called
Use for hover feedback centered on the cursor position.
Parameters
Color col Highlight color and base opacity.
number speed Transition speed for appearing/disappearing.
number trad optional Target radius; defaults to panel width.
Example Usage
panel:CircleHover(Color(255,255,255,30), 6)
SquareCheckbox(inner, outer, speed)
Purpose
Renders an animated square checkbox fill tied to the panel's checked state.
When Called
Use on checkbox panels to visualize toggled state.
Parameters
Color inner Color of the filled square.
Color outer Color of the outline/background.
number speed Transition speed for filling.
Example Usage
checkbox:SquareCheckbox()
CircleCheckbox(inner, outer, speed)
Purpose
Renders an animated circular checkbox tied to the panel's checked state.
When Called
Use on checkbox panels that should appear circular.
Parameters
Color inner Color of the inner filled circle.
Color outer Outline color.
number speed Transition speed for filling.
Example Usage
checkbox:CircleCheckbox()
AvatarMask(mask)
Purpose
Applies a stencil mask to an AvatarImage child using a custom shape.
When Called
Use when an avatar needs to be clipped to a non-rectangular mask.
Parameters
function mask Draw callback that defines the stencil shape.
Example Usage
panel:AvatarMask(function(_, w, h) drawCircle(w/2, h/2, w/2) end)
Circle(col)
Purpose
Paints a filled circle that fits the panel bounds.
When Called
Use for circular panels or backgrounds.
Parameters
Color col Circle color.
Example Usage
panel:Circle(Color(255,255,255))
Gradient(col, dir, frac, op)
Purpose
Draws a directional gradient over the panel.
When Called
Use to overlay a gradient tint from a chosen side.
Parameters
Color col Gradient color.
number dir Direction constant (LEFT, RIGHT, TOP, BOTTOM).
number frac Fraction of the panel to cover with the gradient.
boolean op When true, flips the gradient material for the given direction.
Example Usage
panel:Gradient(Color(0,0,0,180), BOTTOM, 0.4)
SetOpenURL(url)
Purpose
Opens a URL when the panel is clicked.
When Called
Attach to clickable panels that should launch an external link.
Parameters
string url URL to open.
Example Usage
panel:SetOpenURL("https://example.com")
NetMessage(name, data)
Stick(dock, margin, dontInvalidate)
Purpose
Docks the panel with optional margin and parent invalidation.
When Called
Use to pin a panel to a dock position with minimal boilerplate.
Parameters
number dock DOCK constant to apply; defaults to FILL.
number margin Optional uniform margin after docking.
boolean dontInvalidate Skip invalidating the parent when true.
Example Usage
panel:Stick(LEFT, 8)
DivTall(frac, target)
Purpose
Sets the panel height to a fraction of another panel's height.
When Called
Use for proportional layout against a parent or target panel.
Parameters
number frac Divisor applied to the target height.
Panel target Panel to reference; defaults to the parent.
Example Usage
panel:DivTall(3, parentPanel)
DivWide(frac, target)
Purpose
Sets the panel width to a fraction of another panel's width.
When Called
Use for proportional layout against a parent or target panel.
Parameters
number frac Divisor applied to the target width.
Panel target Panel to reference; defaults to the parent.
Example Usage
panel:DivWide(2, parentPanel)
SetRemove(target)
Purpose
Removes a target panel when this panel is clicked.
When Called
Use for close buttons or dismiss actions.
Parameters
Panel target optional Panel to remove; defaults to the panel itself.
Example Usage
closeButton:SetRemove(parentPanel)
SetTransitionFunc(fn)
Purpose
Sets a shared predicate used by transition helpers to determine state.
When Called
Use before invoking helpers like SetupTransition to change their condition.
Parameters
function fn Predicate returning true when the transition should be active.
Example Usage
panel:SetTransitionFunc(function(s) return s:IsVisible() end)
SetAppendOverwrite(fn)
Purpose
Overrides the target function name used by the On helper.
When Called
Use when On should wrap a different function name than the provided one.
Parameters
string fn Function name to force On to wrap.
Example Usage
panel:SetAppendOverwrite("PaintOver")