annotate Libs/DF/split_bar.lua @ 20:dc1c77254f80

- added close button to users panel. - framework update.
author Tercio
date Tue, 11 Aug 2015 12:46:46 -0300
parents 2f09fe4be15c
children dbd417f413a8
rev   line source
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
Tercio@11 15 local cleanfunction = function() end
Tercio@11 16 local SplitBarMetaFunctions = {}
Tercio@11 17 local APISplitBarFunctions
Tercio@11 18
Tercio@11 19 ------------------------------------------------------------------------------------------------------------
Tercio@11 20 --> metatables
Tercio@11 21
Tercio@11 22 SplitBarMetaFunctions.__call = function (_table, value)
Tercio@11 23 if (not value) then
Tercio@11 24 return _table.statusbar:GetValue()
Tercio@11 25 else
Tercio@11 26 _table.div:SetPoint ("left", _table.statusbar, "left", value * (_table.statusbar:GetWidth()/100) - 18, 0)
Tercio@11 27 return _table.statusbar:SetValue (value)
Tercio@11 28 end
Tercio@11 29 end
Tercio@11 30
Tercio@11 31 SplitBarMetaFunctions.__add = function (v1, v2)
Tercio@11 32 if (_type (v1) == "table") then
Tercio@11 33 local v = v1.statusbar:GetValue()
Tercio@11 34 v = v + v2
Tercio@11 35 v1.div:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
Tercio@11 36 v1.statusbar:SetValue (v)
Tercio@11 37 else
Tercio@11 38 local v = v2.statusbar:GetValue()
Tercio@11 39 v = v + v1
Tercio@11 40 v2.div:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
Tercio@11 41 v2.statusbar:SetValue (v)
Tercio@11 42 end
Tercio@11 43 end
Tercio@11 44
Tercio@11 45 SplitBarMetaFunctions.__sub = function (v1, v2)
Tercio@11 46 if (_type (v1) == "table") then
Tercio@11 47 local v = v1.statusbar:GetValue()
Tercio@11 48 v = v - v2
Tercio@11 49 v1.div:SetPoint ("left", v1.statusbar, "left", value * (v1.statusbar:GetWidth()/100) - 18, 0)
Tercio@11 50 v1.statusbar:SetValue (v)
Tercio@11 51 else
Tercio@11 52 local v = v2.statusbar:GetValue()
Tercio@11 53 v = v - v1
Tercio@11 54 v2.div:SetPoint ("left", v2.statusbar, "left", value * (v2.statusbar:GetWidth()/100) - 18, 0)
Tercio@11 55 v2.statusbar:SetValue (v)
Tercio@11 56 end
Tercio@11 57 end
Tercio@11 58
Tercio@11 59 ------------------------------------------------------------------------------------------------------------
Tercio@11 60 --> members
Tercio@11 61
Tercio@11 62 --> tooltip
Tercio@11 63 local function gmember_tooltip (_object)
Tercio@11 64 return _object:GetTooltip()
Tercio@11 65 end
Tercio@11 66 --> shown
Tercio@11 67 local gmember_shown = function (_object)
Tercio@11 68 return _object.statusbar:IsShown()
Tercio@11 69 end
Tercio@11 70 --> frame width
Tercio@11 71 local gmember_width = function (_object)
Tercio@11 72 return _object.statusbar:GetWidth()
Tercio@11 73 end
Tercio@11 74 --> frame height
Tercio@11 75 local gmember_height = function (_object)
Tercio@11 76 return _object.statusbar:GetHeight()
Tercio@11 77 end
Tercio@11 78 --> value
Tercio@11 79 local gmember_value = function (_object)
Tercio@11 80 return _object.statusbar:GetValue()
Tercio@11 81 end
Tercio@11 82 --> right text
Tercio@11 83 local gmember_rtext = function (_object)
Tercio@11 84 return _object.textright:GetText()
Tercio@11 85 end
Tercio@11 86 --> left text
Tercio@11 87 local gmember_ltext = function (_object)
Tercio@11 88 return _object.textleft:GetText()
Tercio@11 89 end
Tercio@11 90 --> right color
Tercio@11 91 local gmember_rcolor = function (_object)
Tercio@11 92 return _object.background.original_colors
Tercio@11 93 end
Tercio@11 94 --> left color
Tercio@11 95 local gmember_lcolor = function (_object)
Tercio@11 96 return _object.texture.original_colors
Tercio@11 97 end
Tercio@11 98 --> right icon
Tercio@11 99 local gmember_ricon = function (_object)
Tercio@11 100 return _object.iconright:GetTexture()
Tercio@11 101 end
Tercio@11 102 --> left icon
Tercio@11 103 local gmember_licon = function (_object)
Tercio@11 104 return _object.iconleft:GetTexture()
Tercio@11 105 end
Tercio@11 106 --> texture
Tercio@11 107 local gmember_texture = function (_object)
Tercio@11 108 return _object.texture:GetTexture()
Tercio@11 109 end
Tercio@11 110 --> font size
Tercio@11 111 local gmember_textsize = function (_object)
Tercio@11 112 local _, fontsize = _object.textleft:GetFont()
Tercio@11 113 return fontsize
Tercio@11 114 end
Tercio@11 115 --> font face
Tercio@11 116 local gmember_textfont = function (_object)
Tercio@11 117 local fontface = _object.textleft:GetFont()
Tercio@11 118 return fontface
Tercio@11 119 end
Tercio@11 120 --> font color
Tercio@11 121 local gmember_textcolor = function (_object)
Tercio@11 122 return _object.textleft:GetTextColor()
Tercio@11 123 end
Tercio@11 124
Tercio@11 125 local get_members_function_index = {
Tercio@11 126 ["tooltip"] = gmember_tooltip,
Tercio@11 127 ["shown"] = gmember_shown,
Tercio@11 128 ["width"] = gmember_width,
Tercio@11 129 ["height"] = gmember_height,
Tercio@11 130 ["value"] = gmember_value,
Tercio@11 131 ["righttext"] = gmember_rtext,
Tercio@11 132 ["lefttext"] = gmember_ltext,
Tercio@11 133 ["rightcolor"] = gmember_rcolor,
Tercio@11 134 ["leftcolor"] = gmember_lcolor,
Tercio@11 135 ["righticon"] = gmember_ricon,
Tercio@11 136 ["lefticon"] = gmember_licon,
Tercio@11 137 ["texture"] = gmember_texture,
Tercio@11 138 ["fontsize"] = gmember_textsize,
Tercio@11 139 ["fontface"] = gmember_textfont,
Tercio@11 140 ["fontcolor"] = gmember_textcolor,
Tercio@11 141 ["textsize"] = gmember_textsize, --alias
Tercio@11 142 ["textfont"] = gmember_textfont, --alias
Tercio@11 143 ["textcolor"] = gmember_textcolor --alias
Tercio@11 144 }
Tercio@11 145
Tercio@11 146 SplitBarMetaFunctions.__index = function (_table, _member_requested)
Tercio@11 147
Tercio@11 148 local func = get_members_function_index [_member_requested]
Tercio@11 149 if (func) then
Tercio@11 150 return func (_table, _member_requested)
Tercio@11 151 end
Tercio@11 152
Tercio@11 153 local fromMe = _rawget (_table, _member_requested)
Tercio@11 154 if (fromMe) then
Tercio@11 155 return fromMe
Tercio@11 156 end
Tercio@11 157
Tercio@11 158 return SplitBarMetaFunctions [_member_requested]
Tercio@11 159 end
Tercio@11 160
Tercio@11 161 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 162
Tercio@11 163 --> tooltip
Tercio@11 164 local smember_tooltip = function (_object, _value)
Tercio@11 165 return _object:SetTooltip (_value)
Tercio@11 166 end
Tercio@11 167 --> show
Tercio@11 168 local smember_shown = function (_object, _value)
Tercio@11 169 if (_value) then
Tercio@11 170 return _object:Show()
Tercio@11 171 else
Tercio@11 172 return _object:Hide()
Tercio@11 173 end
Tercio@11 174 end
Tercio@11 175 --> hide
Tercio@11 176 local smember_hide = function (_object, _value)
Tercio@11 177 if (_value) then
Tercio@11 178 return _object:Hide()
Tercio@11 179 else
Tercio@11 180 return _object:Show()
Tercio@11 181 end
Tercio@11 182 end
Tercio@11 183 --> width
Tercio@11 184 local smember_width = function (_object, _value)
Tercio@11 185 return _object.statusbar:SetWidth (_value)
Tercio@11 186 end
Tercio@11 187 --> height
Tercio@11 188 local smember_height = function (_object, _value)
Tercio@11 189 return _object.statusbar:SetHeight (_value)
Tercio@11 190 end
Tercio@11 191 --> statusbar value
Tercio@11 192 local smember_value = function (_object, _value)
Tercio@11 193 _object.statusbar:SetValue (_value)
Tercio@11 194 return _object.div:SetPoint ("left", _object.statusbar, "left", _value * (_object.statusbar:GetWidth()/100) - 18, 0)
Tercio@11 195 end
Tercio@11 196 --> right text
Tercio@11 197 local smember_rtext = function (_object, _value)
Tercio@11 198 return _object.textright:SetText (_value)
Tercio@11 199 end
Tercio@11 200 --> left text
Tercio@11 201 local smember_ltext = function (_object, _value)
Tercio@11 202 return _object.textleft:SetText (_value)
Tercio@11 203 end
Tercio@11 204 --> right color
Tercio@11 205 local smember_rcolor = function (_object, _value)
Tercio@11 206 local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
Tercio@11 207 _object.background.original_colors = {_value1, _value2, _value3, _value4}
Tercio@11 208 return _object.background:SetVertexColor (_value1, _value2, _value3, _value4)
Tercio@11 209 end
Tercio@11 210 --> left color
Tercio@11 211 local smember_lcolor = function (_object, _value)
Tercio@11 212 local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
Tercio@11 213
Tercio@11 214 _object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4)
Tercio@11 215 _object.texture.original_colors = {_value1, _value2, _value3, _value4}
Tercio@11 216 return _object.texture:SetVertexColor (_value1, _value2, _value3, _value4)
Tercio@11 217 end
Tercio@11 218 --> right icon
Tercio@11 219 local smember_ricon = function (_object, _value)
Tercio@11 220 if (type (_value) == "table") then
Tercio@11 221 local _value1, _value2 = _unpack (_value)
Tercio@11 222 _object.iconright:SetTexture (_value1)
Tercio@11 223 if (_value2) then
Tercio@11 224 _object.iconright:SetTexCoord (_unpack (_value2))
Tercio@11 225 end
Tercio@11 226 else
Tercio@11 227 _object.iconright:SetTexture (_value)
Tercio@11 228 end
Tercio@11 229 return
Tercio@11 230 end
Tercio@11 231 --> left icon
Tercio@11 232 local smember_licon = function (_object, _value)
Tercio@11 233 if (type (_value) == "table") then
Tercio@11 234 local _value1, _value2 = _unpack (_value)
Tercio@11 235 _object.iconleft:SetTexture (_value1)
Tercio@11 236 if (_value2) then
Tercio@11 237 _object.iconleft:SetTexCoord (_unpack (_value2))
Tercio@11 238 end
Tercio@11 239 else
Tercio@11 240 _object.iconleft:SetTexture (_value)
Tercio@11 241 end
Tercio@11 242 return
Tercio@11 243 end
Tercio@11 244 --> texture
Tercio@11 245 local smember_texture = function (_object, _value)
Tercio@11 246 if (type (_value) == "table") then
Tercio@11 247 local _value1, _value2 = _unpack (_value)
Tercio@11 248 _object.texture:SetTexture (_value1)
Tercio@11 249 _object.background:SetTexture (_value1)
Tercio@11 250 if (_value2) then
Tercio@11 251 _object.texture:SetTexCoord (_unpack (_value2))
Tercio@11 252 _object.background:SetTexCoord (_unpack (_value2))
Tercio@11 253 end
Tercio@11 254 else
Tercio@11 255 _object.texture:SetTexture (_value)
Tercio@11 256 _object.background:SetTexture (_value)
Tercio@11 257 end
Tercio@11 258 return
Tercio@11 259 end
Tercio@11 260 --> font face
Tercio@11 261 local smember_textfont = function (_object, _value)
Tercio@11 262 DF:SetFontFace (_object.textleft, _value)
Tercio@11 263 return DF:SetFontFace (_object.textright, _value)
Tercio@11 264 end
Tercio@11 265 --> font size
Tercio@11 266 local smember_textsize = function (_object, _value)
Tercio@11 267 DF:SetFontSize (_object.textleft, _value)
Tercio@11 268 return DF:SetFontSize (_object.textright, _value)
Tercio@11 269 end
Tercio@11 270 --> font color
Tercio@11 271 local smember_textcolor = function (_object, _value)
Tercio@11 272 local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
Tercio@11 273 _object.textleft:SetTextColor (_value1, _value2, _value3, _value4)
Tercio@11 274 return _object.textright:SetTextColor (_value1, _value2, _value3, _value4)
Tercio@11 275 end
Tercio@11 276
Tercio@11 277 local set_members_function_index = {
Tercio@11 278 ["tooltip"] = smember_tooltip,
Tercio@11 279 ["shown"] = smember_shown,
Tercio@11 280 ["width"] = smember_width,
Tercio@11 281 ["height"] = smember_height,
Tercio@11 282 ["value"] = smember_value,
Tercio@11 283 ["righttext"] = smember_rtext,
Tercio@11 284 ["lefttext"] = smember_ltext,
Tercio@11 285 ["rightcolor"] = smember_rcolor,
Tercio@11 286 ["leftcolor"] = smember_lcolor,
Tercio@11 287 ["righticon"] = smember_ricon,
Tercio@11 288 ["lefticon"] = smember_licon,
Tercio@11 289 ["texture"] = smember_texture,
Tercio@11 290 ["fontsize"] = smember_textsize,
Tercio@11 291 ["fontface"] = smember_textfont,
Tercio@11 292 ["fontcolor"] = smember_textcolor,
Tercio@11 293 ["textsize"] = smember_textsize, --alias
Tercio@11 294 ["textfont"] = smember_textfont, --alias
Tercio@11 295 ["textcolor"] = smember_textcolor --alias
Tercio@11 296 }
Tercio@11 297
Tercio@11 298 SplitBarMetaFunctions.__newindex = function (_table, _key, _value)
Tercio@11 299 local func = set_members_function_index [_key]
Tercio@11 300 if (func) then
Tercio@11 301 return func (_table, _value)
Tercio@11 302 else
Tercio@11 303 return _rawset (_table, _key, _value)
Tercio@11 304 end
Tercio@11 305 end
Tercio@11 306
Tercio@11 307 ------------------------------------------------------------------------------------------------------------
Tercio@11 308 --> methods
Tercio@11 309
Tercio@11 310 --> show & hide
Tercio@11 311 function SplitBarMetaFunctions:Show()
Tercio@11 312 return self.statusbar:Show()
Tercio@11 313 end
Tercio@11 314 function SplitBarMetaFunctions:Hide()
Tercio@11 315 return self.statusbar:Hide()
Tercio@11 316 end
Tercio@11 317
Tercio@11 318 -- set split
Tercio@11 319 function SplitBarMetaFunctions:SetSplit (value)
Tercio@11 320 if (not value) then
Tercio@11 321 value = self.statusbar:GetValue()
Tercio@11 322 elseif (value < 0 or value > 100) then
Tercio@11 323 return
Tercio@11 324 end
Tercio@11 325 self.statusbar:SetValue (value)
Tercio@11 326 self.div:SetPoint ("left", self.statusbar, "left", value * (self.statusbar:GetWidth()/100) - 18, 0)
Tercio@11 327 end
Tercio@11 328
Tercio@11 329 -- setpoint
Tercio@11 330 function SplitBarMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
Tercio@11 331 v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
Tercio@11 332 if (not v1) then
Tercio@11 333 print ("Invalid parameter for SetPoint")
Tercio@11 334 return
Tercio@11 335 end
Tercio@11 336 return self.widget:SetPoint (v1, v2, v3, v4, v5)
Tercio@11 337 end
Tercio@11 338
Tercio@11 339 -- sizes
Tercio@11 340 function SplitBarMetaFunctions:SetSize (w, h)
Tercio@11 341 if (w) then
Tercio@11 342 self.statusbar:SetWidth (w)
Tercio@11 343 end
Tercio@11 344 if (h) then
Tercio@11 345 self.statusbar:SetHeight (h)
Tercio@11 346 end
Tercio@11 347 end
Tercio@11 348
Tercio@11 349 -- texture
Tercio@11 350 function SplitBarMetaFunctions:SetTexture (texture)
Tercio@11 351 self.background:SetTexture (texture)
Tercio@11 352 self.texture:SetTexture (texture)
Tercio@11 353 end
Tercio@11 354
Tercio@11 355 -- texts
Tercio@11 356 function SplitBarMetaFunctions:SetLeftText (text)
Tercio@11 357 self.textleft:SetText (text)
Tercio@11 358 end
Tercio@11 359 function SplitBarMetaFunctions:SetRightText (text)
Tercio@11 360 self.textright:SetText (text)
Tercio@11 361 end
Tercio@11 362
Tercio@11 363 -- colors
Tercio@11 364 function SplitBarMetaFunctions:SetLeftColor (r, g, b, a)
Tercio@11 365 r, g, b, a = DF:ParseColors (r, g, b, a)
Tercio@11 366 self.texture:SetVertexColor (r, g, b, a)
Tercio@11 367 self.texture.original_colors = {r, g, b, a}
Tercio@11 368 end
Tercio@11 369 function SplitBarMetaFunctions:SetRightColor (r, g, b, a)
Tercio@11 370 r, g, b, a = DF:ParseColors (r, g, b, a)
Tercio@11 371 self.background:SetVertexColor (r, g, b, a)
Tercio@11 372 self.background.original_colors = {r, g, b, a}
Tercio@11 373 end
Tercio@11 374
Tercio@11 375 -- icons
Tercio@11 376 function SplitBarMetaFunctions:SetLeftIcon (texture, ...)
Tercio@11 377 self.iconleft:SetTexture (texture)
Tercio@11 378 if (...) then
Tercio@11 379 local L, R, U, D = unpack (...)
Tercio@11 380 self.iconleft:SetTexCoord (L, R, U, D)
Tercio@11 381 end
Tercio@11 382 end
Tercio@11 383 function SplitBarMetaFunctions:SetRightIcon (texture, ...)
Tercio@11 384 self.iconright:SetTexture (texture)
Tercio@11 385 if (...) then
Tercio@11 386 local L, R, U, D = unpack (...)
Tercio@11 387 self.iconright:SetTexCoord (L, R, U, D)
Tercio@11 388 end
Tercio@11 389 end
Tercio@11 390
Tercio@11 391 -- tooltip
Tercio@11 392 function SplitBarMetaFunctions:SetTooltip (tooltip)
Tercio@11 393 if (tooltip) then
Tercio@11 394 return _rawset (self, "have_tooltip", tooltip)
Tercio@11 395 else
Tercio@11 396 return _rawset (self, "have_tooltip", nil)
Tercio@11 397 end
Tercio@11 398 end
Tercio@11 399 function SplitBarMetaFunctions:GetTooltip()
Tercio@11 400 return _rawget (self, "have_tooltip")
Tercio@11 401 end
Tercio@11 402
Tercio@11 403 -- frame levels
Tercio@11 404 function SplitBarMetaFunctions:GetFrameLevel()
Tercio@11 405 return self.statusbar:GetFrameLevel()
Tercio@11 406 end
Tercio@11 407 function SplitBarMetaFunctions:SetFrameLevel (level, frame)
Tercio@11 408 if (not frame) then
Tercio@11 409 return self.statusbar:SetFrameLevel (level)
Tercio@11 410 else
Tercio@11 411 local framelevel = frame:GetFrameLevel (frame) + level
Tercio@11 412 return self.statusbar:SetFrameLevel (framelevel)
Tercio@11 413 end
Tercio@11 414 end
Tercio@11 415
Tercio@11 416 -- frame stratas
Tercio@11 417 function SplitBarMetaFunctions:SetFrameStrata()
Tercio@11 418 return self.statusbar:GetFrameStrata()
Tercio@11 419 end
Tercio@11 420 function SplitBarMetaFunctions:SetFrameStrata (strata)
Tercio@11 421 if (_type (strata) == "table") then
Tercio@11 422 self.statusbar:SetFrameStrata (strata:GetFrameStrata())
Tercio@11 423 else
Tercio@11 424 self.statusbar:SetFrameStrata (strata)
Tercio@11 425 end
Tercio@11 426 end
Tercio@11 427
Tercio@11 428 --> hooks
Tercio@11 429 function SplitBarMetaFunctions:SetHook (hookType, func)
Tercio@11 430 if (func) then
Tercio@11 431 _rawset (self, hookType.."Hook", func)
Tercio@11 432 else
Tercio@11 433 _rawset (self, hookType.."Hook", nil)
Tercio@11 434 end
Tercio@11 435 end
Tercio@11 436
Tercio@11 437 ------------------------------------------------------------------------------------------------------------
Tercio@11 438 --> scripts
Tercio@11 439 local OnEnter = function (frame)
Tercio@11 440 if (frame.MyObject.OnEnterHook) then
Tercio@11 441 local interrupt = frame.MyObject.OnEnterHook (frame)
Tercio@11 442 if (interrupt) then
Tercio@11 443 return
Tercio@11 444 end
Tercio@11 445 end
Tercio@11 446
Tercio@11 447 local oc = frame.MyObject.texture.original_colors --original colors
Tercio@11 448 DF:GradientEffect ( frame.MyObject.texture, "texture", oc[1], oc[2], oc[3], oc[4], oc[1]+0.2, oc[2]+0.2, oc[3]+0.2, oc[4], .2)
Tercio@11 449 frame.MyObject.div:SetPoint ("left", frame, "left", frame:GetValue() * (frame:GetWidth()/100) - 18, 0)
Tercio@11 450
Tercio@11 451 if (frame.MyObject.have_tooltip) then
Tercio@11 452 GameCooltip2:Reset()
Tercio@11 453 GameCooltip2:AddLine (frame.MyObject.have_tooltip)
Tercio@11 454 GameCooltip2:ShowCooltip (frame, "tooltip")
Tercio@11 455 end
Tercio@11 456
Tercio@11 457 local parent = frame:GetParent().MyObject
Tercio@11 458 if (parent and parent.type == "panel") then
Tercio@11 459 if (parent.GradientEnabled) then
Tercio@11 460 parent:RunGradient()
Tercio@11 461 end
Tercio@11 462 end
Tercio@11 463 end
Tercio@11 464
Tercio@11 465 local OnLeave = function (frame)
Tercio@11 466 if (frame.MyObject.OnLeaveHook) then
Tercio@11 467 local interrupt = frame.MyObject.OnLeaveHook (frame)
Tercio@11 468 if (interrupt) then
Tercio@11 469 return
Tercio@11 470 end
Tercio@11 471 end
Tercio@11 472
Tercio@11 473 local oc = frame.MyObject.texture.original_colors --original colors
Tercio@11 474 local r, g, b, a = frame.MyObject.texture:GetVertexColor()
Tercio@11 475 DF:GradientEffect ( frame.MyObject.texture, "texture", r, g, b, a, oc[1], oc[2], oc[3], oc[4], .2)
Tercio@11 476
Tercio@11 477 if (frame.MyObject.have_tooltip) then
Tercio@11 478 DF.popup:ShowMe (false)
Tercio@11 479 end
Tercio@11 480
Tercio@11 481 local parent = frame:GetParent().MyObject
Tercio@11 482 if (parent and parent.type == "panel") then
Tercio@11 483 if (parent.GradientEnabled) then
Tercio@11 484 parent:RunGradient (false)
Tercio@11 485 end
Tercio@11 486 end
Tercio@11 487 end
Tercio@11 488
Tercio@11 489 local OnHide = function (frame)
Tercio@11 490 if (frame.MyObject.OnHideHook) then
Tercio@11 491 local interrupt = frame.MyObject.OnHideHook (frame)
Tercio@11 492 if (interrupt) then
Tercio@11 493 return
Tercio@11 494 end
Tercio@11 495 end
Tercio@11 496 end
Tercio@11 497
Tercio@11 498 local OnShow = function (frame)
Tercio@11 499 if (frame.MyObject.OnShowHook) then
Tercio@11 500 local interrupt = frame.MyObject.OnShowHook (frame)
Tercio@11 501 if (interrupt) then
Tercio@11 502 return
Tercio@11 503 end
Tercio@11 504 end
Tercio@11 505 end
Tercio@11 506
Tercio@11 507 local OnMouseDown = function (frame, button)
Tercio@11 508 if (frame.MyObject.OnMouseDownHook) then
Tercio@11 509 local interrupt = frame.MyObject.OnMouseDownHook (frame, button)
Tercio@11 510 if (interrupt) then
Tercio@11 511 return
Tercio@11 512 end
Tercio@11 513 end
Tercio@11 514
Tercio@11 515 if (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
Tercio@11 516 if (not frame.isLocked and frame:IsMovable()) then
Tercio@11 517 frame.MyObject.container.isMoving = true
Tercio@11 518 frame.MyObject.container:StartMoving()
Tercio@11 519 end
Tercio@11 520 end
Tercio@11 521 end
Tercio@11 522
Tercio@11 523 local OnMouseUp = function (frame, button)
Tercio@11 524 if (frame.MyObject.OnMouseUpHook) then
Tercio@11 525 local interrupt = frame.MyObject.OnMouseUpHook (frame, button)
Tercio@11 526 if (interrupt) then
Tercio@11 527 return
Tercio@11 528 end
Tercio@11 529 end
Tercio@11 530
Tercio@11 531 if (frame.MyObject.container.isMoving) then
Tercio@11 532 frame.MyObject.container:StopMovingOrSizing()
Tercio@11 533 frame.MyObject.container.isMoving = false
Tercio@11 534 end
Tercio@11 535 end
Tercio@11 536
Tercio@11 537 local OnSizeChanged = function (statusbar)
Tercio@11 538 statusbar.MyObject.div:SetPoint ("left", statusbar, "left", statusbar:GetValue() * (statusbar:GetWidth()/100) - 18, 0)
Tercio@11 539 end
Tercio@11 540
Tercio@11 541 ------------------------------------------------------------------------------------------------------------
Tercio@11 542 --> object constructor
Tercio@11 543
Tercio@11 544 function DetailsFrameworkSplitlBar_OnCreate (self)
Tercio@11 545 self.texture.original_colors = {1, 1, 1, 1}
Tercio@11 546 self.background.original_colors = {.5, .5, .5, 1}
Tercio@11 547 self.spark:SetPoint ("left", self, "left", self:GetValue() * (self:GetWidth()/100) - 18, 0)
Tercio@11 548 return true
Tercio@11 549 end
Tercio@11 550
Tercio@11 551 function DF:CreateSplitBar (parent, parent, w, h, member, name)
Tercio@11 552 return DF:NewSplitBar (parent, container, name, member, w, h)
Tercio@11 553 end
Tercio@11 554
Tercio@11 555 function DF:NewSplitBar (parent, container, name, member, w, h)
Tercio@11 556
Tercio@11 557 if (not name) then
Tercio@11 558 name = "DetailsFrameworkSplitbar" .. DF.SplitBarCounter
Tercio@11 559 DF.SplitBarCounter = DF.SplitBarCounter + 1
Tercio@11 560 end
Tercio@11 561 if (not parent) then
Tercio@11 562 return nil
Tercio@11 563 end
Tercio@11 564 if (not container) then
Tercio@11 565 container = parent
Tercio@11 566 end
Tercio@11 567
Tercio@11 568 if (name:find ("$parent")) then
Tercio@11 569 name = name:gsub ("$parent", parent:GetName())
Tercio@11 570 end
Tercio@11 571
Tercio@11 572 local SplitBarObject = {type = "barsplit", dframework = true}
Tercio@11 573
Tercio@11 574 if (member) then
Tercio@11 575 parent [member] = SplitBarObject
Tercio@11 576 end
Tercio@11 577
Tercio@11 578 if (parent.dframework) then
Tercio@11 579 parent = parent.widget
Tercio@11 580 end
Tercio@11 581 if (container.dframework) then
Tercio@11 582 container = container.widget
Tercio@11 583 end
Tercio@11 584
Tercio@11 585 --> default members:
Tercio@11 586 --> hooks
Tercio@11 587 SplitBarObject.OnEnterHook = nil
Tercio@11 588 SplitBarObject.OnLeaveHook = nil
Tercio@11 589 SplitBarObject.OnHideHook = nil
Tercio@11 590 SplitBarObject.OnShowHook = nil
Tercio@11 591 SplitBarObject.OnMouseDownHook = nil
Tercio@11 592 SplitBarObject.OnMouseUpHook = nil
Tercio@11 593 --> misc
Tercio@11 594 SplitBarObject.tooltip = nil
Tercio@11 595 SplitBarObject.locked = false
Tercio@11 596 SplitBarObject.have_tooltip = nil
Tercio@11 597 SplitBarObject.container = container
Tercio@11 598
Tercio@11 599 --> create widgets
Tercio@11 600 SplitBarObject.statusbar = CreateFrame ("statusbar", name, parent, "DetailsFrameworkSplitBarTemplate")
Tercio@11 601 SplitBarObject.widget = SplitBarObject.statusbar
Tercio@11 602
Tercio@11 603 if (not APISplitBarFunctions) then
Tercio@11 604 APISplitBarFunctions = true
Tercio@11 605 local idx = getmetatable (SplitBarObject.statusbar).__index
Tercio@11 606 for funcName, funcAddress in pairs (idx) do
Tercio@11 607 if (not SplitBarMetaFunctions [funcName]) then
Tercio@11 608 SplitBarMetaFunctions [funcName] = function (object, ...)
Tercio@20 609 local x = loadstring ( "return _G['"..object.statusbar:GetName().."']:"..funcName.."(...)")
Tercio@11 610 return x (...)
Tercio@11 611 end
Tercio@11 612 end
Tercio@11 613 end
Tercio@11 614 end
Tercio@11 615
Tercio@11 616 SplitBarObject.statusbar:SetHeight (h or 200)
Tercio@11 617 SplitBarObject.statusbar:SetWidth (w or 14)
Tercio@11 618
Tercio@11 619 SplitBarObject.statusbar.MyObject = SplitBarObject
Tercio@11 620
Tercio@11 621 SplitBarObject.textleft = _G [name .. "_TextLeft"]
Tercio@11 622 SplitBarObject.textright = _G [name .. "_TextRight"]
Tercio@11 623
Tercio@11 624 SplitBarObject.iconleft = _G [name .. "_IconLeft"]
Tercio@11 625 SplitBarObject.iconright = _G [name .. "_IconRight"]
Tercio@11 626
Tercio@11 627 SplitBarObject.background = _G [name .. "_StatusBarBackground"]
Tercio@11 628 SplitBarObject.texture = _G [name .. "_StatusBarTexture"]
Tercio@11 629
Tercio@11 630 SplitBarObject.div = _G [name .. "_Spark"]
Tercio@11 631
Tercio@11 632
Tercio@11 633 --> hooks
Tercio@11 634 SplitBarObject.statusbar:SetScript ("OnEnter", OnEnter)
Tercio@11 635 SplitBarObject.statusbar:SetScript ("OnLeave", OnLeave)
Tercio@11 636 SplitBarObject.statusbar:SetScript ("OnHide", OnHide)
Tercio@11 637 SplitBarObject.statusbar:SetScript ("OnShow", OnShow)
Tercio@11 638 SplitBarObject.statusbar:SetScript ("OnMouseDown", OnMouseDown)
Tercio@11 639 SplitBarObject.statusbar:SetScript ("OnMouseUp", OnMouseUp)
Tercio@11 640 SplitBarObject.statusbar:SetScript ("OnSizeChanged", OnSizeChanged)
Tercio@11 641
Tercio@11 642 _setmetatable (SplitBarObject, SplitBarMetaFunctions)
Tercio@11 643
Tercio@11 644 return SplitBarObject
Tercio@11 645 end