WindowItem
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
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
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.
Theme to use for styling this item. If null, the default theme is used.
Generic integer field #0. Usage varies by item kind (e.g., selected index, numeric value, flags).
Generic integer field #1. Usage varies by item kind (e.g., updated value, secondary index).
Generic integer field #2. Usage varies by item kind (e.g., flags, text alignment, point size).
Generic integer field #3. Usage varies by item kind (e.g., preRenderedSize, additional flags).
Label position for labeled items (LEFT, RIGHT, etc.). Used by LabeledView components to position labels relative to content.
Whether this item is disabled. Disabled items typically appear grayed out and don't respond to interaction.
Flex value for layout purposes. Controls how the item grows/shrinks in flexible layouts.
Generic float field #0. Usage varies by item kind (e.g., current value, height, minimum value).
Generic float field #1. Usage varies by item kind (e.g., updated value, width).
Width allocated for labels in labeled items. Used by LabeledView components to size the label area.
Generic float field #3. Usage varies by item kind (e.g., minimum value, range start).
Generic float field #4. Usage varies by item kind (e.g., maximum value, range end).
Generic boolean field #0. Usage varies by item kind (e.g., multiline, enabled state, scale to fit).
Generic boolean field #1. Usage varies by item kind (e.g., submit flag, apply filter).
Generic boolean field #2. Usage varies by item kind (e.g., focus flag, auto-state).
Generic boolean field #3. Usage varies by item kind (e.g., blur flag, additional state).
Generic boolean field #4. Usage varies by item kind (e.g., autocomplete on focus).
Generic string field #0. Usage varies by item kind (e.g., current text value, button text, content).
Generic string field #1. Usage varies by item kind (e.g., updated value, null value text, selected tab).
Generic string field #2. Usage varies by item kind (e.g., label text, field name).
Generic string field #3. Usage varies by item kind (e.g., placeholder text, dialog title).
Generic string field #4. Usage varies by item kind (e.g., additional text, help text).
Generic any-type field #0. Usage varies by item kind (e.g., data object, file filters, list items).
Generic any-type field #1. Usage varies by item kind (e.g., updated data, moved items).
Generic any-type field #2. Usage varies by item kind (e.g., trashed items, additional data).
Generic any-type field #3. Usage varies by item kind (e.g., locked items, state data).
Generic any-type field #4. Usage varies by item kind (e.g., unlocked items, extra state).
Generic any-type field #5. Usage varies by item kind (e.g., duplicated items, extended data).
Visual element associated with this item. Used by VISUAL kind items to display custom visual content.
Generic integer array field #0. Usage varies by item kind (e.g., tab states, indices, flags array).
Generic string array field #0. Usage varies by item kind (e.g., options list, available tabs, file list).
Generic string array field #1. Usage varies by item kind (e.g., tab labels, secondary options).
Generic any-type array field #0. Usage varies by item kind (e.g., data objects, theme list, items collection).
Row identifier for grid-based layouts or grouping. Used to organize items into logical rows.
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 |
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 |
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) |
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
- Resets all data fields to default values
- Handles visual deactivation if not parented
- Returns the item to the object pool for reuse
Creates a new WindowItem instance.
Note: Use WindowItem.get() instead of direct construction to benefit from object pooling.
Private Members
Object pool for efficient WindowItem reuse. Minimizes garbage collection by recycling items instead of creating new ones. @private
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 |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |
Name | Type |
---|---|
view |
ceramic.View |
Returns |
---|
ceramic.View |