Mercurial > wow > askmrrobot
comparison Libs/AceGUI-3.0/widgets/AceGUIContainer-TreeGroup.lua @ 124:e31b02b24488
Updated for 8.0 pre-patch and BfA.
author | yellowfive |
---|---|
date | Tue, 17 Jul 2018 09:57:39 -0700 |
parents | e635cd648e01 |
children |
comparison
equal
deleted
inserted
replaced
123:7a6364917f86 | 124:e31b02b24488 |
---|---|
1 --[[----------------------------------------------------------------------------- | 1 --[[----------------------------------------------------------------------------- |
2 TreeGroup Container | 2 TreeGroup Container |
3 Container that uses a tree control to switch between groups. | 3 Container that uses a tree control to switch between groups. |
4 -------------------------------------------------------------------------------]] | 4 -------------------------------------------------------------------------------]] |
5 local Type, Version = "TreeGroup", 40 | 5 local Type, Version = "TreeGroup", 41 |
6 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) | 6 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) |
7 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end | 7 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end |
8 | |
9 local WoW80 = select(4, GetBuildInfo()) >= 80000 | |
8 | 10 |
9 -- Lua APIs | 11 -- Lua APIs |
10 local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type | 12 local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type |
11 local math_min, math_max, floor = math.min, math.max, floor | 13 local math_min, math_max, floor = math.min, math.max, floor |
12 local select, tremove, unpack, tconcat = select, table.remove, unpack, table.concat | 14 local select, tremove, unpack, tconcat = select, table.remove, unpack, table.concat |
160 | 162 |
161 --fire an update after one frame to catch the treeframes height | 163 --fire an update after one frame to catch the treeframes height |
162 local function FirstFrameUpdate(frame) | 164 local function FirstFrameUpdate(frame) |
163 local self = frame.obj | 165 local self = frame.obj |
164 frame:SetScript("OnUpdate", nil) | 166 frame:SetScript("OnUpdate", nil) |
165 self:RefreshTree() | 167 self:RefreshTree(nil, true) |
166 end | 168 end |
167 | 169 |
168 local function BuildUniqueValue(...) | 170 local function BuildUniqueValue(...) |
169 local n = select('#', ...) | 171 local n = select('#', ...) |
170 if n == 1 then | 172 if n == 1 then |
298 self.frame:SetScript("OnUpdate", FirstFrameUpdate) | 300 self.frame:SetScript("OnUpdate", FirstFrameUpdate) |
299 end, | 301 end, |
300 | 302 |
301 ["OnRelease"] = function(self) | 303 ["OnRelease"] = function(self) |
302 self.status = nil | 304 self.status = nil |
305 self.tree = nil | |
306 self.frame:SetScript("OnUpdate", nil) | |
303 for k, v in pairs(self.localstatus) do | 307 for k, v in pairs(self.localstatus) do |
304 if k == "groups" then | 308 if k == "groups" then |
305 for k2 in pairs(v) do | 309 for k2 in pairs(v) do |
306 v[k2] = nil | 310 v[k2] = nil |
307 end | 311 end |
386 addLine(self, v, tree, level, parent) | 390 addLine(self, v, tree, level, parent) |
387 end | 391 end |
388 end | 392 end |
389 end, | 393 end, |
390 | 394 |
391 ["RefreshTree"] = function(self,scrollToSelection) | 395 ["RefreshTree"] = function(self,scrollToSelection,fromOnUpdate) |
392 local buttons = self.buttons | 396 local buttons = self.buttons |
393 local lines = self.lines | 397 local lines = self.lines |
394 | 398 |
395 for i, v in ipairs(buttons) do | 399 for i, v in ipairs(buttons) do |
396 v:Hide() | 400 v:Hide() |
397 end | 401 end |
417 | 421 |
418 local numlines = #lines | 422 local numlines = #lines |
419 | 423 |
420 local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18)) | 424 local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18)) |
421 if maxlines <= 0 then return end | 425 if maxlines <= 0 then return end |
426 | |
427 -- workaround for lag spikes on WoW 8.0 | |
428 if WoW80 and self.frame:GetParent() == UIParent and not fromOnUpdate then | |
429 self.frame:SetScript("OnUpdate", FirstFrameUpdate) | |
430 return | |
431 end | |
422 | 432 |
423 local first, last | 433 local first, last |
424 | 434 |
425 scrollToSelection = status.scrollToSelection | 435 scrollToSelection = status.scrollToSelection |
426 status.scrollToSelection = nil | 436 status.scrollToSelection = nil |