#include <lib_colorchooser.h>
This class handles the Swatch Data stored globally, in a BaseDocument or a preset. It holds 2 kinds of groups:
Static Public Member Functions | |
| static Bool | PresetExists (const String &name, maxon::BaseArray< SDKBrowserURL > *urls=nullptr) |
| static Bool | ValidPreset (const SDKBrowserURL &url) |
| static SDKBrowserURL | GetPresetDirectory () |
Private Member Functions | |
| ColorSwatchData () | |
| ~ColorSwatchData () | |
Alloc/Free | |
| static ColorSwatchData * | Alloc (BaseDocument *doc=nullptr, Bool global=false) |
| static void | Free (ColorSwatchData *&p) |
|
private |
|
private |
|
static |
Allocates a swatch data. Destroy the allocated swatch data with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.
| [in] | doc | Optional document to load swatches from. |
| [in] | global | If true the Global Swatch Group will be loaded. |
|
static |
| Bool Load | ( | BaseDocument * | doc, |
| Bool | merge = false, |
||
| Bool | loadGlobalColors = false |
||
| ) |
Loads color groups from the given document and/or global colors.
| [in] | doc | The given document. Can be nullptr if only global colors must be loaded. |
| [in] | merge | If true the colors are merged with the stored colors. Otherwise the |
| [in] | loadGlobalColors | If true the global colors are loaded.existing colors are discarded. |
| Bool Save | ( | BaseDocument * | doc, |
| Bool | saveGlobalColors = false |
||
| ) |
Saves the color groups to the given document and/or the global colors.
| [in] | doc | The document to store the color groups. Can be nullptr if only global colors must be saved. |
| [in] | saveGlobalColors | If true the global colors are saved. |
Loads the document-based swatch groups of the first preset with given name found in the user's Color Swatch Preset directory, including subdirectories.
| [in] | name | The preset name to load. |
| [in] | merge | Set to true to merge the preset data with current data, set to false to replace data. |
| Bool LoadPreset | ( | const SDKBrowserURL & | url, |
| Bool | merge = true |
||
| ) |
Loads the document-based swatch groups of the given preset.
| [in] | url | The preset url. |
| [in] | merge | Set to true to merge the preset data with current data, set to false to replace data. |
| Bool SavePreset | ( | const String & | name, |
| const String & | author = String(), |
||
| const String & | info = String(), |
||
| Bool | forceOverwrite = false |
||
| ) |
Saves the document-based groups as a Color Swatch preset.
| [in] | name | The preset name. |
| [in] | author | The preset author. |
| [in] | info | Preset additional info. |
| [in] | forceOverwrite | Set to true to force overwriting the preset in case it already exists. |
| Bool SavePreset | ( | const SDKBrowserURL & | url, |
| const String & | author = String(), |
||
| const String & | info = String(), |
||
| Bool | forceOverwrite = false |
||
| ) |
Saves the document-based groups as a Color Swatch preset.
| [in] | url | The url to save preset to. Must include the preset name and must point to an existing library. Example: SDKBrowserURL presetToSaveURL = ColorSwatchData::GetPresetDirectory() + "MyPreset" |
| [in] | author | The preset author. |
| [in] | info | Preset additional info. |
| [in] | forceOverwrite | Set to true to force overwrite the preset in case it already exists. |
|
static |
Checks if any preset with given name exists at user's Color Swatch Preset directory, including subdirectories.
| [in] | name | The preset name. |
| [out] | urls | Optionally set here a pointer to an array that will be filled with all urls pointing to a Color Swatch preset with the given name. |
|
static |
Checks if the given URL points to a valid Color Swatch preset.
| [in] | url | The url to check. |
|
static |
Gets the user's default Color Swatch Preset directory.
| Bool Merge | ( | ColorSwatchData * | data, |
| Bool | mergeGlobalColors = false |
||
| ) |
Merges groups from data.
| [in] | data | The data to merge groups from. |
| [in] | mergeGlobalColors | If true the global colors will be merged inside the global group. |
| Bool CopyFrom | ( | ColorSwatchData * | data | ) |
Copies color swatch data.
| [in] | data | Swatch data to copy from. |
| Int GetGroupCount | ( | SWATCH_CATEGORY | category = SWATCH_CATEGORY::DOCUMENT | ) | const |
Returns the number of groups stored in category.
| [in] | category | The group category. |
| ColorSwatchGroup* GetGroupAtIndex | ( | Int | index, |
| SWATCH_CATEGORY | category = SWATCH_CATEGORY::DOCUMENT |
||
| ) |
Returns the document-based group at the given index.
| [in] | index | The index of the color group. Must be 0 <= index < GetGroupCount(). |
| [in] | category | The group category. |
| Bool SetGroupAtIndex | ( | Int | index, |
| ColorSwatchGroup * | group, | ||
| SWATCH_CATEGORY | category = SWATCH_CATEGORY::DOCUMENT |
||
| ) |
Replaces the group at given index.
| [in] | index | The index of the color group. Must be 0 <= index < GetGroupCount(). |
| [in] | group | The group to copy from. |
| [in] | category | The group category. |
| ColorSwatchGroup* AddGroup | ( | SWATCH_CATEGORY | category = SWATCH_CATEGORY::DOCUMENT, |
| const String & | name = String(), |
||
| Bool | selected = false, |
||
| Int | insertAt = -1, |
||
| const ColorAlphaArray & | colors = ColorAlphaArray() |
||
| ) |
Adds a new document-based group.
| [in] | category | The category where the group will be inserted. |
| [in] | name | The name of the new group. If empty the default string "Untitled" will be used. |
| [in] | selected | The initial selection state of the new group. |
| [in] | insertAt | The index of the new group (the list size will increase and the existing elements are moved) or -1 to add it to the end of the list. |
| [in] | colors | Colors to fill the group with. |
| Bool InsertGroup | ( | ColorSwatchGroup * | group, |
| Int | insertAt = -1, |
||
| SWATCH_CATEGORY | category = SWATCH_CATEGORY::DOCUMENT |
||
| ) |
Adds a group.
| [in] | group | The group to copy from. |
| [in] | insertAt | The index of the new group (the list size will increase and the existing elements are moved) or -1 to add it to the end of the list. |
| [in] | category | The group category. |
| Bool RemoveGroup | ( | Int | index, |
| SWATCH_CATEGORY | category = SWATCH_CATEGORY::DOCUMENT |
||
| ) |
Removes the group from category at the given index.
| [in] | index | The index of the color group. Must be 0 <= index < GetGroupCount(). |
| [in] | category | The group category. |
| Bool RemoveSelectedItems | ( | ) |
Removes all selected groups and colors, including selected global colors.
| void Reset | ( | ) |
Removes all groups and colors, including globals.