Thread Tools Display Modes
01-03-24, 10:34 AM   #1
dragonflyy
An Aku'mai Servant
 
dragonflyy's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 32
Color picker

Is there a way to embed the color picker into my own frame instead of using WoW's popup? Would I just have to look into the colorpicker.xml and recreate it for my own use, or is there another way?
  Reply With Quote
01-03-24, 11:21 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
The ColorPickerFrame primarily uses the ColorPickerFrame.func to tell something that is has been used to "select" a color (as the mouse drags across it etc..). You can use it with any widget that has a region that can change color (Texture, FontString) or to just to get the changed r, g, b values.

You can create a Button, make it look like anything then eg.
Lua Code:
  1. local function CancelColor()
  2.     local prevColor = ColorPickerFrame.previousValues
  3.     local colorBox = ColorPickerFrame.colorBox.Texture
  4.     colorBox:SetVertexColor(prevColor.r, prevColor.g, prevColor.b)
  5. end
  6.  
  7. local function ColorChanged()
  8.     local r, g, b = ColorPickerFrame:GetColorRGB()
  9.     local colorBox = ColorPickerFrame.colorBox.Texture
  10.     colorBox:SetVertexColor(r, g, b)
  11.     -- maybe save the settings to Saved Variables or ...?
  12. end
  13.  
  14. local f = CreateFrame("Button", ...) -- Create a button to open the ColorPicker
  15. f:SetSize(20, 20)
  16. f:SetPoint(...)
  17. f.Texture = f:CreateTexture()
  18. f.Texture:SetAllPoints()
  19. f.Texture:SetTexture("Interface\\BUTTONS\\WHITE8X8")-- just a white square but could be anything (presumably white)
  20. f.Texture:SetVertexColor( some r, g, b settings possibly from SavedVariables)
  21.  
  22. f:SetScript("OnClick", function(self)
  23.     ColorPickerFrame.colorBox = self
  24.     local startColor = { r, g, b settings possibly copied from SavedVariables }
  25.     ColorPickerFrame.previousValues = startColor
  26.     ColorPickerFrame.cancelFunc = CancelColor
  27.     ColorPickerFrame.opacityFunc = ColorChanged
  28.     ColorPickerFrame.func = ColorChanged
  29.     ColorPickerFrame:SetColorRGB(startColor.r, startColor.g, startColor.b) -- Set the starting color of the ColorPickerFrame
  30.     ColorPickerFrame:ClearAllPoints()
  31.     ColorPickerFrame:SetPoint(...)
  32.     ColorPickerFrame:Show()
  33. end)

Just the basic basics. You would need to decide what to do to make it work for your situation (and fix any errors, cold coded).

If you want to use a different color picker maybe color picker advanced but I don't know how that one works but presumably the same...ish
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 01-03-24 at 12:09 PM.
  Reply With Quote
01-03-24, 02:15 PM   #3
insery
A Kobold Labourer
Join Date: Jan 2024
Posts: 1
What are you working on with the color picker? Have you considered using a different color picker, like Color Picker Advanced, for your project?
  Reply With Quote
01-04-24, 01:15 AM   #4
dragonflyy
An Aku'mai Servant
 
dragonflyy's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 32
I actually changed what I am doing for this, so think you for the responses
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Color picker


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off