classic-ui

Implements retained-mode UI layout, anchors, and button colliders for the classic-wgl Rust engine.

1|1|Updated Aug 18, 2021
One-click install
npx skills add https://github.com/guilledk/classic-wgl --skill classic-ui-guilledk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: classic-ui
Source: https://github.com/guilledk/classic-wgl/tree/main/.agents/skills/classic-ui
Command: npx skills add https://github.com/guilledk/classic-wgl --skill classic-ui-guilledk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building HUDs, buttons, and panels in the classic-wgl Rust engine requires coordinating ECS entities, layout math, rendering, and mouse colliders by hand. This Skill documents the UIManager's retained-mode layout system so you can create, position, and wire interactive UI elements correctly without reverse-engineering the engine. ## Core Features & Use Cases - Factory Methods: Spawn containers, SDF text, flex-like arrays, padding wrappers, sprites, and composite buttons via UIManager helpers that auto-register names and mark layout dirty. - Anchor-Based Layout: Position children with nine UiAnchor variants, scroll offsets, and clip rectangles through the measure-and-position pipeline. - Collider & Hover Integration: Sync UI colliders with PhysicsProvider each frame, get hover highlighting, click callbacks with priority, and click consumption. - Use Case: Add an editor tool panel by spawning a container, stacking buttons in a vertical array, wiring click_action closures, and calling set_button_base_color when toggling editor modes. ## Quick Start Ask the assistant to spawn a button with SDF text and a click handler using the classic-wgl UIManager, then explain how the layout refresh and collider sync keep it interactive each frame.

Frequently Asked Questions about classic-ui

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I spawn a button with a click handler in classic-wgl?

Call UIManager::spawn_button with a size, color, and ButtonOptions containing a click_action closure. It creates a container, optional text or sprite child, registers a collider, sets consumes_click, and wires a HandlerKind::Click callback dispatched by physics.perform_calls().

How does the anchor layout system position UI children?

Each child stores a self_anchor on the parent and a child_anchor on itself. set_child_position computes parent position plus parent anchor offset minus child anchor offset, so MidCenter to MidCenter centers the child within the parent.

Why is my UI element not rendering at the size I spawned it with?

UI rendering uses UiNode.size for the model matrix, not Transform.scale, which factories initialize to Vec3::ONE. For SDF text you must call measure_all_ui_labels() after spawning so the true text dimensions update UiNode.size.

Does ButtonOptions.hover or click_feedback do anything?

No. The hover boolean is stored but never read since hover highlighting is always active, and click_feedback's countdown has no trigger that sets click_frames above zero, making it dead code.

How do UI colliders stay aligned after layout changes?

UIManager::sync_colliders runs at the top of each frame before physics.perform_calls(), calling physics.sync_collider_rect with each element's current Transform.position and UiNode.size so colliders match the refreshed layout.

Can I clip UI children to a scrollable container?

Partially. Setting clip_children propagates a clip_rect to children and position_children_of applies scroll_y, but only the SDF text render arm applies GL scissoring; UiRect and UiSprite children are not visually clipped.