From 9d60db06c3b0141f63e556e4278376c3c8e2585e Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 10 Dec 2016 18:31:20 +0100 Subject: [PATCH] gui: add colorpicker function --- modules/gui.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/modules/gui.lua b/modules/gui.lua index a61aa835..ea44c084 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -398,6 +398,49 @@ pfUI:RegisterModule("gui", function () frame.category = category frame.config = config + if widget == "color" then + -- color picker + frame.color = CreateFrame("Button", nil, frame) + frame.color:SetWidth(12) + frame.color:SetHeight(12) + pfUI.utils:CreateBackdrop(frame.color) + frame.color:SetPoint("TOPRIGHT" , 0, -4) + frame.color.prev = frame.color.backdrop:CreateTexture("OVERLAY") + frame.color.prev:SetAllPoints(frame.color) + + local cr, cg, cb, ca = strsplit(",", category[config]) + frame.color.prev:SetTexture(cr,cg,cb,ca) + + frame.color:SetScript("OnClick", function() + local cr, cg, cb, ca = strsplit(",", category[config]) + local preview = this.prev + + function ColorPickerFrame.func() + local r,g,b = ColorPickerFrame:GetColorRGB() + local a = 1 - OpacitySliderFrame:GetValue() + + preview:SetTexture(r,g,b,a) + + if not this:GetParent():IsShown() then + category[config] = r .. "," .. g .. "," .. b .. "," .. a + pfUI.gui.settingChanged = true + end + end + + function ColorPickerFrame.cancelFunc() + preview:SetTexture(cr,cg,cb,ca) + end + + ColorPickerFrame.opacityFunc = ColorPickerFrame.func + ColorPickerFrame.element = this + ColorPickerFrame.opacity = 1 - ca + ColorPickerFrame.hasOpacity = 1 + ColorPickerFrame:SetColorRGB(cr,cg,cb) + ColorPickerFrame:Show() + ColorPickerFrame:SetFrameStrata("DIALOG") + end) + end + if widget == "warning" then pfUI.utils:CreateBackdrop(frame, nil, true) frame:SetBackdropBorderColor(1,.5,.5)