WindowItem

elements.WindowItem (Class)

A versatile data container for window UI elements with efficient pooling and recycling.

This class serves as a universal data holder for all types of window items (buttons, text fields, lists, etc.) to minimize memory allocations during UI updates. It uses an object pooling system and stores data in generic fields that are interpreted differently based on the item kind.

Features

  • Object pooling for memory efficiency
  • Generic data storage for all item types
  • Automatic view creation and updates
  • Item comparison for change detection
  • Lifecycle management with recycling

Data Storage

The class uses generic fields (int0-4, float0-4, bool0-4, string0-4, any0-5, arrays) that are interpreted differently based on the WindowItemKind. This approach allows a single class to handle all UI element types efficiently.

This class is used internally by Im.* methods and is typically not used by end user.

Usage Examples

// Get a window item from the pool
var item = WindowItem.get();
item.kind = BUTTON;
item.string0 = "Click Me"; // Button text
item.bool0 = true;         // Button enabled state

// Create a view from the item
var view = item.updateView(null);

// Recycle when done
item.recycle();

Static Members

elements
get(): WindowItem

Retrieves a WindowItem from the object pool.

Gets a recycled item from the pool if available, otherwise creates a new one. This is the preferred way to create WindowItem instances for memory efficiency.

Returns Description
WindowItem A WindowItem instance ready for use * ## Examples haxe var item = WindowItem.get(); item.kind = TEXT; item.string0 = "Hello World";

Instance Members

elements
kind: WindowItemKind

The type of window item, determining how data fields are interpreted.


Reference to the previous version of this item for comparison. Used to detect changes and optimize updates.


elements
theme: Theme

Theme to use for styling this item. If null, the default theme is used.


elements
int0: Int

Generic integer field #0. Usage varies by item kind (e.g., selected index, numeric value, flags).


elements
int1: Int

Generic integer field #1. Usage varies by item kind (e.g., updated value, secondary index).


elements
int2: Int

Generic integer field #2. Usage varies by item kind (e.g., flags, text alignment, point size).


elements
int3: Int

Generic integer field #3. Usage varies by item kind (e.g., preRenderedSize, additional flags).


elements
labelPosition: Int

Label position for labeled items (LEFT, RIGHT, etc.). Used by LabeledView components to position labels relative to content.


elements
disabled: Bool

Whether this item is disabled. Disabled items typically appear grayed out and don't respond to interaction.


elements
flex: Int

Flex value for layout purposes. Controls how the item grows/shrinks in flexible layouts.


elements
float0: Float

Generic float field #0. Usage varies by item kind (e.g., current value, height, minimum value).


elements
float1: Float

Generic float field #1. Usage varies by item kind (e.g., updated value, width).


elements
labelWidth: Float

Width allocated for labels in labeled items. Used by LabeledView components to size the label area.


elements
float3: Float

Generic float field #3. Usage varies by item kind (e.g., minimum value, range start).


elements
float4: Float

Generic float field #4. Usage varies by item kind (e.g., maximum value, range end).


elements
bool0: Bool

Generic boolean field #0. Usage varies by item kind (e.g., multiline, enabled state, scale to fit).


elements
bool1: Bool

Generic boolean field #1. Usage varies by item kind (e.g., submit flag, apply filter).


elements
bool2: Bool

Generic boolean field #2. Usage varies by item kind (e.g., focus flag, auto-state).


elements
bool3: Bool

Generic boolean field #3. Usage varies by item kind (e.g., blur flag, additional state).


elements
bool4: Bool

Generic boolean field #4. Usage varies by item kind (e.g., autocomplete on focus).


elements
string0: String

Generic string field #0. Usage varies by item kind (e.g., current text value, button text, content).


elements
string1: String

Generic string field #1. Usage varies by item kind (e.g., updated value, null value text, selected tab).


elements
string2: String

Generic string field #2. Usage varies by item kind (e.g., label text, field name).


elements
string3: String

Generic string field #3. Usage varies by item kind (e.g., placeholder text, dialog title).


elements
string4: String

Generic string field #4. Usage varies by item kind (e.g., additional text, help text).


elements
any0: Any

Generic any-type field #0. Usage varies by item kind (e.g., data object, file filters, list items).


elements
any1: Any

Generic any-type field #1. Usage varies by item kind (e.g., updated data, moved items).


elements
any2: Any

Generic any-type field #2. Usage varies by item kind (e.g., trashed items, additional data).


elements
any3: Any

Generic any-type field #3. Usage varies by item kind (e.g., locked items, state data).


elements
any4: Any

Generic any-type field #4. Usage varies by item kind (e.g., unlocked items, extra state).


elements
any5: Any

Generic any-type field #5. Usage varies by item kind (e.g., duplicated items, extended data).


elements
visual: ceramic.Visual

Visual element associated with this item. Used by VISUAL kind items to display custom visual content.


elements
intArray0: Array<Int>

Generic integer array field #0. Usage varies by item kind (e.g., tab states, indices, flags array).


elements
stringArray0: Array<String>

Generic string array field #0. Usage varies by item kind (e.g., options list, available tabs, file list).


elements
stringArray1: Array<String>

Generic string array field #1. Usage varies by item kind (e.g., tab labels, secondary options).


elements
anyArray0: Array<Any>

Generic any-type array field #0. Usage varies by item kind (e.g., data objects, theme list, items collection).


elements
row: Int

Row identifier for grid-based layouts or grouping. Used to organize items into logical rows.


elements
hasManagedVisual(): Bool

Checks if this item has a managed visual that should be destroyed on cleanup.

Returns true if this is a VISUAL item with the managed flag set (int0 > 0) and a visual is actually assigned.

Returns Description
Bool true if the visual should be automatically managed

elements
isSameItem(item: WindowItem): Bool

Compares this item with another to determine if they represent the same UI element.

This comparison is used to detect when items can be reused between frames rather than recreated. The comparison logic varies by item kind, typically checking the label similarity and other identifying characteristics.

Name Type Description
item WindowItem The other WindowItem to compare against
Returns Description
Bool true if the items represent the same UI element * ## Comparison Logic by Kind - SELECT: Label + options array equality - Text/Edit fields: Label similarity - VISUAL: Label + visual reference equality - Static items (TEXT, BUTTON, etc.): Always true - Unknown: Always false

elements
updateView(view: ceramic.View): ceramic.View

Creates or updates a View based on this item's data and kind.

This method is the main entry point for converting window item data into actual UI views. It delegates to specific creation methods based on the item kind and applies common properties like flex layout.

Name Type Description
view ceramic.View Existing view to update, or null to create a new one
Returns Description
ceramic.View The created or updated view, or null for unknown kinds * ## View Creation Process 1. Determines the appropriate view type from the item kind 2. Creates a new view or updates the existing one 3. Applies item data to the view properties 4. Sets up event handlers and callbacks 5. Applies common layout properties (flex)

elements
recycle(): Void

Resets all fields to default values and returns the item to the object pool.

This method cleans up the item's state and makes it available for reuse. It resets all data fields to their default values and handles visual cleanup appropriately. After calling this method, the item should not be used until retrieved again from the pool.

Cleanup Process

  1. Resets all data fields to default values
  2. Handles visual deactivation if not parented
  3. Returns the item to the object pool for reuse
See: get

elements
new(): Void

Creates a new WindowItem instance.

Note: Use WindowItem.get() instead of direct construction to benefit from object pooling.

See: get

Private Members

elements
pool: ceramic.Pool<WindowItem>

Object pool for efficient WindowItem reuse. Minimizes garbage collection by recycling items instead of creating new ones. @private


elements
isSimilarLabel(item: WindowItem): Bool

Checks if another item has a similar label configuration.

Compares the label presence (string2 field) between items to determine if they have compatible labeling. Both items should either have labels or both should be unlabeled.

@private

Name Type Description
item WindowItem The other item to compare labels with
Returns Description
Bool true if both items have similar label states

elements
createOrUpdateSpace(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateSeparator(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateVisualContainer(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateSelectField(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateBooleanField(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateColorField(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateEditTextField(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateSliderField(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateText(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateButton(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateList(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View

elements
createOrUpdateTabs(view: ceramic.View): ceramic.View
Name Type
view ceramic.View
Returns
ceramic.View