ColorSwatchGroup Class Reference Library » ColorChooser 库

#include <lib_colorchooser.h>

详细描述

This class represents a Color Swatch Group.

由于
R18

公共成员函数

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  重置 ()
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 ()

私有成员函数

  ColorSwatchGroup ()
  ~ColorSwatchGroup ()

Alloc/Free

static ColorSwatchGroup Alloc (const String &name= String (), Bool selected=false, const ColorAlphaArray &colors= ColorAlphaArray ())
static void  Free ( ColorSwatchGroup *&p)

构造函数 & 析构函数文档编制

◆  ColorSwatchGroup()

ColorSwatchGroup () private

◆  ~ColorSwatchGroup()

~ ColorSwatchGroup () private

成员函数文档编制

◆  Alloc()

static ColorSwatchGroup * Alloc ( const String name = String() ,
Bool   selected = false ,
const ColorAlphaArray colors = ColorAlphaArray()  
)
static

Allocates a swatch group. Destroy the allocated swatch group with Free() 。使用 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.
返回
The allocated swatch group, or nullptr if the allocation failed.

◆  Free()

static void Free ( ColorSwatchGroup *&  p )
static

Destructs swatch group allocated with Alloc() 。使用 AutoAlloc to automate the allocation and destruction based on scope.

参数
[in] p The swatch group to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆  Merge()

Bool Merge ( ColorSwatchGroup group )

Merges colors from group .

参数
[in] group The group to merge colors from.
返回
true if successful, otherwise false .

◆  CopyFrom()

Bool CopyFrom ( ColorSwatchGroup group )

Copies a group.

参数
[in] group The group to copy from.
返回
true if successful, otherwise false .

◆  GetName()

String GetName ( ) const

Returns the group name.

返回
The group name.

◆  SetName()

void SetName ( String   name )

Sets the group name.

参数
[in] name The new group name.

◆  GetColorCount()

Int GetColorCount ( ) const

Returns the number of colors stored in the group.

返回
The number of colors stored in the group.

◆  GetColor()

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.
返回
true if the color could be accessed, otherwise false .

◆  GetColorEditable()

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.
返回
A pointer to the color value or nullptr . Can be edited without side effects.

◆  GetColors()

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.
返回
true if successful, otherwise false .

◆  SetColor()

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.
返回
true if the color could be changed, otherwise false .

◆  AddColor()

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.
返回
The index of the new color or -1 if an error occurred.

◆  AddColors()

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 merge 被设为 true , this is the index to insert the new colors.
返回
The index of the new color or -1 if error.

◆  Reset()

void Reset ( )

Removes all colors in this group.

◆  RemoveColor()

Bool RemoveColor ( Int   index ,
Int   removeCount = 1  
)

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.
返回
true if the color was successfully removed, otherwise false .

◆  RemoveSelectedColors()

Bool RemoveSelectedColors ( )

Removes all selected colors in the group.

返回
true if selected colors were successfully removed, otherwise false .

◆  HasDuplicatedColors()

Bool HasDuplicatedColors ( ) const

Checks if the group has duplicated colors.

返回
true if duplicated colors were found, otherwise false .

◆  RemoveDuplicatedColors()

Bool RemoveDuplicatedColors ( )

Removes duplicated colors in the group.

返回
true if duplicated colors were found and removed, otherwise false .

◆  InvertSelection()

void InvertSelection ( )

Inverts the selected colors, so the currently selected colors will be unselected and vice-versa.

◆  SelectColor()

Bool SelectColor ( Int   index ,
Bool   selected  
)

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.
返回
true if the color selection status was successfully set, otherwise false .

◆  IsColorSelected()

Bool IsColorSelected ( Int   index ) const

Checks if the color at the given index 被选中。

参数
[in] index The index of the color. Must be 0 <= index < GetColorCount() .
返回
true if the color is selected, false if it is unselected or index is invalid.

◆  SelectGroup()

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.

◆  IsGroupSelected()

Bool IsGroupSelected ( ) const

Checks if the group is selected.

返回
true if the group is selected, otherwise false .

◆  SortColors()

void SortColors ( )

Sorts colors in the group based in their HSV values.