Skip to content

Commit

Permalink
Lib Up
Browse files Browse the repository at this point in the history
  • Loading branch information
Zariel committed Oct 30, 2008
1 parent 8744d02 commit d36a5ff
Showing 1 changed file with 47 additions and 24 deletions.
71 changes: 47 additions & 24 deletions lib/AceGUI-3.0/widgets/AceGUIWidget-TreeGroup.lua
Expand Up @@ -27,7 +27,7 @@ end

do
local Type = "TreeGroup"
local Version = 16
local Version = 17

local DEFAULT_TREE_WIDTH = 175
local DEFAULT_TREE_SIZABLE = true
Expand Down Expand Up @@ -286,41 +286,61 @@ do
},
}
]]
local function SetTree(self, tree)
local function SetTree(self, tree, filter)
self.filter = filter
if tree then
assert(type(tree) == "table")
end
self.tree = tree
self:RefreshTree()
end

local function ShouldDisplayLevel(tree)
local result = false
for k, v in ipairs(tree) do
if v.children == nil and v.visible ~= false then
result = true
elseif v.children then
result = result or ShouldDisplayLevel(v.children)
end
if result then return result end
end
return false
end

local function addLine(self, v, tree, level, parent)
local line = new()
line.value = v.value
line.text = v.text
line.disabled = v.disabled
line.tree = tree
line.level = level
line.parent = parent
line.visible = v.visible
line.uniquevalue = GetButtonUniqueValue(line)
if v.children then
line.hasChildren = true
else
line.hasChildren = nil
end
self.lines[#self.lines+1] = line
return line
end

local function BuildLevel(self, tree, level, parent)
local lines = self.lines

local status = (self.status or self.localstatus)
local groups = status.groups
local groups = (self.status or self.localstatus).groups
local hasChildren = self.hasChildren

for i, v in ipairs(tree) do
local line = new()
lines[#lines+1] = line
line.value = v.value
line.text = v.text
line.disabled = v.disabled
line.tree = tree
line.level = level
line.parent = parent
line.uniquevalue = GetButtonUniqueValue(line)

if v.children then
line.hasChildren = true
else
line.hasChildren = nil
end
if v.children then
if groups[line.uniquevalue] then
self:BuildLevel(v.children, level+1, line)
if not self.filter or ShouldDisplayLevel(v.children) then
local line = addLine(self, v, tree, level, parent)
if groups[line.uniquevalue] then
self:BuildLevel(v.children, level+1, line)
end
end
elseif v.visible ~= false or not self.filter then
addLine(self, v, tree, level, parent)
end
end
end
Expand All @@ -337,7 +357,7 @@ do
end

local function RefreshTree(self)
local buttons = self.buttons
local buttons = self.buttons
local lines = self.lines

for i, v in ipairs(buttons) do
Expand Down Expand Up @@ -436,6 +456,7 @@ do
end

local function Select(self, uniquevalue, ...)
self.filter = false
local status = self.status or self.localstatus
local groups = status.groups
for i = 1, select('#', ...) do
Expand Down Expand Up @@ -577,6 +598,7 @@ do
self.hasChildren = {}
self.localstatus = {}
self.localstatus.groups = {}
self.filter = false

local treeframe = CreateFrame("Frame",nil,frame)
treeframe.obj = self
Expand Down Expand Up @@ -626,6 +648,7 @@ do
self.OnWidthSet = OnWidthSet
self.OnHeightSet = OnHeightSet
self.EnableButtonTooltips = EnableButtonTooltips
self.Filter = Filter

self.frame = frame
frame.obj = self
Expand Down

0 comments on commit d36a5ff

Please sign in to comment.