|
Tercio@11
|
1
|
|
Tercio@11
|
2 local DF = _G ["DetailsFramework"]
|
|
Tercio@20
|
3 if (not DF or not DetailsFrameworkCanLoad) then
|
|
Tercio@20
|
4 return
|
|
Tercio@20
|
5 end
|
|
Tercio@20
|
6
|
|
Tercio@11
|
7 local _
|
|
Tercio@11
|
8 local _rawset = rawset --> lua local
|
|
Tercio@11
|
9 local _rawget = rawget --> lua local
|
|
Tercio@11
|
10 local _setmetatable = setmetatable --> lua local
|
|
Tercio@11
|
11 local _unpack = unpack --> lua local
|
|
Tercio@11
|
12 local _type = type --> lua local
|
|
Tercio@11
|
13 local _math_floor = math.floor --> lua local
|
|
Tercio@11
|
14 local loadstring = loadstring --> lua local
|
|
Tercio@11
|
15
|
|
Tercio@11
|
16 local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
|
|
Tercio@11
|
17
|
|
Tercio@11
|
18 local cleanfunction = function() end
|
|
Tercio@11
|
19 local APISliderFunctions = false
|
|
Tercio@39
|
20
|
|
Tercio@39
|
21 do
|
|
Tercio@39
|
22 local metaPrototype = {
|
|
Tercio@39
|
23 WidgetType = "slider",
|
|
Tercio@39
|
24 SetHook = DF.SetHook,
|
|
Tercio@39
|
25 RunHooksForWidget = DF.RunHooksForWidget,
|
|
Tercio@39
|
26 }
|
|
Tercio@39
|
27
|
|
Tercio@39
|
28 _G [DF.GlobalWidgetControlNames ["slider"]] = _G [DF.GlobalWidgetControlNames ["slider"]] or metaPrototype
|
|
Tercio@39
|
29 end
|
|
Tercio@39
|
30
|
|
Tercio@39
|
31 local DFSliderMetaFunctions = _G [DF.GlobalWidgetControlNames ["slider"]]
|
|
Tercio@11
|
32
|
|
Tercio@11
|
33 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
34 --> metatables
|
|
Tercio@11
|
35
|
|
Tercio@35
|
36 DFSliderMetaFunctions.__call = function (_table, value)
|
|
Tercio@11
|
37 if (not value) then
|
|
Tercio@11
|
38 if (_table.isSwitch) then
|
|
Tercio@11
|
39
|
|
Tercio@11
|
40 if (type (value) == "boolean") then --> false
|
|
Tercio@11
|
41 return _table.slider:SetValue (1)
|
|
Tercio@11
|
42 end
|
|
Tercio@11
|
43
|
|
Tercio@11
|
44 if (_table.slider:GetValue() == 1) then
|
|
Tercio@11
|
45 return false
|
|
Tercio@11
|
46 else
|
|
Tercio@11
|
47 return true
|
|
Tercio@11
|
48 end
|
|
Tercio@11
|
49 end
|
|
Tercio@11
|
50 return _table.slider:GetValue()
|
|
Tercio@11
|
51 else
|
|
Tercio@11
|
52 if (_table.isSwitch) then
|
|
Tercio@11
|
53 if (type (value) == "boolean") then
|
|
Tercio@11
|
54 if (value) then
|
|
Tercio@11
|
55 _table.slider:SetValue (2)
|
|
Tercio@11
|
56 else
|
|
Tercio@11
|
57 _table.slider:SetValue (1)
|
|
Tercio@11
|
58 end
|
|
Tercio@11
|
59 else
|
|
Tercio@11
|
60 _table.slider:SetValue (value)
|
|
Tercio@11
|
61 end
|
|
Tercio@11
|
62 return
|
|
Tercio@11
|
63 end
|
|
Tercio@11
|
64
|
|
Tercio@11
|
65 return _table.slider:SetValue (value)
|
|
Tercio@11
|
66 end
|
|
Tercio@11
|
67 end
|
|
Tercio@11
|
68
|
|
Tercio@11
|
69 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
70 --> members
|
|
Tercio@11
|
71
|
|
Tercio@11
|
72 --> tooltip
|
|
Tercio@11
|
73 local gmember_tooltip = function (_object)
|
|
Tercio@11
|
74 return _object:GetTooltip()
|
|
Tercio@11
|
75 end
|
|
Tercio@11
|
76 --> shown
|
|
Tercio@11
|
77 local gmember_shown = function (_object)
|
|
Tercio@11
|
78 return _object:IsShown()
|
|
Tercio@11
|
79 end
|
|
Tercio@11
|
80 --> frame width
|
|
Tercio@11
|
81 local gmember_width = function (_object)
|
|
Tercio@11
|
82 return _object.slider:GetWidth()
|
|
Tercio@11
|
83 end
|
|
Tercio@11
|
84 --> frame height
|
|
Tercio@11
|
85 local gmember_height = function (_object)
|
|
Tercio@11
|
86 return _object.slider:GetHeight()
|
|
Tercio@11
|
87 end
|
|
Tercio@11
|
88 --> locked
|
|
Tercio@11
|
89 local gmember_locked = function (_object)
|
|
Tercio@11
|
90 return _rawget (_object, "lockdown")
|
|
Tercio@11
|
91 end
|
|
Tercio@11
|
92 --> fractional
|
|
Tercio@11
|
93 local gmember_fractional = function (_object)
|
|
Tercio@11
|
94 return _rawget (_object, "useDecimals")
|
|
Tercio@11
|
95 end
|
|
Tercio@11
|
96 --> value
|
|
Tercio@11
|
97 local gmember_value = function (_object)
|
|
Tercio@11
|
98 return _object()
|
|
Tercio@11
|
99 end
|
|
Tercio@11
|
100
|
|
Tercio@39
|
101 DFSliderMetaFunctions.GetMembers = DFSliderMetaFunctions.GetMembers or {}
|
|
Tercio@39
|
102 DFSliderMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
|
|
Tercio@39
|
103 DFSliderMetaFunctions.GetMembers ["shown"] = gmember_shown
|
|
Tercio@39
|
104 DFSliderMetaFunctions.GetMembers ["width"] = gmember_width
|
|
Tercio@39
|
105 DFSliderMetaFunctions.GetMembers ["height"] = gmember_height
|
|
Tercio@39
|
106 DFSliderMetaFunctions.GetMembers ["locked"] = gmember_locked
|
|
Tercio@39
|
107 DFSliderMetaFunctions.GetMembers ["fractional"] = gmember_fractional
|
|
Tercio@39
|
108 DFSliderMetaFunctions.GetMembers ["value"] = gmember_value
|
|
Tercio@11
|
109
|
|
Tercio@35
|
110 DFSliderMetaFunctions.__index = function (_table, _member_requested)
|
|
Tercio@11
|
111
|
|
Tercio@39
|
112 local func = DFSliderMetaFunctions.GetMembers [_member_requested]
|
|
Tercio@11
|
113 if (func) then
|
|
Tercio@11
|
114 return func (_table, _member_requested)
|
|
Tercio@11
|
115 end
|
|
Tercio@11
|
116
|
|
Tercio@11
|
117 local fromMe = _rawget (_table, _member_requested)
|
|
Tercio@11
|
118 if (fromMe) then
|
|
Tercio@11
|
119 return fromMe
|
|
Tercio@11
|
120 end
|
|
Tercio@11
|
121
|
|
Tercio@35
|
122 return DFSliderMetaFunctions [_member_requested]
|
|
Tercio@11
|
123 end
|
|
Tercio@11
|
124
|
|
Tercio@11
|
125 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
126
|
|
Tercio@11
|
127 --> tooltip
|
|
Tercio@11
|
128 local smember_tooltip = function (_object, _value)
|
|
Tercio@11
|
129 return _object:SetTooltip (_value)
|
|
Tercio@11
|
130 end
|
|
Tercio@11
|
131 --> show
|
|
Tercio@11
|
132 local smember_show = function (_object, _value)
|
|
Tercio@11
|
133 if (_value) then
|
|
Tercio@11
|
134 return _object:Show()
|
|
Tercio@11
|
135 else
|
|
Tercio@11
|
136 return _object:Hide()
|
|
Tercio@11
|
137 end
|
|
Tercio@11
|
138 end
|
|
Tercio@11
|
139 --> hide
|
|
Tercio@11
|
140 local smember_hide = function (_object, _value)
|
|
Tercio@11
|
141 if (not _value) then
|
|
Tercio@11
|
142 return _object:Show()
|
|
Tercio@11
|
143 else
|
|
Tercio@11
|
144 return _object:Hide()
|
|
Tercio@11
|
145 end
|
|
Tercio@11
|
146 end
|
|
Tercio@11
|
147 --> frame width
|
|
Tercio@11
|
148 local smember_width = function (_object, _value)
|
|
Tercio@11
|
149 return _object.slider:SetWidth (_value)
|
|
Tercio@11
|
150 end
|
|
Tercio@11
|
151 --> frame height
|
|
Tercio@11
|
152 local smember_height = function (_object, _value)
|
|
Tercio@11
|
153 return _object.slider:SetHeight (_value)
|
|
Tercio@11
|
154 end
|
|
Tercio@11
|
155 --> locked
|
|
Tercio@11
|
156 local smember_locked = function (_object, _value)
|
|
Tercio@11
|
157 if (_value) then
|
|
Tercio@11
|
158 return self:Disable()
|
|
Tercio@11
|
159 else
|
|
Tercio@11
|
160 return self:Enable()
|
|
Tercio@11
|
161 end
|
|
Tercio@11
|
162 end
|
|
Tercio@11
|
163 --> backdrop
|
|
Tercio@11
|
164 local smember_backdrop = function (_object, _value)
|
|
Tercio@11
|
165 return _object.slider:SetBackdrop (_value)
|
|
Tercio@11
|
166 end
|
|
Tercio@11
|
167 --> fractional
|
|
Tercio@11
|
168 local smember_fractional = function (_object, _value)
|
|
Tercio@11
|
169 return _rawset (_object, "useDecimals", _value)
|
|
Tercio@11
|
170 end
|
|
Tercio@11
|
171 --> value
|
|
Tercio@11
|
172 local smember_value = function (_object, _value)
|
|
Tercio@11
|
173 _object (_value)
|
|
Tercio@11
|
174 end
|
|
Tercio@11
|
175
|
|
Tercio@39
|
176 DFSliderMetaFunctions.SetMembers = DFSliderMetaFunctions.SetMembers or {}
|
|
Tercio@39
|
177 DFSliderMetaFunctions.SetMembers ["tooltip"] = smember_tooltip
|
|
Tercio@39
|
178 DFSliderMetaFunctions.SetMembers ["show"] = smember_show
|
|
Tercio@39
|
179 DFSliderMetaFunctions.SetMembers ["hide"] = smember_hide
|
|
Tercio@39
|
180 DFSliderMetaFunctions.SetMembers ["backdrop"] = smember_backdrop
|
|
Tercio@39
|
181 DFSliderMetaFunctions.SetMembers ["width"] = smember_width
|
|
Tercio@39
|
182 DFSliderMetaFunctions.SetMembers ["height"] = smember_height
|
|
Tercio@39
|
183 DFSliderMetaFunctions.SetMembers ["locked"] = smember_locked
|
|
Tercio@39
|
184 DFSliderMetaFunctions.SetMembers ["fractional"] = smember_fractional
|
|
Tercio@39
|
185 DFSliderMetaFunctions.SetMembers ["value"] = smember_value
|
|
Tercio@11
|
186
|
|
Tercio@35
|
187 DFSliderMetaFunctions.__newindex = function (_table, _key, _value)
|
|
Tercio@39
|
188 local func = DFSliderMetaFunctions.SetMembers [_key]
|
|
Tercio@11
|
189 if (func) then
|
|
Tercio@11
|
190 return func (_table, _value)
|
|
Tercio@11
|
191 else
|
|
Tercio@11
|
192 return _rawset (_table, _key, _value)
|
|
Tercio@11
|
193 end
|
|
Tercio@11
|
194 end
|
|
Tercio@11
|
195
|
|
Tercio@11
|
196 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
197 --> methods
|
|
Tercio@11
|
198
|
|
Tercio@11
|
199 --> show & hide
|
|
Tercio@35
|
200 function DFSliderMetaFunctions:IsShown()
|
|
Tercio@11
|
201 return self.slider:IsShown()
|
|
Tercio@11
|
202 end
|
|
Tercio@35
|
203 function DFSliderMetaFunctions:Show()
|
|
Tercio@11
|
204 return self.slider:Show()
|
|
Tercio@11
|
205 end
|
|
Tercio@35
|
206 function DFSliderMetaFunctions:Hide()
|
|
Tercio@11
|
207 return self.slider:Hide()
|
|
Tercio@11
|
208 end
|
|
Tercio@11
|
209
|
|
Tercio@11
|
210 --> fixed value
|
|
Tercio@35
|
211 function DFSliderMetaFunctions:SetFixedParameter (value)
|
|
Tercio@11
|
212 _rawset (self, "FixedValue", value)
|
|
Tercio@11
|
213 end
|
|
Tercio@11
|
214
|
|
Tercio@11
|
215 --> set value
|
|
Tercio@35
|
216 function DFSliderMetaFunctions:SetValue (value)
|
|
Tercio@11
|
217 return self (value)
|
|
Tercio@11
|
218 end
|
|
Tercio@11
|
219
|
|
Tercio@11
|
220 -- thumb size
|
|
Tercio@35
|
221 function DFSliderMetaFunctions:SetThumbSize (w, h)
|
|
Tercio@11
|
222 if (not w) then
|
|
Tercio@11
|
223 w = self.thumb:GetWidth()
|
|
Tercio@11
|
224 end
|
|
Tercio@11
|
225 if (not h) then
|
|
Tercio@11
|
226 h = self.thumb:GetHeight()
|
|
Tercio@11
|
227 end
|
|
Tercio@11
|
228 return self.thumb:SetSize (w, h)
|
|
Tercio@11
|
229 end
|
|
Tercio@11
|
230
|
|
Tercio@11
|
231
|
|
Tercio@11
|
232 -- setpoint
|
|
Tercio@35
|
233 function DFSliderMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
|
|
Tercio@11
|
234 v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
|
|
Tercio@11
|
235 if (not v1) then
|
|
Tercio@11
|
236 print ("Invalid parameter for SetPoint")
|
|
Tercio@11
|
237 return
|
|
Tercio@11
|
238 end
|
|
Tercio@11
|
239 return self.widget:SetPoint (v1, v2, v3, v4, v5)
|
|
Tercio@11
|
240 end
|
|
Tercio@11
|
241
|
|
Tercio@11
|
242 -- sizes
|
|
Tercio@35
|
243 function DFSliderMetaFunctions:SetSize (w, h)
|
|
Tercio@11
|
244 if (w) then
|
|
Tercio@11
|
245 self.slider:SetWidth (w)
|
|
Tercio@11
|
246 end
|
|
Tercio@11
|
247 if (h) then
|
|
Tercio@11
|
248 return self.slider:SetHeight (h)
|
|
Tercio@11
|
249 end
|
|
Tercio@11
|
250 end
|
|
Tercio@11
|
251
|
|
Tercio@11
|
252 -- tooltip
|
|
Tercio@35
|
253 function DFSliderMetaFunctions:SetTooltip (tooltip)
|
|
Tercio@11
|
254 if (tooltip) then
|
|
Tercio@11
|
255 return _rawset (self, "have_tooltip", tooltip)
|
|
Tercio@11
|
256 else
|
|
Tercio@11
|
257 return _rawset (self, "have_tooltip", nil)
|
|
Tercio@11
|
258 end
|
|
Tercio@11
|
259 end
|
|
Tercio@35
|
260 function DFSliderMetaFunctions:GetTooltip()
|
|
Tercio@11
|
261 return _rawget (self, "have_tooltip")
|
|
Tercio@11
|
262 end
|
|
Tercio@11
|
263
|
|
Tercio@11
|
264 -- frame levels
|
|
Tercio@35
|
265 function DFSliderMetaFunctions:GetFrameLevel()
|
|
Tercio@11
|
266 return self.slider:GetFrameLevel()
|
|
Tercio@11
|
267 end
|
|
Tercio@35
|
268 function DFSliderMetaFunctions:SetFrameLevel (level, frame)
|
|
Tercio@11
|
269 if (not frame) then
|
|
Tercio@11
|
270 return self.slider:SetFrameLevel (level)
|
|
Tercio@11
|
271 else
|
|
Tercio@11
|
272 local framelevel = frame:GetFrameLevel (frame) + level
|
|
Tercio@11
|
273 return self.slider:SetFrameLevel (framelevel)
|
|
Tercio@11
|
274 end
|
|
Tercio@11
|
275 end
|
|
Tercio@11
|
276
|
|
Tercio@11
|
277 -- frame stratas
|
|
Tercio@35
|
278 function DFSliderMetaFunctions:SetFrameStrata()
|
|
Tercio@11
|
279 return self.slider:GetFrameStrata()
|
|
Tercio@11
|
280 end
|
|
Tercio@35
|
281 function DFSliderMetaFunctions:SetFrameStrata (strata)
|
|
Tercio@11
|
282 if (_type (strata) == "table") then
|
|
Tercio@11
|
283 self.slider:SetFrameStrata (strata:GetFrameStrata())
|
|
Tercio@11
|
284 else
|
|
Tercio@11
|
285 self.slider:SetFrameStrata (strata)
|
|
Tercio@11
|
286 end
|
|
Tercio@11
|
287 end
|
|
Tercio@11
|
288
|
|
Tercio@11
|
289 -- enabled
|
|
Tercio@35
|
290 function DFSliderMetaFunctions:IsEnabled()
|
|
Tercio@11
|
291 return not _rawget (self, "lockdown")
|
|
Tercio@11
|
292 end
|
|
Tercio@35
|
293
|
|
Tercio@35
|
294 function DFSliderMetaFunctions:Enable()
|
|
Tercio@11
|
295 self.slider:Enable()
|
|
Tercio@35
|
296 if (not self.is_checkbox) then
|
|
Tercio@35
|
297 if (not self.lock_texture) then
|
|
Tercio@35
|
298 DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
|
|
Tercio@35
|
299 self.lock_texture:SetDesaturated (true)
|
|
Tercio@35
|
300 self.lock_texture:SetPoint ("center", self.amt, "center")
|
|
Tercio@35
|
301 end
|
|
Tercio@35
|
302 self.lock_texture:Hide()
|
|
Tercio@11
|
303 end
|
|
Tercio@11
|
304 self.slider.amt:Show()
|
|
Tercio@11
|
305 self:SetAlpha (1)
|
|
Tercio@35
|
306
|
|
Tercio@35
|
307 if (self.is_checkbox) then
|
|
Tercio@35
|
308 self.checked_texture:Show()
|
|
Tercio@35
|
309 end
|
|
Tercio@11
|
310 return _rawset (self, "lockdown", false)
|
|
Tercio@11
|
311 end
|
|
Tercio@11
|
312
|
|
Tercio@35
|
313 function DFSliderMetaFunctions:Disable()
|
|
Tercio@11
|
314
|
|
Tercio@11
|
315 self.slider:Disable()
|
|
Tercio@11
|
316 self.slider.amt:Hide()
|
|
Tercio@11
|
317 self:SetAlpha (.4)
|
|
Tercio@35
|
318
|
|
Tercio@35
|
319 if (not self.is_checkbox) then
|
|
Tercio@35
|
320 if (not self.lock_texture) then
|
|
Tercio@35
|
321 DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
|
|
Tercio@35
|
322 self.lock_texture:SetDesaturated (true)
|
|
Tercio@35
|
323 self.lock_texture:SetPoint ("center", self.amt, "center")
|
|
Tercio@35
|
324 end
|
|
Tercio@35
|
325 self.lock_texture:Show()
|
|
Tercio@35
|
326 end
|
|
Tercio@11
|
327
|
|
Tercio@35
|
328 if (self.is_checkbox) then
|
|
Tercio@35
|
329 self.checked_texture:Show()
|
|
Tercio@11
|
330 end
|
|
Tercio@35
|
331
|
|
Tercio@35
|
332 --print ("result 2:", self.checked_texture:IsShown(), self.checked_texture:GetAlpha(), self.checked_texture:GetSize())
|
|
Tercio@11
|
333
|
|
Tercio@11
|
334 return _rawset (self, "lockdown", true)
|
|
Tercio@11
|
335 end
|
|
Tercio@11
|
336
|
|
Tercio@11
|
337 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
338 --> scripts
|
|
Tercio@11
|
339
|
|
Tercio@11
|
340 local OnEnter = function (slider)
|
|
Tercio@11
|
341
|
|
Tercio@11
|
342 if (_rawget (slider.MyObject, "lockdown")) then
|
|
Tercio@11
|
343 return
|
|
Tercio@11
|
344 end
|
|
Tercio@11
|
345
|
|
Tercio@11
|
346 DetailsFrameworkSliderButtons1:ShowMe (slider)
|
|
Tercio@11
|
347
|
|
Tercio@39
|
348 local capsule = slider.MyObject
|
|
Tercio@39
|
349 local kill = capsule:RunHooksForWidget ("OnEnter", slider, capsule)
|
|
Tercio@39
|
350 if (kill) then
|
|
Tercio@39
|
351 return
|
|
Tercio@11
|
352 end
|
|
Tercio@11
|
353
|
|
Tercio@11
|
354 slider.thumb:SetAlpha (1)
|
|
Tercio@11
|
355
|
|
Tercio@22
|
356 if (slider.MyObject.onenter_backdrop_border_color) then
|
|
Tercio@22
|
357 slider:SetBackdropBorderColor (unpack (slider.MyObject.onenter_backdrop_border_color))
|
|
Tercio@22
|
358 end
|
|
Tercio@22
|
359
|
|
Tercio@11
|
360 if (slider.MyObject.have_tooltip and slider.MyObject.have_tooltip ~= "Right Click to Type the Value") then
|
|
Tercio@11
|
361 GameCooltip2:Preset (2)
|
|
Tercio@11
|
362 GameCooltip2:AddLine (slider.MyObject.have_tooltip)
|
|
Tercio@11
|
363 GameCooltip2:ShowCooltip (slider, "tooltip")
|
|
Tercio@11
|
364 else
|
|
Tercio@11
|
365 GameCooltip2:Preset (1)
|
|
Tercio@11
|
366 GameCooltip2:AddLine ("Right Click to Type the Value")
|
|
Tercio@11
|
367 GameCooltip2:AddIcon ([[Interface\TUTORIALFRAME\UI-TUTORIAL-FRAME]], 1, 1, 16, 16, 0.015625, 0.15671875, 0.640625, 0.798828125)
|
|
Tercio@11
|
368 GameCooltip2:ShowCooltip (slider, "tooltip")
|
|
Tercio@11
|
369 end
|
|
Tercio@11
|
370 end
|
|
Tercio@11
|
371
|
|
Tercio@11
|
372 local OnLeave = function (slider)
|
|
Tercio@11
|
373
|
|
Tercio@11
|
374 if (_rawget (slider.MyObject, "lockdown")) then
|
|
Tercio@11
|
375 return
|
|
Tercio@11
|
376 end
|
|
Tercio@11
|
377
|
|
Tercio@11
|
378 DetailsFrameworkSliderButtons1:PrepareToHide()
|
|
Tercio@11
|
379
|
|
Tercio@39
|
380 local capsule = slider.MyObject
|
|
Tercio@39
|
381 local kill = capsule:RunHooksForWidget ("OnLeave", slider, capsule)
|
|
Tercio@39
|
382 if (kill) then
|
|
Tercio@39
|
383 return
|
|
Tercio@11
|
384 end
|
|
Tercio@11
|
385
|
|
Tercio@11
|
386 slider.thumb:SetAlpha (.7)
|
|
Tercio@11
|
387
|
|
Tercio@22
|
388 if (slider.MyObject.onleave_backdrop_border_color) then
|
|
Tercio@22
|
389 slider:SetBackdropBorderColor (unpack (slider.MyObject.onleave_backdrop_border_color))
|
|
Tercio@22
|
390 end
|
|
Tercio@22
|
391
|
|
Tercio@25
|
392 GameCooltip2:ShowMe (false)
|
|
Tercio@25
|
393
|
|
Tercio@11
|
394 end
|
|
Tercio@11
|
395
|
|
Tercio@11
|
396
|
|
Tercio@11
|
397 local f = CreateFrame ("frame", "DetailsFrameworkSliderButtons1", UIParent)
|
|
Tercio@11
|
398 f:Hide()
|
|
Tercio@11
|
399 --f:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]], tile = true, tileSize = 5})
|
|
Tercio@11
|
400 f:SetHeight (18)
|
|
Tercio@11
|
401
|
|
Tercio@11
|
402 local t = 0
|
|
Tercio@11
|
403 f.is_going_hide = false
|
|
Tercio@11
|
404 local going_hide = function (self, elapsed)
|
|
Tercio@11
|
405 t = t + elapsed
|
|
Tercio@11
|
406 if (t > 0.3) then
|
|
Tercio@11
|
407 f:Hide()
|
|
Tercio@11
|
408 f:SetScript ("OnUpdate", nil)
|
|
Tercio@11
|
409 f.is_going_hide = false
|
|
Tercio@11
|
410 end
|
|
Tercio@11
|
411 end
|
|
Tercio@11
|
412
|
|
Tercio@11
|
413 function f:ShowMe (host)
|
|
Tercio@11
|
414 f:SetPoint ("bottomleft", host, "topleft", -3, -5)
|
|
Tercio@11
|
415 f:SetPoint ("bottomright", host, "topright", 3, -5)
|
|
Tercio@11
|
416 f:SetFrameStrata (host:GetFrameStrata())
|
|
Tercio@11
|
417 f:SetFrameLevel (host:GetFrameLevel())
|
|
Tercio@11
|
418 f:Show()
|
|
Tercio@11
|
419 if (f.is_going_hide) then
|
|
Tercio@11
|
420 f:SetScript ("OnUpdate", nil)
|
|
Tercio@11
|
421 f.is_going_hide = false
|
|
Tercio@11
|
422 end
|
|
Tercio@11
|
423
|
|
Tercio@11
|
424 f.host = host.MyObject
|
|
Tercio@11
|
425 end
|
|
Tercio@11
|
426
|
|
Tercio@11
|
427 function f:PrepareToHide()
|
|
Tercio@11
|
428 f.is_going_hide = true
|
|
Tercio@11
|
429 t = 0
|
|
Tercio@11
|
430 f:SetScript ("OnUpdate", going_hide)
|
|
Tercio@11
|
431 end
|
|
Tercio@11
|
432
|
|
Tercio@11
|
433 local button_plus = CreateFrame ("button", "DetailsFrameworkSliderButtonsPlusButton", f)
|
|
Tercio@11
|
434 local button_minor = CreateFrame ("button", "DetailsFrameworkSliderButtonsMinorButton", f)
|
|
Tercio@39
|
435 button_plus:SetFrameStrata (f:GetFrameStrata())
|
|
Tercio@39
|
436 button_minor:SetFrameStrata (f:GetFrameStrata())
|
|
Tercio@11
|
437
|
|
Tercio@11
|
438 button_plus:SetScript ("OnEnter", function (self)
|
|
Tercio@11
|
439 if (f.is_going_hide) then
|
|
Tercio@11
|
440 f:SetScript ("OnUpdate", nil)
|
|
Tercio@11
|
441 f.is_going_hide = false
|
|
Tercio@11
|
442 end
|
|
Tercio@11
|
443 end)
|
|
Tercio@11
|
444 button_minor:SetScript ("OnEnter", function (self)
|
|
Tercio@11
|
445 if (f.is_going_hide) then
|
|
Tercio@11
|
446 f:SetScript ("OnUpdate", nil)
|
|
Tercio@11
|
447 f.is_going_hide = false
|
|
Tercio@11
|
448 end
|
|
Tercio@11
|
449 end)
|
|
Tercio@11
|
450
|
|
Tercio@11
|
451 button_plus:SetScript ("OnLeave", function (self)
|
|
Tercio@11
|
452 f:PrepareToHide()
|
|
Tercio@11
|
453 end)
|
|
Tercio@11
|
454 button_minor:SetScript ("OnLeave", function (self)
|
|
Tercio@11
|
455 f:PrepareToHide()
|
|
Tercio@11
|
456 end)
|
|
Tercio@11
|
457
|
|
Tercio@11
|
458 button_plus:SetNormalTexture ([[Interface\Buttons\UI-PlusButton-Up]])
|
|
Tercio@11
|
459 button_minor:SetNormalTexture ([[Interface\Buttons\UI-MinusButton-Up]])
|
|
Tercio@11
|
460
|
|
Tercio@11
|
461 button_plus:SetPushedTexture ([[Interface\Buttons\UI-PlusButton-Down]])
|
|
Tercio@11
|
462 button_minor:SetPushedTexture ([[Interface\Buttons\UI-MinusButton-Down]])
|
|
Tercio@11
|
463
|
|
Tercio@11
|
464 button_plus:SetDisabledTexture ([[Interface\Buttons\UI-PlusButton-Disabled]])
|
|
Tercio@11
|
465 button_minor:SetDisabledTexture ([[Interface\Buttons\UI-MinusButton-Disabled]])
|
|
Tercio@11
|
466
|
|
Tercio@11
|
467 button_plus:SetHighlightTexture ([[Interface\Buttons\UI-PlusButton-Hilight]])
|
|
Tercio@11
|
468 button_minor:SetHighlightTexture ([[Interface\Buttons\UI-PlusButton-Hilight]])
|
|
Tercio@11
|
469
|
|
Tercio@11
|
470 --button_minor:SetPoint ("bottomleft", f, "bottomleft", -6, -13)
|
|
Tercio@11
|
471 --button_plus:SetPoint ("bottomright", f, "bottomright", 6, -13)
|
|
Tercio@11
|
472
|
|
Tercio@11
|
473 button_minor:SetPoint ("bottomright", f, "bottomright", 13, -13)
|
|
Tercio@11
|
474 button_plus:SetPoint ("left", button_minor, "right", -2, 0)
|
|
Tercio@11
|
475
|
|
Tercio@11
|
476 button_plus:SetSize (16, 16)
|
|
Tercio@11
|
477 button_minor:SetSize (16, 16)
|
|
Tercio@11
|
478
|
|
Tercio@11
|
479 local timer = 0
|
|
Tercio@11
|
480 local change_timer = 0
|
|
Tercio@11
|
481
|
|
Tercio@11
|
482 -- -- --
|
|
Tercio@11
|
483
|
|
Tercio@11
|
484 local plus_button_script = function()
|
|
Tercio@11
|
485
|
|
Tercio@11
|
486 local current = f.host.value
|
|
Tercio@35
|
487 local editbox = DFSliderMetaFunctions.editbox_typevalue
|
|
Tercio@11
|
488
|
|
Tercio@11
|
489 if (f.host.fine_tuning) then
|
|
Tercio@11
|
490 f.host:SetValue (current + f.host.fine_tuning)
|
|
Tercio@35
|
491 if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
|
|
Tercio@35
|
492 DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (string.format ("%.2f", current + f.host.fine_tuning)))
|
|
Tercio@11
|
493 end
|
|
Tercio@11
|
494 else
|
|
Tercio@11
|
495 if (f.host.useDecimals) then
|
|
Tercio@11
|
496 f.host:SetValue (current + 0.1)
|
|
Tercio@35
|
497 if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
|
|
Tercio@35
|
498 DFSliderMetaFunctions.editbox_typevalue:SetText (string.format ("%.2f", current + 0.1))
|
|
Tercio@11
|
499 end
|
|
Tercio@11
|
500 else
|
|
Tercio@11
|
501 f.host:SetValue (current + 1)
|
|
Tercio@35
|
502 if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
|
|
Tercio@35
|
503 DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (math.floor (current + 1)))
|
|
Tercio@11
|
504 end
|
|
Tercio@11
|
505 end
|
|
Tercio@11
|
506 end
|
|
Tercio@11
|
507
|
|
Tercio@11
|
508 end
|
|
Tercio@11
|
509
|
|
Tercio@11
|
510 button_plus:SetScript ("OnMouseUp", function (self)
|
|
Tercio@11
|
511 if (not button_plus.got_click) then
|
|
Tercio@11
|
512 plus_button_script()
|
|
Tercio@11
|
513 end
|
|
Tercio@11
|
514 button_plus.got_click = false
|
|
Tercio@11
|
515 self:SetScript ("OnUpdate", nil)
|
|
Tercio@11
|
516 end)
|
|
Tercio@11
|
517
|
|
Tercio@11
|
518 local on_update = function (self, elapsed)
|
|
Tercio@11
|
519 timer = timer + elapsed
|
|
Tercio@11
|
520 if (timer > 0.4) then
|
|
Tercio@11
|
521 change_timer = change_timer + elapsed
|
|
Tercio@11
|
522 if (change_timer > 0.1) then
|
|
Tercio@11
|
523 change_timer = 0
|
|
Tercio@11
|
524 plus_button_script()
|
|
Tercio@11
|
525 button_plus.got_click = true
|
|
Tercio@11
|
526 end
|
|
Tercio@11
|
527 end
|
|
Tercio@11
|
528 end
|
|
Tercio@11
|
529 button_plus:SetScript ("OnMouseDown", function (self)
|
|
Tercio@11
|
530 timer = 0
|
|
Tercio@11
|
531 change_timer = 0
|
|
Tercio@11
|
532 self:SetScript ("OnUpdate", on_update)
|
|
Tercio@11
|
533 end)
|
|
Tercio@11
|
534
|
|
Tercio@11
|
535 -- -- --
|
|
Tercio@11
|
536
|
|
Tercio@11
|
537 local minor_button_script = function()
|
|
Tercio@11
|
538 local current = f.host.value
|
|
Tercio@35
|
539 local editbox = DFSliderMetaFunctions.editbox_typevalue
|
|
Tercio@11
|
540
|
|
Tercio@11
|
541 if (f.host.fine_tuning) then
|
|
Tercio@11
|
542 f.host:SetValue (current - f.host.fine_tuning)
|
|
Tercio@35
|
543 if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
|
|
Tercio@35
|
544 DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (string.format ("%.2f", current - f.host.fine_tuning)))
|
|
Tercio@11
|
545 end
|
|
Tercio@11
|
546 else
|
|
Tercio@11
|
547 if (f.host.useDecimals) then
|
|
Tercio@11
|
548 f.host:SetValue (current - 0.1)
|
|
Tercio@35
|
549 if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
|
|
Tercio@35
|
550 DFSliderMetaFunctions.editbox_typevalue:SetText (string.format ("%.2f", current - 0.1))
|
|
Tercio@11
|
551 end
|
|
Tercio@11
|
552 else
|
|
Tercio@11
|
553 f.host:SetValue (current - 1)
|
|
Tercio@35
|
554 if (editbox and DFSliderMetaFunctions.editbox_typevalue:IsShown()) then
|
|
Tercio@35
|
555 DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (math.floor (current - 1)))
|
|
Tercio@11
|
556 end
|
|
Tercio@11
|
557 end
|
|
Tercio@11
|
558 end
|
|
Tercio@11
|
559 end
|
|
Tercio@11
|
560
|
|
Tercio@11
|
561 button_minor:SetScript ("OnMouseUp", function (self)
|
|
Tercio@11
|
562 if (not button_minor.got_click) then
|
|
Tercio@11
|
563 minor_button_script()
|
|
Tercio@11
|
564 end
|
|
Tercio@11
|
565 button_minor.got_click = false
|
|
Tercio@11
|
566 self:SetScript ("OnUpdate", nil)
|
|
Tercio@11
|
567 end)
|
|
Tercio@11
|
568
|
|
Tercio@11
|
569 local on_update = function (self, elapsed)
|
|
Tercio@11
|
570 timer = timer + elapsed
|
|
Tercio@11
|
571 if (timer > 0.4) then
|
|
Tercio@11
|
572 change_timer = change_timer + elapsed
|
|
Tercio@11
|
573 if (change_timer > 0.1) then
|
|
Tercio@11
|
574 change_timer = 0
|
|
Tercio@11
|
575 minor_button_script()
|
|
Tercio@11
|
576 button_minor.got_click = true
|
|
Tercio@11
|
577 end
|
|
Tercio@11
|
578 end
|
|
Tercio@11
|
579 end
|
|
Tercio@11
|
580 button_minor:SetScript ("OnMouseDown", function (self)
|
|
Tercio@11
|
581 timer = 0
|
|
Tercio@11
|
582 change_timer = 0
|
|
Tercio@11
|
583 self:SetScript ("OnUpdate", on_update)
|
|
Tercio@11
|
584 end)
|
|
Tercio@11
|
585
|
|
Tercio@35
|
586 function DFSliderMetaFunctions:TypeValue()
|
|
Tercio@11
|
587 if (not self.isSwitch) then
|
|
Tercio@11
|
588
|
|
Tercio@35
|
589 if (not DFSliderMetaFunctions.editbox_typevalue) then
|
|
Tercio@11
|
590
|
|
Tercio@11
|
591 local editbox = CreateFrame ("EditBox", "DetailsFrameworkSliderEditBox", UIParent)
|
|
Tercio@11
|
592
|
|
Tercio@11
|
593 editbox:SetSize (40, 20)
|
|
Tercio@11
|
594 editbox:SetJustifyH ("center")
|
|
Tercio@11
|
595 editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]],
|
|
Tercio@11
|
596 edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", --edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
|
|
Tercio@11
|
597 tile = true, edgeSize = 8, tileSize = 5})
|
|
Tercio@11
|
598 editbox:SetFontObject ("GameFontHighlightSmall")
|
|
Tercio@11
|
599
|
|
Tercio@11
|
600 editbox:SetScript ("OnEnterPressed", function()
|
|
Tercio@11
|
601 editbox:ClearFocus()
|
|
Tercio@11
|
602 editbox:Hide()
|
|
Tercio@11
|
603 editbox:GetParent().MyObject.typing_value = false
|
|
Tercio@11
|
604 editbox:GetParent().MyObject.value = tonumber (editbox:GetText())
|
|
Tercio@11
|
605 end)
|
|
Tercio@11
|
606
|
|
Tercio@11
|
607 editbox:SetScript ("OnEscapePressed", function()
|
|
Tercio@11
|
608 editbox:ClearFocus()
|
|
Tercio@11
|
609 editbox:Hide()
|
|
Tercio@11
|
610 editbox:GetParent().MyObject.typing_value = false
|
|
Tercio@11
|
611 editbox:GetParent().MyObject.value = tonumber (self.typing_value_started)
|
|
Tercio@11
|
612 end)
|
|
Tercio@11
|
613
|
|
Tercio@11
|
614 editbox:SetScript ("OnTextChanged", function()
|
|
Tercio@11
|
615 editbox:GetParent().MyObject.typing_can_change = true
|
|
Tercio@11
|
616 editbox:GetParent().MyObject.value = tonumber (editbox:GetText())
|
|
Tercio@11
|
617 editbox:GetParent().MyObject.typing_can_change = false
|
|
Tercio@11
|
618
|
|
Tercio@11
|
619 -- esse self fica como o primeiro a ser alterado
|
|
Tercio@11
|
620 --print ("text changed", self:GetName())
|
|
Tercio@11
|
621 --print ()
|
|
Tercio@11
|
622 end)
|
|
Tercio@11
|
623
|
|
Tercio@35
|
624 DFSliderMetaFunctions.editbox_typevalue = editbox
|
|
Tercio@11
|
625 end
|
|
Tercio@11
|
626
|
|
Tercio@11
|
627 local pvalue = self.previous_value [2]
|
|
Tercio@11
|
628 self:SetValue (pvalue)
|
|
Tercio@11
|
629
|
|
Tercio@11
|
630 self.typing_value = true
|
|
Tercio@11
|
631 self.typing_value_started = pvalue
|
|
Tercio@11
|
632
|
|
Tercio@35
|
633 DFSliderMetaFunctions.editbox_typevalue:SetSize (self.width, self.height)
|
|
Tercio@35
|
634 DFSliderMetaFunctions.editbox_typevalue:SetPoint ("center", self.widget, "center")
|
|
Tercio@35
|
635 DFSliderMetaFunctions.editbox_typevalue:SetFocus()
|
|
Tercio@35
|
636 DFSliderMetaFunctions.editbox_typevalue:SetParent (self.widget)
|
|
Tercio@35
|
637 DFSliderMetaFunctions.editbox_typevalue:SetFrameLevel (self.widget:GetFrameLevel()+1)
|
|
Tercio@11
|
638
|
|
Tercio@11
|
639 if (self.useDecimals) then
|
|
Tercio@35
|
640 DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (string.format ("%.1f", self.value)))
|
|
Tercio@11
|
641 else
|
|
Tercio@35
|
642 DFSliderMetaFunctions.editbox_typevalue:SetText (tostring (math.floor (self.value)))
|
|
Tercio@11
|
643 end
|
|
Tercio@11
|
644
|
|
Tercio@35
|
645 DFSliderMetaFunctions.editbox_typevalue:HighlightText()
|
|
Tercio@11
|
646
|
|
Tercio@35
|
647 DFSliderMetaFunctions.editbox_typevalue:Show()
|
|
Tercio@11
|
648 end
|
|
Tercio@11
|
649 end
|
|
Tercio@11
|
650
|
|
Tercio@11
|
651 local OnMouseDown = function (slider, button)
|
|
Tercio@39
|
652 slider.MyObject.IsValueChanging = true
|
|
Tercio@39
|
653
|
|
Tercio@39
|
654 local capsule = slider.MyObject
|
|
Tercio@39
|
655 local kill = capsule:RunHooksForWidget ("OnMouseDown", slider, button, capsule)
|
|
Tercio@39
|
656 if (kill) then
|
|
Tercio@39
|
657 return
|
|
Tercio@39
|
658 end
|
|
Tercio@39
|
659
|
|
Tercio@11
|
660 if (button == "RightButton") then
|
|
Tercio@11
|
661 slider.MyObject:TypeValue()
|
|
Tercio@11
|
662 end
|
|
Tercio@11
|
663 end
|
|
Tercio@11
|
664
|
|
Tercio@11
|
665 local OnMouseUp = function (slider, button)
|
|
Tercio@39
|
666 slider.MyObject.IsValueChanging = nil
|
|
Tercio@39
|
667
|
|
Tercio@39
|
668 local capsule = slider.MyObject
|
|
Tercio@39
|
669 local kill = capsule:RunHooksForWidget ("OnMouseUp", slider, button, capsule)
|
|
Tercio@39
|
670 if (kill) then
|
|
Tercio@39
|
671 return
|
|
Tercio@39
|
672 end
|
|
Tercio@11
|
673 end
|
|
Tercio@11
|
674
|
|
Tercio@11
|
675 local OnHide = function (slider)
|
|
Tercio@39
|
676 local capsule = slider.MyObject
|
|
Tercio@39
|
677 local kill = capsule:RunHooksForWidget ("OnHide", slider, capsule)
|
|
Tercio@39
|
678 if (kill) then
|
|
Tercio@39
|
679 return
|
|
Tercio@11
|
680 end
|
|
Tercio@11
|
681
|
|
Tercio@11
|
682 if (slider.MyObject.typing_value) then
|
|
Tercio@35
|
683 DFSliderMetaFunctions.editbox_typevalue:ClearFocus()
|
|
Tercio@35
|
684 DFSliderMetaFunctions.editbox_typevalue:SetText ("")
|
|
Tercio@11
|
685 slider.MyObject.typing_valu = false
|
|
Tercio@11
|
686 end
|
|
Tercio@11
|
687 end
|
|
Tercio@11
|
688
|
|
Tercio@11
|
689 local OnShow = function (slider)
|
|
Tercio@39
|
690 local capsule = slider.MyObject
|
|
Tercio@39
|
691 local kill = capsule:RunHooksForWidget ("OnShow", slider, capsule)
|
|
Tercio@39
|
692 if (kill) then
|
|
Tercio@39
|
693 return
|
|
Tercio@11
|
694 end
|
|
Tercio@11
|
695 end
|
|
Tercio@11
|
696
|
|
Tercio@11
|
697 local table_insert = table.insert
|
|
Tercio@11
|
698 local table_remove = table.remove
|
|
Tercio@11
|
699
|
|
Tercio@11
|
700 local OnValueChanged = function (slider)
|
|
Tercio@11
|
701
|
|
Tercio@12
|
702 local amt
|
|
Tercio@12
|
703 if (slider.MyObject.useDecimals) then
|
|
Tercio@12
|
704 amt = slider:GetValue()
|
|
Tercio@12
|
705 else
|
|
Tercio@12
|
706 amt = _math_floor (slider:GetValue())
|
|
Tercio@12
|
707 end
|
|
Tercio@11
|
708
|
|
Tercio@11
|
709 if (slider.MyObject.typing_value and not slider.MyObject.typing_can_change) then
|
|
Tercio@11
|
710 slider.MyObject:SetValue (slider.MyObject.typing_value_started)
|
|
Tercio@11
|
711 return
|
|
Tercio@11
|
712 end
|
|
Tercio@11
|
713
|
|
Tercio@11
|
714 table_insert (slider.MyObject.previous_value, 1, amt)
|
|
Tercio@11
|
715 table_remove (slider.MyObject.previous_value, 4)
|
|
Tercio@11
|
716
|
|
Tercio@39
|
717 local capsule = slider.MyObject
|
|
Tercio@39
|
718 local kill = capsule:RunHooksForWidget ("OnValueChanged", slider, capsule.FixedValue, amt, capsule)
|
|
Tercio@39
|
719 if (kill) then
|
|
Tercio@39
|
720 return
|
|
Tercio@11
|
721 end
|
|
Tercio@39
|
722 local kill = capsule:RunHooksForWidget ("OnValueChange", slider, capsule.FixedValue, amt, capsule)
|
|
Tercio@39
|
723 if (kill) then
|
|
Tercio@39
|
724 return
|
|
Tercio@39
|
725 end
|
|
Tercio@39
|
726
|
|
Tercio@11
|
727 if (slider.MyObject.OnValueChanged) then
|
|
Tercio@11
|
728 slider.MyObject.OnValueChanged (slider, slider.MyObject.FixedValue, amt)
|
|
Tercio@11
|
729 end
|
|
Tercio@11
|
730
|
|
Tercio@11
|
731 if (amt < 10 and amt >= 1) then
|
|
Tercio@11
|
732 amt = "0"..amt
|
|
Tercio@11
|
733 end
|
|
Tercio@11
|
734
|
|
Tercio@11
|
735 if (slider.MyObject.useDecimals) then
|
|
Tercio@11
|
736 slider.amt:SetText (string.format ("%.2f", amt))
|
|
Tercio@11
|
737 else
|
|
Tercio@11
|
738 slider.amt:SetText (math.floor (amt))
|
|
Tercio@11
|
739 end
|
|
Tercio@11
|
740 slider.MyObject.ivalue = amt
|
|
Tercio@11
|
741 end
|
|
Tercio@11
|
742
|
|
Tercio@11
|
743 ------------------------------------------------------------------------------------------------------------
|
|
Tercio@11
|
744 --> object constructor
|
|
Tercio@11
|
745
|
|
Tercio@11
|
746 local SwitchOnClick = function (self, button, forced_value, value)
|
|
Tercio@11
|
747
|
|
Tercio@11
|
748 local slider = self.MyObject
|
|
Tercio@11
|
749
|
|
Tercio@11
|
750 if (_rawget (slider, "lockdown")) then
|
|
Tercio@11
|
751 return
|
|
Tercio@11
|
752 end
|
|
Tercio@11
|
753
|
|
Tercio@11
|
754 if (forced_value) then
|
|
Tercio@11
|
755 _rawset (slider, "value", not value)
|
|
Tercio@11
|
756 end
|
|
Tercio@11
|
757
|
|
Tercio@11
|
758 if (_rawget (slider, "value")) then --actived
|
|
Tercio@11
|
759 _rawset (slider, "value", false)
|
|
Tercio@11
|
760
|
|
Tercio@22
|
761 if (slider.backdrop_disabledcolor) then
|
|
Tercio@22
|
762 slider:SetBackdropColor (unpack (slider.backdrop_disabledcolor))
|
|
Tercio@22
|
763 else
|
|
Tercio@22
|
764 slider:SetBackdropColor (1, 0, 0, 0.4)
|
|
Tercio@22
|
765 end
|
|
Tercio@22
|
766
|
|
Tercio@22
|
767 if (slider.is_checkbox) then
|
|
Tercio@22
|
768 slider.checked_texture:Hide()
|
|
Tercio@22
|
769 else
|
|
Tercio@22
|
770 slider._text:SetText (slider._ltext)
|
|
Tercio@22
|
771 slider._thumb:ClearAllPoints()
|
|
Tercio@22
|
772 slider._thumb:SetPoint ("left", slider.widget, "left")
|
|
Tercio@22
|
773 end
|
|
Tercio@11
|
774 else
|
|
Tercio@11
|
775 _rawset (slider, "value", true)
|
|
Tercio@22
|
776 if (slider.backdrop_enabledcolor) then
|
|
Tercio@22
|
777 slider:SetBackdropColor (unpack (slider.backdrop_enabledcolor))
|
|
Tercio@22
|
778 else
|
|
Tercio@22
|
779 slider:SetBackdropColor (0, 0, 1, 0.4)
|
|
Tercio@22
|
780 end
|
|
Tercio@22
|
781 if (slider.is_checkbox) then
|
|
Tercio@22
|
782 slider.checked_texture:Show()
|
|
Tercio@22
|
783 else
|
|
Tercio@22
|
784 slider._text:SetText (slider._rtext)
|
|
Tercio@22
|
785 slider._thumb:ClearAllPoints()
|
|
Tercio@22
|
786 slider._thumb:SetPoint ("right", slider.widget, "right")
|
|
Tercio@22
|
787 end
|
|
Tercio@11
|
788 end
|
|
Tercio@11
|
789
|
|
Tercio@11
|
790 if (slider.OnSwitch and not forced_value) then
|
|
Tercio@11
|
791 local value = _rawget (slider, "value")
|
|
Tercio@11
|
792 if (slider.return_func) then
|
|
Tercio@11
|
793 value = slider:return_func (value)
|
|
Tercio@11
|
794 end
|
|
Tercio@11
|
795 slider.OnSwitch (slider, slider.FixedValue, value)
|
|
Tercio@11
|
796 end
|
|
Tercio@11
|
797
|
|
Tercio@11
|
798 end
|
|
Tercio@11
|
799
|
|
Tercio@11
|
800 local default_switch_func = function (self, passed_value)
|
|
Tercio@11
|
801 if (self.value) then
|
|
Tercio@11
|
802 return false
|
|
Tercio@11
|
803 else
|
|
Tercio@11
|
804 return true
|
|
Tercio@11
|
805 end
|
|
Tercio@11
|
806 end
|
|
Tercio@11
|
807
|
|
Tercio@11
|
808 local switch_get_value = function (self)
|
|
Tercio@11
|
809 return self.value
|
|
Tercio@11
|
810 end
|
|
Tercio@11
|
811
|
|
Tercio@11
|
812 local switch_set_value = function (self, value)
|
|
Tercio@11
|
813 if (self.switch_func) then
|
|
Tercio@11
|
814 value = self:switch_func (value)
|
|
Tercio@11
|
815 end
|
|
Tercio@11
|
816
|
|
Tercio@11
|
817 SwitchOnClick (self.widget, nil, true, value)
|
|
Tercio@11
|
818 end
|
|
Tercio@11
|
819
|
|
Tercio@11
|
820 local switch_set_fixparameter = function (self, value)
|
|
Tercio@11
|
821 _rawset (self, "FixedValue", value)
|
|
Tercio@11
|
822 end
|
|
Tercio@11
|
823
|
|
Tercio@11
|
824 local switch_disable = function (self)
|
|
Tercio@11
|
825
|
|
Tercio@22
|
826 if (self.is_checkbox) then
|
|
Tercio@22
|
827 self.checked_texture:Hide()
|
|
Tercio@22
|
828 else
|
|
Tercio@22
|
829 self._text:Hide()
|
|
Tercio@35
|
830 if (not self.lock_texture) then
|
|
Tercio@35
|
831 DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
|
|
Tercio@35
|
832 self.lock_texture:SetDesaturated (true)
|
|
Tercio@35
|
833 self.lock_texture:SetPoint ("center", self._thumb, "center")
|
|
Tercio@35
|
834 end
|
|
Tercio@35
|
835 self.lock_texture:Show()
|
|
Tercio@22
|
836 end
|
|
Tercio@22
|
837
|
|
Tercio@11
|
838 self:SetAlpha (.4)
|
|
Tercio@11
|
839 _rawset (self, "lockdown", true)
|
|
Tercio@11
|
840 end
|
|
Tercio@11
|
841 local switch_enable = function (self)
|
|
Tercio@22
|
842 if (self.is_checkbox) then
|
|
Tercio@22
|
843 if (_rawget (self, "value")) then
|
|
Tercio@22
|
844 self.checked_texture:Show()
|
|
Tercio@22
|
845 else
|
|
Tercio@22
|
846 self.checked_texture:Hide()
|
|
Tercio@22
|
847 end
|
|
Tercio@22
|
848 else
|
|
Tercio@35
|
849 if (not self.lock_texture) then
|
|
Tercio@35
|
850 DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
|
|
Tercio@35
|
851 self.lock_texture:SetDesaturated (true)
|
|
Tercio@35
|
852 self.lock_texture:SetPoint ("center", self._thumb, "center")
|
|
Tercio@35
|
853 end
|
|
Tercio@35
|
854 self.lock_texture:Hide()
|
|
Tercio@22
|
855 self._text:Show()
|
|
Tercio@22
|
856 end
|
|
Tercio@22
|
857
|
|
Tercio@11
|
858 self:SetAlpha (1)
|
|
Tercio@11
|
859 return _rawset (self, "lockdown", false)
|
|
Tercio@11
|
860 end
|
|
Tercio@11
|
861
|
|
Tercio@22
|
862 local set_as_checkbok = function (self)
|
|
Tercio@35
|
863 local checked = self:CreateTexture (self:GetName() .. "CheckTexture", "overlay")
|
|
Tercio@22
|
864 checked:SetTexture ([[Interface\Buttons\UI-CheckBox-Check]])
|
|
Tercio@22
|
865 checked:SetPoint ("center", self.button, "center", -1, -1)
|
|
Tercio@22
|
866 local size_pct = self:GetWidth()/32
|
|
Tercio@22
|
867 checked:SetSize (32*size_pct, 32*size_pct)
|
|
Tercio@22
|
868 self.checked_texture = checked
|
|
Tercio@22
|
869
|
|
Tercio@22
|
870 self._thumb:Hide()
|
|
Tercio@22
|
871 self._text:Hide()
|
|
Tercio@22
|
872
|
|
Tercio@22
|
873 self.is_checkbox = true
|
|
Tercio@22
|
874
|
|
Tercio@22
|
875 if (_rawget (self, "value")) then
|
|
Tercio@22
|
876 self.checked_texture:Show()
|
|
Tercio@22
|
877 if (self.backdrop_enabledcolor) then
|
|
Tercio@22
|
878 self:SetBackdropColor (unpack (self.backdrop_enabledcolor))
|
|
Tercio@22
|
879 else
|
|
Tercio@22
|
880 self:SetBackdropColor (0, 0, 1, 0.4)
|
|
Tercio@22
|
881 end
|
|
Tercio@22
|
882 else
|
|
Tercio@22
|
883 self.checked_texture:Hide()
|
|
Tercio@22
|
884 if (self.backdrop_disabledcolor) then
|
|
Tercio@22
|
885 self:SetBackdropColor (unpack (self.backdrop_disabledcolor))
|
|
Tercio@22
|
886 else
|
|
Tercio@22
|
887 self:SetBackdropColor (0, 0, 1, 0.4)
|
|
Tercio@22
|
888 end
|
|
Tercio@22
|
889 end
|
|
Tercio@35
|
890
|
|
Tercio@22
|
891 end
|
|
Tercio@22
|
892
|
|
Tercio@22
|
893 function DF:CreateSwitch (parent, on_switch, default_value, w, h, ltext, rtext, member, name, color_inverted, switch_func, return_func, with_label, switch_template, label_template)
|
|
Tercio@22
|
894 local switch, label = DF:NewSwitch (parent, parent, name, member, w or 60, h or 20, ltext, rtext, default_value, color_inverted, switch_func, return_func, with_label, switch_template, label_template)
|
|
Tercio@11
|
895 if (on_switch) then
|
|
Tercio@11
|
896 switch.OnSwitch = on_switch
|
|
Tercio@11
|
897 end
|
|
Tercio@11
|
898 return switch, label
|
|
Tercio@11
|
899 end
|
|
Tercio@11
|
900
|
|
Tercio@22
|
901 function DF:NewSwitch (parent, container, name, member, w, h, ltext, rtext, default_value, color_inverted, switch_func, return_func, with_label, switch_template, label_template)
|
|
Tercio@11
|
902
|
|
Tercio@11
|
903 --> early checks
|
|
Tercio@11
|
904 if (not name) then
|
|
Tercioo@29
|
905 name = "DetailsFrameWorkSlider" .. DF.SwitchCounter
|
|
Tercioo@29
|
906 DF.SwitchCounter = DF.SwitchCounter + 1
|
|
Tercio@11
|
907 elseif (not parent) then
|
|
Tercioo@29
|
908 return error ("Details! FrameWork: parent not found.", 2)
|
|
Tercio@11
|
909 end
|
|
Tercio@11
|
910 if (not container) then
|
|
Tercio@11
|
911 container = parent
|
|
Tercio@11
|
912 end
|
|
Tercio@11
|
913
|
|
Tercio@11
|
914 --> defaults
|
|
Tercio@11
|
915 ltext = ltext or "OFF"
|
|
Tercio@11
|
916 rtext = rtext or "ON"
|
|
Tercio@11
|
917
|
|
Tercio@11
|
918 --> build frames
|
|
Tercio@11
|
919
|
|
Tercio@11
|
920 w = w or 60
|
|
Tercio@11
|
921 h = h or 20
|
|
Tercio@11
|
922
|
|
Tercio@11
|
923 local slider = DF:NewButton (parent, container, name, member, w, h)
|
|
Tercio@11
|
924
|
|
Tercio@11
|
925 slider.switch_func = switch_func
|
|
Tercio@11
|
926 slider.return_func = return_func
|
|
Tercio@11
|
927 slider.SetValue = switch_set_value
|
|
Tercio@11
|
928 slider.GetValue = switch_get_value
|
|
Tercio@11
|
929 slider.SetFixedParameter = switch_set_fixparameter
|
|
Tercio@11
|
930 slider.Disable = switch_disable
|
|
Tercio@11
|
931 slider.Enable = switch_enable
|
|
Tercio@22
|
932 slider.SetAsCheckBox = set_as_checkbok
|
|
Tercio@35
|
933 slider.SetTemplate = DFSliderMetaFunctions.SetTemplate
|
|
Tercio@11
|
934
|
|
Tercio@11
|
935 if (member) then
|
|
Tercio@11
|
936 parent [member] = slider
|
|
Tercio@11
|
937 end
|
|
Tercio@11
|
938
|
|
Tercio@11
|
939 slider:SetBackdrop ({edgeFile = [[Interface\Buttons\UI-SliderBar-Border]], edgeSize = 8,
|
|
Tercio@11
|
940 bgFile = [[Interface\AddOns\Details\images\background]], insets = {left = 3, right = 3, top = 5, bottom = 5}})
|
|
Tercio@11
|
941
|
|
Tercio@11
|
942 local thumb = slider:CreateTexture (nil, "artwork")
|
|
Tercio@11
|
943 thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
|
|
Tercio@11
|
944 thumb:SetSize (34+(h*0.2), h*1.2)
|
|
Tercio@11
|
945 thumb:SetAlpha (0.7)
|
|
Tercio@11
|
946 thumb:SetPoint ("left", slider.widget, "left")
|
|
Tercio@11
|
947
|
|
Tercio@11
|
948 local text = slider:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
|
|
Tercio@11
|
949 text:SetTextColor (.8, .8, .8, 1)
|
|
Tercio@11
|
950 text:SetPoint ("center", thumb, "center")
|
|
Tercio@11
|
951
|
|
Tercio@11
|
952 slider._text = text
|
|
Tercio@11
|
953 slider._thumb = thumb
|
|
Tercio@11
|
954 slider._ltext = ltext
|
|
Tercio@11
|
955 slider._rtext = rtext
|
|
Tercio@11
|
956 slider.thumb = thumb
|
|
Tercio@11
|
957
|
|
Tercio@11
|
958 slider.invert_colors = color_inverted
|
|
Tercio@11
|
959
|
|
Tercio@11
|
960 slider:SetScript ("OnClick", SwitchOnClick)
|
|
Tercio@11
|
961
|
|
Tercio@11
|
962 slider:SetValue (default_value)
|
|
Tercio@11
|
963
|
|
Tercio@11
|
964 slider.isSwitch = true
|
|
Tercio@11
|
965
|
|
Tercio@22
|
966 if (switch_template) then
|
|
Tercio@22
|
967 slider:SetTemplate (switch_template)
|
|
Tercio@22
|
968 end
|
|
Tercio@22
|
969
|
|
Tercio@11
|
970 if (with_label) then
|
|
Tercio@11
|
971 local label = DF:CreateLabel (slider.widget, with_label, nil, nil, nil, "label", nil, "overlay")
|
|
Tercio@11
|
972 label.text = with_label
|
|
Tercio@11
|
973 slider.widget:SetPoint ("left", label.widget, "right", 2, 0)
|
|
Tercio@11
|
974 with_label = label
|
|
Tercio@22
|
975
|
|
Tercio@22
|
976 if (label_template) then
|
|
Tercio@22
|
977 label:SetTemplate (label_template)
|
|
Tercio@22
|
978 end
|
|
Tercio@11
|
979 end
|
|
Tercio@11
|
980
|
|
Tercio@11
|
981 return slider, with_label
|
|
Tercio@11
|
982 end
|
|
Tercio@11
|
983
|
|
Tercio@35
|
984 function DFSliderMetaFunctions:SetTemplate (template)
|
|
Tercio@22
|
985
|
|
Tercio@22
|
986 --slider e switch
|
|
Tercio@22
|
987 if (template.width) then
|
|
Tercio@22
|
988 self:SetWidth (template.width)
|
|
Tercio@22
|
989 end
|
|
Tercio@22
|
990 if (template.height) then
|
|
Tercio@22
|
991 self:SetHeight (template.height)
|
|
Tercio@22
|
992 end
|
|
Tercio@22
|
993
|
|
Tercio@22
|
994 if (template.backdrop) then
|
|
Tercio@22
|
995 self:SetBackdrop (template.backdrop)
|
|
Tercio@22
|
996 end
|
|
Tercio@22
|
997 if (template.backdropcolor) then
|
|
Tercio@22
|
998 local r, g, b, a = DF:ParseColors (template.backdropcolor)
|
|
Tercio@22
|
999 self:SetBackdropColor (r, g, b, a)
|
|
Tercio@22
|
1000 end
|
|
Tercio@22
|
1001 if (template.backdropbordercolor) then
|
|
Tercio@22
|
1002 local r, g, b, a = DF:ParseColors (template.backdropbordercolor)
|
|
Tercio@22
|
1003 self:SetBackdropBorderColor (r, g, b, a)
|
|
Tercio@22
|
1004 self.onleave_backdrop_border_color = {r, g, b, a}
|
|
Tercio@22
|
1005 end
|
|
Tercio@22
|
1006
|
|
Tercio@22
|
1007 if (template.onenterbordercolor) then
|
|
Tercio@22
|
1008 local r, g, b, a = DF:ParseColors (template.onenterbordercolor)
|
|
Tercio@22
|
1009 self.onenter_backdrop_border_color = {r, g, b, a}
|
|
Tercio@22
|
1010 end
|
|
Tercio@22
|
1011
|
|
Tercio@22
|
1012 if (template.onleavebordercolor) then
|
|
Tercio@22
|
1013 local r, g, b, a = DF:ParseColors (template.onleavebordercolor)
|
|
Tercio@22
|
1014 self.onleave_backdrop_border_color = {r, g, b, a}
|
|
Tercio@22
|
1015 end
|
|
Tercio@22
|
1016
|
|
Tercio@22
|
1017 if (template.thumbtexture) then
|
|
Tercio@22
|
1018 if (self.thumb) then
|
|
Tercio@22
|
1019 self.thumb:SetTexture (template.thumbtexture)
|
|
Tercio@22
|
1020 end
|
|
Tercio@22
|
1021 end
|
|
Tercio@22
|
1022 if (template.thumbwidth) then
|
|
Tercio@22
|
1023 if (self.thumb) then
|
|
Tercio@22
|
1024 self.thumb:SetWidth (template.thumbwidth)
|
|
Tercio@22
|
1025 end
|
|
Tercio@22
|
1026 end
|
|
Tercio@22
|
1027 if (template.thumbheight) then
|
|
Tercio@22
|
1028 if (self.thumb) then
|
|
Tercio@22
|
1029 self.thumb:SetHeight (template.thumbheight)
|
|
Tercio@22
|
1030 end
|
|
Tercio@22
|
1031 end
|
|
Tercio@22
|
1032 if (template.thumbcolor) then
|
|
Tercio@22
|
1033 if (self.thumb) then
|
|
Tercio@22
|
1034 local r, g, b, a = DF:ParseColors (template.thumbcolor)
|
|
Tercio@22
|
1035 self.thumb:SetVertexColor (r, g, b, a)
|
|
Tercio@22
|
1036 end
|
|
Tercio@22
|
1037 end
|
|
Tercio@22
|
1038
|
|
Tercio@22
|
1039 --switch only
|
|
Tercio@22
|
1040 if (template.enabled_backdropcolor) then
|
|
Tercio@22
|
1041 local r, g, b, a = DF:ParseColors (template.enabled_backdropcolor)
|
|
Tercio@22
|
1042 self.backdrop_enabledcolor = {r, g, b, a}
|
|
Tercio@22
|
1043 end
|
|
Tercio@22
|
1044 if (template.disabled_backdropcolor) then
|
|
Tercio@22
|
1045 local r, g, b, a = DF:ParseColors (template.disabled_backdropcolor)
|
|
Tercio@22
|
1046 self.backdrop_disabledcolor = {r, g, b, a}
|
|
Tercio@22
|
1047 end
|
|
Tercio@22
|
1048 end
|
|
Tercio@22
|
1049
|
|
Tercio@22
|
1050 function DF:CreateSlider (parent, w, h, min, max, step, defaultv, isDecemal, member, name, with_label, slider_template, label_template)
|
|
Tercio@22
|
1051 local slider, label = DF:NewSlider (parent, parent, name, member, w, h, min, max, step, defaultv, isDecemal, false, with_label, slider_template, label_template)
|
|
Tercio@11
|
1052 return slider, label
|
|
Tercio@11
|
1053 end
|
|
Tercio@11
|
1054
|
|
Tercio@22
|
1055 function DF:NewSlider (parent, container, name, member, w, h, min, max, step, defaultv, isDecemal, isSwitch, with_label, slider_template, label_template)
|
|
Tercio@11
|
1056
|
|
Tercio@11
|
1057 --> early checks
|
|
Tercio@11
|
1058 if (not name) then
|
|
Tercio@11
|
1059 name = "DetailsFrameworkSlider" .. DF.SliderCounter
|
|
Tercio@11
|
1060 DF.SliderCounter = DF.SliderCounter + 1
|
|
Tercio@11
|
1061 end
|
|
Tercio@11
|
1062 if (not parent) then
|
|
Tercioo@29
|
1063 return error ("Details! FrameWork: parent not found.", 2)
|
|
Tercio@11
|
1064 end
|
|
Tercio@11
|
1065 if (not container) then
|
|
Tercio@11
|
1066 container = parent
|
|
Tercio@11
|
1067 end
|
|
Tercio@11
|
1068
|
|
Tercio@11
|
1069 if (name:find ("$parent")) then
|
|
Tercioo@29
|
1070 local parentName = DF.GetParentName (parent)
|
|
Tercioo@29
|
1071 name = name:gsub ("$parent", parentName)
|
|
Tercio@11
|
1072 end
|
|
Tercio@11
|
1073
|
|
Tercio@11
|
1074 local SliderObject = {type = "slider", dframework = true}
|
|
Tercio@11
|
1075
|
|
Tercio@11
|
1076 if (member) then
|
|
Tercio@11
|
1077 parent [member] = SliderObject
|
|
Tercio@11
|
1078 end
|
|
Tercio@11
|
1079
|
|
Tercio@11
|
1080 if (parent.dframework) then
|
|
Tercio@11
|
1081 parent = parent.widget
|
|
Tercio@11
|
1082 end
|
|
Tercio@11
|
1083 if (container.dframework) then
|
|
Tercio@11
|
1084 container = container.widget
|
|
Tercio@11
|
1085 end
|
|
Tercio@11
|
1086
|
|
Tercio@11
|
1087 --> defaults
|
|
Tercio@11
|
1088 min = min or 1
|
|
Tercio@11
|
1089 max = max or 2
|
|
Tercio@11
|
1090 step = step or 1
|
|
Tercio@11
|
1091 defaultv = defaultv or min
|
|
Tercio@11
|
1092
|
|
Tercio@11
|
1093 w = w or 130
|
|
Tercio@11
|
1094 h = h or 19
|
|
Tercio@11
|
1095
|
|
Tercio@11
|
1096 --> default members:
|
|
Tercio@11
|
1097 SliderObject.lockdown = false
|
|
Tercio@11
|
1098 SliderObject.container = container
|
|
Tercio@11
|
1099 SliderObject.useDecimals = isDecemal or false
|
|
Tercio@11
|
1100
|
|
Tercio@11
|
1101 SliderObject.slider = CreateFrame ("slider", name, parent)
|
|
Tercio@11
|
1102 SliderObject.widget = SliderObject.slider
|
|
Tercio@11
|
1103
|
|
Tercio@11
|
1104 if (not APISliderFunctions) then
|
|
Tercio@11
|
1105 APISliderFunctions = true
|
|
Tercio@11
|
1106 local idx = getmetatable (SliderObject.slider).__index
|
|
Tercio@11
|
1107 for funcName, funcAddress in pairs (idx) do
|
|
Tercio@35
|
1108 if (not DFSliderMetaFunctions [funcName]) then
|
|
Tercio@35
|
1109 DFSliderMetaFunctions [funcName] = function (object, ...)
|
|
Tercio@20
|
1110 local x = loadstring ( "return _G['"..object.slider:GetName().."']:"..funcName.."(...)")
|
|
Tercio@11
|
1111 return x (...)
|
|
Tercio@11
|
1112 end
|
|
Tercio@11
|
1113 end
|
|
Tercio@11
|
1114 end
|
|
Tercio@11
|
1115 end
|
|
Tercio@11
|
1116
|
|
Tercio@11
|
1117 SliderObject.slider.MyObject = SliderObject
|
|
Tercio@11
|
1118 SliderObject.slider:SetWidth (w)
|
|
Tercio@11
|
1119 SliderObject.slider:SetHeight (h)
|
|
Tercio@11
|
1120 SliderObject.slider:SetOrientation ("horizontal")
|
|
Tercio@11
|
1121 SliderObject.slider:SetMinMaxValues (min, max)
|
|
Tercio@11
|
1122 SliderObject.slider:SetValueStep (step)
|
|
Tercio@11
|
1123 SliderObject.slider:SetValue (defaultv)
|
|
Tercio@11
|
1124 SliderObject.ivalue = defaultv
|
|
Tercio@11
|
1125
|
|
Tercio@11
|
1126 SliderObject.slider:SetBackdrop ({edgeFile = "Interface\\Buttons\\UI-SliderBar-Border", edgeSize = 8})
|
|
Tercio@11
|
1127 SliderObject.slider:SetBackdropColor (0.9, 0.7, 0.7, 1.0)
|
|
Tercio@39
|
1128 --SliderObject.slider:SetBackdropColor (0, 0, 0, 1)
|
|
Tercio@11
|
1129
|
|
Tercio@11
|
1130 SliderObject.thumb = SliderObject.slider:CreateTexture (nil, "artwork")
|
|
Tercio@11
|
1131 SliderObject.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
|
|
Tercio@11
|
1132 SliderObject.thumb:SetSize (30+(h*0.2), h*1.2)
|
|
Tercio@11
|
1133 SliderObject.thumb:SetAlpha (0.7)
|
|
Tercio@11
|
1134 SliderObject.slider:SetThumbTexture (SliderObject.thumb)
|
|
Tercio@11
|
1135 SliderObject.slider.thumb = SliderObject.thumb
|
|
Tercio@11
|
1136
|
|
Tercio@11
|
1137 if (not isSwitch) then
|
|
Tercio@11
|
1138 SliderObject.have_tooltip = "Right Click to Type the Value"
|
|
Tercio@11
|
1139 end
|
|
Tercio@11
|
1140
|
|
Tercio@11
|
1141 SliderObject.amt = SliderObject.slider:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
|
|
Tercio@11
|
1142
|
|
Tercio@11
|
1143 local amt = defaultv
|
|
Tercio@11
|
1144 if (amt < 10 and amt >= 1) then
|
|
Tercio@11
|
1145 amt = "0"..amt
|
|
Tercio@11
|
1146 end
|
|
Tercio@11
|
1147
|
|
Tercio@11
|
1148 if (SliderObject.useDecimals) then
|
|
Tercio@11
|
1149 SliderObject.amt:SetText (string.format ("%.2f", amt))
|
|
Tercio@11
|
1150 else
|
|
Tercio@11
|
1151 SliderObject.amt:SetText (math.floor (amt))
|
|
Tercio@11
|
1152 end
|
|
Tercio@11
|
1153
|
|
Tercio@11
|
1154 SliderObject.amt:SetTextColor (.8, .8, .8, 1)
|
|
Tercio@11
|
1155 SliderObject.amt:SetPoint ("center", SliderObject.thumb, "center")
|
|
Tercio@11
|
1156 SliderObject.slider.amt = SliderObject.amt
|
|
Tercio@11
|
1157
|
|
Tercio@11
|
1158 SliderObject.previous_value = {defaultv or 0, 0, 0}
|
|
Tercio@11
|
1159
|
|
Tercio@11
|
1160 --> hooks
|
|
Tercio@39
|
1161 SliderObject.HookList = {
|
|
Tercio@39
|
1162 OnEnter = {},
|
|
Tercio@39
|
1163 OnLeave = {},
|
|
Tercio@39
|
1164 OnHide = {},
|
|
Tercio@39
|
1165 OnShow = {},
|
|
Tercio@39
|
1166 OnMouseDown = {},
|
|
Tercio@39
|
1167 OnMouseUp = {},
|
|
Tercio@11
|
1168
|
|
Tercio@39
|
1169 OnValueChange = {},
|
|
Tercio@39
|
1170 OnValueChanged = {},
|
|
Tercio@39
|
1171 }
|
|
Tercio@39
|
1172
|
|
Tercio@39
|
1173 SliderObject.slider:SetScript ("OnEnter", OnEnter)
|
|
Tercio@39
|
1174 SliderObject.slider:SetScript ("OnLeave", OnLeave)
|
|
Tercio@39
|
1175 SliderObject.slider:SetScript ("OnHide", OnHide)
|
|
Tercio@39
|
1176 SliderObject.slider:SetScript ("OnShow", OnShow)
|
|
Tercio@39
|
1177 SliderObject.slider:SetScript ("OnValueChanged", OnValueChanged)
|
|
Tercio@39
|
1178 SliderObject.slider:SetScript ("OnMouseDown", OnMouseDown)
|
|
Tercio@39
|
1179 SliderObject.slider:SetScript ("OnMouseUp", OnMouseUp)
|
|
Tercio@39
|
1180
|
|
Tercio@35
|
1181 _setmetatable (SliderObject, DFSliderMetaFunctions)
|
|
Tercio@11
|
1182
|
|
Tercio@11
|
1183 if (with_label) then
|
|
Tercio@11
|
1184 local label = DF:CreateLabel (SliderObject.slider, with_label, nil, nil, nil, "label", nil, "overlay")
|
|
Tercio@11
|
1185 label.text = with_label
|
|
Tercio@11
|
1186 SliderObject.slider:SetPoint ("left", label.widget, "right", 2, 0)
|
|
Tercio@11
|
1187 with_label = label
|
|
Tercio@22
|
1188
|
|
Tercio@22
|
1189 if (label_template) then
|
|
Tercio@22
|
1190 label:SetTemplate (label_template)
|
|
Tercio@22
|
1191 end
|
|
Tercio@22
|
1192 end
|
|
Tercio@22
|
1193
|
|
Tercio@22
|
1194 if (slider_template) then
|
|
Tercio@22
|
1195 SliderObject:SetTemplate (slider_template)
|
|
Tercio@11
|
1196 end
|
|
Tercio@11
|
1197
|
|
Tercio@11
|
1198 return SliderObject, with_label
|
|
Tercio@11
|
1199
|
|
Tercio@11
|
1200 end |