annotate Libs/DF/panel.lua @ 40:a960d5372b0c

- framework update from v22 to v44.
author Tercio
date Wed, 31 Aug 2016 19:55:14 -0300
parents 7944c081e5b4
children e0a8f43009ea
rev   line source
Tercio@11 1
Tercio@11 2 local DF = _G ["DetailsFramework"]
Tercio@20 3 if (not DF or not DetailsFrameworkCanLoad) then
Tercio@18 4 return
Tercio@18 5 end
Tercio@18 6
Tercio@20 7 local _
Tercio@11 8 --> lua locals
Tercio@11 9 local _rawset = rawset --> lua local
Tercio@11 10 local _rawget = rawget --> lua local
Tercio@11 11 local _setmetatable = setmetatable --> lua local
Tercio@11 12 local _unpack = unpack --> lua local
Tercio@11 13 local _type = type --> lua local
Tercio@11 14 local _math_floor = math.floor --> lua local
Tercio@11 15 local loadstring = loadstring --> lua local
Tercio@11 16
Tercio@11 17 local cleanfunction = function() end
Tercio@11 18 local APIFrameFunctions
Tercio@11 19
Tercio@39 20 do
Tercio@39 21 local metaPrototype = {
Tercio@39 22 WidgetType = "panel",
Tercio@39 23 SetHook = DF.SetHook,
Tercio@39 24 RunHooksForWidget = DF.RunHooksForWidget,
Tercio@39 25 }
Tercio@39 26
Tercio@39 27 _G [DF.GlobalWidgetControlNames ["panel"]] = _G [DF.GlobalWidgetControlNames ["panel"]] or metaPrototype
Tercio@39 28 end
Tercio@39 29
Tercio@39 30 local PanelMetaFunctions = _G [DF.GlobalWidgetControlNames ["panel"]]
Tercio@39 31
Tercio@11 32 ------------------------------------------------------------------------------------------------------------
Tercio@11 33 --> metatables
Tercio@11 34
Tercio@11 35 PanelMetaFunctions.__call = function (_table, value)
Tercio@11 36 --> nothing to do
Tercio@11 37 return true
Tercio@11 38 end
Tercio@11 39
Tercio@11 40 ------------------------------------------------------------------------------------------------------------
Tercio@11 41 --> members
Tercio@11 42
Tercio@11 43 --> tooltip
Tercio@11 44 local gmember_tooltip = function (_object)
Tercio@11 45 return _object:GetTooltip()
Tercio@11 46 end
Tercio@11 47 --> shown
Tercio@11 48 local gmember_shown = function (_object)
Tercio@11 49 return _object:IsShown()
Tercio@11 50 end
Tercio@11 51 --> backdrop color
Tercio@11 52 local gmember_color = function (_object)
Tercio@11 53 return _object.frame:GetBackdropColor()
Tercio@11 54 end
Tercio@11 55 --> backdrop table
Tercio@11 56 local gmember_backdrop = function (_object)
Tercio@11 57 return _object.frame:GetBackdrop()
Tercio@11 58 end
Tercio@11 59 --> frame width
Tercio@11 60 local gmember_width = function (_object)
Tercio@11 61 return _object.frame:GetWidth()
Tercio@11 62 end
Tercio@11 63 --> frame height
Tercio@11 64 local gmember_height = function (_object)
Tercio@11 65 return _object.frame:GetHeight()
Tercio@11 66 end
Tercio@11 67 --> locked
Tercio@11 68 local gmember_locked = function (_object)
Tercio@11 69 return _rawget (_object, "is_locked")
Tercio@11 70 end
Tercio@11 71
Tercio@39 72 PanelMetaFunctions.GetMembers = PanelMetaFunctions.GetMembers or {}
Tercio@39 73 PanelMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
Tercio@39 74 PanelMetaFunctions.GetMembers ["shown"] = gmember_shown
Tercio@39 75 PanelMetaFunctions.GetMembers ["color"] = gmember_color
Tercio@39 76 PanelMetaFunctions.GetMembers ["backdrop"] = gmember_backdrop
Tercio@39 77 PanelMetaFunctions.GetMembers ["width"] = gmember_width
Tercio@39 78 PanelMetaFunctions.GetMembers ["height"] = gmember_height
Tercio@39 79 PanelMetaFunctions.GetMembers ["locked"] = gmember_locked
Tercio@11 80
Tercio@11 81 PanelMetaFunctions.__index = function (_table, _member_requested)
Tercio@11 82
Tercio@39 83 local func = PanelMetaFunctions.GetMembers [_member_requested]
Tercio@11 84 if (func) then
Tercio@11 85 return func (_table, _member_requested)
Tercio@11 86 end
Tercio@11 87
Tercio@11 88 local fromMe = _rawget (_table, _member_requested)
Tercio@11 89 if (fromMe) then
Tercio@11 90 return fromMe
Tercio@11 91 end
Tercio@11 92
Tercio@11 93 return PanelMetaFunctions [_member_requested]
Tercio@11 94 end
Tercio@11 95
Tercio@11 96
Tercio@11 97 --> tooltip
Tercio@11 98 local smember_tooltip = function (_object, _value)
Tercio@11 99 return _object:SetTooltip (_value)
Tercio@11 100 end
Tercio@11 101 --> show
Tercio@11 102 local smember_show = function (_object, _value)
Tercio@11 103 if (_value) then
Tercio@11 104 return _object:Show()
Tercio@11 105 else
Tercio@11 106 return _object:Hide()
Tercio@11 107 end
Tercio@11 108 end
Tercio@11 109 --> hide
Tercio@11 110 local smember_hide = function (_object, _value)
Tercio@11 111 if (not _value) then
Tercio@11 112 return _object:Show()
Tercio@11 113 else
Tercio@11 114 return _object:Hide()
Tercio@11 115 end
Tercio@11 116 end
Tercio@11 117 --> backdrop color
Tercio@11 118 local smember_color = function (_object, _value)
Tercio@11 119 local _value1, _value2, _value3, _value4 = DF:ParseColors (_value)
Tercio@11 120 return _object:SetBackdropColor (_value1, _value2, _value3, _value4)
Tercio@11 121 end
Tercio@11 122 --> frame width
Tercio@11 123 local smember_width = function (_object, _value)
Tercio@11 124 return _object.frame:SetWidth (_value)
Tercio@11 125 end
Tercio@11 126 --> frame height
Tercio@11 127 local smember_height = function (_object, _value)
Tercio@11 128 return _object.frame:SetHeight (_value)
Tercio@11 129 end
Tercio@11 130
Tercio@11 131 --> locked
Tercio@11 132 local smember_locked = function (_object, _value)
Tercio@11 133 if (_value) then
Tercio@11 134 _object.frame:SetMovable (false)
Tercio@11 135 return _rawset (_object, "is_locked", true)
Tercio@11 136 else
Tercio@11 137 _object.frame:SetMovable (true)
Tercio@11 138 _rawset (_object, "is_locked", false)
Tercio@11 139 return
Tercio@11 140 end
Tercio@11 141 end
Tercio@11 142
Tercio@11 143 --> backdrop
Tercio@11 144 local smember_backdrop = function (_object, _value)
Tercio@11 145 return _object.frame:SetBackdrop (_value)
Tercio@11 146 end
Tercio@11 147
Tercio@11 148 --> close with right button
Tercio@11 149 local smember_right_close = function (_object, _value)
Tercio@11 150 return _rawset (_object, "rightButtonClose", _value)
Tercio@11 151 end
Tercio@11 152
Tercio@39 153 PanelMetaFunctions.SetMembers = PanelMetaFunctions.SetMembers or {}
Tercio@39 154 PanelMetaFunctions.SetMembers["tooltip"] = smember_tooltip
Tercio@39 155 PanelMetaFunctions.SetMembers["show"] = smember_show
Tercio@39 156 PanelMetaFunctions.SetMembers["hide"] = smember_hide
Tercio@39 157 PanelMetaFunctions.SetMembers["color"] = smember_color
Tercio@39 158 PanelMetaFunctions.SetMembers["backdrop"] = smember_backdrop
Tercio@39 159 PanelMetaFunctions.SetMembers["width"] = smember_width
Tercio@39 160 PanelMetaFunctions.SetMembers["height"] = smember_height
Tercio@39 161 PanelMetaFunctions.SetMembers["locked"] = smember_locked
Tercio@39 162 PanelMetaFunctions.SetMembers["close_with_right"] = smember_right_close
Tercio@39 163
Tercio@11 164 PanelMetaFunctions.__newindex = function (_table, _key, _value)
Tercio@39 165 local func = PanelMetaFunctions.SetMembers [_key]
Tercio@11 166 if (func) then
Tercio@11 167 return func (_table, _value)
Tercio@11 168 else
Tercio@11 169 return _rawset (_table, _key, _value)
Tercio@11 170 end
Tercio@11 171 end
Tercio@11 172
Tercio@11 173 ------------------------------------------------------------------------------------------------------------
Tercio@11 174 --> methods
Tercio@11 175
Tercio@11 176 --> right click to close
Tercio@11 177 function PanelMetaFunctions:CreateRightClickLabel (textType, w, h, close_text)
Tercio@11 178 local text
Tercio@11 179 w = w or 20
Tercio@11 180 h = h or 20
Tercio@11 181
Tercio@11 182 if (close_text) then
Tercio@11 183 text = close_text
Tercio@11 184 else
Tercio@11 185 if (textType) then
Tercio@11 186 textType = string.lower (textType)
Tercio@11 187 if (textType == "short") then
Tercio@11 188 text = "close window"
Tercio@11 189 elseif (textType == "medium") then
Tercio@11 190 text = "close window"
Tercio@11 191 elseif (textType == "large") then
Tercio@11 192 text = "close window"
Tercio@11 193 end
Tercio@11 194 else
Tercio@11 195 text = "close window"
Tercio@11 196 end
Tercio@11 197 end
Tercio@11 198
Tercio@11 199 return DF:NewLabel (self, _, "$parentRightMouseToClose", nil, "|TInterface\\TUTORIALFRAME\\UI-TUTORIAL-FRAME:"..w..":"..h..":0:1:512:512:8:70:328:409|t " .. text)
Tercio@11 200 end
Tercio@11 201
Tercio@11 202 --> show & hide
Tercio@11 203 function PanelMetaFunctions:Show()
Tercio@11 204 self.frame:Show()
Tercio@11 205
Tercio@11 206 end
Tercio@11 207 function PanelMetaFunctions:Hide()
Tercio@11 208 self.frame:Hide()
Tercio@11 209
Tercio@11 210 end
Tercio@11 211
Tercio@11 212 -- setpoint
Tercio@11 213 function PanelMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
Tercio@11 214 v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
Tercio@11 215 if (not v1) then
Tercio@11 216 print ("Invalid parameter for SetPoint")
Tercio@11 217 return
Tercio@11 218 end
Tercio@11 219 return self.widget:SetPoint (v1, v2, v3, v4, v5)
Tercio@11 220 end
Tercio@11 221
Tercio@11 222 -- sizes
Tercio@11 223 function PanelMetaFunctions:SetSize (w, h)
Tercio@11 224 if (w) then
Tercio@11 225 self.frame:SetWidth (w)
Tercio@11 226 end
Tercio@11 227 if (h) then
Tercio@11 228 self.frame:SetHeight (h)
Tercio@11 229 end
Tercio@11 230 end
Tercio@11 231
Tercio@11 232 -- clear
Tercio@11 233 function PanelMetaFunctions:HideWidgets()
Tercio@11 234 for widgetName, widgetSelf in pairs (self) do
Tercio@11 235 if (type (widgetSelf) == "table" and widgetSelf.dframework) then
Tercio@11 236 widgetSelf:Hide()
Tercio@11 237 end
Tercio@11 238 end
Tercio@11 239 end
Tercio@11 240
Tercio@11 241 -- backdrop
Tercio@11 242 function PanelMetaFunctions:SetBackdrop (background, edge, tilesize, edgesize, tile, left, right, top, bottom)
Tercio@11 243
Tercio@11 244 if (_type (background) == "boolean" and not background) then
Tercio@11 245 return self.frame:SetBackdrop (nil)
Tercio@11 246
Tercio@11 247 elseif (_type (background) == "table") then
Tercio@11 248 self.frame:SetBackdrop (background)
Tercio@11 249
Tercio@11 250 else
Tercio@11 251 local currentBackdrop = self.frame:GetBackdrop() or {edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border", bgFile="Interface\\DialogFrame\\UI-DialogBox-Background", tile=true, tileSize=16, edgeSize=16, insets={left=1, right=0, top=0, bottom=0}}
Tercio@11 252 currentBackdrop.bgFile = background or currentBackdrop.bgFile
Tercio@11 253 currentBackdrop.edgeFile = edgeFile or currentBackdrop.edgeFile
Tercio@11 254 currentBackdrop.tileSize = tilesize or currentBackdrop.tileSize
Tercio@11 255 currentBackdrop.edgeSize = edgesize or currentBackdrop.edgeSize
Tercio@11 256 currentBackdrop.tile = tile or currentBackdrop.tile
Tercio@11 257 currentBackdrop.insets.left = left or currentBackdrop.insets.left
Tercio@11 258 currentBackdrop.insets.right = left or currentBackdrop.insets.right
Tercio@11 259 currentBackdrop.insets.top = left or currentBackdrop.insets.top
Tercio@11 260 currentBackdrop.insets.bottom = left or currentBackdrop.insets.bottom
Tercio@11 261 self.frame:SetBackdrop (currentBackdrop)
Tercio@11 262 end
Tercio@11 263 end
Tercio@11 264
Tercio@11 265 -- backdropcolor
Tercio@11 266 function PanelMetaFunctions:SetBackdropColor (color, arg2, arg3, arg4)
Tercio@11 267 if (arg2) then
Tercio@11 268 self.frame:SetBackdropColor (color, arg2, arg3, arg4 or 1)
Tercio@11 269 else
Tercio@11 270 local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
Tercio@11 271 self.frame:SetBackdropColor (_value1, _value2, _value3, _value4)
Tercio@11 272 end
Tercio@11 273 end
Tercio@11 274
Tercio@11 275 -- border color
Tercio@11 276 function PanelMetaFunctions:SetBackdropBorderColor (color, arg2, arg3, arg4)
Tercio@11 277 if (arg2) then
Tercio@11 278 return self.frame:SetBackdropBorderColor (color, arg2, arg3, arg4)
Tercio@11 279 end
Tercio@11 280 local _value1, _value2, _value3, _value4 = DF:ParseColors (color)
Tercio@11 281 self.frame:SetBackdropBorderColor (_value1, _value2, _value3, _value4)
Tercio@11 282 end
Tercio@11 283
Tercio@11 284 -- tooltip
Tercio@11 285 function PanelMetaFunctions:SetTooltip (tooltip)
Tercio@11 286 if (tooltip) then
Tercio@11 287 return _rawset (self, "have_tooltip", tooltip)
Tercio@11 288 else
Tercio@11 289 return _rawset (self, "have_tooltip", nil)
Tercio@11 290 end
Tercio@11 291 end
Tercio@11 292 function PanelMetaFunctions:GetTooltip()
Tercio@11 293 return _rawget (self, "have_tooltip")
Tercio@11 294 end
Tercio@11 295
Tercio@11 296 -- frame levels
Tercio@11 297 function PanelMetaFunctions:GetFrameLevel()
Tercio@11 298 return self.widget:GetFrameLevel()
Tercio@11 299 end
Tercio@11 300 function PanelMetaFunctions:SetFrameLevel (level, frame)
Tercio@11 301 if (not frame) then
Tercio@11 302 return self.widget:SetFrameLevel (level)
Tercio@11 303 else
Tercio@11 304 local framelevel = frame:GetFrameLevel (frame) + level
Tercio@11 305 return self.widget:SetFrameLevel (framelevel)
Tercio@11 306 end
Tercio@11 307 end
Tercio@11 308
Tercio@11 309 -- frame stratas
Tercio@11 310 function PanelMetaFunctions:SetFrameStrata()
Tercio@11 311 return self.widget:GetFrameStrata()
Tercio@11 312 end
Tercio@11 313 function PanelMetaFunctions:SetFrameStrata (strata)
Tercio@11 314 if (_type (strata) == "table") then
Tercio@11 315 self.widget:SetFrameStrata (strata:GetFrameStrata())
Tercio@11 316 else
Tercio@11 317 self.widget:SetFrameStrata (strata)
Tercio@11 318 end
Tercio@11 319 end
Tercio@11 320
Tercio@11 321 ------------------------------------------------------------------------------------------------------------
Tercio@11 322 --> scripts
Tercio@11 323
Tercio@11 324 local OnEnter = function (frame)
Tercio@39 325 local capsule = frame.MyObject
Tercio@39 326 local kill = capsule:RunHooksForWidget ("OnEnter", frame, capsule)
Tercio@39 327 if (kill) then
Tercio@39 328 return
Tercio@11 329 end
Tercio@11 330
Tercio@11 331 if (frame.MyObject.have_tooltip) then
Tercio@11 332 GameCooltip2:Reset()
Tercio@11 333 GameCooltip2:SetType ("tooltip")
Tercio@11 334 GameCooltip2:SetColor ("main", "transparent")
Tercio@11 335 GameCooltip2:AddLine (frame.MyObject.have_tooltip)
Tercio@11 336 GameCooltip2:SetOwner (frame)
Tercio@11 337 GameCooltip2:ShowCooltip()
Tercio@11 338 end
Tercio@11 339 end
Tercio@11 340
Tercio@11 341 local OnLeave = function (frame)
Tercio@39 342 local capsule = frame.MyObject
Tercio@39 343 local kill = capsule:RunHooksForWidget ("OnLeave", frame, capsule)
Tercio@39 344 if (kill) then
Tercio@39 345 return
Tercio@11 346 end
Tercio@11 347
Tercio@11 348 if (frame.MyObject.have_tooltip) then
Tercio@11 349 GameCooltip2:ShowMe (false)
Tercio@11 350 end
Tercio@11 351
Tercio@11 352 end
Tercio@11 353
Tercio@11 354 local OnHide = function (frame)
Tercio@39 355 local capsule = frame.MyObject
Tercio@39 356 local kill = capsule:RunHooksForWidget ("OnHide", frame, capsule)
Tercio@39 357 if (kill) then
Tercio@39 358 return
Tercio@11 359 end
Tercio@11 360 end
Tercio@11 361
Tercio@11 362 local OnShow = function (frame)
Tercio@39 363 local capsule = frame.MyObject
Tercio@39 364 local kill = capsule:RunHooksForWidget ("OnShow", frame, capsule)
Tercio@39 365 if (kill) then
Tercio@39 366 return
Tercio@11 367 end
Tercio@11 368 end
Tercio@11 369
Tercio@11 370 local OnMouseDown = function (frame, button)
Tercio@39 371 local capsule = frame.MyObject
Tercio@39 372 local kill = capsule:RunHooksForWidget ("OnMouseDown", frame, button, capsule)
Tercio@39 373 if (kill) then
Tercio@39 374 return
Tercio@11 375 end
Tercio@11 376
Tercio@11 377 if (frame.MyObject.container == UIParent) then
Tercio@11 378 if (not frame.isLocked and frame:IsMovable()) then
Tercio@11 379 frame.isMoving = true
Tercio@11 380 frame:StartMoving()
Tercio@11 381 end
Tercio@11 382
Tercio@11 383 elseif (not frame.MyObject.container.isLocked and frame.MyObject.container:IsMovable()) then
Tercio@11 384 if (not frame.isLocked and frame:IsMovable()) then
Tercio@11 385 frame.MyObject.container.isMoving = true
Tercio@11 386 frame.MyObject.container:StartMoving()
Tercio@11 387 end
Tercio@11 388 end
Tercio@11 389
Tercio@11 390
Tercio@11 391 end
Tercio@11 392
Tercio@11 393 local OnMouseUp = function (frame, button)
Tercio@39 394 local capsule = frame.MyObject
Tercio@39 395 local kill = capsule:RunHooksForWidget ("OnMouseUp", frame, button, capsule)
Tercio@39 396 if (kill) then
Tercio@39 397 return
Tercio@11 398 end
Tercio@11 399
Tercio@11 400 if (button == "RightButton" and frame.MyObject.rightButtonClose) then
Tercio@11 401 frame.MyObject:Hide()
Tercio@11 402 end
Tercio@11 403
Tercio@11 404 if (frame.MyObject.container == UIParent) then
Tercio@11 405 if (frame.isMoving) then
Tercio@11 406 frame:StopMovingOrSizing()
Tercio@11 407 frame.isMoving = false
Tercio@11 408 end
Tercio@11 409 else
Tercio@11 410 if (frame.MyObject.container.isMoving) then
Tercio@11 411 frame.MyObject.container:StopMovingOrSizing()
Tercio@11 412 frame.MyObject.container.isMoving = false
Tercio@11 413 end
Tercio@11 414 end
Tercio@11 415 end
Tercio@11 416
Tercio@11 417 ------------------------------------------------------------------------------------------------------------
Tercio@11 418 --> object constructor
Tercio@11 419 function DF:CreatePanel (parent, w, h, backdrop, backdropcolor, bordercolor, member, name)
Tercio@11 420 return DF:NewPanel (parent, parent, name, member, w, h, backdrop, backdropcolor, bordercolor)
Tercio@11 421 end
Tercio@11 422
Tercio@11 423 function DF:NewPanel (parent, container, name, member, w, h, backdrop, backdropcolor, bordercolor)
Tercio@11 424
Tercio@11 425 if (not name) then
Tercio@11 426 name = "DetailsFrameworkPanelNumber" .. DF.PanelCounter
Tercio@11 427 DF.PanelCounter = DF.PanelCounter + 1
Tercio@11 428
Tercio@11 429 elseif (not parent) then
Tercio@11 430 parent = UIParent
Tercio@11 431 end
Tercio@11 432 if (not container) then
Tercio@11 433 container = parent
Tercio@11 434 end
Tercio@11 435
Tercio@11 436 if (name:find ("$parent")) then
Tercio@11 437 name = name:gsub ("$parent", parent:GetName())
Tercio@11 438 end
Tercio@11 439
Tercio@11 440 local PanelObject = {type = "panel", dframework = true}
Tercio@11 441
Tercio@11 442 if (member) then
Tercio@11 443 parent [member] = PanelObject
Tercio@11 444 end
Tercio@11 445
Tercio@11 446 if (parent.dframework) then
Tercio@11 447 parent = parent.widget
Tercio@11 448 end
Tercio@11 449 if (container.dframework) then
Tercio@11 450 container = container.widget
Tercio@11 451 end
Tercio@11 452
Tercio@11 453 --> default members:
Tercio@11 454 --> misc
Tercio@11 455 PanelObject.is_locked = true
Tercio@11 456 PanelObject.container = container
Tercio@11 457 PanelObject.rightButtonClose = false
Tercio@11 458
Tercio@11 459 PanelObject.frame = CreateFrame ("frame", name, parent, "DetailsFrameworkPanelTemplate")
Tercio@11 460 PanelObject.widget = PanelObject.frame
Tercio@11 461
Tercio@11 462 if (not APIFrameFunctions) then
Tercio@11 463 APIFrameFunctions = {}
Tercio@11 464 local idx = getmetatable (PanelObject.frame).__index
Tercio@11 465 for funcName, funcAddress in pairs (idx) do
Tercio@11 466 if (not PanelMetaFunctions [funcName]) then
Tercio@11 467 PanelMetaFunctions [funcName] = function (object, ...)
Tercio@20 468 local x = loadstring ( "return _G['"..object.frame:GetName().."']:"..funcName.."(...)")
Tercio@11 469 return x (...)
Tercio@11 470 end
Tercio@11 471 end
Tercio@11 472 end
Tercio@11 473 end
Tercio@11 474
Tercio@11 475 PanelObject.frame:SetWidth (w or 100)
Tercio@11 476 PanelObject.frame:SetHeight (h or 100)
Tercio@11 477
Tercio@11 478 PanelObject.frame.MyObject = PanelObject
Tercio@11 479
Tercio@39 480 PanelObject.HookList = {
Tercio@39 481 OnEnter = {},
Tercio@39 482 OnLeave = {},
Tercio@39 483 OnHide = {},
Tercio@39 484 OnShow = {},
Tercio@39 485 OnMouseDown = {},
Tercio@39 486 OnMouseUp = {},
Tercio@39 487 }
Tercio@39 488
Tercio@11 489 --> hooks
Tercio@11 490 PanelObject.frame:SetScript ("OnEnter", OnEnter)
Tercio@11 491 PanelObject.frame:SetScript ("OnLeave", OnLeave)
Tercio@11 492 PanelObject.frame:SetScript ("OnHide", OnHide)
Tercio@11 493 PanelObject.frame:SetScript ("OnShow", OnShow)
Tercio@11 494 PanelObject.frame:SetScript ("OnMouseDown", OnMouseDown)
Tercio@11 495 PanelObject.frame:SetScript ("OnMouseUp", OnMouseUp)
Tercio@11 496
Tercio@11 497 _setmetatable (PanelObject, PanelMetaFunctions)
Tercio@11 498
Tercio@11 499 if (backdrop) then
Tercio@11 500 PanelObject:SetBackdrop (backdrop)
Tercio@11 501 elseif (_type (backdrop) == "boolean") then
Tercio@11 502 PanelObject.frame:SetBackdrop (nil)
Tercio@11 503 end
Tercio@11 504
Tercio@11 505 if (backdropcolor) then
Tercio@11 506 PanelObject:SetBackdropColor (backdropcolor)
Tercio@11 507 end
Tercio@11 508
Tercio@11 509 if (bordercolor) then
Tercio@11 510 PanelObject:SetBackdropBorderColor (bordercolor)
Tercio@11 511 end
Tercio@11 512
Tercio@11 513 return PanelObject
Tercio@11 514 end
Tercio@11 515
Tercio@11 516 ------------fill panel
Tercio@11 517
Tercio@11 518 local button_on_enter = function (self)
Tercio@11 519 self.MyObject._icon:SetBlendMode ("ADD")
Tercio@11 520 end
Tercio@11 521 local button_on_leave = function (self)
Tercio@11 522 self.MyObject._icon:SetBlendMode ("BLEND")
Tercio@11 523 end
Tercio@11 524
Tercio@20 525 local add_row = function (self, t, need_update)
Tercio@20 526 local index = #self.rows+1
Tercio@20 527
Tercio@20 528 local thisrow = DF:NewPanel (self, self, "$parentHeader_" .. self._name .. index, nil, 1, 20)
Tercio@20 529 thisrow.backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Gold-Background]]}
Tercio@20 530 thisrow.color = "silver"
Tercio@20 531 thisrow.type = t.type
Tercio@20 532 thisrow.func = t.func
Tercio@20 533 thisrow.name = t.name
Tercio@20 534 thisrow.notext = t.notext
Tercio@20 535 thisrow.icon = t.icon
Tercio@20 536 thisrow.iconalign = t.iconalign
Tercio@20 537
Tercio@20 538 thisrow.hidden = t.hidden or false
Tercio@20 539
Tercio@20 540 local text = DF:NewLabel (thisrow, nil, self._name .. "$parentLabel" .. index, "text")
Tercio@20 541 text:SetPoint ("left", thisrow, "left", 2, 0)
Tercio@20 542 text:SetText (t.name)
Tercio@20 543
Tercio@20 544 tinsert (self._raw_rows, t)
Tercio@20 545 tinsert (self.rows, thisrow)
Tercio@20 546
Tercio@20 547 if (need_update) then
Tercio@20 548 self:AlignRows()
Tercio@20 549 end
Tercio@11 550 end
Tercio@11 551
Tercio@20 552 local align_rows = function (self)
Tercio@20 553
Tercio@20 554 local rows_shown = 0
Tercio@20 555 for index, row in ipairs (self.rows) do
Tercio@20 556 if (not row.hidden) then
Tercio@20 557 rows_shown = rows_shown + 1
Tercio@20 558 end
Tercio@20 559 end
Tercio@20 560
Tercio@20 561 local cur_width = 0
Tercio@20 562 local row_width = self._width / rows_shown
Tercio@22 563
Tercio@20 564 local sindex = 1
Tercio@20 565
Tercio@20 566 wipe (self._anchors)
Tercio@20 567
Tercio@20 568 for index, row in ipairs (self.rows) do
Tercio@20 569 if (not row.hidden) then
Tercio@20 570 if (self._autowidth) then
Tercio@20 571 if (self._raw_rows [index].width) then
Tercio@20 572 row.width = self._raw_rows [index].width
Tercio@20 573 else
Tercio@20 574 row.width = row_width
Tercio@20 575 end
Tercio@20 576 row:SetPoint ("topleft", self, "topleft", cur_width, 0)
Tercio@20 577 tinsert (self._anchors, cur_width)
Tercio@20 578 cur_width = cur_width + row_width + 1
Tercio@20 579 else
Tercio@20 580 row:SetPoint ("topleft", self, "topleft", cur_width, 0)
Tercio@20 581 row.width = self._raw_rows [index].width
Tercio@20 582 tinsert (self._anchors, cur_width)
Tercio@20 583 cur_width = cur_width + self._raw_rows [index].width + 1
Tercio@20 584 end
Tercio@20 585 row:Show()
Tercio@20 586
Tercio@20 587 local type = row.type
Tercio@20 588
Tercio@20 589 if (type == "text") then
Tercio@20 590 for i = 1, #self.scrollframe.lines do
Tercio@20 591 local line = self.scrollframe.lines [i]
Tercio@20 592 local text = tremove (line.text_available)
Tercio@20 593 if (not text) then
Tercio@20 594 self:CreateRowText (line)
Tercio@20 595 text = tremove (line.text_available)
Tercio@20 596 end
Tercio@20 597 tinsert (line.text_inuse, text)
Tercio@20 598 text:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
Tercio@20 599 text:SetWidth (row.width)
Tercio@20 600 end
Tercio@20 601 elseif (type == "entry") then
Tercio@20 602 for i = 1, #self.scrollframe.lines do
Tercio@20 603 local line = self.scrollframe.lines [i]
Tercio@20 604 local entry = tremove (line.entry_available)
Tercio@20 605 if (not entry) then
Tercio@20 606 self:CreateRowEntry (line)
Tercio@20 607 entry = tremove (line.entry_available)
Tercio@20 608 end
Tercio@20 609 tinsert (line.entry_inuse, entry)
Tercio@20 610 entry:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
Tercio@20 611 if (sindex == rows_shown) then
Tercio@20 612 entry:SetWidth (row.width - 25)
Tercio@20 613 else
Tercio@20 614 entry:SetWidth (row.width)
Tercio@20 615 end
Tercio@20 616 entry.func = row.func
Tercio@20 617 end
Tercio@20 618 elseif (type == "button") then
Tercio@20 619 for i = 1, #self.scrollframe.lines do
Tercio@20 620 local line = self.scrollframe.lines [i]
Tercio@20 621 local button = tremove (line.button_available)
Tercio@20 622 if (not button) then
Tercio@20 623 self:CreateRowButton (line)
Tercio@20 624 button = tremove (line.button_available)
Tercio@20 625 end
Tercio@20 626 tinsert (line.button_inuse, button)
Tercio@20 627 button:SetPoint ("left", line, "left", self._anchors [#self._anchors], 0)
Tercio@20 628 if (sindex == rows_shown) then
Tercio@20 629 button:SetWidth (row.width - 25)
Tercio@20 630 else
Tercio@20 631 button:SetWidth (row.width)
Tercio@20 632 end
Tercio@20 633
Tercio@20 634 if (row.icon) then
Tercio@20 635 button._icon.texture = row.icon
Tercio@20 636 button._icon:ClearAllPoints()
Tercio@20 637 if (row.iconalign) then
Tercio@20 638 if (row.iconalign == "center") then
Tercio@20 639 button._icon:SetPoint ("center", button, "center")
Tercio@20 640 elseif (row.iconalign == "right") then
Tercio@20 641 button._icon:SetPoint ("right", button, "right")
Tercio@20 642 end
Tercio@20 643 else
Tercio@20 644 button._icon:SetPoint ("left", button, "left")
Tercio@20 645 end
Tercio@20 646 end
Tercio@20 647
Tercio@20 648 if (row.name and not row.notext) then
Tercio@20 649 button._text:SetPoint ("left", button._icon, "right", 2, 0)
Tercio@20 650 button._text.text = row.name
Tercio@20 651 end
Tercio@20 652
Tercio@20 653 end
Tercio@20 654 elseif (type == "icon") then
Tercio@20 655 for i = 1, #self.scrollframe.lines do
Tercio@20 656 local line = self.scrollframe.lines [i]
Tercio@20 657 local icon = tremove (line.icon_available)
Tercio@20 658 if (not icon) then
Tercio@20 659 self:CreateRowIcon (line)
Tercio@20 660 icon = tremove (line.icon_available)
Tercio@20 661 end
Tercio@20 662 tinsert (line.icon_inuse, icon)
Tercio@20 663 icon:SetPoint ("left", line, "left", self._anchors [#self._anchors] + ( ((row.width or 22) - 22) / 2), 0)
Tercio@20 664 icon.func = row.func
Tercio@20 665 end
Tercio@20 666 end
Tercio@20 667
Tercio@20 668 sindex = sindex + 1
Tercio@20 669 else
Tercio@20 670 row:Hide()
Tercio@20 671 end
Tercio@20 672 end
Tercio@20 673
Tercio@20 674 if (#self.rows > 0) then
Tercio@20 675 if (self._autowidth) then
Tercio@20 676 self.rows [#self.rows]:SetWidth (row_width - rows_shown + 1)
Tercio@20 677 else
Tercio@20 678 self.rows [#self.rows]:SetWidth (self._raw_rows [rows_shown].width - rows_shown + 1)
Tercio@20 679 end
Tercio@20 680 end
Tercio@20 681
Tercio@20 682 self.showing_amt = rows_shown
Tercio@20 683 end
Tercio@20 684
Tercio@20 685 local update_rows = function (self, updated_rows)
Tercio@20 686 for i = 1, #updated_rows do
Tercio@20 687 local t = updated_rows [i]
Tercio@20 688 local raw = self._raw_rows [i]
Tercio@20 689
Tercio@20 690 if (not raw) then
Tercio@20 691 self:AddRow (t)
Tercio@20 692 else
Tercio@20 693 raw.name = t.name
Tercio@20 694 raw.hidden = t.hidden or false
Tercio@20 695
Tercio@20 696 local widget = self.rows [i]
Tercio@20 697 widget.name = t.name
Tercio@20 698 widget.hidden = t.hidden or false
Tercio@20 699
Tercio@20 700 widget.text:SetText (t.name)
Tercio@20 701 end
Tercio@20 702 end
Tercio@20 703
Tercio@20 704 for i = #updated_rows+1, #self._raw_rows do
Tercio@20 705 local raw = self._raw_rows [i]
Tercio@20 706 local widget = self.rows [i]
Tercio@20 707 raw.hidden = true
Tercio@20 708 widget.hidden = true
Tercio@20 709 end
Tercio@20 710
Tercio@20 711 for index, row in ipairs (self.scrollframe.lines) do
Tercio@20 712 for i = #row.text_inuse, 1, -1 do
Tercio@20 713 tinsert (row.text_available, tremove (row.text_inuse, i))
Tercio@20 714 end
Tercio@20 715 for i = 1, #row.text_available do
Tercio@20 716 row.text_available[i]:Hide()
Tercio@20 717 end
Tercio@20 718
Tercio@20 719 for i = #row.entry_inuse, 1, -1 do
Tercio@20 720 tinsert (row.entry_available, tremove (row.entry_inuse, i))
Tercio@20 721 end
Tercio@20 722 for i = 1, #row.entry_available do
Tercio@20 723 row.entry_available[i]:Hide()
Tercio@20 724 end
Tercio@20 725
Tercio@20 726 for i = #row.button_inuse, 1, -1 do
Tercio@20 727 tinsert (row.button_available, tremove (row.button_inuse, i))
Tercio@20 728 end
Tercio@20 729 for i = 1, #row.button_available do
Tercio@20 730 row.button_available[i]:Hide()
Tercio@20 731 end
Tercio@20 732
Tercio@20 733 for i = #row.icon_inuse, 1, -1 do
Tercio@20 734 tinsert (row.icon_available, tremove (row.icon_inuse, i))
Tercio@20 735 end
Tercio@20 736 for i = 1, #row.icon_available do
Tercio@20 737 row.icon_available[i]:Hide()
Tercio@20 738 end
Tercio@20 739 end
Tercio@20 740
Tercio@22 741 self.current_header = updated_rows
Tercio@22 742
Tercio@20 743 self:AlignRows()
Tercio@20 744
Tercio@20 745 end
Tercio@20 746
Tercio@20 747 local create_panel_text = function (self, row)
Tercio@20 748 row.text_total = row.text_total + 1
Tercio@20 749 local text = DF:NewLabel (row, nil, self._name .. "$parentLabel" .. row.text_total, "text" .. row.text_total)
Tercio@20 750 tinsert (row.text_available, text)
Tercio@20 751 end
Tercio@20 752
Tercio@20 753 local create_panel_entry = function (self, row)
Tercio@20 754 row.entry_total = row.entry_total + 1
Tercio@20 755 local editbox = DF:NewTextEntry (row, nil, "$parentEntry" .. row.entry_total, "entry", 120, 20)
Tercio@20 756 editbox.align = "left"
Tercio@20 757
Tercio@20 758 editbox:SetHook ("OnEnterPressed", function()
Tercio@20 759 editbox.widget.focuslost = true
Tercio@20 760 editbox:ClearFocus()
Tercio@20 761 editbox.func (editbox.index, editbox.text)
Tercio@20 762 return true
Tercio@20 763 end)
Tercio@20 764
Tercio@20 765 editbox:SetBackdrop ({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = "Interface\\ChatFrame\\ChatFrameBackground", edgeSize = 1})
Tercio@20 766 editbox:SetBackdropColor (1, 1, 1, 0.1)
Tercio@20 767 editbox:SetBackdropBorderColor (1, 1, 1, 0.1)
Tercio@20 768 editbox.editbox.current_bordercolor = {1, 1, 1, 0.1}
Tercio@20 769
Tercio@20 770 tinsert (row.entry_available, editbox)
Tercio@20 771 end
Tercio@20 772
Tercio@20 773 local create_panel_button = function (self, row)
Tercio@20 774 row.button_total = row.button_total + 1
Tercio@20 775 local button = DF:NewButton (row, nil, "$parentButton" .. row.button_total, "button" .. row.button_total, 120, 20)
Tercio@22 776 --, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
Tercio@22 777 --button:InstallCustomTexture()
Tercio@20 778
Tercio@20 779 --> create icon and the text
Tercio@20 780 local icon = DF:NewImage (button, nil, 20, 20)
Tercio@20 781 local text = DF:NewLabel (button)
Tercio@20 782
Tercio@20 783 button._icon = icon
Tercio@20 784 button._text = text
Tercio@20 785
Tercio@20 786 button:SetHook ("OnEnter", button_on_enter)
Tercio@20 787 button:SetHook ("OnLeave", button_on_leave)
Tercio@20 788
Tercio@20 789 tinsert (row.button_available, button)
Tercio@20 790 end
Tercio@20 791
Tercio@20 792 local icon_onclick = function (texture, iconbutton)
Tercio@20 793 iconbutton._icon.texture = texture
Tercio@20 794 iconbutton.func (iconbutton.index, texture)
Tercio@20 795 end
Tercio@20 796
Tercio@20 797 local create_panel_icon = function (self, row)
Tercio@20 798 row.icon_total = row.icon_total + 1
Tercio@20 799 local iconbutton = DF:NewButton (row, nil, "$parentIconButton" .. row.icon_total, "iconbutton", 22, 20)
Tercio@20 800 iconbutton:InstallCustomTexture()
Tercio@20 801
Tercio@20 802 iconbutton:SetHook ("OnEnter", button_on_enter)
Tercio@20 803 iconbutton:SetHook ("OnLeave", button_on_leave)
Tercio@20 804
Tercio@20 805 iconbutton:SetHook ("OnMouseUp", function()
Tercio@20 806 DF:IconPick (icon_onclick, true, iconbutton)
Tercio@20 807 return true
Tercio@20 808 end)
Tercio@20 809
Tercio@20 810 local icon = DF:NewImage (iconbutton, nil, 20, 20, "artwork", nil, "_icon", "$parentIcon" .. row.icon_total)
Tercio@20 811 iconbutton._icon = icon
Tercio@20 812
Tercio@20 813 icon:SetPoint ("center", iconbutton, "center", 0, 0)
Tercio@20 814
Tercio@20 815 tinsert (row.icon_available, iconbutton)
Tercio@20 816 end
Tercio@20 817
Tercio@20 818 local set_fill_function = function (self, func)
Tercio@20 819 self._fillfunc = func
Tercio@20 820 end
Tercio@20 821 local set_total_function = function (self, func)
Tercio@20 822 self._totalfunc = func
Tercio@20 823 end
Tercio@20 824 local drop_header_function = function (self)
Tercio@20 825 wipe (self.rows)
Tercio@20 826 end
Tercio@22 827
Tercio@22 828 local fillpanel_update_size = function (self, elapsed)
Tercio@22 829 local panel = self.MyObject
Tercio@22 830
Tercio@22 831 panel._width = panel:GetWidth()
Tercio@22 832 panel._height = panel:GetHeight()
Tercio@22 833
Tercio@22 834 panel:UpdateRowAmount()
Tercio@22 835 if (panel.current_header) then
Tercio@22 836 update_rows (panel, panel.current_header)
Tercio@22 837 end
Tercio@22 838 panel:Refresh()
Tercio@22 839
Tercio@22 840 self:SetScript ("OnUpdate", nil)
Tercio@22 841 end
Tercio@22 842
Tercio@20 843 -- ~fillpanel
Tercio@22 844 --alias
Tercio@22 845 function DF:CreateFillPanel (parent, rows, w, h, total_lines, fill_row, autowidth, options, member, name)
Tercio@22 846 return DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
Tercio@22 847 end
Tercio@22 848
Tercio@11 849 function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_row, autowidth, options)
Tercio@11 850
Tercio@11 851 local panel = DF:NewPanel (parent, parent, name, member, w, h)
Tercio@11 852 panel.backdrop = nil
Tercio@11 853
Tercio@11 854 options = options or {rowheight = 20}
Tercio@11 855 panel.rows = {}
Tercio@20 856
Tercio@20 857 panel.AddRow = add_row
Tercio@20 858 panel.AlignRows = align_rows
Tercio@20 859 panel.UpdateRows = update_rows
Tercio@20 860 panel.CreateRowText = create_panel_text
Tercio@20 861 panel.CreateRowEntry = create_panel_entry
Tercio@20 862 panel.CreateRowButton = create_panel_button
Tercio@20 863 panel.CreateRowIcon = create_panel_icon
Tercio@20 864 panel.SetFillFunction = set_fill_function
Tercio@20 865 panel.SetTotalFunction = set_total_function
Tercio@20 866 panel.DropHeader = drop_header_function
Tercio@20 867
Tercio@20 868 panel._name = name
Tercio@20 869 panel._width = w
Tercio@20 870 panel._height = h
Tercio@20 871 panel._raw_rows = {}
Tercio@20 872 panel._anchors = {}
Tercio@20 873 panel._fillfunc = fill_row
Tercio@20 874 panel._totalfunc = total_lines
Tercio@20 875 panel._autowidth = autowidth
Tercio@20 876
Tercio@22 877 panel:SetScript ("OnSizeChanged", function()
Tercio@22 878 panel:SetScript ("OnUpdate", fillpanel_update_size)
Tercio@22 879 end)
Tercio@22 880
Tercio@11 881 for index, t in ipairs (rows) do
Tercio@20 882 panel.AddRow (panel, t)
Tercio@11 883 end
Tercio@11 884
Tercio@11 885 local refresh_fillbox = function (self)
Tercio@20 886
Tercio@11 887 local offset = FauxScrollFrame_GetOffset (self)
Tercio@20 888 local filled_lines = panel._totalfunc (panel)
Tercio@20 889
Tercio@11 890 for index = 1, #self.lines do
Tercio@20 891
Tercio@11 892 local row = self.lines [index]
Tercio@11 893 if (index <= filled_lines) then
Tercio@20 894
Tercio@11 895 local real_index = index + offset
Tercio@20 896 local results = panel._fillfunc (real_index, panel)
Tercio@11 897
Tercio@11 898 if (results [1]) then
Tercio@11 899 row:Show()
Tercio@20 900
Tercio@20 901 local text, entry, button, icon = 1, 1, 1, 1
Tercio@11 902
Tercio@20 903 for index, t in ipairs (panel.rows) do
Tercio@20 904 if (not t.hidden) then
Tercio@20 905 if (t.type == "text") then
Tercio@20 906 local fontstring = row.text_inuse [text]
Tercio@20 907 text = text + 1
Tercio@20 908 fontstring:SetText (results [index])
Tercio@20 909 fontstring.index = real_index
Tercio@20 910 fontstring:Show()
Tercio@11 911
Tercio@20 912 elseif (t.type == "entry") then
Tercio@20 913 local entrywidget = row.entry_inuse [entry]
Tercio@20 914 entry = entry + 1
Tercio@20 915 entrywidget:SetText (results [index])
Tercio@20 916 entrywidget.index = real_index
Tercio@20 917 entrywidget:Show()
Tercio@20 918
Tercio@20 919 elseif (t.type == "button") then
Tercio@20 920 local buttonwidget = row.button_inuse [button]
Tercio@20 921 button = button + 1
Tercio@20 922 buttonwidget.index = real_index
Tercio@11 923
Tercio@22 924
Tercio@20 925
Tercio@20 926 if (type (results [index]) == "table") then
Tercio@20 927 if (results [index].text) then
Tercio@20 928 buttonwidget:SetText (results [index].text)
Tercio@20 929 end
Tercio@20 930
Tercio@20 931 if (results [index].icon) then
Tercio@20 932 buttonwidget._icon:SetTexture (results [index].icon)
Tercio@20 933 end
Tercio@20 934
Tercio@20 935 if (results [index].func) then
Tercio@22 936 local func = function()
Tercio@22 937 t.func (real_index, results [index].value)
Tercio@22 938 panel:Refresh()
Tercio@22 939 end
Tercio@22 940 buttonwidget:SetClickFunction (func)
Tercio@22 941 else
Tercio@22 942 local func = function()
Tercio@22 943 t.func (real_index, index)
Tercio@22 944 panel:Refresh()
Tercio@22 945 end
Tercio@22 946 buttonwidget:SetClickFunction (func)
Tercio@20 947 end
Tercio@20 948 else
Tercio@22 949 local func = function()
Tercio@22 950 t.func (real_index, index)
Tercio@22 951 panel:Refresh()
Tercio@22 952 end
Tercio@22 953 buttonwidget:SetClickFunction (func)
Tercio@20 954 buttonwidget:SetText (results [index])
Tercio@11 955 end
Tercio@11 956
Tercio@20 957 buttonwidget:Show()
Tercio@11 958
Tercio@20 959 elseif (t.type == "icon") then
Tercio@20 960 local iconwidget = row.icon_inuse [icon]
Tercio@20 961 icon = icon + 1
Tercio@20 962
Tercio@20 963 iconwidget.line = index
Tercio@20 964 iconwidget.index = real_index
Tercio@20 965
Tercio@39 966 --print (index, results [index])
Tercio@39 967 if (type (results [index]) == "string") then
Tercio@39 968 local result = results [index]:gsub (".-%\\", "")
Tercio@39 969 iconwidget._icon.texture = results [index]
Tercio@39 970 else
Tercio@39 971 iconwidget._icon:SetTexture (results [index])
Tercio@39 972 end
Tercio@20 973
Tercio@20 974 iconwidget:Show()
Tercio@11 975 end
Tercio@11 976 end
Tercio@11 977 end
Tercio@20 978
Tercio@11 979 else
Tercio@11 980 row:Hide()
Tercio@11 981 end
Tercio@11 982 else
Tercio@11 983 row:Hide()
Tercio@11 984 end
Tercio@11 985 end
Tercio@11 986 end
Tercio@11 987
Tercio@11 988 function panel:Refresh()
Tercio@22 989 if (type (panel._totalfunc) == "boolean") then
Tercio@22 990 --> not yet initialized
Tercio@22 991 return
Tercio@22 992 end
Tercio@20 993 local filled_lines = panel._totalfunc (panel)
Tercio@17 994 local scroll_total_lines = #panel.scrollframe.lines
Tercio@11 995 local line_height = options.rowheight
Tercio@20 996 refresh_fillbox (panel.scrollframe)
Tercio@11 997 FauxScrollFrame_Update (panel.scrollframe, filled_lines, scroll_total_lines, line_height)
Tercio@11 998 end
Tercio@11 999
Tercio@11 1000 local scrollframe = CreateFrame ("scrollframe", name .. "Scroll", panel.widget, "FauxScrollFrameTemplate")
Tercio@11 1001 scrollframe:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (self, offset, 20, panel.Refresh) end)
Tercio@11 1002 scrollframe:SetPoint ("topleft", panel.widget, "topleft", 0, -21)
Tercio@11 1003 scrollframe:SetPoint ("topright", panel.widget, "topright", -23, -21)
Tercio@11 1004 scrollframe:SetPoint ("bottomleft", panel.widget, "bottomleft")
Tercio@11 1005 scrollframe:SetPoint ("bottomright", panel.widget, "bottomright", -23, 0)
Tercio@11 1006 scrollframe:SetSize (w, h)
Tercio@11 1007 panel.scrollframe = scrollframe
Tercio@11 1008 scrollframe.lines = {}
Tercio@11 1009
Tercio@11 1010 --create lines
Tercio@22 1011 function panel:UpdateRowAmount()
Tercio@22 1012 local size = options.rowheight
Tercio@22 1013 local amount = math.floor (((panel._height-21) / size))
Tercio@22 1014
Tercio@22 1015 for i = #scrollframe.lines+1, amount do
Tercio@22 1016 local row = CreateFrame ("frame", panel:GetName() .. "Row_" .. i, panel.widget)
Tercio@22 1017 row:SetSize (1, size)
Tercio@22 1018 row.color = {1, 1, 1, .2}
Tercio@22 1019
Tercio@22 1020 row:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]]})
Tercio@22 1021
Tercio@22 1022 if (i%2 == 0) then
Tercio@22 1023 row:SetBackdropColor (.5, .5, .5, 0.2)
Tercio@22 1024 else
Tercio@22 1025 row:SetBackdropColor (1, 1, 1, 0.00)
Tercio@22 1026 end
Tercio@22 1027
Tercio@22 1028 row:SetPoint ("topleft", scrollframe, "topleft", 0, (i-1) * size * -1)
Tercio@22 1029 row:SetPoint ("topright", scrollframe, "topright", 0, (i-1) * size * -1)
Tercio@22 1030 tinsert (scrollframe.lines, row)
Tercio@22 1031
Tercio@22 1032 row.text_available = {}
Tercio@22 1033 row.text_inuse = {}
Tercio@22 1034 row.text_total = 0
Tercio@22 1035
Tercio@22 1036 row.entry_available = {}
Tercio@22 1037 row.entry_inuse = {}
Tercio@22 1038 row.entry_total = 0
Tercio@22 1039
Tercio@22 1040 row.button_available = {}
Tercio@22 1041 row.button_inuse = {}
Tercio@22 1042 row.button_total = 0
Tercio@22 1043
Tercio@22 1044 row.icon_available = {}
Tercio@22 1045 row.icon_inuse = {}
Tercio@22 1046 row.icon_total = 0
Tercio@20 1047 end
Tercio@11 1048 end
Tercio@22 1049 panel:UpdateRowAmount()
Tercio@22 1050
Tercio@20 1051 panel.AlignRows (panel)
Tercio@20 1052
Tercio@11 1053 return panel
Tercio@11 1054 end
Tercio@11 1055
Tercio@11 1056
Tercio@11 1057 ------------color pick
Tercio@11 1058 local color_pick_func = function()
Tercio@11 1059 local r, g, b = ColorPickerFrame:GetColorRGB()
Tercio@11 1060 local a = OpacitySliderFrame:GetValue()
Tercio@11 1061 ColorPickerFrame:dcallback (r, g, b, a, ColorPickerFrame.dframe)
Tercio@11 1062 end
Tercio@11 1063 local color_pick_func_cancel = function()
Tercio@11 1064 ColorPickerFrame:SetColorRGB (unpack (ColorPickerFrame.previousValues))
Tercio@11 1065 local r, g, b = ColorPickerFrame:GetColorRGB()
Tercio@11 1066 local a = OpacitySliderFrame:GetValue()
Tercio@11 1067 ColorPickerFrame:dcallback (r, g, b, a, ColorPickerFrame.dframe)
Tercio@11 1068 end
Tercio@11 1069
Tercio@11 1070 function DF:ColorPick (frame, r, g, b, alpha, callback)
Tercio@11 1071
Tercio@11 1072 ColorPickerFrame:ClearAllPoints()
Tercio@11 1073 ColorPickerFrame:SetPoint ("bottomleft", frame, "topright", 0, 0)
Tercio@11 1074
Tercio@11 1075 ColorPickerFrame.dcallback = callback
Tercio@11 1076 ColorPickerFrame.dframe = frame
Tercio@11 1077
Tercio@11 1078 ColorPickerFrame.func = color_pick_func
Tercio@11 1079 ColorPickerFrame.opacityFunc = color_pick_func
Tercio@11 1080 ColorPickerFrame.cancelFunc = color_pick_func_cancel
Tercio@11 1081
Tercio@11 1082 ColorPickerFrame.opacity = alpha
Tercio@11 1083 ColorPickerFrame.hasOpacity = alpha and true
Tercio@11 1084
Tercio@11 1085 ColorPickerFrame.previousValues = {r, g, b}
Tercio@11 1086 ColorPickerFrame:SetParent (UIParent)
Tercio@11 1087 ColorPickerFrame:SetFrameStrata ("tooltip")
Tercio@11 1088 ColorPickerFrame:SetColorRGB (r, g, b)
Tercio@11 1089 ColorPickerFrame:Show()
Tercio@11 1090
Tercio@11 1091 end
Tercio@11 1092
Tercio@11 1093 ------------icon pick
Tercio@20 1094 function DF:IconPick (callback, close_when_select, param1, param2)
Tercio@11 1095
Tercio@11 1096 if (not DF.IconPickFrame) then
Tercio@11 1097
Tercio@11 1098 local string_lower = string.lower
Tercio@11 1099
Tercio@11 1100 DF.IconPickFrame = CreateFrame ("frame", "DetailsFrameworkIconPickFrame", UIParent)
Tercio@11 1101 tinsert (UISpecialFrames, "DetailsFrameworkIconPickFrame")
Tercio@11 1102 DF.IconPickFrame:SetFrameStrata ("DIALOG")
Tercio@11 1103
Tercio@11 1104 DF.IconPickFrame:SetPoint ("center", UIParent, "center")
Tercio@11 1105 DF.IconPickFrame:SetWidth (350)
Tercio@11 1106 DF.IconPickFrame:SetHeight (227)
Tercio@11 1107 DF.IconPickFrame:EnableMouse (true)
Tercio@11 1108 DF.IconPickFrame:SetMovable (true)
Tercio@11 1109 DF.IconPickFrame:SetBackdrop ({bgFile = DF.folder .. "background", edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
Tercio@11 1110 tile = true, tileSize = 32, edgeSize = 32, insets = {left = 5, right = 5, top = 5, bottom = 5}})
Tercio@11 1111
Tercio@11 1112 DF.IconPickFrame:SetBackdropBorderColor (170/255, 170/255, 170/255)
Tercio@11 1113 DF.IconPickFrame:SetBackdropColor (24/255, 24/255, 24/255, .8)
Tercio@11 1114 DF.IconPickFrame:SetFrameLevel (1)
Tercio@11 1115
Tercio@11 1116 DF.IconPickFrame.emptyFunction = function() end
Tercio@11 1117 DF.IconPickFrame.callback = DF.IconPickFrame.emptyFunction
Tercio@11 1118
Tercio@11 1119 DF.IconPickFrame.preview = CreateFrame ("frame", nil, UIParent)
Tercio@11 1120 DF.IconPickFrame.preview:SetFrameStrata ("tooltip")
Tercio@11 1121 DF.IconPickFrame.preview:SetSize (76, 76)
Tercio@11 1122 local preview_image = DF:NewImage (DF.IconPickFrame.preview, nil, 76, 76)
Tercio@11 1123 preview_image:SetAllPoints (DF.IconPickFrame.preview)
Tercio@11 1124 DF.IconPickFrame.preview.icon = preview_image
Tercio@11 1125 DF.IconPickFrame.preview:Hide()
Tercio@11 1126
Tercio@11 1127 DF.IconPickFrame.searchLabel = DF:NewLabel (DF.IconPickFrame, nil, "$parentSearchBoxLabel", nil, "search:", font, size, color)
Tercio@11 1128 DF.IconPickFrame.searchLabel:SetPoint ("topleft", DF.IconPickFrame, "topleft", 12, -20)
Tercio@11 1129 DF.IconPickFrame.search = DF:NewTextEntry (DF.IconPickFrame, nil, "$parentSearchBox", nil, 140, 20)
Tercio@11 1130 DF.IconPickFrame.search:SetPoint ("left", DF.IconPickFrame.searchLabel, "right", 2, 0)
Tercio@11 1131 DF.IconPickFrame.search:SetHook ("OnTextChanged", function()
Tercio@11 1132 DF.IconPickFrame.searching = DF.IconPickFrame.search:GetText()
Tercio@11 1133 if (DF.IconPickFrame.searching == "") then
Tercio@11 1134 DF.IconPickFrameScroll:Show()
Tercio@11 1135 DF.IconPickFrame.searching = nil
Tercio@11 1136 DF.IconPickFrame.updateFunc()
Tercio@11 1137 else
Tercio@11 1138 DF.IconPickFrameScroll:Hide()
Tercio@11 1139 FauxScrollFrame_SetOffset (DF.IconPickFrame, 1)
Tercio@11 1140 DF.IconPickFrame.last_filter_index = 1
Tercio@11 1141 DF.IconPickFrame.updateFunc()
Tercio@11 1142 end
Tercio@11 1143 end)
Tercio@11 1144
Tercio@11 1145 --> close button
Tercio@11 1146 local close_button = CreateFrame ("button", nil, DF.IconPickFrame, "UIPanelCloseButton")
Tercio@11 1147 close_button:SetWidth (32)
Tercio@11 1148 close_button:SetHeight (32)
Tercio@11 1149 close_button:SetPoint ("TOPRIGHT", DF.IconPickFrame, "TOPRIGHT", -8, -7)
Tercio@11 1150 close_button:SetFrameLevel (close_button:GetFrameLevel()+2)
Tercio@11 1151
Tercio@11 1152 local MACRO_ICON_FILENAMES = {}
Tercio@11 1153 DF.IconPickFrame:SetScript ("OnShow", function()
Tercio@11 1154
Tercio@11 1155 MACRO_ICON_FILENAMES = {};
Tercio@11 1156 MACRO_ICON_FILENAMES[1] = "INV_MISC_QUESTIONMARK";
Tercio@11 1157 local index = 2;
Tercio@11 1158
Tercio@11 1159 for i = 1, GetNumSpellTabs() do
Tercio@11 1160 local tab, tabTex, offset, numSpells, _ = GetSpellTabInfo(i);
Tercio@11 1161 offset = offset + 1;
Tercio@11 1162 local tabEnd = offset + numSpells;
Tercio@11 1163 for j = offset, tabEnd - 1 do
Tercio@11 1164 --to get spell info by slot, you have to pass in a pet argument
Tercio@11 1165 local spellType, ID = GetSpellBookItemInfo(j, "player");
Tercio@11 1166 if (spellType ~= "FUTURESPELL") then
Tercio@11 1167 local spellTexture = strupper(GetSpellBookItemTexture(j, "player"));
Tercio@11 1168 if ( not string.match( spellTexture, "INTERFACE\\BUTTONS\\") ) then
Tercio@11 1169 MACRO_ICON_FILENAMES[index] = gsub( spellTexture, "INTERFACE\\ICONS\\", "");
Tercio@11 1170 index = index + 1;
Tercio@11 1171 end
Tercio@11 1172 end
Tercio@11 1173 if (spellType == "FLYOUT") then
Tercio@11 1174 local _, _, numSlots, isKnown = GetFlyoutInfo(ID);
Tercio@11 1175 if (isKnown and numSlots > 0) then
Tercio@11 1176 for k = 1, numSlots do
Tercio@11 1177 local spellID, overrideSpellID, isKnown = GetFlyoutSlotInfo(ID, k)
Tercio@11 1178 if (isKnown) then
Tercio@11 1179 MACRO_ICON_FILENAMES[index] = gsub( strupper(GetSpellTexture(spellID)), "INTERFACE\\ICONS\\", "");
Tercio@11 1180 index = index + 1;
Tercio@11 1181 end
Tercio@11 1182 end
Tercio@11 1183 end
Tercio@11 1184 end
Tercio@11 1185 end
Tercio@11 1186 end
Tercio@11 1187
Tercio@11 1188 GetLooseMacroItemIcons (MACRO_ICON_FILENAMES)
Tercio@11 1189 GetLooseMacroIcons (MACRO_ICON_FILENAMES)
Tercio@11 1190 GetMacroIcons (MACRO_ICON_FILENAMES)
Tercio@11 1191 GetMacroItemIcons (MACRO_ICON_FILENAMES )
Tercio@11 1192
Tercio@11 1193 end)
Tercio@11 1194
Tercio@11 1195 DF.IconPickFrame:SetScript ("OnHide", function()
Tercio@11 1196 MACRO_ICON_FILENAMES = nil;
Tercio@11 1197 collectgarbage()
Tercio@11 1198 end)
Tercio@11 1199
Tercio@11 1200 DF.IconPickFrame.buttons = {}
Tercio@11 1201
Tercio@11 1202 local OnClickFunction = function (self)
Tercio@20 1203 DF.IconPickFrame.callback (self.icon:GetTexture(), DF.IconPickFrame.param1, DF.IconPickFrame.param2)
Tercio@11 1204 if (DF.IconPickFrame.click_close) then
Tercio@11 1205 close_button:Click()
Tercio@11 1206 end
Tercio@11 1207 end
Tercio@11 1208
Tercio@11 1209 local onenter = function (self)
Tercio@11 1210 DF.IconPickFrame.preview:SetPoint ("bottom", self, "top", 0, 2)
Tercio@11 1211 DF.IconPickFrame.preview.icon:SetTexture (self.icon:GetTexture())
Tercio@11 1212 DF.IconPickFrame.preview:Show()
Tercio@11 1213 self.icon:SetBlendMode ("ADD")
Tercio@11 1214 end
Tercio@11 1215 local onleave = function (self)
Tercio@11 1216 DF.IconPickFrame.preview:Hide()
Tercio@11 1217 self.icon:SetBlendMode ("BLEND")
Tercio@11 1218 end
Tercio@11 1219
Tercio@11 1220 local backdrop = {bgFile = DF.folder .. "background", tile = true, tileSize = 16,
Tercio@11 1221 insets = {left = 0, right = 0, top = 0, bottom = 0}, edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]], edgeSize = 10}
Tercio@11 1222
Tercio@11 1223 for i = 0, 9 do
Tercio@11 1224 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..(i+1), DF.IconPickFrame)
Tercio@11 1225 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..(i+1).."Icon", "overlay")
Tercio@11 1226 newcheck.icon = image
Tercio@11 1227 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
Tercio@11 1228 newcheck:SetSize (30, 28)
Tercio@11 1229 newcheck:SetBackdrop (backdrop)
Tercio@11 1230
Tercio@11 1231 newcheck:SetScript ("OnClick", OnClickFunction)
Tercio@11 1232 newcheck.param1 = i+1
Tercio@11 1233
Tercio@11 1234 newcheck:SetPoint ("topleft", DF.IconPickFrame, "topleft", 12 + (i*30), -40)
Tercio@11 1235 newcheck:SetID (i+1)
Tercio@11 1236 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
Tercio@11 1237 newcheck:SetScript ("OnEnter", onenter)
Tercio@11 1238 newcheck:SetScript ("OnLeave", onleave)
Tercio@11 1239 end
Tercio@11 1240 for i = 11, 20 do
Tercio@11 1241 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
Tercio@11 1242 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
Tercio@11 1243 newcheck.icon = image
Tercio@11 1244 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
Tercio@11 1245 newcheck:SetSize (30, 28)
Tercio@11 1246 newcheck:SetBackdrop (backdrop)
Tercio@11 1247
Tercio@11 1248 newcheck:SetScript ("OnClick", OnClickFunction)
Tercio@11 1249 newcheck.param1 = i
Tercio@11 1250
Tercio@11 1251 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
Tercio@11 1252 newcheck:SetID (i)
Tercio@11 1253 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
Tercio@11 1254 newcheck:SetScript ("OnEnter", onenter)
Tercio@11 1255 newcheck:SetScript ("OnLeave", onleave)
Tercio@11 1256 end
Tercio@11 1257 for i = 21, 30 do
Tercio@11 1258 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
Tercio@11 1259 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
Tercio@11 1260 newcheck.icon = image
Tercio@11 1261 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
Tercio@11 1262 newcheck:SetSize (30, 28)
Tercio@11 1263 newcheck:SetBackdrop (backdrop)
Tercio@11 1264
Tercio@11 1265 newcheck:SetScript ("OnClick", OnClickFunction)
Tercio@11 1266 newcheck.param1 = i
Tercio@11 1267
Tercio@11 1268 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
Tercio@11 1269 newcheck:SetID (i)
Tercio@11 1270 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
Tercio@11 1271 newcheck:SetScript ("OnEnter", onenter)
Tercio@11 1272 newcheck:SetScript ("OnLeave", onleave)
Tercio@11 1273 end
Tercio@11 1274 for i = 31, 40 do
Tercio@11 1275 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
Tercio@11 1276 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
Tercio@11 1277 newcheck.icon = image
Tercio@11 1278 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
Tercio@11 1279 newcheck:SetSize (30, 28)
Tercio@11 1280 newcheck:SetBackdrop (backdrop)
Tercio@11 1281
Tercio@11 1282 newcheck:SetScript ("OnClick", OnClickFunction)
Tercio@11 1283 newcheck.param1 = i
Tercio@11 1284
Tercio@11 1285 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
Tercio@11 1286 newcheck:SetID (i)
Tercio@11 1287 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
Tercio@11 1288 newcheck:SetScript ("OnEnter", onenter)
Tercio@11 1289 newcheck:SetScript ("OnLeave", onleave)
Tercio@11 1290 end
Tercio@11 1291 for i = 41, 50 do
Tercio@11 1292 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
Tercio@11 1293 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
Tercio@11 1294 newcheck.icon = image
Tercio@11 1295 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
Tercio@11 1296 newcheck:SetSize (30, 28)
Tercio@11 1297 newcheck:SetBackdrop (backdrop)
Tercio@11 1298
Tercio@11 1299 newcheck:SetScript ("OnClick", OnClickFunction)
Tercio@11 1300 newcheck.param1 = i
Tercio@11 1301
Tercio@11 1302 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
Tercio@11 1303 newcheck:SetID (i)
Tercio@11 1304 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
Tercio@11 1305 newcheck:SetScript ("OnEnter", onenter)
Tercio@11 1306 newcheck:SetScript ("OnLeave", onleave)
Tercio@11 1307 end
Tercio@11 1308 for i = 51, 60 do
Tercio@11 1309 local newcheck = CreateFrame ("Button", "DetailsFrameworkIconPickFrameButton"..i, DF.IconPickFrame)
Tercio@11 1310 local image = newcheck:CreateTexture ("DetailsFrameworkIconPickFrameButton"..i.."Icon", "overlay")
Tercio@11 1311 newcheck.icon = image
Tercio@11 1312 image:SetPoint ("topleft", newcheck, "topleft", 2, -2); image:SetPoint ("bottomright", newcheck, "bottomright", -2, 2)
Tercio@11 1313 newcheck:SetSize (30, 28)
Tercio@11 1314 newcheck:SetBackdrop (backdrop)
Tercio@11 1315
Tercio@11 1316 newcheck:SetScript ("OnClick", OnClickFunction)
Tercio@11 1317 newcheck.param1 = i
Tercio@11 1318
Tercio@11 1319 newcheck:SetPoint ("topleft", "DetailsFrameworkIconPickFrameButton"..(i-10), "bottomleft", 0, -1)
Tercio@11 1320 newcheck:SetID (i)
Tercio@11 1321 DF.IconPickFrame.buttons [#DF.IconPickFrame.buttons+1] = newcheck
Tercio@11 1322 newcheck:SetScript ("OnEnter", onenter)
Tercio@11 1323 newcheck:SetScript ("OnLeave", onleave)
Tercio@11 1324 end
Tercio@11 1325
Tercio@11 1326 local scroll = CreateFrame ("ScrollFrame", "DetailsFrameworkIconPickFrameScroll", DF.IconPickFrame, "ListScrollFrameTemplate")
Tercio@11 1327
Tercio@11 1328 local ChecksFrame_Update = function (self)
Tercio@11 1329
Tercio@11 1330 local numMacroIcons = #MACRO_ICON_FILENAMES
Tercio@11 1331 local macroPopupIcon, macroPopupButton
Tercio@11 1332 local macroPopupOffset = FauxScrollFrame_GetOffset (scroll)
Tercio@11 1333 local index
Tercio@11 1334
Tercio@11 1335 local texture
Tercio@11 1336 local filter
Tercio@11 1337 if (DF.IconPickFrame.searching) then
Tercio@11 1338 filter = string_lower (DF.IconPickFrame.searching)
Tercio@11 1339 end
Tercio@11 1340
Tercio@11 1341 if (filter and filter ~= "") then
Tercio@11 1342
Tercio@11 1343 local ignored = 0
Tercio@11 1344 local tryed = 0
Tercio@11 1345 local found = 0
Tercio@11 1346 local type = type
Tercio@11 1347 local buttons = DF.IconPickFrame.buttons
Tercio@11 1348 index = 1
Tercio@11 1349
Tercio@11 1350 for i = 1, 60 do
Tercio@11 1351
Tercio@11 1352 macroPopupIcon = buttons[i].icon
Tercio@11 1353 macroPopupButton = buttons[i]
Tercio@11 1354
Tercio@11 1355 for o = index, numMacroIcons do
Tercio@11 1356
Tercio@11 1357 tryed = tryed + 1
Tercio@11 1358
Tercio@11 1359 texture = MACRO_ICON_FILENAMES [o]
Tercio@11 1360 if (type (texture) == "number") then
Tercio@11 1361 macroPopupIcon:SetToFileData (texture)
Tercio@11 1362 texture = macroPopupIcon:GetTexture()
Tercio@11 1363 macroPopupIcon:SetTexture (nil)
Tercio@11 1364 else
Tercio@11 1365 texture = "INTERFACE\\ICONS\\" .. texture
Tercio@11 1366 end
Tercio@11 1367
Tercio@11 1368 if (texture and texture:find (filter)) then
Tercio@11 1369 macroPopupIcon:SetTexture (texture)
Tercio@11 1370 macroPopupButton:Show()
Tercio@11 1371 found = found + 1
Tercio@11 1372 DF.IconPickFrame.last_filter_index = o
Tercio@11 1373 index = o+1
Tercio@11 1374 break
Tercio@11 1375 else
Tercio@11 1376 ignored = ignored + 1
Tercio@11 1377 end
Tercio@11 1378
Tercio@11 1379 end
Tercio@11 1380 end
Tercio@11 1381
Tercio@11 1382 for o = found+1, 60 do
Tercio@11 1383 macroPopupButton = _G ["DetailsFrameworkIconPickFrameButton"..o]
Tercio@11 1384 macroPopupButton:Hide()
Tercio@11 1385 end
Tercio@11 1386 else
Tercio@11 1387 for i = 1, 60 do
Tercio@11 1388 macroPopupIcon = _G ["DetailsFrameworkIconPickFrameButton"..i.."Icon"]
Tercio@11 1389 macroPopupButton = _G ["DetailsFrameworkIconPickFrameButton"..i]
Tercio@11 1390 index = (macroPopupOffset * 10) + i
Tercio@11 1391 texture = MACRO_ICON_FILENAMES [index]
Tercio@11 1392 if ( index <= numMacroIcons and texture ) then
Tercio@11 1393
Tercio@11 1394 if (type (texture) == "number") then
Tercio@11 1395 macroPopupIcon:SetToFileData (texture)
Tercio@11 1396 else
Tercio@11 1397 macroPopupIcon:SetTexture ("INTERFACE\\ICONS\\" .. texture)
Tercio@11 1398 end
Tercio@11 1399
Tercio@11 1400 macroPopupIcon:SetTexCoord (4/64, 60/64, 4/64, 60/64)
Tercio@11 1401 macroPopupButton.IconID = index
Tercio@11 1402 macroPopupButton:Show()
Tercio@11 1403 else
Tercio@11 1404 macroPopupButton:Hide()
Tercio@11 1405 end
Tercio@11 1406 end
Tercio@11 1407 end
Tercio@11 1408
Tercio@11 1409 -- Scrollbar stuff
Tercio@11 1410 FauxScrollFrame_Update (scroll, ceil (numMacroIcons / 10) , 5, 20 )
Tercio@11 1411 end
Tercio@11 1412
Tercio@11 1413 DF.IconPickFrame.updateFunc = ChecksFrame_Update
Tercio@11 1414
Tercio@11 1415 scroll:SetPoint ("topleft", DF.IconPickFrame, "topleft", -18, -37)
Tercio@11 1416 scroll:SetWidth (330)
Tercio@11 1417 scroll:SetHeight (178)
Tercio@11 1418 scroll:SetScript ("OnVerticalScroll", function (self, offset) FauxScrollFrame_OnVerticalScroll (scroll, offset, 20, ChecksFrame_Update) end)
Tercio@11 1419 scroll.update = ChecksFrame_Update
Tercio@11 1420 DF.IconPickFrameScroll = scroll
Tercio@11 1421 DF.IconPickFrame:Hide()
Tercio@11 1422
Tercio@11 1423 end
Tercio@11 1424
Tercio@20 1425 DF.IconPickFrame.param1, DF.IconPickFrame.param2 = param1, param2
Tercio@20 1426
Tercio@11 1427 DF.IconPickFrame:Show()
Tercio@11 1428 DF.IconPickFrameScroll.update (DF.IconPickFrameScroll)
Tercio@11 1429 DF.IconPickFrame.callback = callback or DF.IconPickFrame.emptyFunction
Tercio@11 1430 DF.IconPickFrame.click_close = close_when_select
Tercio@11 1431
Tercio@11 1432 end
Tercio@11 1433
Tercioo@29 1434 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercioo@29 1435
Tercioo@29 1436 function DF:ShowPanicWarning (text)
Tercioo@29 1437 if (not DF.PanicWarningWindow) then
Tercioo@29 1438 DF.PanicWarningWindow = CreateFrame ("frame", "DetailsFrameworkPanicWarningWindow", UIParent)
Tercioo@29 1439 DF.PanicWarningWindow:SetHeight (80)
Tercioo@29 1440 DF.PanicWarningWindow:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
Tercioo@29 1441 DF.PanicWarningWindow:SetBackdropColor (1, 0, 0, 0.2)
Tercioo@29 1442 DF.PanicWarningWindow:SetPoint ("topleft", UIParent, "topleft", 0, -250)
Tercioo@29 1443 DF.PanicWarningWindow:SetPoint ("topright", UIParent, "topright", 0, -250)
Tercioo@29 1444
Tercioo@29 1445 DF.PanicWarningWindow.text = DF.PanicWarningWindow:CreateFontString (nil, "overlay", "GameFontNormal")
Tercioo@29 1446 DF.PanicWarningWindow.text:SetPoint ("center", DF.PanicWarningWindow, "center")
Tercioo@29 1447 DF.PanicWarningWindow.text:SetTextColor (1, 0.6, 0)
Tercioo@29 1448 end
Tercioo@29 1449
Tercioo@29 1450 DF.PanicWarningWindow.text:SetText (text)
Tercioo@29 1451 DF.PanicWarningWindow:Show()
Tercioo@29 1452 end
Tercioo@29 1453
Tercioo@29 1454 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercioo@29 1455
Tercioo@29 1456
Tercio@11 1457 local simple_panel_mouse_down = function (self, button)
Tercio@11 1458 if (button == "RightButton") then
Tercio@11 1459 if (self.IsMoving) then
Tercio@11 1460 self.IsMoving = false
Tercio@11 1461 self:StopMovingOrSizing()
Tercio@11 1462 if (self.db and self.db.position) then
Tercio@11 1463 DF:SavePositionOnScreen (self)
Tercio@11 1464 end
Tercio@11 1465 end
Tercio@17 1466 if (not self.DontRightClickClose) then
Tercio@17 1467 self:Hide()
Tercio@17 1468 end
Tercio@11 1469 return
Tercio@11 1470 end
Tercio@11 1471 if (not self.IsMoving and not self.IsLocked) then
Tercio@11 1472 self.IsMoving = true
Tercio@11 1473 self:StartMoving()
Tercio@11 1474 end
Tercio@11 1475 end
Tercio@11 1476 local simple_panel_mouse_up = function (self, button)
Tercio@11 1477 if (self.IsMoving) then
Tercio@11 1478 self.IsMoving = false
Tercio@11 1479 self:StopMovingOrSizing()
Tercio@11 1480 if (self.db and self.db.position) then
Tercio@11 1481 DF:SavePositionOnScreen (self)
Tercio@11 1482 end
Tercio@11 1483 end
Tercio@11 1484 end
Tercio@11 1485 local simple_panel_settitle = function (self, title)
Tercio@22 1486 self.Title:SetText (title)
Tercio@11 1487 end
Tercio@11 1488
Tercio@22 1489 local simple_panel_close_click = function (self)
Tercio@22 1490 self:GetParent():GetParent():Hide()
Tercio@22 1491 end
Tercio@22 1492
Tercio@22 1493 local SimplePanel_frame_backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}
Tercio@22 1494 local SimplePanel_frame_backdrop_color = {0, 0, 0, 0.9}
Tercio@22 1495 local SimplePanel_frame_backdrop_border_color = {0, 0, 0, 1}
Tercio@22 1496
Tercio@39 1497 function DF:CreateScaleBar (frame, config)
Tercio@39 1498 local scaleBar = DF:CreateSlider (frame, 120, 14, 0.6, 1.6, 0.1, config.scale, true, "ScaleBar", nil, "Scale:", DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE"), DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
Tercio@40 1499 scaleBar:SetPoint ("right", frame.Close, "left", -26, 0)
Tercio@39 1500 scaleBar:SetFrameLevel (DF.FRAMELEVEL_OVERLAY)
Tercio@39 1501 scaleBar.OnValueChanged = function (_, _, value)
Tercio@39 1502 config.scale = value
Tercio@39 1503 if (not scaleBar.IsValueChanging) then
Tercio@39 1504 frame:SetScale (config.scale)
Tercio@39 1505 end
Tercio@39 1506 end
Tercio@39 1507 scaleBar:SetHook ("OnMouseUp", function()
Tercio@39 1508 frame:SetScale (config.scale)
Tercio@39 1509 end)
Tercio@39 1510 end
Tercio@39 1511
Tercio@26 1512 local no_options = {}
Tercio@39 1513 function DF:CreateSimplePanel (parent, w, h, title, name, panel_options, db)
Tercio@39 1514
Tercio@39 1515 if (db and name and not db [name]) then
Tercio@39 1516 db [name] = {scale = 1}
Tercio@39 1517 end
Tercio@11 1518
Tercio@11 1519 if (not name) then
Tercioo@29 1520 name = "DetailsFrameworkSimplePanel" .. DF.SimplePanelCounter
Tercioo@29 1521 DF.SimplePanelCounter = DF.SimplePanelCounter + 1
Tercio@11 1522 end
Tercio@11 1523 if (not parent) then
Tercio@11 1524 parent = UIParent
Tercio@11 1525 end
Tercio@26 1526
Tercio@26 1527 panel_options = panel_options or no_options
Tercio@11 1528
Tercio@11 1529 local f = CreateFrame ("frame", name, UIParent)
Tercio@11 1530 f:SetSize (w or 400, h or 250)
Tercio@11 1531 f:SetPoint ("center", UIParent, "center", 0, 0)
Tercio@11 1532 f:SetFrameStrata ("FULLSCREEN")
Tercio@11 1533 f:EnableMouse()
Tercio@11 1534 f:SetMovable (true)
Tercio@22 1535 f:SetBackdrop (SimplePanel_frame_backdrop)
Tercio@22 1536 f:SetBackdropColor (unpack (SimplePanel_frame_backdrop_color))
Tercio@22 1537 f:SetBackdropBorderColor (unpack (SimplePanel_frame_backdrop_border_color))
Tercio@26 1538
Tercio@26 1539 f.DontRightClickClose = panel_options.DontRightClickClose
Tercio@26 1540
Tercio@26 1541 if (not panel_options.NoTUISpecialFrame) then
Tercio@26 1542 tinsert (UISpecialFrames, name)
Tercio@26 1543 end
Tercio@22 1544
Tercio@22 1545 local title_bar = CreateFrame ("frame", name .. "TitleBar", f)
Tercio@22 1546 title_bar:SetPoint ("topleft", f, "topleft", 2, -3)
Tercio@22 1547 title_bar:SetPoint ("topright", f, "topright", -2, -3)
Tercio@22 1548 title_bar:SetHeight (20)
Tercio@22 1549 title_bar:SetBackdrop (SimplePanel_frame_backdrop)
Tercio@22 1550 title_bar:SetBackdropColor (.2, .2, .2, 1)
Tercio@22 1551 title_bar:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@26 1552 f.TitleBar = title_bar
Tercio@22 1553
Tercio@22 1554 local close = CreateFrame ("button", name and name .. "CloseButton", title_bar)
Tercio@39 1555 close:SetFrameLevel (DF.FRAMELEVEL_OVERLAY)
Tercio@22 1556 close:SetSize (16, 16)
Tercio@22 1557 close:SetNormalTexture (DF.folder .. "icons")
Tercio@22 1558 close:SetHighlightTexture (DF.folder .. "icons")
Tercio@22 1559 close:SetPushedTexture (DF.folder .. "icons")
Tercio@22 1560 close:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
Tercio@22 1561 close:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
Tercio@22 1562 close:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
Tercio@22 1563 close:SetAlpha (0.7)
Tercio@22 1564 close:SetScript ("OnClick", simple_panel_close_click)
Tercio@22 1565 f.Close = close
Tercio@22 1566
Tercio@22 1567 local title_string = title_bar:CreateFontString (name and name .. "Title", "overlay", "GameFontNormal")
Tercio@22 1568 title_string:SetTextColor (.8, .8, .8, 1)
Tercio@22 1569 title_string:SetText (title or "")
Tercio@22 1570 f.Title = title_string
Tercio@22 1571
Tercio@39 1572 if (panel_options.UseScaleBar and db [name]) then
Tercio@39 1573 DF:CreateScaleBar (f, db [name])
Tercio@39 1574 f:SetScale (db [name].scale)
Tercio@39 1575 end
Tercio@39 1576
Tercio@22 1577 f.Title:SetPoint ("center", title_bar, "center")
Tercio@22 1578 f.Close:SetPoint ("right", title_bar, "right", -2, 0)
Tercio@22 1579
Tercio@11 1580 f:SetScript ("OnMouseDown", simple_panel_mouse_down)
Tercio@11 1581 f:SetScript ("OnMouseUp", simple_panel_mouse_up)
Tercio@11 1582
Tercio@11 1583 f.SetTitle = simple_panel_settitle
Tercio@11 1584
Tercio@11 1585 return f
Tercio@11 1586 end
Tercio@11 1587
Tercio@11 1588 local Panel1PxBackdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 64,
Tercio@11 1589 edgeFile = DF.folder .. "border_3", edgeSize = 9, insets = {left = 2, right = 2, top = 3, bottom = 3}}
Tercio@11 1590
Tercio@11 1591 local Panel1PxOnClickClose = function (self)
Tercio@11 1592 self:GetParent():Hide()
Tercio@11 1593 end
Tercio@11 1594 local Panel1PxOnToggleLock = function (self)
Tercio@11 1595 if (self.IsLocked) then
Tercio@11 1596 self.IsLocked = false
Tercio@11 1597 self:SetMovable (true)
Tercio@11 1598 self:EnableMouse (true)
Tercio@11 1599 self.Lock:GetNormalTexture():SetTexCoord (32/128, 48/128, 0, 1)
Tercio@11 1600 self.Lock:GetHighlightTexture():SetTexCoord (32/128, 48/128, 0, 1)
Tercio@11 1601 self.Lock:GetPushedTexture():SetTexCoord (32/128, 48/128, 0, 1)
Tercio@17 1602 if (self.OnUnlock) then
Tercio@17 1603 self:OnUnlock()
Tercio@17 1604 end
Tercio@17 1605 if (self.db) then
Tercio@17 1606 self.db.IsLocked = self.IsLocked
Tercio@17 1607 end
Tercio@11 1608 else
Tercio@11 1609 self.IsLocked = true
Tercio@11 1610 self:SetMovable (false)
Tercio@11 1611 self:EnableMouse (false)
Tercio@11 1612 self.Lock:GetNormalTexture():SetTexCoord (16/128, 32/128, 0, 1)
Tercio@11 1613 self.Lock:GetHighlightTexture():SetTexCoord (16/128, 32/128, 0, 1)
Tercio@11 1614 self.Lock:GetPushedTexture():SetTexCoord (16/128, 32/128, 0, 1)
Tercio@17 1615 if (self.OnLock) then
Tercio@17 1616 self:OnLock()
Tercio@17 1617 end
Tercio@17 1618 if (self.db) then
Tercio@17 1619 self.db.IsLocked = self.IsLocked
Tercio@17 1620 end
Tercio@11 1621 end
Tercio@11 1622 end
Tercio@11 1623 local Panel1PxOnClickLock = function (self)
Tercio@11 1624 local f = self:GetParent()
Tercio@11 1625 Panel1PxOnToggleLock (f)
Tercio@11 1626 end
Tercio@11 1627 local Panel1PxSetTitle = function (self, text)
Tercio@11 1628 self.Title:SetText (text or "")
Tercio@11 1629 end
Tercio@11 1630
Tercio@20 1631 local Panel1PxSetLocked= function (self, lock_state)
Tercio@20 1632 if (type (lock_state) ~= "boolean") then
Tercio@20 1633 return
Tercio@20 1634 end
Tercio@20 1635 if (lock_state) then
Tercio@20 1636 -- lock it
Tercio@20 1637 self.IsLocked = false
Tercio@20 1638 Panel1PxOnClickLock (self.Lock)
Tercio@20 1639 else
Tercio@20 1640 -- unlockit
Tercio@20 1641 self.IsLocked = true
Tercio@20 1642 Panel1PxOnClickLock (self.Lock)
Tercio@20 1643 end
Tercio@20 1644 end
Tercio@20 1645
Tercio@11 1646 local Panel1PxReadConfig = function (self)
Tercio@11 1647 local db = self.db
Tercio@11 1648 if (db) then
Tercio@11 1649 db.IsLocked = db.IsLocked or false
Tercio@11 1650 self.IsLocked = db.IsLocked
Tercio@11 1651 db.position = db.position or {x = 0, y = 0}
Tercio@19 1652 db.position.x = db.position.x or 0
Tercio@19 1653 db.position.y = db.position.y or 0
Tercio@11 1654 DF:RestoreFramePosition (self)
Tercio@11 1655 end
Tercio@11 1656 end
Tercio@11 1657
Tercio@11 1658 function DF:SavePositionOnScreen (frame)
Tercio@11 1659 if (frame.db and frame.db.position) then
Tercio@11 1660 local x, y = DF:GetPositionOnScreen (frame)
Tercio@18 1661 --print ("saving...", x, y, frame:GetName())
Tercio@19 1662 if (x and y) then
Tercio@19 1663 frame.db.position.x, frame.db.position.y = x, y
Tercio@19 1664 end
Tercio@11 1665 end
Tercio@11 1666 end
Tercio@11 1667
Tercio@11 1668 function DF:GetPositionOnScreen (frame)
Tercio@11 1669 local xOfs, yOfs = frame:GetCenter()
Tercio@11 1670 if (not xOfs) then
Tercio@11 1671 return
Tercio@11 1672 end
Tercio@11 1673 local scale = frame:GetEffectiveScale()
Tercio@11 1674 local UIscale = UIParent:GetScale()
Tercio@11 1675 xOfs = xOfs*scale - GetScreenWidth()*UIscale/2
Tercio@11 1676 yOfs = yOfs*scale - GetScreenHeight()*UIscale/2
Tercio@11 1677 return xOfs/UIscale, yOfs/UIscale
Tercio@11 1678 end
Tercio@11 1679
Tercio@11 1680 function DF:RestoreFramePosition (frame)
Tercio@11 1681 if (frame.db and frame.db.position) then
Tercio@11 1682 local scale, UIscale = frame:GetEffectiveScale(), UIParent:GetScale()
Tercio@11 1683 frame:ClearAllPoints()
Tercio@19 1684 frame.db.position.x = frame.db.position.x or 0
Tercio@19 1685 frame.db.position.y = frame.db.position.y or 0
Tercio@11 1686 frame:SetPoint ("center", UIParent, "center", frame.db.position.x * UIscale / scale, frame.db.position.y * UIscale / scale)
Tercio@11 1687 end
Tercio@11 1688 end
Tercio@11 1689
Tercio@20 1690 local Panel1PxSavePosition= function (self)
Tercio@20 1691 DF:SavePositionOnScreen (self)
Tercio@20 1692 end
Tercio@20 1693
Tercio@18 1694 local Panel1PxHasPosition = function (self)
Tercio@18 1695 local db = self.db
Tercio@18 1696 if (db) then
Tercio@18 1697 if (db.position and db.position.x and (db.position.x ~= 0 or db.position.y ~= 0)) then
Tercio@18 1698 return true
Tercio@18 1699 end
Tercio@18 1700 end
Tercio@18 1701 end
Tercio@18 1702
Tercio@13 1703 function DF:Create1PxPanel (parent, w, h, title, name, config, title_anchor, no_special_frame)
Tercio@11 1704 local f = CreateFrame ("frame", name, parent or UIParent)
Tercio@11 1705 f:SetSize (w or 100, h or 75)
Tercio@11 1706 f:SetPoint ("center", UIParent, "center")
Tercio@11 1707
Tercio@13 1708 if (name and not no_special_frame) then
Tercio@11 1709 tinsert (UISpecialFrames, name)
Tercio@11 1710 end
Tercio@11 1711
Tercio@11 1712 f:SetScript ("OnMouseDown", simple_panel_mouse_down)
Tercio@11 1713 f:SetScript ("OnMouseUp", simple_panel_mouse_up)
Tercio@11 1714
Tercio@11 1715 f:SetBackdrop (Panel1PxBackdrop)
Tercio@11 1716 f:SetBackdropColor (0, 0, 0, 0.5)
Tercio@11 1717
Tercio@17 1718 f.IsLocked = (config and config.IsLocked ~= nil and config.IsLocked) or false
Tercio@11 1719 f:SetMovable (true)
Tercio@11 1720 f:EnableMouse (true)
Tercio@11 1721 f:SetUserPlaced (true)
Tercio@11 1722
Tercio@11 1723 f.db = config
Tercio@18 1724 --print (config.position.x, config.position.x)
Tercio@11 1725 Panel1PxReadConfig (f)
Tercio@11 1726
Tercio@11 1727 local close = CreateFrame ("button", name and name .. "CloseButton", f)
Tercio@11 1728 close:SetSize (16, 16)
Tercio@11 1729 close:SetNormalTexture (DF.folder .. "icons")
Tercio@11 1730 close:SetHighlightTexture (DF.folder .. "icons")
Tercio@11 1731 close:SetPushedTexture (DF.folder .. "icons")
Tercio@11 1732 close:GetNormalTexture():SetTexCoord (0, 16/128, 0, 1)
Tercio@11 1733 close:GetHighlightTexture():SetTexCoord (0, 16/128, 0, 1)
Tercio@11 1734 close:GetPushedTexture():SetTexCoord (0, 16/128, 0, 1)
Tercio@11 1735 close:SetAlpha (0.7)
Tercio@11 1736
Tercio@11 1737 local lock = CreateFrame ("button", name and name .. "LockButton", f)
Tercio@11 1738 lock:SetSize (16, 16)
Tercio@11 1739 lock:SetNormalTexture (DF.folder .. "icons")
Tercio@11 1740 lock:SetHighlightTexture (DF.folder .. "icons")
Tercio@11 1741 lock:SetPushedTexture (DF.folder .. "icons")
Tercio@11 1742 lock:GetNormalTexture():SetTexCoord (32/128, 48/128, 0, 1)
Tercio@11 1743 lock:GetHighlightTexture():SetTexCoord (32/128, 48/128, 0, 1)
Tercio@11 1744 lock:GetPushedTexture():SetTexCoord (32/128, 48/128, 0, 1)
Tercio@11 1745 lock:SetAlpha (0.7)
Tercio@11 1746
Tercio@11 1747 close:SetPoint ("topright", f, "topright", -3, -3)
Tercio@11 1748 lock:SetPoint ("right", close, "left", 3, 0)
Tercio@11 1749
Tercio@11 1750 close:SetScript ("OnClick", Panel1PxOnClickClose)
Tercio@11 1751 lock:SetScript ("OnClick", Panel1PxOnClickLock)
Tercio@11 1752
Tercio@11 1753 local title_string = f:CreateFontString (name and name .. "Title", "overlay", "GameFontNormal")
Tercio@11 1754 title_string:SetPoint ("topleft", f, "topleft", 5, -5)
Tercio@11 1755 title_string:SetText (title or "")
Tercio@11 1756
Tercio@11 1757 if (title_anchor) then
Tercio@11 1758 if (title_anchor == "top") then
Tercio@11 1759 title_string:ClearAllPoints()
Tercio@11 1760 title_string:SetPoint ("bottomleft", f, "topleft", 0, 0)
Tercio@11 1761 close:ClearAllPoints()
Tercio@11 1762 close:SetPoint ("bottomright", f, "topright", 0, 0)
Tercio@11 1763 end
Tercio@11 1764 f.title_anchor = title_anchor
Tercio@11 1765 end
Tercio@11 1766
Tercio@11 1767 f.SetTitle = Panel1PxSetTitle
Tercio@11 1768 f.Title = title_string
Tercio@11 1769 f.Lock = lock
Tercio@11 1770 f.Close = close
Tercio@18 1771 f.HasPosition = Panel1PxHasPosition
Tercio@20 1772 f.SavePosition = Panel1PxSavePosition
Tercio@11 1773
Tercio@17 1774 f.IsLocked = not f.IsLocked
Tercio@20 1775 f.SetLocked = Panel1PxSetLocked
Tercio@17 1776 Panel1PxOnToggleLock (f)
Tercio@17 1777
Tercio@11 1778 return f
Tercio@11 1779 end
Tercio@11 1780
Tercio@11 1781 ------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@20 1782 -- ~prompt
Tercio@20 1783 function DF:ShowPromptPanel (message, func_true, func_false)
Tercio@20 1784
Tercio@20 1785 if (not DF.prompt_panel) then
Tercio@20 1786 local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent)
Tercio@22 1787 f:SetSize (400, 65)
Tercio@20 1788 f:SetFrameStrata ("DIALOG")
Tercio@22 1789 f:SetPoint ("center", UIParent, "center", 0, 300)
Tercio@20 1790 f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
Tercio@20 1791 f:SetBackdropColor (0, 0, 0, 0.8)
Tercio@20 1792 f:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@20 1793
Tercio@22 1794 local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@22 1795 prompt:SetPoint ("top", f, "top", 0, -15)
Tercio@22 1796 prompt:SetJustifyH ("center")
Tercio@22 1797 f.prompt = prompt
Tercio@22 1798
Tercio@22 1799 local button_true = DF:CreateButton (f, nil, 60, 20, "Yes")
Tercio@20 1800 button_true:SetPoint ("bottomleft", f, "bottomleft", 5, 5)
Tercio@20 1801 f.button_true = button_true
Tercio@20 1802
Tercio@22 1803 local button_false = DF:CreateButton (f, nil, 60, 20, "No")
Tercio@20 1804 button_false:SetPoint ("bottomright", f, "bottomright", -5, 5)
Tercio@20 1805 f.button_false = button_false
Tercio@20 1806
Tercio@20 1807 button_true:SetClickFunction (function()
Tercio@20 1808 local my_func = button_true.true_function
Tercio@20 1809 if (my_func) then
Tercio@20 1810 local okey, errormessage = pcall (my_func, true)
Tercio@20 1811 if (not okey) then
Tercio@20 1812 print ("error:", errormessage)
Tercio@20 1813 end
Tercio@22 1814 f:Hide()
Tercio@20 1815 end
Tercio@20 1816 end)
Tercio@20 1817
Tercio@20 1818 button_false:SetClickFunction (function()
Tercio@20 1819 local my_func = button_false.false_function
Tercio@20 1820 if (my_func) then
Tercio@20 1821 local okey, errormessage = pcall (my_func, true)
Tercio@20 1822 if (not okey) then
Tercio@20 1823 print ("error:", errormessage)
Tercio@20 1824 end
Tercio@22 1825 f:Hide()
Tercio@20 1826 end
Tercio@20 1827 end)
Tercio@20 1828
Tercio@20 1829 f:Hide()
Tercio@20 1830 DF.promtp_panel = f
Tercio@20 1831 end
Tercio@20 1832
Tercio@20 1833 assert (type (func_true) == "function" and type (func_false) == "function", "ShowPromptPanel expects two functions.")
Tercio@20 1834
Tercio@22 1835 DF.promtp_panel.prompt:SetText (message)
Tercio@20 1836 DF.promtp_panel.button_true.true_function = func_true
Tercio@20 1837 DF.promtp_panel.button_false.false_function = func_false
Tercio@20 1838
Tercio@20 1839 DF.promtp_panel:Show()
Tercio@20 1840 end
Tercio@22 1841
Tercio@22 1842
Tercio@22 1843 function DF:ShowTextPromptPanel (message, callback)
Tercio@22 1844
Tercio@22 1845 if (not DF.text_prompt_panel) then
Tercio@22 1846
Tercio@22 1847 local f = CreateFrame ("frame", "DetailsFrameworkPrompt", UIParent)
Tercio@22 1848 f:SetSize (400, 100)
Tercio@22 1849 f:SetFrameStrata ("DIALOG")
Tercio@22 1850 f:SetPoint ("center", UIParent, "center", 0, 300)
Tercio@22 1851 f:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
Tercio@22 1852 f:SetBackdropColor (0, 0, 0, 0.8)
Tercio@22 1853 f:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@22 1854
Tercio@22 1855 local prompt = f:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@22 1856 prompt:SetPoint ("top", f, "top", 0, -15)
Tercio@22 1857 prompt:SetJustifyH ("center")
Tercio@22 1858 f.prompt = prompt
Tercioo@29 1859
Tercioo@29 1860 local button_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
Tercioo@29 1861 local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
Tercioo@29 1862
Tercioo@29 1863 local button_true = DF:CreateButton (f, nil, 60, 20, "Okey", nil, nil, nil, nil, nil, nil, options_dropdown_template, button_text_template)
Tercio@22 1864 button_true:SetPoint ("bottomleft", f, "bottomleft", 10, 5)
Tercio@22 1865 f.button_true = button_true
Tercio@22 1866
Tercioo@29 1867 local button_false = DF:CreateButton (f, function() f.textbox:ClearFocus(); f:Hide() end, 60, 20, "Cancel", nil, nil, nil, nil, nil, nil, options_dropdown_template, button_text_template)
Tercio@22 1868 button_false:SetPoint ("bottomright", f, "bottomright", -10, 5)
Tercio@22 1869 f.button_false = button_false
Tercio@22 1870
Tercioo@29 1871 local textbox = DF:CreateTextEntry (f, function()end, 380, 20, "textbox", nil, nil, options_dropdown_template)
Tercio@22 1872 textbox:SetPoint ("topleft", f, "topleft", 10, -45)
Tercioo@29 1873 f.EntryBox = textbox
Tercio@22 1874
Tercio@22 1875 button_true:SetClickFunction (function()
Tercio@22 1876 local my_func = button_true.true_function
Tercio@22 1877 if (my_func) then
Tercio@22 1878 local okey, errormessage = pcall (my_func, textbox:GetText())
Tercio@22 1879 textbox:ClearFocus()
Tercio@22 1880 if (not okey) then
Tercio@22 1881 print ("error:", errormessage)
Tercio@22 1882 end
Tercio@22 1883 f:Hide()
Tercio@22 1884 end
Tercio@22 1885 end)
Tercio@22 1886
Tercio@22 1887 f:Hide()
Tercio@22 1888 DF.text_prompt_panel = f
Tercio@22 1889 end
Tercio@22 1890
Tercio@22 1891 DF.text_prompt_panel:Show()
Tercio@22 1892
Tercioo@29 1893 DetailsFrameworkPrompt.EntryBox:SetText ("")
Tercio@22 1894 DF.text_prompt_panel.prompt:SetText (message)
Tercio@22 1895 DF.text_prompt_panel.button_true.true_function = callback
Tercioo@29 1896
Tercio@22 1897 DF.text_prompt_panel.textbox:SetFocus (true)
Tercio@22 1898
Tercio@22 1899 end
Tercio@22 1900
Tercio@20 1901 ------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 1902 --> options button -- ~options
Tercio@11 1903 function DF:CreateOptionsButton (parent, callback, name)
Tercio@11 1904
Tercio@11 1905 local b = CreateFrame ("button", name, parent)
Tercio@11 1906 b:SetSize (14, 14)
Tercio@11 1907 b:SetNormalTexture (DF.folder .. "icons")
Tercio@11 1908 b:SetHighlightTexture (DF.folder .. "icons")
Tercio@11 1909 b:SetPushedTexture (DF.folder .. "icons")
Tercio@11 1910 b:GetNormalTexture():SetTexCoord (48/128, 64/128, 0, 1)
Tercio@11 1911 b:GetHighlightTexture():SetTexCoord (48/128, 64/128, 0, 1)
Tercio@11 1912 b:GetPushedTexture():SetTexCoord (48/128, 64/128, 0, 1)
Tercio@11 1913 b:SetAlpha (0.7)
Tercio@11 1914
Tercio@11 1915 b:SetScript ("OnClick", callback)
Tercio@11 1916 b:SetScript ("OnEnter", function (self)
Tercio@11 1917 GameCooltip2:Reset()
Tercio@11 1918 GameCooltip2:AddLine ("Options")
Tercio@11 1919 GameCooltip2:ShowCooltip (self, "tooltip")
Tercio@11 1920 end)
Tercio@11 1921 b:SetScript ("OnLeave", function (self)
Tercio@11 1922 GameCooltip2:Hide()
Tercio@11 1923 end)
Tercio@11 1924
Tercio@11 1925 return b
Tercio@11 1926
Tercio@11 1927 end
Tercio@11 1928
Tercio@11 1929 ------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 1930 --> feedback panel -- ~feedback
Tercio@11 1931
Tercio@11 1932 function DF:CreateFeedbackButton (parent, callback, name)
Tercio@11 1933 local b = CreateFrame ("button", name, parent)
Tercio@11 1934 b:SetSize (12, 13)
Tercio@11 1935 b:SetNormalTexture (DF.folder .. "mail")
Tercio@11 1936 b:SetPushedTexture (DF.folder .. "mail")
Tercio@11 1937 b:SetHighlightTexture (DF.folder .. "mail")
Tercio@11 1938
Tercio@11 1939 b:SetScript ("OnClick", callback)
Tercio@11 1940 b:SetScript ("OnEnter", function (self)
Tercio@11 1941 GameCooltip2:Reset()
Tercio@11 1942 GameCooltip2:AddLine ("Send Feedback")
Tercio@11 1943 GameCooltip2:ShowCooltip (self, "tooltip")
Tercio@11 1944 end)
Tercio@11 1945 b:SetScript ("OnLeave", function (self)
Tercio@11 1946 GameCooltip2:Hide()
Tercio@11 1947 end)
Tercio@11 1948
Tercio@11 1949 return b
Tercio@11 1950 end
Tercio@11 1951
Tercio@11 1952 local backdrop_fb_line = {bgFile = DF.folder .. "background", edgeFile = DF.folder .. "border_3",
Tercio@11 1953 tile = true, tileSize = 64, edgeSize = 8, insets = {left = 2, right = 2, top = 2, bottom = 2}}
Tercio@11 1954
Tercio@11 1955 local on_enter_feedback = function (self)
Tercio@11 1956 self:SetBackdropColor (1, 1, 0, 0.5)
Tercio@11 1957 end
Tercio@11 1958 local on_leave_feedback = function (self)
Tercio@11 1959 self:SetBackdropColor (0, 0, 0, 0.3)
Tercio@11 1960 end
Tercio@11 1961
Tercio@11 1962 local on_click_feedback = function (self)
Tercio@11 1963
Tercio@11 1964 local feedback_link_textbox = DF.feedback_link_textbox
Tercio@11 1965
Tercio@11 1966 if (not feedback_link_textbox) then
Tercio@11 1967 local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 275, 34)
Tercio@11 1968 editbox:SetAutoFocus (false)
Tercio@11 1969 editbox:SetHook ("OnEditFocusGained", function()
Tercio@11 1970 editbox.text = editbox.link
Tercio@11 1971 editbox:HighlightText()
Tercio@11 1972 end)
Tercio@11 1973 editbox:SetHook ("OnEditFocusLost", function()
Tercio@11 1974 editbox:Hide()
Tercio@11 1975 end)
Tercio@11 1976 editbox:SetHook ("OnChar", function()
Tercio@11 1977 editbox.text = editbox.link
Tercio@11 1978 editbox:HighlightText()
Tercio@11 1979 end)
Tercio@11 1980 editbox.text = ""
Tercio@11 1981
Tercio@11 1982 DF.feedback_link_textbox = editbox
Tercio@11 1983 feedback_link_textbox = editbox
Tercio@11 1984 end
Tercio@11 1985
Tercio@11 1986 feedback_link_textbox.link = self.link
Tercio@11 1987 feedback_link_textbox.text = self.link
Tercio@11 1988 feedback_link_textbox:Show()
Tercio@11 1989
Tercio@11 1990 feedback_link_textbox:SetPoint ("topleft", self.icon, "topright", 3, 0)
Tercio@11 1991
Tercio@11 1992 feedback_link_textbox:HighlightText()
Tercio@11 1993
Tercio@11 1994 feedback_link_textbox:SetFocus()
Tercio@11 1995 feedback_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
Tercio@11 1996 end
Tercio@11 1997
Tercio@11 1998 local feedback_get_fb_line = function (self)
Tercio@11 1999
Tercio@11 2000 local line = self.feedback_lines [self.next_feedback]
Tercio@11 2001 if (not line) then
Tercio@11 2002 line = CreateFrame ("frame", "AddonFeedbackPanelFB" .. self.next_feedback, self)
Tercio@11 2003 line:SetBackdrop (backdrop_fb_line)
Tercio@11 2004 line:SetBackdropColor (0, 0, 0, 0.3)
Tercio@11 2005 line:SetSize (390, 42)
Tercio@11 2006 line:SetPoint ("topleft", self.feedback_anchor, "bottomleft", 0, -5 + ((self.next_feedback-1) * 46 * -1))
Tercio@11 2007 line:SetScript ("OnEnter", on_enter_feedback)
Tercio@11 2008 line:SetScript ("OnLeave", on_leave_feedback)
Tercio@11 2009 line:SetScript ("OnMouseUp", on_click_feedback)
Tercio@11 2010
Tercio@11 2011 line.icon = line:CreateTexture (nil, "overlay")
Tercio@11 2012 line.icon:SetSize (90, 36)
Tercio@11 2013
Tercio@11 2014 line.desc = line:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
Tercio@11 2015
Tercio@11 2016 line.icon:SetPoint ("left", line, "left", 5, 0)
Tercio@11 2017 line.desc:SetPoint ("left", line.icon, "right", 5, 0)
Tercio@11 2018
Tercio@11 2019 local arrow = line:CreateTexture (nil, "overlay")
Tercio@11 2020 arrow:SetTexture ([[Interface\Buttons\JumpUpArrow]])
Tercio@11 2021 arrow:SetRotation (-1.55)
Tercio@11 2022 arrow:SetPoint ("right", line, "right", -5, 0)
Tercio@11 2023
Tercio@11 2024 self.feedback_lines [self.next_feedback] = line
Tercio@11 2025 end
Tercio@11 2026
Tercio@11 2027 self.next_feedback = self.next_feedback + 1
Tercio@11 2028
Tercio@11 2029 return line
Tercio@11 2030 end
Tercio@11 2031
Tercio@11 2032 local on_click_feedback = function (self)
Tercio@11 2033
Tercio@11 2034 local feedback_link_textbox = DF.feedback_link_textbox
Tercio@11 2035
Tercio@11 2036 if (not feedback_link_textbox) then
Tercio@11 2037 local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 275, 34)
Tercio@11 2038 editbox:SetAutoFocus (false)
Tercio@11 2039 editbox:SetHook ("OnEditFocusGained", function()
Tercio@11 2040 editbox.text = editbox.link
Tercio@11 2041 editbox:HighlightText()
Tercio@11 2042 end)
Tercio@11 2043 editbox:SetHook ("OnEditFocusLost", function()
Tercio@11 2044 editbox:Hide()
Tercio@11 2045 end)
Tercio@11 2046 editbox:SetHook ("OnChar", function()
Tercio@11 2047 editbox.text = editbox.link
Tercio@11 2048 editbox:HighlightText()
Tercio@11 2049 end)
Tercio@11 2050 editbox.text = ""
Tercio@11 2051
Tercio@11 2052 DF.feedback_link_textbox = editbox
Tercio@11 2053 feedback_link_textbox = editbox
Tercio@11 2054 end
Tercio@11 2055
Tercio@11 2056 feedback_link_textbox.link = self.link
Tercio@11 2057 feedback_link_textbox.text = self.link
Tercio@11 2058 feedback_link_textbox:Show()
Tercio@11 2059
Tercio@11 2060 feedback_link_textbox:SetPoint ("topleft", self.icon, "topright", 3, 0)
Tercio@11 2061
Tercio@11 2062 feedback_link_textbox:HighlightText()
Tercio@11 2063
Tercio@11 2064 feedback_link_textbox:SetFocus()
Tercio@11 2065 feedback_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
Tercio@11 2066 end
Tercio@11 2067
Tercio@11 2068 local on_enter_addon = function (self)
Tercio@11 2069 if (self.tooltip) then
Tercio@11 2070 GameCooltip2:Preset (2)
Tercio@11 2071 GameCooltip2:AddLine ("|cFFFFFF00" .. self.name .. "|r")
Tercio@11 2072 GameCooltip2:AddLine ("")
Tercio@11 2073 GameCooltip2:AddLine (self.tooltip)
Tercio@11 2074 GameCooltip2:ShowCooltip (self, "tooltip")
Tercio@11 2075 end
Tercio@11 2076 self.icon:SetBlendMode ("ADD")
Tercio@11 2077 end
Tercio@11 2078 local on_leave_addon = function (self)
Tercio@11 2079 if (self.tooltip) then
Tercio@11 2080 GameCooltip2:Hide()
Tercio@11 2081 end
Tercio@11 2082 self.icon:SetBlendMode ("BLEND")
Tercio@11 2083 end
Tercio@11 2084 local on_click_addon = function (self)
Tercio@11 2085 local addon_link_textbox = DF.addon_link_textbox
Tercio@11 2086
Tercio@11 2087 if (not addon_link_textbox) then
Tercio@11 2088 local editbox = DF:CreateTextEntry (AddonFeedbackPanel, _, 128, 64)
Tercio@11 2089 editbox:SetAutoFocus (false)
Tercio@11 2090 editbox:SetHook ("OnEditFocusGained", function()
Tercio@11 2091 editbox.text = editbox.link
Tercio@11 2092 editbox:HighlightText()
Tercio@11 2093 end)
Tercio@11 2094 editbox:SetHook ("OnEditFocusLost", function()
Tercio@11 2095 editbox:Hide()
Tercio@11 2096 end)
Tercio@11 2097 editbox:SetHook ("OnChar", function()
Tercio@11 2098 editbox.text = editbox.link
Tercio@11 2099 editbox:HighlightText()
Tercio@11 2100 end)
Tercio@11 2101 editbox.text = ""
Tercio@11 2102
Tercio@11 2103 DF.addon_link_textbox = editbox
Tercio@11 2104 addon_link_textbox = editbox
Tercio@11 2105 end
Tercio@11 2106
Tercio@11 2107 addon_link_textbox.link = self.link
Tercio@11 2108 addon_link_textbox.text = self.link
Tercio@11 2109 addon_link_textbox:Show()
Tercio@11 2110
Tercio@11 2111 addon_link_textbox:SetPoint ("topleft", self.icon, "topleft", 0, 0)
Tercio@11 2112
Tercio@11 2113 addon_link_textbox:HighlightText()
Tercio@11 2114
Tercio@11 2115 addon_link_textbox:SetFocus()
Tercio@11 2116 addon_link_textbox:SetFrameLevel (self:GetFrameLevel()+2)
Tercio@11 2117 end
Tercio@11 2118
Tercio@11 2119 local feedback_get_addons_line = function (self)
Tercio@11 2120 local line = self.addons_lines [self.next_addons]
Tercio@11 2121 if (not line) then
Tercio@11 2122
Tercio@11 2123 line = CreateFrame ("frame", "AddonFeedbackPanelSA" .. self.next_addons, self)
Tercio@11 2124 line:SetSize (128, 64)
Tercio@11 2125
Tercio@11 2126 if (self.next_addons == 1) then
Tercio@11 2127 line:SetPoint ("topleft", self.addons_anchor, "bottomleft", 0, -5)
Tercio@11 2128 elseif (self.next_addons_line_break == self.next_addons) then
Tercio@11 2129 line:SetPoint ("topleft", self.addons_anchor, "bottomleft", 0, -5 + floor (self.next_addons_line_break/3) * 66 * -1)
Tercio@11 2130 self.next_addons_line_break = self.next_addons_line_break + 3
Tercio@11 2131 else
Tercio@11 2132 local previous = self.addons_lines [self.next_addons - 1]
Tercio@11 2133 line:SetPoint ("topleft", previous, "topright", 2, 0)
Tercio@11 2134 end
Tercio@11 2135
Tercio@11 2136 line:SetScript ("OnEnter", on_enter_addon)
Tercio@11 2137 line:SetScript ("OnLeave", on_leave_addon)
Tercio@11 2138 line:SetScript ("OnMouseUp", on_click_addon)
Tercio@11 2139
Tercio@11 2140 line.icon = line:CreateTexture (nil, "overlay")
Tercio@11 2141 line.icon:SetSize (128, 64)
Tercio@11 2142
Tercio@11 2143 line.icon:SetPoint ("topleft", line, "topleft", 0, 0)
Tercio@11 2144
Tercio@11 2145 self.addons_lines [self.next_addons] = line
Tercio@11 2146 end
Tercio@11 2147
Tercio@11 2148 self.next_addons = self.next_addons + 1
Tercio@11 2149
Tercio@11 2150 return line
Tercio@11 2151 end
Tercio@11 2152
Tercio@11 2153 local default_coords = {0, 1, 0, 1}
Tercio@11 2154 local feedback_add_fb = function (self, table)
Tercio@11 2155 local line = self:GetFeedbackLine()
Tercio@11 2156 line.icon:SetTexture (table.icon)
Tercio@11 2157 line.icon:SetTexCoord (unpack (table.coords or default_coords))
Tercio@11 2158 line.desc:SetText (table.desc)
Tercio@11 2159 line.link = table.link
Tercio@11 2160 line:Show()
Tercio@11 2161 end
Tercio@11 2162
Tercio@11 2163 local feedback_add_addon = function (self, table)
Tercio@11 2164 local block = self:GetAddonsLine()
Tercio@11 2165 block.icon:SetTexture (table.icon)
Tercio@11 2166 block.icon:SetTexCoord (unpack (table.coords or default_coords))
Tercio@11 2167 block.link = table.link
Tercio@11 2168 block.tooltip = table.desc
Tercio@11 2169 block.name = table.name
Tercio@11 2170 block:Show()
Tercio@11 2171 end
Tercio@11 2172
Tercio@11 2173 local feedback_hide_all = function (self)
Tercio@11 2174 self.next_feedback = 1
Tercio@11 2175 self.next_addons = 1
Tercio@11 2176
Tercio@11 2177 for index, line in ipairs (self.feedback_lines) do
Tercio@11 2178 line:Hide()
Tercio@11 2179 end
Tercio@11 2180
Tercio@11 2181 for index, line in ipairs (self.addons_lines) do
Tercio@11 2182 line:Hide()
Tercio@11 2183 end
Tercio@11 2184 end
Tercio@11 2185
Tercio@11 2186 -- feedback_methods = { { icon = icon path, desc = description, link = url}}
Tercio@11 2187 function DF:ShowFeedbackPanel (addon_name, version, feedback_methods, more_addons)
Tercio@11 2188
Tercio@11 2189 local f = _G.AddonFeedbackPanel
Tercio@11 2190
Tercio@11 2191 if (not f) then
Tercio@11 2192 f = DF:Create1PxPanel (UIParent, 400, 100, addon_name .. " Feedback", "AddonFeedbackPanel", nil)
Tercio@11 2193 f:SetFrameStrata ("FULLSCREEN")
Tercio@11 2194 f:SetPoint ("center", UIParent, "center")
Tercio@11 2195 f:SetBackdropColor (0, 0, 0, 0.8)
Tercio@11 2196 f.feedback_lines = {}
Tercio@11 2197 f.addons_lines = {}
Tercio@11 2198 f.next_feedback = 1
Tercio@11 2199 f.next_addons = 1
Tercio@11 2200 f.next_addons_line_break = 4
Tercio@11 2201
Tercio@11 2202 local feedback_anchor = f:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@11 2203 feedback_anchor:SetText ("Feedback:")
Tercio@11 2204 feedback_anchor:SetPoint ("topleft", f, "topleft", 5, -30)
Tercio@11 2205 f.feedback_anchor = feedback_anchor
Tercio@11 2206 local excla_text = f:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@11 2207 excla_text:SetText ("click and copy the link")
Tercio@11 2208 excla_text:SetPoint ("topright", f, "topright", -5, -30)
Tercio@11 2209 excla_text:SetTextColor (1, 0.8, 0.2, 0.6)
Tercio@11 2210
Tercio@11 2211 local addons_anchor = f:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@11 2212 addons_anchor:SetText ("AddOns From the Same Author:")
Tercio@11 2213 f.addons_anchor = addons_anchor
Tercio@11 2214 local excla_text2 = f:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@11 2215 excla_text2:SetText ("click and copy the link")
Tercio@11 2216 excla_text2:SetTextColor (1, 0.8, 0.2, 0.6)
Tercio@11 2217 f.excla_text2 = excla_text2
Tercio@11 2218
Tercio@11 2219 f.GetFeedbackLine = feedback_get_fb_line
Tercio@11 2220 f.GetAddonsLine = feedback_get_addons_line
Tercio@11 2221 f.AddFeedbackMethod = feedback_add_fb
Tercio@11 2222 f.AddOtherAddon = feedback_add_addon
Tercio@11 2223 f.HideAll = feedback_hide_all
Tercio@11 2224
Tercio@11 2225 DF:SetFontSize (f.Title, 14)
Tercio@11 2226
Tercio@11 2227 end
Tercio@11 2228
Tercio@11 2229 f:HideAll()
Tercio@11 2230 f:SetTitle (addon_name)
Tercio@11 2231
Tercio@11 2232 for index, feedback in ipairs (feedback_methods) do
Tercio@11 2233 f:AddFeedbackMethod (feedback)
Tercio@11 2234 end
Tercio@11 2235
Tercio@11 2236 f.addons_anchor:SetPoint ("topleft", f, "topleft", 5, f.next_feedback * 50 * -1)
Tercio@11 2237 f.excla_text2:SetPoint ("topright", f, "topright", -5, f.next_feedback * 50 * -1)
Tercio@11 2238
Tercio@11 2239 for index, addon in ipairs (more_addons) do
Tercio@11 2240 f:AddOtherAddon (addon)
Tercio@11 2241 end
Tercio@11 2242
Tercio@11 2243 f:SetHeight (80 + ((f.next_feedback-1) * 50) + (ceil ((f.next_addons-1)/3) * 66))
Tercio@11 2244
Tercio@11 2245 f:Show()
Tercio@11 2246
Tercio@11 2247 return true
Tercio@11 2248 end
Tercio@11 2249
Tercio@11 2250
Tercio@11 2251 ------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@11 2252 --> chart panel -- ~chart
Tercio@11 2253
Tercio@11 2254 local chart_panel_backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16,
Tercio@11 2255 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 32, insets = {left = 5, right = 5, top = 5, bottom = 5}}
Tercio@11 2256
Tercio@11 2257 local chart_panel_align_timelabels = function (self, elapsed_time)
Tercio@11 2258
Tercio@11 2259 self.TimeScale = elapsed_time
Tercio@11 2260
Tercio@11 2261 local linha = self.TimeLabels [17]
Tercio@11 2262 local minutos, segundos = math.floor (elapsed_time / 60), math.floor (elapsed_time % 60)
Tercio@11 2263 if (segundos < 10) then
Tercio@11 2264 segundos = "0" .. segundos
Tercio@11 2265 end
Tercio@11 2266
Tercio@11 2267 if (minutos > 0) then
Tercio@11 2268 if (minutos < 10) then
Tercio@11 2269 minutos = "0" .. minutos
Tercio@11 2270 end
Tercio@11 2271 linha:SetText (minutos .. ":" .. segundos)
Tercio@11 2272 else
Tercio@11 2273 linha:SetText ("00:" .. segundos)
Tercio@11 2274 end
Tercio@11 2275
Tercio@11 2276 local time_div = elapsed_time / 16 --786 -- 49.125
Tercio@11 2277
Tercio@11 2278 for i = 2, 16 do
Tercio@11 2279
Tercio@11 2280 local linha = self.TimeLabels [i]
Tercio@11 2281
Tercio@11 2282 local this_time = time_div * (i-1)
Tercio@11 2283 local minutos, segundos = math.floor (this_time / 60), math.floor (this_time % 60)
Tercio@11 2284
Tercio@11 2285 if (segundos < 10) then
Tercio@11 2286 segundos = "0" .. segundos
Tercio@11 2287 end
Tercio@11 2288
Tercio@11 2289 if (minutos > 0) then
Tercio@11 2290 if (minutos < 10) then
Tercio@11 2291 minutos = "0" .. minutos
Tercio@11 2292 end
Tercio@11 2293 linha:SetText (minutos .. ":" .. segundos)
Tercio@11 2294 else
Tercio@11 2295 linha:SetText ("00:" .. segundos)
Tercio@11 2296 end
Tercio@11 2297
Tercio@11 2298 end
Tercio@11 2299
Tercio@11 2300 end
Tercio@11 2301
Tercio@11 2302 local chart_panel_set_scale = function (self, amt, func, text)
Tercio@22 2303
Tercio@11 2304 if (type (amt) ~= "number") then
Tercio@11 2305 return
Tercio@11 2306 end
Tercio@11 2307
Tercio@11 2308 local piece = amt / 1000 / 8
Tercio@22 2309 if (not text or text == "") then
Tercio@22 2310 text = amt > 1000000 and "M" or amt > 1000 and "K"
Tercio@22 2311 end
Tercio@11 2312
Tercio@11 2313 for i = 1, 8 do
Tercio@11 2314 if (func) then
Tercio@11 2315 self ["dpsamt" .. math.abs (i-9)]:SetText ( func (piece*i) .. (text or ""))
Tercio@11 2316 else
Tercio@11 2317 if (piece*i > 1) then
Tercio@22 2318 self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.1f", piece*i) .. (text or ""))
Tercio@11 2319 else
Tercio@11 2320 self ["dpsamt" .. math.abs (i-9)]:SetText ( format ("%.3f", piece*i) .. (text or ""))
Tercio@11 2321 end
Tercio@11 2322 end
Tercio@11 2323 end
Tercio@11 2324 end
Tercio@11 2325
Tercio@11 2326 local chart_panel_can_move = function (self, can)
Tercio@11 2327 self.can_move = can
Tercio@11 2328 end
Tercio@11 2329
Tercio@11 2330 local chart_panel_overlay_reset = function (self)
Tercio@11 2331 self.OverlaysAmount = 1
Tercio@11 2332 for index, pack in ipairs (self.Overlays) do
Tercio@11 2333 for index2, texture in ipairs (pack) do
Tercio@11 2334 texture:Hide()
Tercio@11 2335 end
Tercio@11 2336 end
Tercio@11 2337 end
Tercio@11 2338
Tercio@11 2339 local chart_panel_reset = function (self)
Tercio@11 2340
Tercio@11 2341 self.Graphic:ResetData()
Tercio@11 2342 self.Graphic.max_value = 0
Tercio@11 2343
Tercio@11 2344 self.TimeScale = nil
Tercio@11 2345 self.BoxLabelsAmount = 1
Tercio@11 2346 table.wipe (self.GData)
Tercio@11 2347 table.wipe (self.OData)
Tercio@11 2348
Tercio@11 2349 for index, box in ipairs (self.BoxLabels) do
Tercio@11 2350 box.check:Hide()
Tercio@11 2351 box.button:Hide()
Tercio@11 2352 box.box:Hide()
Tercio@11 2353 box.text:Hide()
Tercio@11 2354 box.border:Hide()
Tercio@11 2355 box.showing = false
Tercio@11 2356 end
Tercio@11 2357
Tercio@11 2358 chart_panel_overlay_reset (self)
Tercio@11 2359 end
Tercio@11 2360
Tercio@11 2361 local chart_panel_enable_line = function (f, thisbox)
Tercio@11 2362
Tercio@11 2363 local index = thisbox.index
Tercio@11 2364 local type = thisbox.type
Tercio@11 2365
Tercio@11 2366 if (thisbox.enabled) then
Tercio@11 2367 --disable
Tercio@11 2368 thisbox.check:Hide()
Tercio@11 2369 thisbox.enabled = false
Tercio@11 2370 else
Tercio@11 2371 --enable
Tercio@11 2372 thisbox.check:Show()
Tercio@11 2373 thisbox.enabled = true
Tercio@11 2374 end
Tercio@11 2375
Tercio@11 2376 if (type == "graphic") then
Tercio@11 2377
Tercio@11 2378 f.Graphic:ResetData()
Tercio@11 2379 f.Graphic.max_value = 0
Tercio@11 2380
Tercio@11 2381 local max = 0
Tercio@11 2382 local max_time = 0
Tercio@11 2383
Tercio@11 2384 for index, box in ipairs (f.BoxLabels) do
Tercio@11 2385 if (box.type == type and box.showing and box.enabled) then
Tercio@11 2386 local data = f.GData [index]
Tercio@11 2387
Tercio@11 2388 f.Graphic:AddDataSeries (data[1], data[2], nil, data[3])
Tercio@11 2389
Tercio@11 2390 if (data[4] > max) then
Tercio@11 2391 max = data[4]
Tercio@11 2392 end
Tercio@11 2393 if (data [5] > max_time) then
Tercio@11 2394 max_time = data [5]
Tercio@11 2395 end
Tercio@11 2396 end
Tercio@11 2397 end
Tercio@11 2398
Tercio@11 2399 f:SetScale (max)
Tercio@11 2400 f:SetTime (max_time)
Tercio@11 2401
Tercio@11 2402 elseif (type == "overlay") then
Tercio@11 2403
Tercio@11 2404 chart_panel_overlay_reset (f)
Tercio@11 2405
Tercio@11 2406 for index, box in ipairs (f.BoxLabels) do
Tercio@11 2407 if (box.type == type and box.showing and box.enabled) then
Tercio@11 2408
Tercio@11 2409 f:AddOverlay (box.index)
Tercio@11 2410
Tercio@11 2411 end
Tercio@11 2412 end
Tercio@11 2413
Tercio@11 2414 end
Tercio@11 2415 end
Tercio@11 2416
Tercio@11 2417 local create_box = function (self, next_box)
Tercio@11 2418
Tercio@11 2419 local thisbox = {}
Tercio@11 2420 self.BoxLabels [next_box] = thisbox
Tercio@11 2421
Tercio@11 2422 local box = DF:NewImage (self.Graphic, nil, 16, 16, "border")
Tercio@11 2423
Tercio@11 2424 local text = DF:NewLabel (self.Graphic)
Tercio@11 2425
Tercio@11 2426 local border = DF:NewImage (self.Graphic, [[Interface\DialogFrame\UI-DialogBox-Gold-Corner]], 30, 30, "artwork")
Tercio@11 2427 border:SetPoint ("center", box, "center", -3, -4)
Tercio@11 2428 border:SetTexture ([[Interface\DialogFrame\UI-DialogBox-Gold-Corner]])
Tercio@11 2429
Tercio@11 2430 local checktexture = DF:NewImage (self.Graphic, [[Interface\Buttons\UI-CheckBox-Check]], 18, 18, "overlay")
Tercio@11 2431 checktexture:SetPoint ("center", box, "center", -1, -1)
Tercio@11 2432 checktexture:SetTexture ([[Interface\Buttons\UI-CheckBox-Check]])
Tercio@11 2433
Tercio@11 2434 thisbox.box = box
Tercio@11 2435 thisbox.text = text
Tercio@11 2436 thisbox.border = border
Tercio@11 2437 thisbox.check = checktexture
Tercio@11 2438 thisbox.enabled = true
Tercio@11 2439
Tercio@11 2440 local button = CreateFrame ("button", nil, self.Graphic)
Tercio@11 2441 button:SetSize (20, 20)
Tercio@11 2442 button:SetScript ("OnClick", function()
Tercio@11 2443 chart_panel_enable_line (self, thisbox)
Tercio@11 2444 end)
Tercio@22 2445 button:SetPoint ("center", box.widget or box, "center")
Tercio@11 2446
Tercio@11 2447 thisbox.button = button
Tercio@11 2448
Tercio@11 2449 thisbox.box:SetPoint ("right", text, "left", -4, 0)
Tercio@11 2450
Tercio@11 2451 if (next_box == 1) then
Tercio@11 2452 thisbox.text:SetPoint ("topright", self, "topright", -35, -16)
Tercio@11 2453 else
Tercio@11 2454 thisbox.text:SetPoint ("right", self.BoxLabels [next_box-1].box, "left", -7, 0)
Tercio@11 2455 end
Tercio@11 2456
Tercio@11 2457 return thisbox
Tercio@11 2458
Tercio@11 2459 end
Tercio@11 2460
Tercio@11 2461 local realign_labels = function (self)
Tercio@11 2462
Tercio@11 2463 local width = self:GetWidth() - 108
Tercio@11 2464
Tercio@11 2465 local first_box = self.BoxLabels [1]
Tercio@11 2466 first_box.text:SetPoint ("topright", self, "topright", -35, -16)
Tercio@11 2467
Tercio@11 2468 local line_width = first_box.text:GetStringWidth() + 26
Tercio@11 2469
Tercio@11 2470 for i = 2, #self.BoxLabels do
Tercio@11 2471
Tercio@11 2472 local box = self.BoxLabels [i]
Tercio@11 2473
Tercio@11 2474 if (box.box:IsShown()) then
Tercio@11 2475
Tercio@11 2476 line_width = line_width + box.text:GetStringWidth() + 26
Tercio@11 2477
Tercio@11 2478 if (line_width > width) then
Tercio@11 2479 line_width = box.text:GetStringWidth() + 26
Tercio@11 2480 box.text:SetPoint ("topright", self, "topright", -35, -40)
Tercio@11 2481 else
Tercio@11 2482 box.text:SetPoint ("right", self.BoxLabels [i-1].box, "left", -7, 0)
Tercio@11 2483 end
Tercio@11 2484 else
Tercio@11 2485 break
Tercio@11 2486 end
Tercio@11 2487 end
Tercio@11 2488
Tercio@11 2489 end
Tercio@11 2490
Tercio@11 2491 local chart_panel_add_label = function (self, color, name, type, number)
Tercio@11 2492
Tercio@11 2493 local next_box = self.BoxLabelsAmount
Tercio@11 2494 local thisbox = self.BoxLabels [next_box]
Tercio@11 2495
Tercio@11 2496 if (not thisbox) then
Tercio@11 2497 thisbox = create_box (self, next_box)
Tercio@11 2498 end
Tercio@11 2499
Tercio@11 2500 self.BoxLabelsAmount = self.BoxLabelsAmount + 1
Tercio@11 2501
Tercio@11 2502 thisbox.type = type
Tercio@11 2503 thisbox.index = number
Tercio@11 2504
Tercio@39 2505 thisbox.box:SetColorTexture (unpack (color))
Tercio@11 2506 thisbox.text:SetText (name)
Tercio@11 2507
Tercio@11 2508 thisbox.check:Show()
Tercio@11 2509 thisbox.button:Show()
Tercio@11 2510 thisbox.border:Show()
Tercio@11 2511 thisbox.box:Show()
Tercio@11 2512 thisbox.text:Show()
Tercio@11 2513
Tercio@11 2514 thisbox.showing = true
Tercio@11 2515 thisbox.enabled = true
Tercio@11 2516
Tercio@11 2517 realign_labels (self)
Tercio@11 2518
Tercio@11 2519 end
Tercio@11 2520
Tercio@11 2521 local line_default_color = {1, 1, 1}
Tercio@11 2522 local draw_overlay = function (self, this_overlay, overlayData, color)
Tercio@11 2523
Tercio@11 2524 local pixel = self.Graphic:GetWidth() / self.TimeScale
Tercio@11 2525 local index = 1
Tercio@40 2526 local r, g, b = unpack (color or line_default_color)
Tercio@11 2527
Tercio@11 2528 for i = 1, #overlayData, 2 do
Tercio@11 2529 local aura_start = overlayData [i]
Tercio@11 2530 local aura_end = overlayData [i+1]
Tercio@11 2531
Tercio@11 2532 local this_block = this_overlay [index]
Tercio@11 2533 if (not this_block) then
Tercio@11 2534 this_block = self.Graphic:CreateTexture (nil, "border")
Tercio@11 2535 tinsert (this_overlay, this_block)
Tercio@11 2536 end
Tercio@11 2537 this_block:SetHeight (self.Graphic:GetHeight())
Tercio@11 2538
Tercio@11 2539 this_block:SetPoint ("left", self.Graphic, "left", pixel * aura_start, 0)
Tercio@11 2540 if (aura_end) then
Tercio@11 2541 this_block:SetWidth ((aura_end-aura_start)*pixel)
Tercio@11 2542 else
Tercio@11 2543 --malformed table
Tercio@11 2544 this_block:SetWidth (pixel*5)
Tercio@11 2545 end
Tercio@11 2546
Tercio@39 2547 this_block:SetColorTexture (r, g, b, 0.25)
Tercio@11 2548 this_block:Show()
Tercio@11 2549
Tercio@11 2550 index = index + 1
Tercio@11 2551 end
Tercio@11 2552
Tercio@11 2553 end
Tercio@11 2554
Tercio@11 2555 local chart_panel_add_overlay = function (self, overlayData, color, name, icon)
Tercio@11 2556
Tercio@11 2557 if (not self.TimeScale) then
Tercio@11 2558 error ("Use SetTime (time) before adding an overlay.")
Tercio@11 2559 end
Tercio@11 2560
Tercio@11 2561 if (type (overlayData) == "number") then
Tercio@11 2562 local overlay_index = overlayData
Tercio@11 2563 draw_overlay (self, self.Overlays [self.OverlaysAmount], self.OData [overlay_index][1], self.OData [overlay_index][2])
Tercio@11 2564 else
Tercio@11 2565 local this_overlay = self.Overlays [self.OverlaysAmount]
Tercio@11 2566 if (not this_overlay) then
Tercio@11 2567 this_overlay = {}
Tercio@11 2568 tinsert (self.Overlays, this_overlay)
Tercio@11 2569 end
Tercio@11 2570
Tercio@11 2571 draw_overlay (self, this_overlay, overlayData, color)
Tercio@11 2572
Tercio@11 2573 tinsert (self.OData, {overlayData, color or line_default_color})
Tercio@11 2574 if (name) then
Tercio@11 2575 self:AddLabel (color or line_default_color, name, "overlay", #self.OData)
Tercio@11 2576 end
Tercio@11 2577 end
Tercio@11 2578
Tercio@11 2579 self.OverlaysAmount = self.OverlaysAmount + 1
Tercio@11 2580 end
Tercio@11 2581
Tercio@11 2582 local SMA_table = {}
Tercio@11 2583 local SMA_max = 0
Tercio@11 2584 local reset_SMA = function()
Tercio@11 2585 table.wipe (SMA_table)
Tercio@11 2586 SMA_max = 0
Tercio@11 2587 end
Tercio@11 2588
Tercio@11 2589 local calc_SMA
Tercio@11 2590 calc_SMA = function (a, b, ...)
Tercio@11 2591 if (b) then
Tercio@11 2592 return calc_SMA (a + b, ...)
Tercio@11 2593 else
Tercio@11 2594 return a
Tercio@11 2595 end
Tercio@11 2596 end
Tercio@11 2597
Tercio@11 2598 local do_SMA = function (value, max_value)
Tercio@11 2599
Tercio@11 2600 if (#SMA_table == 10) then
Tercio@11 2601 tremove (SMA_table, 1)
Tercio@11 2602 end
Tercio@11 2603
Tercio@11 2604 SMA_table [#SMA_table + 1] = value
Tercio@11 2605
Tercio@11 2606 local new_value = calc_SMA (unpack (SMA_table)) / #SMA_table
Tercio@11 2607
Tercio@11 2608 if (new_value > SMA_max) then
Tercio@11 2609 SMA_max = new_value
Tercio@11 2610 return new_value, SMA_max
Tercio@11 2611 else
Tercio@11 2612 return new_value
Tercio@11 2613 end
Tercio@11 2614
Tercio@11 2615 end
Tercio@11 2616
Tercio@11 2617 local chart_panel_add_data = function (self, graphicData, color, name, elapsed_time, lineTexture, smoothLevel, firstIndex)
Tercio@11 2618
Tercio@11 2619 local f = self
Tercio@11 2620 self = self.Graphic
Tercio@22 2621
Tercio@11 2622 local _data = {}
Tercio@11 2623 local max_value = graphicData.max_value
Tercio@11 2624 local amount = #graphicData
Tercio@11 2625
Tercio@11 2626 local scaleW = 1/self:GetWidth()
Tercio@11 2627
Tercio@11 2628 local content = graphicData
Tercio@11 2629 tinsert (content, 1, 0)
Tercio@11 2630 tinsert (content, 1, 0)
Tercio@11 2631 tinsert (content, #content+1, 0)
Tercio@11 2632 tinsert (content, #content+1, 0)
Tercio@11 2633
Tercio@11 2634 local _i = 3
Tercio@11 2635
Tercio@11 2636 local graphMaxDps = math.max (self.max_value, max_value)
Tercio@11 2637
Tercio@11 2638 if (not smoothLevel) then
Tercio@11 2639 while (_i <= #content-2) do
Tercio@11 2640 local v = (content[_i-2]+content[_i-1]+content[_i]+content[_i+1]+content[_i+2])/5 --> normalize
Tercio@11 2641 _data [#_data+1] = {scaleW*(_i-2), v/graphMaxDps} --> x and y coords
Tercio@11 2642 _i = _i + 1
Tercio@11 2643 end
Tercio@11 2644
Tercio@11 2645 elseif (smoothLevel == "SHORT") then
Tercio@11 2646 while (_i <= #content-2) do
Tercio@11 2647 local value = (content[_i] + content[_i+1]) / 2
Tercio@11 2648 _data [#_data+1] = {scaleW*(_i-2), value}
Tercio@11 2649 _data [#_data+1] = {scaleW*(_i-2), value}
Tercio@11 2650 _i = _i + 2
Tercio@11 2651 end
Tercio@11 2652
Tercio@11 2653 elseif (smoothLevel == "SMA") then
Tercio@11 2654 reset_SMA()
Tercio@11 2655 while (_i <= #content-2) do
Tercio@11 2656 local value, is_new_max_value = do_SMA (content[_i], max_value)
Tercio@11 2657 if (is_new_max_value) then
Tercio@11 2658 max_value = is_new_max_value
Tercio@11 2659 end
Tercio@11 2660 _data [#_data+1] = {scaleW*(_i-2), value} --> x and y coords
Tercio@11 2661 _i = _i + 1
Tercio@11 2662 end
Tercio@11 2663
Tercio@11 2664 elseif (smoothLevel == -1) then
Tercio@11 2665 while (_i <= #content-2) do
Tercio@11 2666 local current = content[_i]
Tercio@11 2667
Tercio@11 2668 local minus_2 = content[_i-2] * 0.6
Tercio@11 2669 local minus_1 = content[_i-1] * 0.8
Tercio@11 2670 local plus_1 = content[_i+1] * 0.8
Tercio@11 2671 local plus_2 = content[_i+2] * 0.6
Tercio@11 2672
Tercio@11 2673 local v = (current + minus_2 + minus_1 + plus_1 + plus_2)/5 --> normalize
Tercio@11 2674 _data [#_data+1] = {scaleW*(_i-2), v/graphMaxDps} --> x and y coords
Tercio@11 2675 _i = _i + 1
Tercio@11 2676 end
Tercio@11 2677
Tercio@11 2678 elseif (smoothLevel == 1) then
Tercio@11 2679 _i = 2
Tercio@11 2680 while (_i <= #content-1) do
Tercio@11 2681 local v = (content[_i-1]+content[_i]+content[_i+1])/3 --> normalize
Tercio@11 2682 _data [#_data+1] = {scaleW*(_i-1), v/graphMaxDps} --> x and y coords
Tercio@11 2683 _i = _i + 1
Tercio@11 2684 end
Tercio@11 2685
Tercio@11 2686 elseif (smoothLevel == 2) then
Tercio@11 2687 _i = 1
Tercio@11 2688 while (_i <= #content) do
Tercio@11 2689 local v = content[_i] --> do not normalize
Tercio@11 2690 _data [#_data+1] = {scaleW*(_i), v/graphMaxDps} --> x and y coords
Tercio@11 2691 _i = _i + 1
Tercio@11 2692 end
Tercio@11 2693
Tercio@11 2694 end
Tercio@11 2695
Tercio@11 2696 tremove (content, 1)
Tercio@11 2697 tremove (content, 1)
Tercio@11 2698 tremove (content, #graphicData)
Tercio@11 2699 tremove (content, #graphicData)
Tercio@11 2700
Tercio@11 2701 if (max_value > self.max_value) then
Tercio@11 2702 --> normalize previous data
Tercio@11 2703 if (self.max_value > 0) then
Tercio@11 2704 local normalizePercent = self.max_value / max_value
Tercio@11 2705 for dataIndex, Data in ipairs (self.Data) do
Tercio@11 2706 local Points = Data.Points
Tercio@11 2707 for i = 1, #Points do
Tercio@11 2708 Points[i][2] = Points[i][2]*normalizePercent
Tercio@11 2709 end
Tercio@11 2710 end
Tercio@11 2711 end
Tercio@11 2712
Tercio@11 2713 self.max_value = max_value
Tercio@11 2714 f:SetScale (max_value)
Tercio@11 2715
Tercio@11 2716 end
Tercio@11 2717
Tercio@11 2718 tinsert (f.GData, {_data, color or line_default_color, lineTexture, max_value, elapsed_time})
Tercio@11 2719 if (name) then
Tercio@11 2720 f:AddLabel (color or line_default_color, name, "graphic", #f.GData)
Tercio@11 2721 end
Tercio@11 2722
Tercio@11 2723 if (firstIndex) then
Tercio@11 2724 if (lineTexture) then
Tercio@11 2725 if (not lineTexture:find ("\\") and not lineTexture:find ("//")) then
Tercio@11 2726 local path = string.match (debugstack (1, 1, 0), "AddOns\\(.+)LibGraph%-2%.0%.lua")
Tercio@11 2727 if path then
Tercio@11 2728 lineTexture = "Interface\\AddOns\\" .. path .. lineTexture
Tercio@11 2729 else
Tercio@11 2730 lineTexture = nil
Tercio@11 2731 end
Tercio@11 2732 end
Tercio@11 2733 end
Tercio@11 2734
Tercio@11 2735 table.insert (self.Data, 1, {Points = _data, Color = color or line_default_color, lineTexture = lineTexture, ElapsedTime = elapsed_time})
Tercio@11 2736 self.NeedsUpdate = true
Tercio@11 2737 else
Tercio@11 2738 self:AddDataSeries (_data, color or line_default_color, nil, lineTexture)
Tercio@11 2739 self.Data [#self.Data].ElapsedTime = elapsed_time
Tercio@11 2740 end
Tercio@11 2741
Tercio@11 2742 local max_time = 0
Tercio@11 2743 for _, data in ipairs (self.Data) do
Tercio@11 2744 if (data.ElapsedTime > max_time) then
Tercio@11 2745 max_time = data.ElapsedTime
Tercio@11 2746 end
Tercio@11 2747 end
Tercio@11 2748
Tercio@11 2749 f:SetTime (max_time)
Tercio@11 2750
Tercio@11 2751 end
Tercio@11 2752
Tercio@11 2753 local chart_panel_onresize = function (self)
Tercio@11 2754 local width, height = self:GetSize()
Tercio@11 2755 local spacement = width - 78 - 60
Tercio@11 2756 spacement = spacement / 16
Tercio@11 2757
Tercio@11 2758 for i = 1, 17 do
Tercio@11 2759 local label = self.TimeLabels [i]
Tercio@11 2760 label:SetPoint ("bottomleft", self, "bottomleft", 78 + ((i-1)*spacement), 13)
Tercio@11 2761 label.line:SetHeight (height - 45)
Tercio@11 2762 end
Tercio@11 2763
Tercio@11 2764 local spacement = (self.Graphic:GetHeight()) / 8
Tercio@11 2765 for i = 1, 8 do
Tercio@11 2766 self ["dpsamt"..i]:SetPoint ("TOPLEFT", self, "TOPLEFT", 27, -25 + (-(spacement* (i-1))) )
Tercio@11 2767 self ["dpsamt"..i].line:SetWidth (width-20)
Tercio@11 2768 end
Tercio@11 2769
Tercio@11 2770 self.Graphic:SetSize (width - 135, height - 67)
Tercio@11 2771 self.Graphic:SetPoint ("topleft", self, "topleft", 108, -35)
Tercio@11 2772 end
Tercio@11 2773
Tercio@11 2774 local chart_panel_vlines_on = function (self)
Tercio@11 2775 for i = 1, 17 do
Tercio@11 2776 local label = self.TimeLabels [i]
Tercio@11 2777 label.line:Show()
Tercio@11 2778 end
Tercio@11 2779 end
Tercio@11 2780
Tercio@11 2781 local chart_panel_vlines_off = function (self)
Tercio@11 2782 for i = 1, 17 do
Tercio@11 2783 local label = self.TimeLabels [i]
Tercio@11 2784 label.line:Hide()
Tercio@11 2785 end
Tercio@11 2786 end
Tercio@11 2787
Tercio@11 2788 local chart_panel_set_title = function (self, title)
Tercio@11 2789 self.chart_title.text = title
Tercio@11 2790 end
Tercio@11 2791
Tercio@11 2792 local chart_panel_mousedown = function (self, button)
Tercio@11 2793 if (button == "LeftButton" and self.can_move) then
Tercio@11 2794 if (not self.isMoving) then
Tercio@11 2795 self:StartMoving()
Tercio@11 2796 self.isMoving = true
Tercio@11 2797 end
Tercio@11 2798 elseif (button == "RightButton" and not self.no_right_click_close) then
Tercio@11 2799 if (not self.isMoving) then
Tercio@11 2800 self:Hide()
Tercio@11 2801 end
Tercio@11 2802 end
Tercio@11 2803 end
Tercio@11 2804 local chart_panel_mouseup = function (self, button)
Tercio@11 2805 if (button == "LeftButton" and self.isMoving) then
Tercio@11 2806 self:StopMovingOrSizing()
Tercio@11 2807 self.isMoving = nil
Tercio@11 2808 end
Tercio@11 2809 end
Tercio@11 2810
Tercio@11 2811 local chart_panel_hide_close_button = function (self)
Tercio@11 2812 self.CloseButton:Hide()
Tercio@11 2813 end
Tercio@11 2814
Tercio@11 2815 local chart_panel_right_click_close = function (self, value)
Tercio@11 2816 if (type (value) == "boolean") then
Tercio@11 2817 if (value) then
Tercio@11 2818 self.no_right_click_close = nil
Tercio@11 2819 else
Tercio@11 2820 self.no_right_click_close = true
Tercio@11 2821 end
Tercio@11 2822 end
Tercio@11 2823 end
Tercio@11 2824
Tercio@11 2825 function DF:CreateChartPanel (parent, w, h, name)
Tercio@11 2826
Tercio@11 2827 if (not name) then
Tercio@11 2828 name = "DFPanel" .. DF.PanelCounter
Tercio@11 2829 DF.PanelCounter = DF.PanelCounter + 1
Tercio@11 2830 end
Tercio@11 2831
Tercio@11 2832 parent = parent or UIParent
Tercio@11 2833 w = w or 800
Tercio@11 2834 h = h or 500
Tercio@11 2835
Tercio@11 2836 local f = CreateFrame ("frame", name, parent)
Tercio@11 2837 f:SetSize (w or 500, h or 400)
Tercio@11 2838 f:EnableMouse (true)
Tercio@11 2839 f:SetMovable (true)
Tercio@11 2840
Tercio@11 2841 f:SetScript ("OnMouseDown", chart_panel_mousedown)
Tercio@11 2842 f:SetScript ("OnMouseUp", chart_panel_mouseup)
Tercio@11 2843
Tercio@11 2844 f:SetBackdrop (chart_panel_backdrop)
Tercio@11 2845 f:SetBackdropColor (.3, .3, .3, .3)
Tercio@11 2846
Tercio@11 2847 local c = CreateFrame ("Button", nil, f, "UIPanelCloseButton")
Tercio@11 2848 c:SetWidth (32)
Tercio@11 2849 c:SetHeight (32)
Tercio@11 2850 c:SetPoint ("TOPRIGHT", f, "TOPRIGHT", -3, -7)
Tercio@11 2851 c:SetFrameLevel (f:GetFrameLevel()+1)
Tercio@11 2852 c:SetAlpha (0.9)
Tercio@11 2853 f.CloseButton = c
Tercio@11 2854
Tercio@11 2855 local title = DF:NewLabel (f, nil, "$parentTitle", "chart_title", "Chart!", nil, 20, {1, 1, 0})
Tercio@11 2856 title:SetPoint ("topleft", f, "topleft", 110, -13)
Tercio@11 2857
Tercio@11 2858 local bottom_texture = DF:NewImage (f, nil, 702, 25, "background", nil, nil, "$parentBottomTexture")
Tercio@39 2859 bottom_texture:SetColorTexture (0, 0, 0, .6)
Tercio@11 2860 bottom_texture:SetPoint ("bottomleft", f, "bottomleft", 8, 7)
Tercio@11 2861 bottom_texture:SetPoint ("bottomright", f, "bottomright", -8, 7)
Tercio@11 2862
Tercio@11 2863 f.Overlays = {}
Tercio@11 2864 f.OverlaysAmount = 1
Tercio@11 2865
Tercio@11 2866 f.BoxLabels = {}
Tercio@11 2867 f.BoxLabelsAmount = 1
Tercio@11 2868
Tercio@11 2869 f.TimeLabels = {}
Tercio@11 2870 for i = 1, 17 do
Tercio@11 2871 local time = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
Tercio@11 2872 time:SetText ("00:00")
Tercio@11 2873 time:SetPoint ("bottomleft", f, "bottomleft", 78 + ((i-1)*36), 13)
Tercio@11 2874 f.TimeLabels [i] = time
Tercio@11 2875
Tercio@11 2876 local line = f:CreateTexture (nil, "border")
Tercio@11 2877 line:SetSize (1, h-45)
Tercio@39 2878 line:SetColorTexture (1, 1, 1, .1)
Tercio@11 2879 line:SetPoint ("bottomleft", time, "topright", 0, -10)
Tercio@11 2880 line:Hide()
Tercio@11 2881 time.line = line
Tercio@11 2882 end
Tercio@11 2883
Tercio@11 2884 --graphic
Tercio@11 2885 local g = LibStub:GetLibrary("LibGraph-2.0"):CreateGraphLine (name .. "Graphic", f, "topleft","topleft", 108, -35, w - 120, h - 67)
Tercio@11 2886 g:SetXAxis (-1,1)
Tercio@11 2887 g:SetYAxis (-1,1)
Tercio@11 2888 g:SetGridSpacing (false, false)
Tercio@11 2889 g:SetGridColor ({0.5,0.5,0.5,0.3})
Tercio@11 2890 g:SetAxisDrawing (false,false)
Tercio@11 2891 g:SetAxisColor({1.0,1.0,1.0,1.0})
Tercio@11 2892 g:SetAutoScale (true)
Tercio@11 2893 g:SetLineTexture ("smallline")
Tercio@11 2894 g:SetBorderSize ("right", 0.001)
Tercio@11 2895 g:SetBorderSize ("left", 0.000)
Tercio@11 2896 g:SetBorderSize ("top", 0.002)
Tercio@11 2897 g:SetBorderSize ("bottom", 0.001)
Tercio@11 2898 g.VerticalLines = {}
Tercio@11 2899 g.max_value = 0
Tercio@11 2900
Tercio@11 2901 g:SetLineTexture ("line")
Tercio@11 2902
Tercio@11 2903 f.Graphic = g
Tercio@11 2904 f.GData = {}
Tercio@11 2905 f.OData = {}
Tercio@11 2906
Tercio@11 2907 --div lines
Tercio@11 2908 for i = 1, 8, 1 do
Tercio@11 2909 local line = g:CreateTexture (nil, "overlay")
Tercio@39 2910 line:SetColorTexture (1, 1, 1, .2)
Tercio@11 2911 line:SetWidth (670)
Tercio@11 2912 line:SetHeight (1.1)
Tercio@11 2913
Tercio@11 2914 local s = f:CreateFontString (nil, "overlay", "GameFontHighlightSmall")
Tercio@11 2915 f ["dpsamt"..i] = s
Tercio@11 2916 s:SetText ("100k")
Tercio@11 2917 s:SetPoint ("topleft", f, "topleft", 27, -61 + (-(24.6*i)))
Tercio@11 2918
Tercio@11 2919 line:SetPoint ("topleft", s, "bottom", -27, 0)
Tercio@11 2920 s.line = line
Tercio@11 2921 end
Tercio@11 2922
Tercio@11 2923 f.SetTime = chart_panel_align_timelabels
Tercio@11 2924 f.EnableVerticalLines = chart_panel_vlines_on
Tercio@11 2925 f.DisableVerticalLines = chart_panel_vlines_off
Tercio@11 2926 f.SetTitle = chart_panel_set_title
Tercio@11 2927 f.SetScale = chart_panel_set_scale
Tercio@11 2928 f.Reset = chart_panel_reset
Tercio@11 2929 f.AddLine = chart_panel_add_data
Tercio@11 2930 f.CanMove = chart_panel_can_move
Tercio@11 2931 f.AddLabel = chart_panel_add_label
Tercio@11 2932 f.AddOverlay = chart_panel_add_overlay
Tercio@11 2933 f.HideCloseButton = chart_panel_hide_close_button
Tercio@11 2934 f.RightClickClose = chart_panel_right_click_close
Tercio@11 2935
Tercio@11 2936 f:SetScript ("OnSizeChanged", chart_panel_onresize)
Tercio@11 2937 chart_panel_onresize (f)
Tercio@11 2938
Tercio@11 2939 return f
Tercio@20 2940 end
Tercio@20 2941
Tercio@20 2942 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@20 2943 -- ~gframe
Tercio@20 2944 local gframe_on_enter_line = function (self)
Tercio@20 2945 self:SetBackdropColor (0, 0, 0, 0)
Tercio@20 2946
Tercio@20 2947 local parent = self:GetParent()
Tercio@20 2948 local ball = self.ball
Tercio@20 2949 ball:SetBlendMode ("ADD")
Tercio@20 2950
Tercio@20 2951 local on_enter = parent._onenter_line
Tercio@20 2952 if (on_enter) then
Tercio@20 2953 return on_enter (self, parent)
Tercio@20 2954 end
Tercio@20 2955 end
Tercio@20 2956
Tercio@20 2957 local gframe_on_leave_line = function (self)
Tercio@20 2958 self:SetBackdropColor (0, 0, 0, .6)
Tercio@20 2959
Tercio@20 2960 local parent = self:GetParent()
Tercio@20 2961 local ball = self.ball
Tercio@20 2962 ball:SetBlendMode ("BLEND")
Tercio@20 2963
Tercio@20 2964 local on_leave = parent._onleave_line
Tercio@20 2965 if (on_leave) then
Tercio@20 2966 return on_leave (self, parent)
Tercio@20 2967 end
Tercio@20 2968 end
Tercio@20 2969
Tercio@20 2970 local gframe_create_line = function (self)
Tercio@20 2971 local index = #self._lines+1
Tercio@20 2972
Tercio@20 2973 local f = CreateFrame ("frame", nil, self)
Tercio@20 2974 self._lines [index] = f
Tercio@20 2975 f.id = index
Tercio@20 2976 f:SetScript ("OnEnter", gframe_on_enter_line)
Tercio@20 2977 f:SetScript ("OnLeave", gframe_on_leave_line)
Tercio@20 2978
Tercio@20 2979 f:SetWidth (self._linewidth)
Tercio@20 2980
Tercio@20 2981 if (index == 1) then
Tercio@20 2982 f:SetPoint ("topleft", self, "topleft")
Tercio@20 2983 f:SetPoint ("bottomleft", self, "bottomleft")
Tercio@20 2984 else
Tercio@20 2985 local previous_line = self._lines [index-1]
Tercio@20 2986 f:SetPoint ("topleft", previous_line, "topright")
Tercio@20 2987 f:SetPoint ("bottomleft", previous_line, "bottomright")
Tercio@20 2988 end
Tercio@20 2989
Tercio@20 2990 local t = f:CreateTexture (nil, "background")
Tercio@20 2991 t:SetWidth (1)
Tercio@20 2992 t:SetPoint ("topright", f, "topright")
Tercio@20 2993 t:SetPoint ("bottomright", f, "bottomright")
Tercio@39 2994 t:SetColorTexture (1, 1, 1, .1)
Tercio@20 2995 f.grid = t
Tercio@20 2996
Tercio@20 2997 local b = f:CreateTexture (nil, "overlay")
Tercio@20 2998 b:SetTexture ([[Interface\COMMON\Indicator-Yellow]])
Tercio@20 2999 b:SetSize (16, 16)
Tercio@20 3000 f.ball = b
Tercio@20 3001 local anchor = CreateFrame ("frame", nil, f)
Tercio@20 3002 anchor:SetAllPoints (b)
Tercio@20 3003 b.tooltip_anchor = anchor
Tercio@20 3004
Tercio@20 3005 local spellicon = f:CreateTexture (nil, "artwork")
Tercio@20 3006 spellicon:SetPoint ("bottom", b, "bottom", 0, 10)
Tercio@20 3007 spellicon:SetSize (16, 16)
Tercio@20 3008 f.spellicon = spellicon
Tercio@20 3009
Tercio@20 3010 local timeline = f:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@20 3011 timeline:SetPoint ("bottomright", f, "bottomright", -2, 0)
Tercio@40 3012 DF:SetFontSize (timeline, 8)
Tercio@20 3013 f.timeline = timeline
Tercio@20 3014
Tercio@20 3015 return f
Tercio@20 3016 end
Tercio@20 3017
Tercio@20 3018 local gframe_getline = function (self, index)
Tercio@20 3019 local line = self._lines [index]
Tercio@20 3020 if (not line) then
Tercio@20 3021 line = gframe_create_line (self)
Tercio@20 3022 end
Tercio@20 3023 return line
Tercio@20 3024 end
Tercio@20 3025
Tercio@20 3026 local gframe_reset = function (self)
Tercio@20 3027 for i, line in ipairs (self._lines) do
Tercio@20 3028 line:Hide()
Tercio@20 3029 end
Tercio@20 3030 if (self.GraphLib_Lines_Used) then
Tercio@20 3031 for i = #self.GraphLib_Lines_Used, 1, -1 do
Tercio@20 3032 local line = tremove (self.GraphLib_Lines_Used)
Tercio@20 3033 tinsert (self.GraphLib_Lines, line)
Tercio@20 3034 line:Hide()
Tercio@20 3035 end
Tercio@20 3036 end
Tercio@20 3037 end
Tercio@20 3038
Tercio@20 3039 local gframe_update = function (self, lines)
Tercio@20 3040
Tercio@20 3041 local g = LibStub:GetLibrary ("LibGraph-2.0")
Tercio@20 3042 local h = self:GetHeight()/100
Tercio@20 3043 local amtlines = #lines
Tercio@20 3044 local linewidth = self._linewidth
Tercio@20 3045
Tercio@20 3046 local max_value = 0
Tercio@20 3047 for i = 1, amtlines do
Tercio@20 3048 if (lines [i].value > max_value) then
Tercio@20 3049 max_value = lines [i].value
Tercio@20 3050 end
Tercio@20 3051 end
Tercio@20 3052
Tercio@40 3053 self.MaxValue = max_value
Tercio@40 3054
Tercio@20 3055 local o = 1
Tercio@20 3056 local lastvalue = self:GetHeight()/2
Tercio@40 3057 max_value = math.max (max_value, 0.0000001)
Tercio@20 3058
Tercio@20 3059 for i = 1, min (amtlines, self._maxlines) do
Tercio@20 3060
Tercio@20 3061 local data = lines [i]
Tercio@20 3062
Tercio@20 3063 local pvalue = data.value / max_value * 100
Tercio@20 3064 if (pvalue > 98) then
Tercio@20 3065 pvalue = 98
Tercio@20 3066 end
Tercio@20 3067 pvalue = pvalue * h
Tercio@20 3068
Tercio@20 3069 g:DrawLine (self, (o-1)*linewidth, lastvalue, o*linewidth, pvalue, linewidth, {1, 1, 1, 1}, "overlay")
Tercio@20 3070 lastvalue = pvalue
Tercio@20 3071
Tercio@20 3072 local line = self:GetLine (i)
Tercio@20 3073 line:Show()
Tercio@20 3074 line.ball:Show()
Tercio@20 3075
Tercio@20 3076 line.ball:SetPoint ("bottomleft", self, "bottomleft", (o*linewidth)-8, pvalue-8)
Tercio@20 3077 line.spellicon:SetTexture (nil)
Tercio@20 3078 line.timeline:SetText (data.text)
Tercio@20 3079 line.timeline:Show()
Tercio@20 3080
Tercio@20 3081 line.data = data
Tercio@20 3082
Tercio@20 3083 o = o + 1
Tercio@20 3084 end
Tercio@20 3085
Tercio@20 3086 end
Tercio@20 3087
Tercio@20 3088 function DF:CreateGFrame (parent, w, h, linewidth, onenter, onleave, member, name)
Tercio@20 3089 local f = CreateFrame ("frame", name, parent)
Tercio@20 3090 f:SetSize (w or 450, h or 150)
Tercio@20 3091 f.CustomLine = [[Interface\AddOns\Details\Libs\LibGraph-2.0\line]]
Tercio@20 3092
Tercio@20 3093 if (member) then
Tercio@20 3094 parent [member] = f
Tercio@20 3095 end
Tercio@20 3096
Tercio@20 3097 f.CreateLine = gframe_create_line
Tercio@20 3098 f.GetLine = gframe_getline
Tercio@20 3099 f.Reset = gframe_reset
Tercio@20 3100 f.UpdateLines = gframe_update
Tercio@20 3101
Tercio@40 3102 f.MaxValue = 0
Tercio@40 3103
Tercio@20 3104 f._lines = {}
Tercio@20 3105
Tercio@20 3106 f._onenter_line = onenter
Tercio@20 3107 f._onleave_line = onleave
Tercio@20 3108
Tercio@20 3109 f._linewidth = linewidth or 50
Tercio@20 3110 f._maxlines = floor (f:GetWidth() / f._linewidth)
Tercio@20 3111
Tercio@20 3112 return f
Tercio@39 3113 end
Tercio@39 3114
Tercio@39 3115
Tercio@39 3116 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@39 3117 -- ~buttoncontainer
Tercio@39 3118
Tercio@39 3119 function DF:CreateButtonContainer (parent, name)
Tercio@39 3120 local f = CreateFrame ("frame", name, parent)
Tercio@39 3121 -- f.
Tercio@39 3122 end
Tercio@39 3123
Tercio@39 3124
Tercio@39 3125 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@39 3126 --> options tabs and buttons -dot
Tercio@39 3127
Tercio@39 3128 function DF:FindHighestParent (self)
Tercio@39 3129 local f
Tercio@39 3130 if (self:GetParent() == UIParent) then
Tercio@39 3131 f = self
Tercio@39 3132 end
Tercio@39 3133 if (not f) then
Tercio@39 3134 f = self
Tercio@39 3135 for i = 1, 6 do
Tercio@39 3136 local parent = f:GetParent()
Tercio@39 3137 if (parent == UIParent) then
Tercio@39 3138 break
Tercio@39 3139 else
Tercio@39 3140 f = parent
Tercio@39 3141 end
Tercio@39 3142 end
Tercio@39 3143 end
Tercio@39 3144
Tercio@39 3145 return f
Tercio@39 3146 end
Tercio@39 3147
Tercio@39 3148 DF.TabContainerFunctions = {}
Tercio@39 3149
Tercio@39 3150 local button_tab_template = DF.table.copy ({}, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
Tercio@39 3151 button_tab_template.backdropbordercolor = nil
Tercio@39 3152
Tercio@39 3153 DF.TabContainerFunctions.CreateUnderlineGlow = function (button)
Tercio@39 3154 local selectedGlow = button:CreateTexture (nil, "background", -4)
Tercio@39 3155 selectedGlow:SetPoint ("topleft", button.widget, "bottomleft", -7, 0)
Tercio@39 3156 selectedGlow:SetPoint ("topright", button.widget, "bottomright", 7, 0)
Tercio@39 3157 selectedGlow:SetTexture ([[Interface\BUTTONS\UI-Panel-Button-Glow]])
Tercio@39 3158 selectedGlow:SetTexCoord (0, 95/128, 30/64, 38/64)
Tercio@39 3159 selectedGlow:SetBlendMode ("ADD")
Tercio@39 3160 selectedGlow:SetHeight (8)
Tercio@39 3161 selectedGlow:SetAlpha (.75)
Tercio@39 3162 selectedGlow:Hide()
Tercio@39 3163 button.selectedUnderlineGlow = selectedGlow
Tercio@39 3164 end
Tercio@39 3165
Tercio@39 3166 DF.TabContainerFunctions.OnMouseDown = function (self, button)
Tercio@39 3167 --> search for UIParent
Tercio@39 3168 local f = DF:FindHighestParent (self)
Tercio@39 3169 local container = self:GetParent()
Tercio@39 3170
Tercio@39 3171 if (button == "LeftButton") then
Tercio@39 3172 if (not f.IsMoving and f:IsMovable()) then
Tercio@39 3173 f:StartMoving()
Tercio@39 3174 f.IsMoving = true
Tercio@39 3175 end
Tercio@39 3176 elseif (button == "RightButton") then
Tercio@39 3177 if (not f.IsMoving and container.IsContainer) then
Tercio@39 3178 if (self.IsFrontPage) then
Tercio@39 3179 if (container.CanCloseWithRightClick) then
Tercio@39 3180 if (f.CloseFunction) then
Tercio@39 3181 f:CloseFunction()
Tercio@39 3182 else
Tercio@39 3183 f:Hide()
Tercio@39 3184 end
Tercio@39 3185 end
Tercio@39 3186 else
Tercio@39 3187 --goes back to front page
Tercio@39 3188 DF.TabContainerFunctions.SelectIndex (self, _, 1)
Tercio@39 3189 end
Tercio@39 3190 end
Tercio@39 3191 end
Tercio@39 3192 end
Tercio@39 3193
Tercio@39 3194 DF.TabContainerFunctions.OnMouseUp = function (self, button)
Tercio@39 3195 local f = DF:FindHighestParent (self)
Tercio@39 3196 if (f.IsMoving) then
Tercio@39 3197 f:StopMovingOrSizing()
Tercio@39 3198 f.IsMoving = false
Tercio@39 3199 end
Tercio@39 3200 end
Tercio@39 3201
Tercio@39 3202 DF.TabContainerFunctions.SelectIndex = function (self, fixedParam, menuIndex)
Tercio@39 3203 local mainFrame = self.AllFrames and self or self.mainFrame or self:GetParent()
Tercio@39 3204
Tercio@39 3205 for i = 1, #mainFrame.AllFrames do
Tercio@39 3206 mainFrame.AllFrames[i]:Hide()
Tercio@39 3207 if (mainFrame.ButtonNotSelectedBorderColor) then
Tercio@39 3208 mainFrame.AllButtons[i]:SetBackdropBorderColor (unpack (mainFrame.ButtonNotSelectedBorderColor))
Tercio@39 3209 end
Tercio@39 3210 if (mainFrame.AllButtons[i].selectedUnderlineGlow) then
Tercio@39 3211 mainFrame.AllButtons[i].selectedUnderlineGlow:Hide()
Tercio@39 3212 end
Tercio@39 3213 end
Tercio@39 3214
Tercio@39 3215 mainFrame.AllFrames[menuIndex]:Show()
Tercio@39 3216 if (mainFrame.ButtonSelectedBorderColor) then
Tercio@39 3217 mainFrame.AllButtons[menuIndex]:SetBackdropBorderColor (unpack (mainFrame.ButtonSelectedBorderColor))
Tercio@39 3218 end
Tercio@39 3219 if (mainFrame.AllButtons[menuIndex].selectedUnderlineGlow) then
Tercio@39 3220 mainFrame.AllButtons[menuIndex].selectedUnderlineGlow:Show()
Tercio@39 3221 end
Tercio@39 3222 mainFrame.CurrentIndex = menuIndex
Tercio@39 3223 end
Tercio@39 3224
Tercio@39 3225 DF.TabContainerFunctions.SetIndex = function (self, index)
Tercio@39 3226 self.CurrentIndex = index
Tercio@39 3227 end
Tercio@39 3228
Tercio@39 3229 local tab_container_on_show = function (self)
Tercio@39 3230 local index = self.CurrentIndex
Tercio@39 3231 self.SelectIndex (self.AllButtons[index], nil, index)
Tercio@39 3232 end
Tercio@39 3233
Tercio@39 3234 function DF:CreateTabContainer (parent, title, frame_name, frame_list, options_table)
Tercio@39 3235
Tercio@39 3236 local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
Tercio@39 3237 local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
Tercio@39 3238 local options_switch_template = DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
Tercio@39 3239 local options_slider_template = DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
Tercio@39 3240 local options_button_template = DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
Tercio@39 3241
Tercio@39 3242 options_table = options_table or {}
Tercio@39 3243 local frame_width = parent:GetWidth()
Tercio@39 3244 local frame_height = parent:GetHeight()
Tercio@39 3245 local y_offset = options_table.y_offset or 0
Tercio@39 3246 local button_width = options_table.button_width or 160
Tercio@39 3247 local button_height = options_table.button_height or 20
Tercio@39 3248 local button_anchor_x = options_table.button_x or 230
Tercio@39 3249 local button_anchor_y = options_table.button_y or -32
Tercio@39 3250 local button_text_size = options_table.button_text_size or 10
Tercio@39 3251
Tercio@39 3252 local mainFrame = CreateFrame ("frame", frame_name, parent.widget or parent)
Tercio@39 3253 mainFrame:SetAllPoints()
Tercio@39 3254 DF:Mixin (mainFrame, DF.TabContainerFunctions)
Tercio@39 3255
Tercio@39 3256 local mainTitle = DF:CreateLabel (mainFrame, title, 24, "white")
Tercio@39 3257 mainTitle:SetPoint ("topleft", mainFrame, "topleft", 10, -30 + y_offset)
Tercio@39 3258
Tercio@39 3259 mainFrame:SetFrameLevel (200)
Tercio@39 3260
Tercio@39 3261 mainFrame.AllFrames = {}
Tercio@39 3262 mainFrame.AllButtons = {}
Tercio@39 3263 mainFrame.CurrentIndex = 1
Tercio@39 3264 mainFrame.IsContainer = true
Tercio@39 3265 mainFrame.ButtonSelectedBorderColor = options_table.button_selected_border_color or {1, 1, 0, 1}
Tercio@39 3266 mainFrame.ButtonNotSelectedBorderColor = options_table.button_border_color or {0, 0, 0, 0}
Tercio@39 3267
Tercio@39 3268 if (options_table.right_click_interact ~= nil) then
Tercio@39 3269 mainFrame.CanCloseWithRightClick = options_table.right_click_interact
Tercio@39 3270 else
Tercio@39 3271 mainFrame.CanCloseWithRightClick = true
Tercio@39 3272 end
Tercio@39 3273
Tercio@39 3274 for i, frame in ipairs (frame_list) do
Tercio@39 3275 local f = CreateFrame ("frame", "$parent" .. frame.name, mainFrame)
Tercio@39 3276 f:SetAllPoints()
Tercio@39 3277 f:SetFrameLevel (210)
Tercio@39 3278 f:Hide()
Tercio@39 3279
Tercio@39 3280 local title = DF:CreateLabel (f, frame.title, 16, "silver")
Tercio@39 3281 title:SetPoint ("topleft", mainTitle, "bottomleft", 0, 0)
Tercio@39 3282
Tercio@39 3283 local tabButton = DF:CreateButton (mainFrame, DF.TabContainerFunctions.SelectIndex, button_width, button_height, frame.title, i, nil, nil, nil, nil, false, button_tab_template)
Tercio@39 3284 tabButton:SetFrameLevel (220)
Tercio@39 3285 tabButton.textsize = button_text_size
Tercio@39 3286 tabButton.mainFrame = mainFrame
Tercio@39 3287 DF.TabContainerFunctions.CreateUnderlineGlow (tabButton)
Tercio@39 3288
Tercio@39 3289 if (i == 1) then
Tercio@39 3290 local right_click_to_back = DF:CreateLabel (f, "right click to close", 10, "gray")
Tercio@39 3291 right_click_to_back:SetPoint ("bottomright", f, "bottomright", -1, 0)
Tercio@39 3292 f.IsFrontPage = true
Tercio@39 3293 else
Tercio@39 3294 local right_click_to_back = DF:CreateLabel (f, "right click to go back to main menu", 10, "gray")
Tercio@39 3295 right_click_to_back:SetPoint ("bottomright", f, "bottomright", -1, 0)
Tercio@39 3296 end
Tercio@39 3297
Tercio@39 3298 f:SetScript ("OnMouseDown", DF.TabContainerFunctions.OnMouseDown)
Tercio@39 3299 f:SetScript ("OnMouseUp", DF.TabContainerFunctions.OnMouseUp)
Tercio@39 3300
Tercio@39 3301 tinsert (mainFrame.AllFrames, f)
Tercio@39 3302 tinsert (mainFrame.AllButtons, tabButton)
Tercio@39 3303 end
Tercio@39 3304
Tercio@39 3305 --order buttons
Tercio@39 3306 local x = button_anchor_x
Tercio@39 3307 local y = button_anchor_y
Tercio@39 3308 local space_for_buttons = frame_width - (#frame_list*3) - button_anchor_x
Tercio@39 3309 local amount_buttons_per_row = floor (space_for_buttons / button_width)
Tercio@39 3310 local last_button = mainFrame.AllButtons[1]
Tercio@39 3311
Tercio@39 3312 mainFrame.AllButtons[1]:SetPoint ("topleft", mainTitle, "topleft", x, y)
Tercio@39 3313 x = x + button_width + 2
Tercio@39 3314
Tercio@39 3315 for i = 2, #mainFrame.AllButtons do
Tercio@39 3316 local button = mainFrame.AllButtons [i]
Tercio@39 3317 button:SetPoint ("topleft", mainTitle, "topleft", x, y)
Tercio@39 3318 x = x + button_width + 2
Tercio@39 3319
Tercio@39 3320 if (i % amount_buttons_per_row == 0) then
Tercio@39 3321 x = button_anchor_x
Tercio@39 3322 y = y - button_height - 1
Tercio@39 3323 end
Tercio@39 3324 end
Tercio@39 3325
Tercio@39 3326 --> when show the frame, reset to the current internal index
Tercio@39 3327 mainFrame:SetScript ("OnShow", tab_container_on_show)
Tercio@39 3328 --> select the first frame
Tercio@39 3329 mainFrame.SelectIndex (mainFrame.AllButtons[1], nil, 1)
Tercio@39 3330
Tercio@39 3331 return mainFrame
Tercio@39 3332 end
Tercio@39 3333
Tercio@39 3334
Tercio@39 3335
Tercio@39 3336
Tercio@39 3337
Tercio@40 3338 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@40 3339 -- ~listbox
Tercio@39 3340
Tercio@40 3341 local simple_list_box_ResetWidgets = function (self)
Tercio@40 3342 for _, widget in ipairs (self.widgets) do
Tercio@40 3343 widget:Hide()
Tercio@40 3344 end
Tercio@40 3345 self.nextWidget = 1
Tercio@40 3346 end
Tercio@39 3347
Tercio@40 3348 local simple_list_box_onenter = function (self, capsule)
Tercio@40 3349 self:GetParent().options.onenter (self, capsule, capsule.value)
Tercio@40 3350 end
Tercio@39 3351
Tercio@40 3352 local simple_list_box_onleave = function (self, capsule)
Tercio@40 3353 self:GetParent().options.onleave (self, capsule, capsule.value)
Tercio@40 3354 GameTooltip:Hide()
Tercio@40 3355 end
Tercio@39 3356
Tercio@40 3357 local simple_list_box_GetOrCreateWidget = function (self)
Tercio@40 3358 local index = self.nextWidget
Tercio@40 3359 local widget = self.widgets [index]
Tercio@40 3360 if (not widget) then
Tercio@40 3361 widget = DF:CreateButton (self, function()end, self.options.width, self.options.row_height, "", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
Tercio@40 3362 widget:SetHook ("OnEnter", simple_list_box_onenter)
Tercio@40 3363 widget:SetHook ("OnLeave", simple_list_box_onleave)
Tercio@40 3364 widget.textcolor = self.options.textcolor
Tercio@40 3365 tinsert (self.widgets, widget)
Tercio@40 3366 end
Tercio@40 3367 self.nextWidget = self.nextWidget + 1
Tercio@40 3368 return widget
Tercio@40 3369 end
Tercio@39 3370
Tercio@40 3371 local simple_list_box_RefreshWidgets = function (self)
Tercio@40 3372 self:ResetWidgets()
Tercio@40 3373 local amt = 0
Tercio@40 3374 for value, _ in pairs (self.list_table) do
Tercio@40 3375 local widget = self:GetOrCreateWidget()
Tercio@40 3376 widget:SetPoint ("topleft", self, "topleft", 1, -self.options.row_height * (self.nextWidget-2) - 4)
Tercio@40 3377 widget:SetPoint ("topright", self, "topright", -1, -self.options.row_height * (self.nextWidget-2) - 4)
Tercio@40 3378 widget:SetClickFunction (self.func, value)
Tercio@40 3379 widget.value = value
Tercio@40 3380
Tercio@40 3381 if (self.options.icon) then
Tercio@40 3382 if (type (self.options.icon) == "string" or type (self.options.icon) == "number") then
Tercio@40 3383 widget:SetIcon (self.options.icon, self.options.row_height, self.options.row_height)
Tercio@40 3384 elseif (type (self.options.icon) == "function") then
Tercio@40 3385 local icon = self.options.icon (value)
Tercio@40 3386 if (icon) then
Tercio@40 3387 widget:SetIcon (icon, self.options.row_height, self.options.row_height)
Tercio@40 3388 end
Tercio@40 3389 end
Tercio@40 3390 else
Tercio@40 3391 widget:SetIcon ("", self.options.row_height, self.options.row_height)
Tercio@40 3392 end
Tercio@40 3393
Tercio@40 3394 if (self.options.text) then
Tercio@40 3395 if (type (self.options.text) == "function") then
Tercio@40 3396 local text = self.options.text (value)
Tercio@40 3397 if (text) then
Tercio@40 3398 widget:SetText (text)
Tercio@40 3399 else
Tercio@40 3400 widget:SetText ("")
Tercio@40 3401 end
Tercio@40 3402 else
Tercio@40 3403 widget:SetText (self.options.text or "")
Tercio@40 3404 end
Tercio@40 3405 else
Tercio@40 3406 widget:SetText ("")
Tercio@40 3407 end
Tercio@40 3408
Tercio@40 3409 widget.value = value
Tercio@40 3410 widget:Show()
Tercio@40 3411 amt = amt + 1
Tercio@40 3412 end
Tercio@40 3413 if (amt == 0) then
Tercio@40 3414 self.EmptyLabel:Show()
Tercio@40 3415 else
Tercio@40 3416 self.EmptyLabel:Hide()
Tercio@40 3417 end
Tercio@40 3418 end
Tercio@39 3419
Tercio@40 3420 local backdrop = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1}
Tercio@40 3421 local default_options = {
Tercio@40 3422 height = 400,
Tercio@40 3423 row_height = 16,
Tercio@40 3424 width = 230,
Tercio@40 3425 icon = false,
Tercio@40 3426 text = "",
Tercio@40 3427 textcolor = "wheat",
Tercio@40 3428 onenter = function (self, capsule)
Tercio@40 3429 if (capsule) then
Tercio@40 3430 capsule.textcolor = "white"
Tercio@40 3431 end
Tercio@40 3432 end,
Tercio@40 3433 onleave = function (self, capsule)
Tercio@40 3434 if (capsule) then
Tercio@40 3435 capsule.textcolor = self:GetParent().options.textcolor
Tercio@40 3436 end
Tercio@40 3437 GameTooltip:Hide()
Tercio@40 3438 end,
Tercio@40 3439 }
Tercio@39 3440
Tercio@40 3441 local simple_list_box_SetData = function (self, t)
Tercio@40 3442 self.list_table = t
Tercio@40 3443 end
Tercio@40 3444
Tercio@40 3445 function DF:CreateSimpleListBox (parent, name, title, empty_text, list_table, onclick, options)
Tercio@40 3446 local f = CreateFrame ("frame", name, parent)
Tercio@40 3447
Tercio@40 3448 f.ResetWidgets = simple_list_box_ResetWidgets
Tercio@40 3449 f.GetOrCreateWidget = simple_list_box_GetOrCreateWidget
Tercio@40 3450 f.Refresh = simple_list_box_RefreshWidgets
Tercio@40 3451 f.SetData = simple_list_box_SetData
Tercio@40 3452 f.nextWidget = 1
Tercio@40 3453 f.list_table = list_table
Tercio@40 3454 f.func = function (self, button, value)
Tercio@40 3455 onclick (value)
Tercio@40 3456 f:Refresh()
Tercio@40 3457 end
Tercio@40 3458 f.widgets = {}
Tercio@40 3459 f:SetBackdrop (backdrop)
Tercio@40 3460 f:SetBackdropColor (0, 0, 0, 0.3)
Tercio@40 3461 f:SetBackdropBorderColor (0, 0, 0, 0.5)
Tercio@40 3462 f.options = options or {}
Tercio@40 3463 self.table.deploy (f.options, default_options)
Tercio@40 3464
Tercio@40 3465 f:SetSize (f.options.width + 2, f.options.height)
Tercio@40 3466
Tercio@40 3467 local name = DF:CreateLabel (f, title, 12, "silver")
Tercio@40 3468 name:SetTemplate (DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
Tercio@40 3469 name:SetPoint ("bottomleft", f, "topleft", 0, 2)
Tercio@40 3470 f.Title = name
Tercio@40 3471
Tercio@40 3472 local emptyLabel = DF:CreateLabel (f, empty_text, 12, "gray")
Tercio@40 3473 emptyLabel:SetAlpha (.6)
Tercio@40 3474 emptyLabel:SetSize (f.options.width-10, f.options.height)
Tercio@40 3475 emptyLabel:SetPoint ("center", 0, 0)
Tercio@40 3476 emptyLabel:Hide()
Tercio@40 3477 emptyLabel.align = "center"
Tercio@40 3478 f.EmptyLabel = emptyLabel
Tercio@40 3479
Tercio@40 3480 return f
Tercio@40 3481 end
Tercio@40 3482
Tercio@40 3483
Tercio@40 3484 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Tercio@40 3485 -- ~scrollbox
Tercio@40 3486
Tercio@40 3487
Tercio@40 3488 -- preciso de uma fauxscroll que seja facil de lidar
Tercio@40 3489 -- ele cria scroll aqui, preciso falar a função que cria a linha e a função que atualiza
Tercio@40 3490 -- precisa passsar o tamanho em height width quantas barras vai mostrar
Tercio@40 3491 -- search box incluso opcionalmente
Tercio@40 3492
Tercio@40 3493
Tercio@40 3494 DF.SortFunctions = {}
Tercio@40 3495
Tercio@40 3496 local SortMember = ""
Tercio@40 3497 local SortByMember = function (t1, t2)
Tercio@40 3498 return t1[SortMember] > t2[SortMember]
Tercio@40 3499 end
Tercio@40 3500 local SortByMemberReverse = function (t1, t2)
Tercio@40 3501 return t1[SortMember] < t2[SortMember]
Tercio@40 3502 end
Tercio@40 3503
Tercio@40 3504 DF.SortFunctions.Sort = function (self, t, by, is_reverse)
Tercio@40 3505 SortMember = by
Tercio@40 3506 if (not is_reverse) then
Tercio@40 3507 table.sort (t, SortByMember)
Tercio@40 3508 else
Tercio@40 3509 table.sort (t, SortByMemberReverse)
Tercio@40 3510 end
Tercio@40 3511 end
Tercio@40 3512
Tercio@40 3513
Tercio@40 3514 DF.ScrollBoxFunctions = {}
Tercio@40 3515
Tercio@40 3516 DF.ScrollBoxFunctions.Refresh = function (self)
Tercio@40 3517 for _, frame in ipairs (self.Frames) do
Tercio@40 3518 frame:Hide()
Tercio@40 3519 frame._InUse = nil
Tercio@40 3520 end
Tercio@40 3521
Tercio@40 3522 local offset = 0
Tercio@40 3523 if (self.IsFauxScroll) then
Tercio@40 3524 FauxScrollFrame_Update (self, #self.data, self.LineAmount, self.LineHeight+1)
Tercio@40 3525 offset = FauxScrollFrame_GetOffset (self)
Tercio@40 3526 end
Tercio@40 3527
Tercio@40 3528 local okay, totalLines = pcall (self.refresh_func, self, self.data, offset, #self.Frames)
Tercio@40 3529 if (not okay) then
Tercio@40 3530 error ("Details! FrameWork: Refresh(): " .. totalLines)
Tercio@40 3531 end
Tercio@40 3532
Tercio@40 3533 for _, frame in ipairs (self.Frames) do
Tercio@40 3534 if (not frame._InUse) then
Tercio@40 3535 frame:Hide()
Tercio@40 3536 else
Tercio@40 3537 frame:Show()
Tercio@40 3538 end
Tercio@40 3539 end
Tercio@40 3540
Tercio@40 3541 self:Show()
Tercio@40 3542
Tercio@40 3543 return self.Frames
Tercio@40 3544 end
Tercio@40 3545
Tercio@40 3546 DF.ScrollBoxFunctions.OnVerticalScroll = function (self, offset)
Tercio@40 3547 FauxScrollFrame_OnVerticalScroll (self, offset, self.LineHeight, self.Refresh)
Tercio@40 3548 return true
Tercio@40 3549 end
Tercio@40 3550
Tercio@40 3551 DF.ScrollBoxFunctions.CreateLine = function (self, func)
Tercio@40 3552 local okay, newLine = pcall (func, self, #self.Frames+1)
Tercio@40 3553 if (okay) then
Tercio@40 3554 tinsert (self.Frames, newLine)
Tercio@40 3555 return newLine
Tercio@40 3556 else
Tercio@40 3557 error ("Details! FrameWork: CreateLine(): " .. newLine)
Tercio@40 3558 end
Tercio@40 3559 end
Tercio@40 3560
Tercio@40 3561 DF.ScrollBoxFunctions.GetLine = function (self, line_index)
Tercio@40 3562 local line = self.Frames [line_index]
Tercio@40 3563 if (line) then
Tercio@40 3564 line._InUse = true
Tercio@40 3565 end
Tercio@40 3566 return line
Tercio@40 3567 end
Tercio@40 3568
Tercio@40 3569 DF.ScrollBoxFunctions.SetData = function (self, data)
Tercio@40 3570 self.data = data
Tercio@40 3571 end
Tercio@40 3572 DF.ScrollBoxFunctions.GetData = function (self)
Tercio@40 3573 return self.data
Tercio@40 3574 end
Tercio@40 3575
Tercio@40 3576 function DF:CreateScrollBox (parent, name, refresh_func, data, width, height, line_amount, line_height)
Tercio@40 3577 local scroll = CreateFrame ("scrollframe", name, parent, "FauxScrollFrameTemplate")
Tercio@40 3578
Tercio@40 3579 scroll:SetSize (width, height)
Tercio@40 3580 scroll.LineAmount = line_amount
Tercio@40 3581 scroll.LineHeight = line_height
Tercio@40 3582 scroll.IsFauxScroll = true
Tercio@40 3583 scroll.Frames = {}
Tercio@40 3584
Tercio@40 3585 DF:Mixin (scroll, DF.SortFunctions)
Tercio@40 3586 DF:Mixin (scroll, DF.ScrollBoxFunctions)
Tercio@40 3587
Tercio@40 3588 scroll.refresh_func = refresh_func
Tercio@40 3589 scroll.data = data
Tercio@40 3590
Tercio@40 3591 scroll:SetScript ("OnVerticalScroll", scroll.OnVerticalScroll)
Tercio@40 3592
Tercio@40 3593 return scroll
Tercio@40 3594 end
Tercio@40 3595
Tercio@40 3596
Tercio@40 3597