-
首页
-
C4D R23.110 C++ SDK
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()
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()
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()
Merges colors from
group
.
-
参数
-
[in]
|
group
|
The group to merge colors from.
|
-
返回
-
true
if successful, otherwise
false
.
◆
CopyFrom()
Copies a group.
-
参数
-
[in]
|
group
|
The group to copy from.
|
-
返回
-
true
if successful, otherwise
false
.
◆
GetName()
Returns the group name.
-
返回
-
The group name.
◆
SetName()
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()
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()
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()
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()
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()
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()
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()
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()
Inverts the selected colors, so the currently selected colors will be unselected and vice-versa.
◆
SelectColor()
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
被选中。
-
参数
-
-
返回
-
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()
Sorts colors in the group based in their HSV values.