-
Notifications
You must be signed in to change notification settings - Fork 26
Color Picker
Color picker component has 2 widgets and one static (meaning it cannot be created more than once):
- Dynamic:
- Static:
StdUi:ColorPicker(parent, alphaSliderTexture)
Description:
Creates instance of ColorSelect
. It is not
ColorPickerFrame
! It is the actual instance of ColorSelect that can be spawned multiple times.
It does not affect ColorPickerFrame
in any way.
That being said, don't use this widget unless you absolutely must. It is pretty heavy.
StdUi
provides a static implementation of dialog window called ColorPickerFrame
(which is yet again not related to blizzard ColorPickerFrame
).
Note:
OnColorSelect
script handler is already set. Please useHookScript
instead.
Arguments:
-
parent
Frame - Object that should be a parent of font string -
alphaSliderTexture
string - Location ofCheckers.tga
or another texture used as background for alpha slider
Setting width/height for this object has a little sense unless you plan to reposition all children widgets.
Returns:
Named children:
ColorSelect has multiple named children:
-
colorSelect.wheelTexture
- Texture with colors palette -
colorSelect.wheelThumbTexture
- Thumb texture used to mark position on color wheel -
colorSelect.valueTexture
- Value texture of color brightness -
colorSelect.valueThumbTexture
- Thumb texture used to mark brightness -
colorSelect.alphaSlider
-Slider
used as alpha selection -
colorSelect.alphaTexture
- Texture used as alpha selection background -
colorSelect.alphaThumbTexture
- Thumb texture used to mark alpha -
colorSelect.newTexture
- Thumb showing newly selected color -
colorSelect.oldTexture
- Thumb showing old initial color (you need to SetVertexColor yourself) -
colorSelect.oldTexture
- Thumb showing old initial color (you need to SetVertexColor yourself)
EditBoxes:
-
colorSelect.rEdit
-NumericBox
for red channel (0-255) -
colorSelect.gEdit
-NumericBox
for green channel (0-255) -
colorSelect.bEdit
-NumericBox
for blue channel (0-255) -
colorSelect.aEdit
-NumericBox
for alpha channel (0-100)
Their labels can be accessed by
-
colorSelect.aEdit.label
- Label ('A'
) forNumericBox
alpha channel. Similar for other channels.
Buttons:
-
colorSelect.okButton
- Confirmation button -
colorSelect.cancelButton
- Cancel button
Methods:
-
SetColorRGBA(r, g, b, a)
- Sets the current color - all arguments must be from 0 to 1 -
GetColorRGBA()
- Gets the current color -
SetColorAlpha(a)
- Sets the alpha channel -
GetColorAlpha()
- Gets the alpha channel
Example:
local colorSelect = StdUi:ColorPicker(window);
StdUi:ColorInput(parent, label, width, height, r, g, b, a)
Description:
Creates a Button
similar to Checkbox
which is
has color as provided in arguments r, g, b, a. Label is glued to the right side.
When user click on this button, StdUi:ColorPickerFrame
is shown (not the blizzard frame).
Arguments:
-
parent
Frame - Object that should be a parent of Color input -
label
string - Label for color input button -
width
number - Width of just the button -
height
number - Height of just the button -
r
number|table - Red channel value (0 - 1), this can be also a full color table{r = 1, g = 1, b = 1, a = 1}
. If you provide a color table, argumentsg
,b
,a
are ignored. -
g
number (Optional) - Green channel value (0 - 1) -
b
number (Optional) - Blue channel value (0 - 1) -
a
number (Optional) - Alpha channel value (0 - 1)
Returns:
Named children:
ColorSelect has multiple named children:
-
colorInput.label
- Label of the color input -
colorInput.color
- Color table{r = 1, g = 1, b = 1, a = 1}
Methods:
-
SetColor(r, g, b, a)
- Sets the color of button (and the .color children), you can provide full color table object as first arguments (similar to how constructor arguments works) -
GetColor(format)
- Gets the color of button,format
changes the output of the function:- type =
'rgba'
, function returns 4 values: r, g, b, a - type =
nil
or not provided, function returns color table:{r = 1, g = 1, b = 1, a = 1}
- type =
Example:
local colorInput = StdUi:ColorInput(window, 'Select a color', 20, 20, 1, 1, 1, 1);
StdUi:ColorPickerFrame(r, g, b, a, okCallback, cancelCallback, alphaSliderTexture)
Description:
Shows a static color picker frame similar to blizzard ColorPickerFrame
but is completely different object, it does not affect blizzard frame in any way. You cannot instantiate it.
Arguments:
-
r
number|table - Red channel value (0 - 1), this can be also a full color table{r = 1, g = 1, b = 1, a = 1}
. If you provide a color table, argumentsg
,b
,a
are ignored. -
g
number (Optional) - Green channel value (0 - 1) -
b
number (Optional) - Blue channel value (0 - 1) -
a
number (Optional) - Alpha channel value (0 - 1) -
okCallback
function - function to execute when user click OK button -
cancelCallback
function - function to execute when user click Cancel button -
alphaSliderTexture
string - Location ofCheckers.tga
or another texture used as background for alpha slider
Note: Both of the callbacks get the ColorPicker instance as first argument
Returns:
It does not return anything.
Example:
StdUi:ColorPickerFrame(1, 1, 1, 1, function(colorSelect)
print(colorSelect:GetColorRGBA());
end);