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