UserData
Persistent user data model for storing application-specific user preferences and state.
This class extends Model to provide serializable storage for user settings, window configurations, and other persistent application data. It manages window positioning/sizing data and color palette preferences with built-in methods for manipulation.
Features
- Persistent window data storage with automatic serialization
- Color palette management with add/remove/move operations
- Color picker mode preferences (HSLuv vs HSB)
- Automatic duplicate prevention for palette colors
Usage Examples
// Create or load user data
var userData = new UserData();
// Add colors to palette
userData.addPaletteColor(Color.RED);
userData.addPaletteColor(Color.BLUE, false); // Allow duplicates
// Manage color palette
userData.movePaletteColor(0, 2); // Move first color to third position
userData.removePaletteColor(1); // Remove color at index 1
// Configure color picker
userData.colorPickerHsluv = true; // Use HSLuv color space
Instance Members
Storage for window-specific data mapped by window identifiers.
Each window can have its own persistent data including position, size, visibility state, and other window-specific preferences. The data is automatically serialized and restored between application sessions.
Whether to use HSLuv color space in color pickers.
When true, color pickers will use the HSLuv color space which provides perceptually uniform lightness. When false, traditional HSB/HSV color space is used. This preference affects the behavior of color selection interfaces throughout the application.
@default false
Array of colors in the user's custom color palette.
This palette allows users to save frequently used colors for quick access in color pickers and other color selection interfaces. Colors can be added, removed, and reordered using the provided methods.
Adds a color to the user's palette.
Appends the specified color to the end of the palette array. By default, duplicate colors are not allowed and will be rejected with a warning.
Name | Type | Default | Description |
---|---|---|---|
color |
ceramic.Color | The color to add to the palette | |
forbidDuplicate |
Bool | true |
Whether to prevent adding duplicate colors (default: true) * ## Examples haxe // Add a unique color (default behavior) userData.addPaletteColor(Color.RED); * // Allow duplicate colors userData.addPaletteColor(Color.RED, false); |
Moves a color from one position to another in the palette.
Reorders the palette by moving the color at the specified source index to the target index. All other colors shift positions accordingly.
Name | Type | Description |
---|---|---|
fromIndex |
Int | The current index of the color to move |
toIndex |
Int | The target index where the color should be moved * ## Examples haxe // Move the first color to the third position userData.movePaletteColor(0, 2); * // Move the last color to the beginning var lastIndex = userData.paletteColors.length - 1; userData.movePaletteColor(lastIndex, 0); |
Removes a color from the palette at the specified index.
Deletes the color at the given index from the palette array. All subsequent colors shift down by one position.
Name | Type | Description |
---|---|---|
index |
Int | The index of the color to remove * ## Examples haxe // Remove the first color userData.removePaletteColor(0); * // Remove the last color var lastIndex = userData.paletteColors.length - 1; userData.removePaletteColor(lastIndex); |
Creates a new UserData instance. Initializes the model with default values for all properties.
Private Members
emitWindowsDataChange(current: ceramic.ReadOnlyMap<String, WindowData>, previous: ceramic.ReadOnlyMap<String, WindowData>): Void
Event when windowsData field changes.
Name | Type |
---|---|
current |
ceramic.ReadOnlyMap<String, WindowData> |
previous |
ceramic.ReadOnlyMap<String, WindowData> |
Event when colorPickerHsluv field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
emitPaletteColorsChange(current: ceramic.ReadOnlyArray<ceramic.Color>, previous: ceramic.ReadOnlyArray<ceramic.Color>): Void
Event when paletteColors field changes.
Name | Type |
---|---|
current |
ceramic.ReadOnlyArray<ceramic.Color> |
previous |
ceramic.ReadOnlyArray<ceramic.Color> |
Metadata
Name | Parameters |
---|---|
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.ObservableMacro.build() |
:autoBuild |
tracker.macros.ObservableMacro.build() |
:build |
tracker.macros.SerializableMacro.build() |
:autoBuild |
tracker.macros.SerializableMacro.build() |