A themed icon that can be dropped into any widget or layout. Sources:

  • Glyph — a built-in UIGlyph drawn as a vector (no asset). Use UIIcon.fromGlyph(...) or assign glyph; takes precedence over asset when set.
  • SVG (preferred) when the optional svg haxelib is present (-lib svg sets the svg define automatically) — rasterized once per (asset, pixel size) into a shared static cache, so N icons of the same glyph cost one texture and batch as bitmaps.
  • Bitmap assets (png etc.) otherwise, scaled into the same cache.

Tinting forces every opaque pixel to a theme colour (tone ramp or colorOverride) via a reused ColorTransform, so monochrome icon sets follow theme swaps with zero extra bitmaps; set tinted = false for full-colour art. Missing assets render a placeholder ring so layouts never break. Non-interactive and pointer-transparent — attach freely to buttons, rows, rails (addChild + position).

Static methods

staticclearCache():Void

Drops all cached rasters and parsed SVG documents (e.g. after a UITheme.setScale change made every old pixel size stale, or on state teardown). Live icons re-rasterize on their next render. Cached BitmapData is left to the GC — it may still be displayed by live Bitmaps.

@:value({ tone : SECONDARY, size : 16 })staticfromGlyph(glyph:UIGlyph, size:Float = 16, tone:UITone = SECONDARY):UIIcon

Builds an icon that draws a built-in vector UIGlyph (no asset needed).

Parameters:

glyph

the glyph to draw

size

base (unscaled) square edge length

tone

theme text ramp tint (PRIMARY/SECONDARY/TERTIARY)

Returns:

the configured icon

staticgetBitmap(asset:String, sizePx:Int):BitmapData

The shared rasterized bitmap for an asset at an exact pixel size (rendered/scaled and cached on first request). Custom widgets can draw icons directly from this in their own render() without a child UIIcon.

Parameters:

asset

the icon asset path

sizePx

the exact square pixel size

Returns:

the cached bitmap, or null when the asset is missing (or .svg without the lib)

Constructor

@:value({ tone : SECONDARY, size : 16 })new(asset:String, size:Float = 16, tone:UITone = SECONDARY)

Parameters:

asset

the icon asset path

size

base (unscaled) square edge length

tone

theme text ramp tint (PRIMARY/SECONDARY/TERTIARY)

Variables

asset:String

The icon asset path (.svg with the svg lib, or any bitmap format).

@:value(0)colorOverride:Int = 0

Explicit ARGB tint; overrides tone when != 0.

@:value(cast -1)glyph:UIGlyph = cast -1

A built-in vector glyph to draw instead of an asset; < 0 (the default) means none.

size:Float

Base (unscaled) square edge length.

@:value(true)tinted:Bool = true

false renders the source colours untouched (full-colour art).

@:value(SECONDARY)tone:UITone = SECONDARY

Tint from the theme text ramp: PRIMARY, SECONDARY or TERTIARY.

Methods

Inherited Variables

Defined by UIComponent

@:value(true)enabled:Bool = true

Disabled widgets ignore the pointer and typically render dimmed.

@:value(0)read onlyh:Float = 0

Layout height in UI units.

@:value(MouseCursor.BUTTON)hoverCursor:MouseCursor = MouseCursor.BUTTON

Native cursor while hovering (interactive widgets; null keeps the arrow).

@:value(false)read onlyhovered:Bool = false

true while the cursor is over this widget.

@:value(null)onClick:() ‑> Void = null

Fired on a completed click (press + release on this widget).

@:value(null)onHover:() ‑> Void = null

Fired when the cursor first enters this widget (hover-driven descriptions/previews).

@:value(null)onRightClick:() ‑> Void = null

Fired on a right mouse press over this widget (context menus).

@:value(false)read onlypressed:Bool = false

true while a press that started here is held.

@:value(null)tooltip:String = null

Optional tooltip text (already-localized or a fixed string).

@:value(null)tooltipShortcut:String = null

Optional right-aligned shortcut hint rendered in the tooltip.

@:value(0)read onlyw:Float = 0

Layout width in UI units (independent of DisplayObject's content-derived width).

Inherited Methods

Defined by UIComponent

dispose():Void

Tears the widget down: listeners, pointer references, children, parent link.

invalidate():Void

Schedules a repaint for the next frame (cheap; deduplicated).

resize(width:Float, height:Float):Void

Sets the layout size and repaints when it changed.

Parameters:

width

the new layout width in UI units

height

the new layout height in UI units