update ColorPicker

This commit is contained in:
Crum
2018-01-13 23:13:57 -06:00
parent d0fd753039
commit 4b4bb06dcd
3 changed files with 28 additions and 21 deletions
@@ -2,12 +2,12 @@
Credit to Jaslm, most of this code is his from the addon ColorPickerPlus Credit to Jaslm, most of this code is his from the addon ColorPickerPlus
]] ]]
local E, L, DF = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB local E, L, DF = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local B = E:GetModule("Blizzard", true); local B = E:GetModule("Blizzard");
local S = E:GetModule("Skins", true); local S = E:GetModule("Skins");
local tonumber, collectgarbage = tonumber, collectgarbage local tonumber, collectgarbage = tonumber, collectgarbage
local floor = math.floor local floor = math.floor
local format, strsub = string.format, strsub local format = string.format
local CreateFrame = CreateFrame local CreateFrame = CreateFrame
local RAID_CLASS_COLORS = RAID_CLASS_COLORS local RAID_CLASS_COLORS = RAID_CLASS_COLORS
@@ -47,15 +47,15 @@ function B:EnhanceColorPicker()
ColorPickerFrameHeader:SetTexture("") ColorPickerFrameHeader:SetTexture("")
ColorPickerFrameHeader:ClearAllPoints() ColorPickerFrameHeader:ClearAllPoints()
ColorPickerFrameHeader:SetPoint("TOP", ColorPickerFrame, 0, 0) ColorPickerFrameHeader:SetPoint("TOP", ColorPickerFrame, 0, 0)
-- S:HandleButton(ColorPickerOkayButton) S:HandleButton(ColorPickerOkayButton)
-- S:HandleButton(ColorPickerCancelButton) S:HandleButton(ColorPickerCancelButton)
ColorPickerCancelButton:ClearAllPoints() ColorPickerCancelButton:ClearAllPoints()
ColorPickerOkayButton:ClearAllPoints() ColorPickerOkayButton:ClearAllPoints()
ColorPickerCancelButton:SetPoint("BOTTOMRIGHT", ColorPickerFrame, "BOTTOMRIGHT", -6, 6) ColorPickerCancelButton:SetPoint("BOTTOMRIGHT", ColorPickerFrame, "BOTTOMRIGHT", -6, 6)
ColorPickerCancelButton:SetPoint("BOTTOMLEFT", ColorPickerFrame, "BOTTOM", 0, 6) ColorPickerCancelButton:SetPoint("BOTTOMLEFT", ColorPickerFrame, "BOTTOM", 0, 6)
ColorPickerOkayButton:SetPoint("BOTTOMLEFT", ColorPickerFrame,"BOTTOMLEFT", 6,6) ColorPickerOkayButton:SetPoint("BOTTOMLEFT", ColorPickerFrame,"BOTTOMLEFT", 6,6)
ColorPickerOkayButton:SetPoint("RIGHT", ColorPickerCancelButton,"LEFT", -4,0) ColorPickerOkayButton:SetPoint("RIGHT", ColorPickerCancelButton,"LEFT", -4,0)
-- S:HandleSliderFrame(OpacitySliderFrame) S:HandleSliderFrame(OpacitySliderFrame)
HookScript(ColorPickerFrame, "OnShow", function() HookScript(ColorPickerFrame, "OnShow", function()
-- get color that will be replaced -- get color that will be replaced
local r, g, b = ColorPickerFrame:GetColorRGB() local r, g, b = ColorPickerFrame:GetColorRGB()
@@ -121,7 +121,7 @@ function B:EnhanceColorPicker()
-- add copy button to the ColorPickerFrame -- add copy button to the ColorPickerFrame
local b = CreateFrame("Button", "ColorPPCopy", ColorPickerFrame, "UIPanelButtonTemplate") local b = CreateFrame("Button", "ColorPPCopy", ColorPickerFrame, "UIPanelButtonTemplate")
-- S:HandleButton(b) S:HandleButton(b)
b:SetText(L["Copy"]) b:SetText(L["Copy"])
b:SetWidth(60) b:SetWidth(60)
b:SetHeight(22) b:SetHeight(22)
@@ -147,7 +147,7 @@ function B:EnhanceColorPicker()
--class color button --class color button
b = CreateFrame("Button", "ColorPPClass", ColorPickerFrame, "UIPanelButtonTemplate") b = CreateFrame("Button", "ColorPPClass", ColorPickerFrame, "UIPanelButtonTemplate")
b:SetText(CLASS) b:SetText(CLASS)
-- S:HandleButton(b) S:HandleButton(b)
b:SetWidth(80) b:SetWidth(80)
b:SetHeight(22) b:SetHeight(22)
b:SetPoint("TOP", "ColorPPCopy", "BOTTOMRIGHT", 0, -7) b:SetPoint("TOP", "ColorPPCopy", "BOTTOMRIGHT", 0, -7)
@@ -164,7 +164,7 @@ function B:EnhanceColorPicker()
-- add paste button to the ColorPickerFrame -- add paste button to the ColorPickerFrame
b = CreateFrame("Button", "ColorPPPaste", ColorPickerFrame, "UIPanelButtonTemplate") b = CreateFrame("Button", "ColorPPPaste", ColorPickerFrame, "UIPanelButtonTemplate")
b:SetText(L["Paste"]) b:SetText(L["Paste"])
-- S:HandleButton(b) S:HandleButton(b)
b:SetWidth(60) b:SetWidth(60)
b:SetHeight(22) b:SetHeight(22)
b:SetPoint("TOPLEFT", "ColorPPCopy", "TOPRIGHT", 2, 0) b:SetPoint("TOPLEFT", "ColorPPCopy", "TOPRIGHT", 2, 0)
@@ -184,7 +184,7 @@ function B:EnhanceColorPicker()
-- add defaults button to the ColorPickerFrame -- add defaults button to the ColorPickerFrame
b = CreateFrame("Button", "ColorPPDefault", ColorPickerFrame, "UIPanelButtonTemplate") b = CreateFrame("Button", "ColorPPDefault", ColorPickerFrame, "UIPanelButtonTemplate")
b:SetText(DEFAULTS) b:SetText(DEFAULTS)
-- S:HandleButton(b) S:HandleButton(b)
b:SetWidth(80) b:SetWidth(80)
b:SetHeight(22) b:SetHeight(22)
b:SetPoint("TOPLEFT", "ColorPPClass", "BOTTOMLEFT", 0, -7) b:SetPoint("TOPLEFT", "ColorPPClass", "BOTTOMLEFT", 0, -7)
@@ -226,12 +226,12 @@ function B:EnhanceColorPicker()
local rgb = boxes[i] local rgb = boxes[i]
local box = CreateFrame("EditBox", "ColorPPBox"..rgb, ColorPickerFrame, "InputBoxTemplate") local box = CreateFrame("EditBox", "ColorPPBox"..rgb, ColorPickerFrame, "InputBoxTemplate")
-- S:HandleEditBox(box) S:HandleEditBox(box)
box:SetID(i) box:SetID(i)
box:SetFrameStrata("DIALOG") box:SetFrameStrata("DIALOG")
box:SetAutoFocus(false) box:SetAutoFocus(false)
box:SetTextInsets(0,7,0,0) box:SetTextInsets(0,14,0,0)
box:SetJustifyH("RIGHT") box:SetJustifyH("CENTER")
box:SetHeight(24) box:SetHeight(24)
if i == 4 then if i == 4 then
@@ -265,7 +265,7 @@ function B:EnhanceColorPicker()
box:SetScript("OnEnterPressed", function() this:ClearFocus() UpdateColorTexts() end) box:SetScript("OnEnterPressed", function() this:ClearFocus() UpdateColorTexts() end)
end end
box:SetScript("OnEditFocusGained", function() this:SetCursorPosition(0) this:HighlightText() end) box:SetScript("OnEditFocusGained", function() this:HighlightText() end)
box:SetScript("OnEditFocusLost", function() this:HighlightText(0,0) end) box:SetScript("OnEditFocusLost", function() this:HighlightText(0,0) end)
box:SetScript("OnTextSet", function() this:ClearFocus() end) box:SetScript("OnTextSet", function() this:ClearFocus() end)
box:Show() box:Show()
+3 -3
View File
@@ -1,15 +1,15 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Ui xmlns="http://www.blizzard.com/wow/ui/">
<Include file="NamePlates\Load_NamePlates.xml"/> <Include file="NamePlates\Load_NamePlates.xml"/>
<Include file="Auras\Load_Auras.xml"/>
<Include file="Blizzard\Load_Blizzard.xml"/>
<Include file="Tooltip\Load_Tooltip.xml"/> <Include file="Tooltip\Load_Tooltip.xml"/>
<Include file="DataTexts\Load_DataTexts.xml"/> <Include file="DataTexts\Load_DataTexts.xml"/>
<Include file="ActionBars\Load_ActionBars.xml"/> <Include file="ActionBars\Load_ActionBars.xml"/>
<Include file="UnitFrames\Load_UnitFrames.xml"/> <Include file="UnitFrames\Load_UnitFrames.xml"/>
<Include file="Maps\Load_Maps.xml"/> <Include file="Maps\Load_Maps.xml"/>
<Include file="Misc\Load_Misc.xml"/> <Include file="Auras\Load_Auras.xml"/>
<Include file="Chat\Load_Chat.xml"/> <Include file="Chat\Load_Chat.xml"/>
<Include file="Bags\Load_Bags.xml"/> <Include file="Bags\Load_Bags.xml"/>
<Include file="Misc\Load_Misc.xml"/>
<Include file="Skins\Load_Skins.xml"/> <Include file="Skins\Load_Skins.xml"/>
<Include file="Blizzard\Load_Blizzard.xml"/>
<Include file="DataBars\Load_DataBars.xml"/> <Include file="DataBars\Load_DataBars.xml"/>
</Ui> </Ui>
+11 -4
View File
@@ -6,7 +6,7 @@ local S = E:NewModule("Skins", "AceHook-3.0", "AceEvent-3.0");
local _G = _G local _G = _G
local unpack, assert, pairs, ipairs, type, pcall = unpack, assert, pairs, ipairs, type, pcall local unpack, assert, pairs, ipairs, type, pcall = unpack, assert, pairs, ipairs, type, pcall
local tinsert, wipe = table.insert, table.wipe local tinsert, wipe = table.insert, table.wipe
local lower = string.lower local find, gfind, lower = string.find, string.gfind, string.lower
--WoW API / Variables --WoW API / Variables
local CreateFrame = CreateFrame local CreateFrame = CreateFrame
local SetDesaturation = SetDesaturation local SetDesaturation = SetDesaturation
@@ -21,8 +21,6 @@ S.allowBypass = {}
S.addonCallbacks = {} S.addonCallbacks = {}
S.nonAddonCallbacks = {["CallPriority"] = {}} S.nonAddonCallbacks = {["CallPriority"] = {}}
local find = string.find
S.SQUARE_BUTTON_TEXCOORDS = { S.SQUARE_BUTTON_TEXCOORDS = {
["UP"] = { 0.45312500, 0.64062500, 0.01562500, 0.20312500}; ["UP"] = { 0.45312500, 0.64062500, 0.01562500, 0.20312500};
["DOWN"] = { 0.45312500, 0.64062500, 0.20312500, 0.01562500}; ["DOWN"] = { 0.45312500, 0.64062500, 0.20312500, 0.01562500};
@@ -244,7 +242,7 @@ function S:HandleEditBox(frame)
if _G[frame:GetName() .."Right"] then E:Kill(_G[frame:GetName() .."Right"]) end if _G[frame:GetName() .."Right"] then E:Kill(_G[frame:GetName() .."Right"]) end
if _G[frame:GetName() .."Mid"] then E:Kill(_G[frame:GetName() .."Mid"]) end if _G[frame:GetName() .."Mid"] then E:Kill(_G[frame:GetName() .."Mid"]) end
if string.gfind(frame:GetName(), "Silver") or string.gfind(frame:GetName(), "Copper") then if gfind(frame:GetName(), "Silver") or gfind(frame:GetName(), "Copper") then
frame.backdrop:SetPoint("BOTTOMRIGHT", -12, -2) frame.backdrop:SetPoint("BOTTOMRIGHT", -12, -2)
end end
end end
@@ -387,6 +385,15 @@ function S:HandleSliderFrame(frame)
else else
frame:SetHeight(SIZE) frame:SetHeight(SIZE)
for _, region in ipairs({frame:GetRegions()}) do
if region and region:GetObjectType() == "FontString" then
local point, anchor, anchorPoint, x, y = region:GetPoint()
if find(anchorPoint, "BOTTOM") then
region:SetPoint(point, anchor, anchorPoint, x, y - 4)
end
end
end
--[[for i = 1, frame:GetNumRegions() do --[[for i = 1, frame:GetNumRegions() do
local region = select(i, frame:GetRegions()) local region = select(i, frame:GetRegions())
if region and region:GetObjectType() == "FontString" then if region and region:GetObjectType() == "FontString" then