#include <lib_colorchooser.h>
This class represents a Color Swatch Group.
Public Member Functions | |
Bool | Merge (ColorSwatchGroup *group) |
Bool | CopyFrom (ColorSwatchGroup *group) |
String | GetName () const |
void | SetName (String name) |
Int | GetColorCount () const |
Bool | GetColor (Int index, maxon::ColorA &color, Bool *selected=nullptr) const |
maxon::ColorA * | GetColorEditable (Int index, Bool *selected=nullptr) |
Bool | GetColors (ColorAlphaArray &colors, Bool selectedOnly=false) const |
Bool | SetColor (Int index, const maxon::ColorA &color, Int selected=-1) |
Int | AddColor (const maxon::ColorA &color, Bool selected=false, Int insertAt=-1) |
Int | AddColors (const ColorAlphaArray &colors, Bool selected=false, Bool merge=true, Int insertAt=-1) |
void | Reset () |
Bool | RemoveColor (Int index, Int removeCount=1) |
Bool | RemoveSelectedColors () |
Bool | HasDuplicatedColors () const |
Bool | RemoveDuplicatedColors () |
void | InvertSelection () |
Bool | SelectColor (Int index, Bool selected) |
Bool | IsColorSelected (Int index) const |
void | SelectGroup (Bool select) |
Bool | IsGroupSelected () const |
void | SortColors () |
Private Member Functions | |
ColorSwatchGroup () | |
~ColorSwatchGroup () | |
Alloc/Free | |
static ColorSwatchGroup * | Alloc (const String &name=String(), Bool selected=false, const ColorAlphaArray &colors=ColorAlphaArray()) |
static void | Free (ColorSwatchGroup *&p) |
|
private |
|
private |
|
static |
Allocates a swatch group. Destroy the allocated swatch group with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.
[in] | name | The name of the group. |
[in] | selected | The selection state of the group. |
[in] | colors | Colors to fill the group with. |
|
static |
Bool Merge | ( | ColorSwatchGroup * | group | ) |
Merges colors from group.
[in] | group | The group to merge colors from. |
Bool CopyFrom | ( | ColorSwatchGroup * | group | ) |
Copies a group.
[in] | group | The group to copy from. |
String GetName | ( | ) | const |
Returns the group name.
void SetName | ( | String | name | ) |
Sets the group name.
[in] | name | The new group name. |
Int GetColorCount | ( | ) | const |
Returns the number of colors stored in the group.
Bool GetColor | ( | Int | index, |
maxon::ColorA & | color, | ||
Bool * | selected = nullptr |
||
) | const |
Returns the color at the given index.
[in] | index | The index of the color. Must be 0 <= index < GetColorCount(). |
[out] | color | The color value. |
[out] | selected | Optionally this gets the selection status of the color. Set to nullptr to ignore. |
maxon::ColorA* GetColorEditable | ( | Int | index, |
Bool * | selected = nullptr |
||
) |
Returns the color at the given index.
[in] | index | The index of the color. Must be 0 <= index < GetColorCount(). |
[out] | selected | Optionally this gets the selection status of the color. Set to nullptr to ignore. |
Bool GetColors | ( | ColorAlphaArray & | colors, |
Bool | selectedOnly = false |
||
) | const |
Gets the colors stored in this group.
[in] | colors | The list to add the colors to. Stored data is preserved. |
[in] | selectedOnly | Set to true to get only the selected colors, set to false to get all colors. |
Bool SetColor | ( | Int | index, |
const maxon::ColorA & | color, | ||
Int | selected = -1 |
||
) |
Edits the color at the given index.
[in] | index | The index of the color. Must be 0 <= index < GetColorCount(). |
[in] | color | The new color value. |
[in] | selected | The new selection status. Possible values are: -1 = keep current selection status unchanged, 0 = unselect, 1 = select. |
Int AddColor | ( | const maxon::ColorA & | color, |
Bool | selected = false , |
||
Int | insertAt = -1 |
||
) |
Adds a new color to the group.
[in] | color | The color value. |
[in] | selected | The initial selection state of color. |
[in] | insertAt | The index of the new color (the list size will increase and the existing elements are moved) or -1 to add it to the end of the list. |
Int AddColors | ( | const ColorAlphaArray & | colors, |
Bool | selected = false , |
||
Bool | merge = true , |
||
Int | insertAt = -1 |
||
) |
Adds colors to this group.
[in] | colors | The list with colors to add to. |
[in] | selected | The initial selection state of added colors. |
[in] | merge | Set to true to merge the colors with current group colors. Use insertAt to define the insertion position. Set to false to replace the content of the group. |
[in] | insertAt | If merge is set to true, this is the index to insert the new colors. |
void Reset | ( | ) |
Removes all colors in this group.
Removes the color at the given index.
[in] | index | The index of the color. Must be 0 <= index < GetColorCount(). |
[in] | removeCount | Number of colors to be removed. If removeCnt is higher than what is available at position RemoveColor() will succeed, but will remove only the number of available colors. |
Bool RemoveSelectedColors | ( | ) |
Removes all selected colors in the group.
Bool HasDuplicatedColors | ( | ) | const |
Checks if the group has duplicated colors.
Bool RemoveDuplicatedColors | ( | ) |
Removes duplicated colors in the group.
void InvertSelection | ( | ) |
Inverts the selected colors, so the currently selected colors will be unselected and vice-versa.
Selects/unselects the color at the given index.
[in] | index | The index of the color. Must be 0 <= index < GetColorCount(). |
[in] | selected | The new selection status. |
Checks if the color at the given index is selected.
[in] | index | The index of the color. Must be 0 <= index < GetColorCount(). |
void SelectGroup | ( | Bool | select | ) |
Selects the group. This will select/unselect the group icon and all colors in the group.
[in] | select | The new selection status. |
Bool IsGroupSelected | ( | ) | const |
Checks if the group is selected.
void SortColors | ( | ) |
Sorts colors in the group based in their HSV values.