View Single Post
01-23-24, 10:05 PM   #11
dragonflyy
An Aku'mai Servant
 
dragonflyy's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 32
Not sure if this will help you are not, the new color picker is acutally well made (in my opinion). I am leaving a small code snippet from my addon so anyone else can use it to use the new color picker. It's all contained in one function call now, and there is no callback.

Lua Code:
  1. ColorPickerFrame:SetupColorPickerAndShow({
  2.     r = colors.red,
  3.     g = colors.green,
  4.     b = colors.blue,
  5.     opacity = colors.alpha,
  6.     hasOpacity = true,
  7.     swatchFunc = function()
  8.         colors.red, colors.green, colors.blue = ColorPickerFrame:GetColorRGB()
  9.         colors.alpha = ColorPickerFrame:GetColorAlpha()
  10.         L.AttachedFrame.ScrollFrame.listView:Refresh()
  11.     end,
  12.     cancelFunc = function()
  13.         colors.red, colors.green, colors.blue, colors.alpha =
  14.         ColorPickerFrame.previousValues.r, ColorPickerFrame.previousValues.g,
  15.             ColorPickerFrame.previousValues.b, ColorPickerFrame.previousValues.a
  16.         L.AttachedFrame.ScrollFrame.listView:Refresh()
  17.     end
  18. })

An alternative way (this is more how Blizzard did this)
Lua Code:
  1. local info = {}
  2. info.r, info.g, info.b = colors.red, colors.green, colors.blue
  3. info.opacity = colors.alpha
  4. info.hasOpacity = true
  5. info.swatchFunc = function()
  6.     colors.red, colors.green, colors.blue = ColorPickerFrame:GetColorRGB()
  7.     colors.alpha = ColorPickerFrame:GetColorAlpha()
  8.     L.AttachedFrame.ScrollFrame.listView:Refresh()
  9. end
  10. info.cancelFunc = function()
  11.     colors.red, colors.green, colors.blue, colors.alpha =
  12.         ColorPickerFrame.previousValues.r, ColorPickerFrame.previousValues.g,
  13.         ColorPickerFrame.previousValues.b, ColorPickerFrame.previousValues.a
  14.     L.AttachedFrame.ScrollFrame.listView:Refresh()
  15. end
  16. ColorPickerFrame:SetupColorPickerAndShow(info)

Also one thing to note, the new window is moveable and it remembers where it was. It also has hex code for colors

Last edited by dragonflyy : 01-23-24 at 10:08 PM.
  Reply With Quote