This repository has been archived by the owner on Jun 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
colorOptions.lua
110 lines (82 loc) · 1.87 KB
/
colorOptions.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
--[[
Frame.lua
General Bagnon settings
--]]
local AddonName, Addon = ...
local L = Addon.L
local ColorOptions
do
ColorOptions = Addon.OptionsPanel:New(
'tullaRange_ColorOptions',
nil,
'tullaRange',
L.ColorSettingsTitle
)
-- ColorOptions:Hide()
Addon.ColorOptions = ColorOptions
end
local SPACING = 4
local COLOR_TYPES = {'oor', 'oom', 'unusable'}
--[[
Startup
--]]
function ColorOptions:Load()
self:SetScript('OnShow', self.OnShow)
self:AddWidgets()
self:UpdateWidgets()
end
--[[
Frame Events
--]]
function ColorOptions:OnShow()
self:UpdateWidgets()
end
--[[
Components
--]]
function ColorOptions:AddWidgets()
local lastSelector = nil
for i, type in self:GetColorTypes() do
local selector = self:CreateColorSelector(type)
selector:SetHeight(132)
if i == 1 then
selector:SetPoint('TOPLEFT', 12, -84)
selector:SetPoint('TOPRIGHT', -12, -84)
else
selector:SetPoint('TOPLEFT', lastSelector, 'BOTTOMLEFT', 0, -(SPACING + 24))
selector:SetPoint('TOPRIGHT', lastSelector, 'BOTTOMRIGHT', 0, -(SPACING + 24))
end
lastSelector = selector
end
end
function ColorOptions:UpdateWidgets()
if not self:IsVisible() then
return
end
if self.sliders then
for i, s in pairs(self.sliders) do
s:UpdateValue()
end
end
for i, type in self:GetColorTypes() do
local selector = self:GetColorSelector(type)
selector:UpdateValues()
end
end
function ColorOptions:GetColorTypes()
return pairs(COLOR_TYPES)
end
--[[ Color Pickers ]]--
--frame color
function ColorOptions:CreateColorSelector(type)
local selector = Addon.ColorSelector:New(type, self)
local colorSelectors = self.colorSelectors or {}
colorSelectors[type] = selector
self.colorSelectors = colorSelectors
return selector
end
function ColorOptions:GetColorSelector(type)
return self.colorSelectors and self.colorSelectors[type]
end
--[[ Load the thing ]]--
ColorOptions:Load()