Asa@0: local AceGUI = LibStub("AceGUI-3.0") Asa@0: Asa@0: -- Lua APIs Asa@0: local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type Asa@0: local math_min, math_max, floor = math.min, math.max, floor Asa@0: local select, tremove, unpack = select, table.remove, unpack Asa@0: Asa@0: -- WoW APIs Asa@0: local CreateFrame, UIParent = CreateFrame, UIParent Asa@0: Asa@0: -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded Asa@0: -- List them here for Mikk's FindGlobals script Asa@0: -- GLOBALS: GameTooltip, FONT_COLOR_CODE_CLOSE Asa@0: Asa@0: -- Recycling functions Asa@0: local new, del Asa@0: do Asa@0: local pool = setmetatable({},{__mode='k'}) Asa@0: function new() Asa@0: local t = next(pool) Asa@0: if t then Asa@0: pool[t] = nil Asa@0: return t Asa@0: else Asa@0: return {} Asa@0: end Asa@0: end Asa@0: function del(t) Asa@0: for k in pairs(t) do Asa@0: t[k] = nil Asa@0: end Asa@0: pool[t] = true Asa@0: end Asa@0: end Asa@0: Asa@0: -------------- Asa@0: -- TreeView -- Asa@0: -------------- Asa@0: Asa@0: do Asa@0: local Type = "TreeGroup" Asa@0: local Version = 23 Asa@0: Asa@0: local DEFAULT_TREE_WIDTH = 175 Asa@0: local DEFAULT_TREE_SIZABLE = true Asa@0: Asa@0: local PaneBackdrop = { Asa@0: bgFile = "Interface\\ChatFrame\\ChatFrameBackground", Asa@0: edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", Asa@0: tile = true, tileSize = 16, edgeSize = 16, Asa@0: insets = { left = 3, right = 3, top = 5, bottom = 3 } Asa@0: } Asa@0: Asa@0: local DraggerBackdrop = { Asa@0: bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", Asa@0: edgeFile = nil, Asa@0: tile = true, tileSize = 16, edgeSize = 0, Asa@0: insets = { left = 3, right = 3, top = 7, bottom = 7 } Asa@0: } Asa@0: Asa@0: local function OnAcquire(self) Asa@0: self:SetTreeWidth(DEFAULT_TREE_WIDTH,DEFAULT_TREE_SIZABLE) Asa@0: self:EnableButtonTooltips(true) Asa@0: end Asa@0: Asa@0: local function OnRelease(self) Asa@0: Asa@0: self.frame:ClearAllPoints() Asa@0: self.frame:Hide() Asa@0: self.status = nil Asa@0: for k, v in pairs(self.localstatus) do Asa@0: if k == "groups" then Asa@0: for k2 in pairs(v) do Asa@0: v[k2] = nil Asa@0: end Asa@0: else Asa@0: self.localstatus[k] = nil Asa@0: end Asa@0: end Asa@0: self.localstatus.scrollvalue = 0 Asa@0: self.localstatus.treewidth = DEFAULT_TREE_WIDTH Asa@0: self.localstatus.treesizable = DEFAULT_TREE_SIZABLE Asa@0: end Asa@0: Asa@0: local function GetButtonParents(line) Asa@0: local parent = line.parent Asa@0: if parent and parent.value then Asa@0: return parent.value, GetButtonParents(parent) Asa@0: end Asa@0: end Asa@0: Asa@0: local function GetButtonUniqueValue(line) Asa@0: local parent = line.parent Asa@0: if parent and parent.value then Asa@0: return GetButtonUniqueValue(parent).."\001"..line.value Asa@0: else Asa@0: return line.value Asa@0: end Asa@0: end Asa@0: Asa@0: local function ButtonOnClick(this) Asa@0: local self = this.obj Asa@0: self:Fire("OnClick",this.uniquevalue, this.selected) Asa@0: if not this.selected then Asa@0: self:SetSelected(this.uniquevalue) Asa@0: this.selected = true Asa@0: this:LockHighlight() Asa@0: self:RefreshTree() Asa@0: end Asa@0: AceGUI:ClearFocus() Asa@0: end Asa@0: Asa@0: local function ExpandOnClick(this) Asa@0: local button = this.button Asa@0: local self = button.obj Asa@0: local status = (self.status or self.localstatus).groups Asa@0: status[button.uniquevalue] = not status[button.uniquevalue] Asa@0: self:RefreshTree() Asa@0: end Asa@0: Asa@0: local function ButtonOnDoubleClick(button) Asa@0: local self = button.obj Asa@0: local status = self.status or self.localstatus Asa@0: local status = (self.status or self.localstatus).groups Asa@0: status[button.uniquevalue] = not status[button.uniquevalue] Asa@0: self:RefreshTree() Asa@0: end Asa@0: Asa@0: local function EnableButtonTooltips(self, enable) Asa@0: self.enabletooltips = enable Asa@0: end Asa@0: Asa@0: local function Button_OnEnter(this) Asa@0: local self = this.obj Asa@0: self:Fire("OnButtonEnter", this.uniquevalue, this) Asa@0: Asa@0: if self.enabletooltips then Asa@0: GameTooltip:SetOwner(this, "ANCHOR_NONE") Asa@0: GameTooltip:SetPoint("LEFT",this,"RIGHT") Asa@0: GameTooltip:SetText(this.text:GetText() or "", 1, .82, 0, 1) Asa@0: Asa@0: GameTooltip:Show() Asa@0: end Asa@0: end Asa@0: Asa@0: local function Button_OnLeave(this) Asa@0: local self = this.obj Asa@0: self:Fire("OnButtonLeave", this.uniquevalue, this) Asa@0: Asa@0: if self.enabletooltips then Asa@0: GameTooltip:Hide() Asa@0: end Asa@0: end Asa@0: Asa@0: Asa@0: local buttoncount = 1 Asa@0: local function CreateButton(self) Asa@0: local button = CreateFrame("Button",("AceGUI30TreeButton%d"):format(buttoncount),self.treeframe, "OptionsListButtonTemplate") Asa@0: buttoncount = buttoncount + 1 Asa@0: button.obj = self Asa@0: Asa@0: local icon = button:CreateTexture(nil, "OVERLAY") Asa@0: icon:SetWidth(14) Asa@0: icon:SetHeight(14) Asa@0: button.icon = icon Asa@0: Asa@0: button:SetScript("OnClick",ButtonOnClick) Asa@0: button:SetScript("OnDoubleClick", ButtonOnDoubleClick) Asa@0: button:SetScript("OnEnter",Button_OnEnter) Asa@0: button:SetScript("OnLeave",Button_OnLeave) Asa@0: Asa@0: button.toggle.button = button Asa@0: button.toggle:SetScript("OnClick",ExpandOnClick) Asa@0: Asa@0: return button Asa@0: end Asa@0: Asa@0: local function UpdateButton(button, treeline, selected, canExpand, isExpanded) Asa@0: local self = button.obj Asa@0: local toggle = button.toggle Asa@0: local frame = self.frame Asa@0: local text = treeline.text or "" Asa@0: local icon = treeline.icon Asa@0: local iconCoords = treeline.iconCoords Asa@0: local level = treeline.level Asa@0: local value = treeline.value Asa@0: local uniquevalue = treeline.uniquevalue Asa@0: local disabled = treeline.disabled Asa@0: Asa@0: button.treeline = treeline Asa@0: button.value = value Asa@0: button.uniquevalue = uniquevalue Asa@0: if selected then Asa@0: button:LockHighlight() Asa@0: button.selected = true Asa@0: else Asa@0: button:UnlockHighlight() Asa@0: button.selected = false Asa@0: end Asa@0: local normalTexture = button:GetNormalTexture() Asa@0: local line = button.line Asa@0: button.level = level Asa@0: if ( level == 1 ) then Asa@0: button:SetNormalFontObject("GameFontNormal") Asa@0: button:SetHighlightFontObject("GameFontHighlight") Asa@0: button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2) Asa@0: else Asa@0: button:SetNormalFontObject("GameFontHighlightSmall") Asa@0: button:SetHighlightFontObject("GameFontHighlightSmall") Asa@0: button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2) Asa@0: end Asa@0: Asa@0: if disabled then Asa@0: button:EnableMouse(false) Asa@0: button.text:SetText("|cff808080"..text..FONT_COLOR_CODE_CLOSE) Asa@0: else Asa@0: button.text:SetText(text) Asa@0: button:EnableMouse(true) Asa@0: end Asa@0: Asa@0: if icon then Asa@0: button.icon:SetTexture(icon) Asa@0: button.icon:SetPoint("LEFT", button, "LEFT", 8 * level, (level == 1) and 0 or 1) Asa@0: else Asa@0: button.icon:SetTexture(nil) Asa@0: end Asa@0: Asa@0: if iconCoords then Asa@0: button.icon:SetTexCoord(unpack(iconCoords)) Asa@0: else Asa@0: button.icon:SetTexCoord(0, 1, 0, 1) Asa@0: end Asa@0: Asa@0: if canExpand then Asa@0: if not isExpanded then Asa@0: toggle:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-UP") Asa@0: toggle:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-DOWN") Asa@0: else Asa@0: toggle:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP") Asa@0: toggle:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN") Asa@0: end Asa@0: toggle:Show() Asa@0: else Asa@0: toggle:Hide() Asa@0: end Asa@0: end Asa@0: Asa@0: Asa@0: local function OnScrollValueChanged(this, value) Asa@0: if this.obj.noupdate then return end Asa@0: local self = this.obj Asa@0: local status = self.status or self.localstatus Asa@0: status.scrollvalue = value Asa@0: self:RefreshTree() Asa@0: AceGUI:ClearFocus() Asa@0: end Asa@0: Asa@0: -- called to set an external table to store status in Asa@0: local function SetStatusTable(self, status) Asa@0: assert(type(status) == "table") Asa@0: self.status = status Asa@0: if not status.groups then Asa@0: status.groups = {} Asa@0: end Asa@0: if not status.scrollvalue then Asa@0: status.scrollvalue = 0 Asa@0: end Asa@0: if not status.treewidth then Asa@0: status.treewidth = DEFAULT_TREE_WIDTH Asa@0: end Asa@0: if not status.treesizable then Asa@0: status.treesizable = DEFAULT_TREE_SIZABLE Asa@0: end Asa@0: self:SetTreeWidth(status.treewidth,status.treesizable) Asa@0: self:RefreshTree() Asa@0: end Asa@0: Asa@0: --sets the tree to be displayed Asa@0: --[[ Asa@0: example tree Asa@0: Asa@0: Alpha Asa@0: Bravo Asa@0: -Charlie Asa@0: -Delta Asa@0: -Echo Asa@0: Foxtrot Asa@0: Asa@0: tree = { Asa@0: { Asa@0: value = "A", Asa@0: text = "Alpha" Asa@0: }, Asa@0: { Asa@0: value = "B", Asa@0: text = "Bravo", Asa@0: children = { Asa@0: { Asa@0: value = "C", Asa@0: text = "Charlie" Asa@0: }, Asa@0: { Asa@0: value = "D", Asa@0: text = "Delta" Asa@0: children = { Asa@0: { Asa@0: value = "E", Asa@0: text = "Echo" Asa@0: } Asa@0: } Asa@0: } Asa@0: } Asa@0: }, Asa@0: { Asa@0: value = "F", Asa@0: text = "Foxtrot" Asa@0: }, Asa@0: } Asa@0: ]] Asa@0: local function SetTree(self, tree, filter) Asa@0: self.filter = filter Asa@0: if tree then Asa@0: assert(type(tree) == "table") Asa@0: end Asa@0: self.tree = tree Asa@0: self:RefreshTree() Asa@0: end Asa@0: Asa@0: local function ShouldDisplayLevel(tree) Asa@0: local result = false Asa@0: for k, v in ipairs(tree) do Asa@0: if v.children == nil and v.visible ~= false then Asa@0: result = true Asa@0: elseif v.children then Asa@0: result = result or ShouldDisplayLevel(v.children) Asa@0: end Asa@0: if result then return result end Asa@0: end Asa@0: return false Asa@0: end Asa@0: Asa@0: local function addLine(self, v, tree, level, parent) Asa@0: local line = new() Asa@0: line.value = v.value Asa@0: line.text = v.text Asa@0: line.icon = v.icon Asa@0: line.iconCoords = v.iconCoords Asa@0: line.disabled = v.disabled Asa@0: line.tree = tree Asa@0: line.level = level Asa@0: line.parent = parent Asa@0: line.visible = v.visible Asa@0: line.uniquevalue = GetButtonUniqueValue(line) Asa@0: if v.children then Asa@0: line.hasChildren = true Asa@0: else Asa@0: line.hasChildren = nil Asa@0: end Asa@0: self.lines[#self.lines+1] = line Asa@0: return line Asa@0: end Asa@0: Asa@0: local function BuildLevel(self, tree, level, parent) Asa@0: local groups = (self.status or self.localstatus).groups Asa@0: local hasChildren = self.hasChildren Asa@0: Asa@0: for i, v in ipairs(tree) do Asa@0: if v.children then Asa@0: if not self.filter or ShouldDisplayLevel(v.children) then Asa@0: local line = addLine(self, v, tree, level, parent) Asa@0: if groups[line.uniquevalue] then Asa@0: self:BuildLevel(v.children, level+1, line) Asa@0: end Asa@0: end Asa@0: elseif v.visible ~= false or not self.filter then Asa@0: addLine(self, v, tree, level, parent) Asa@0: end Asa@0: end Asa@0: end Asa@0: Asa@0: --fire an update after one frame to catch the treeframes height Asa@0: local function FirstFrameUpdate(this) Asa@0: local self = this.obj Asa@0: this:SetScript("OnUpdate",nil) Asa@0: self:RefreshTree() Asa@0: end Asa@0: Asa@0: local function ResizeUpdate(this) Asa@0: this.obj:RefreshTree() Asa@0: end Asa@0: Asa@0: local function RefreshTree(self) Asa@0: local buttons = self.buttons Asa@0: local lines = self.lines Asa@0: Asa@0: for i, v in ipairs(buttons) do Asa@0: v:Hide() Asa@0: end Asa@0: while lines[1] do Asa@0: local t = tremove(lines) Asa@0: for k in pairs(t) do Asa@0: t[k] = nil Asa@0: end Asa@0: del(t) Asa@0: end Asa@0: Asa@0: if not self.tree then return end Asa@0: --Build the list of visible entries from the tree and status tables Asa@0: local status = self.status or self.localstatus Asa@0: local groupstatus = status.groups Asa@0: local tree = self.tree Asa@0: Asa@0: local treeframe = self.treeframe Asa@0: Asa@0: self:BuildLevel(tree, 1) Asa@0: Asa@0: local numlines = #lines Asa@0: Asa@0: local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18)) Asa@0: Asa@0: local first, last Asa@0: Asa@0: if numlines <= maxlines then Asa@0: --the whole tree fits in the frame Asa@0: status.scrollvalue = 0 Asa@0: self:ShowScroll(false) Asa@0: first, last = 1, numlines Asa@0: else Asa@0: self:ShowScroll(true) Asa@0: --scrolling will be needed Asa@0: self.noupdate = true Asa@0: self.scrollbar:SetMinMaxValues(0, numlines - maxlines) Asa@0: --check if we are scrolled down too far Asa@0: if numlines - status.scrollvalue < maxlines then Asa@0: status.scrollvalue = numlines - maxlines Asa@0: self.scrollbar:SetValue(status.scrollvalue) Asa@0: end Asa@0: self.noupdate = nil Asa@0: first, last = status.scrollvalue+1, status.scrollvalue + maxlines Asa@0: end Asa@0: Asa@0: local buttonnum = 1 Asa@0: for i = first, last do Asa@0: local line = lines[i] Asa@0: local button = buttons[buttonnum] Asa@0: if not button then Asa@0: button = self:CreateButton() Asa@0: Asa@0: buttons[buttonnum] = button Asa@0: button:SetParent(treeframe) Asa@0: button:SetFrameLevel(treeframe:GetFrameLevel()+1) Asa@0: button:ClearAllPoints() Asa@0: if i == 1 then Asa@0: if self.showscroll then Asa@0: button:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",-22,-10) Asa@0: button:SetPoint("TOPLEFT", self.treeframe, "TOPLEFT", 0, -10) Asa@0: else Asa@0: button:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",0,-10) Asa@0: button:SetPoint("TOPLEFT", self.treeframe, "TOPLEFT", 0, -10) Asa@0: end Asa@0: else Asa@0: button:SetPoint("TOPRIGHT", buttons[buttonnum-1], "BOTTOMRIGHT",0,0) Asa@0: button:SetPoint("TOPLEFT", buttons[buttonnum-1], "BOTTOMLEFT",0,0) Asa@0: end Asa@0: end Asa@0: Asa@0: UpdateButton(button, line, status.selected == line.uniquevalue, line.hasChildren, groupstatus[line.uniquevalue] ) Asa@0: button:Show() Asa@0: buttonnum = buttonnum + 1 Asa@0: end Asa@0: Asa@0: end Asa@0: Asa@0: local function SetSelected(self, value) Asa@0: local status = self.status or self.localstatus Asa@0: if status.selected ~= value then Asa@0: status.selected = value Asa@0: self:Fire("OnGroupSelected", value) Asa@0: end Asa@0: end Asa@0: Asa@0: local function BuildUniqueValue(...) Asa@0: local n = select('#', ...) Asa@0: if n == 1 then Asa@0: return ... Asa@0: else Asa@0: return (...).."\001"..BuildUniqueValue(select(2,...)) Asa@0: end Asa@0: end Asa@0: Asa@0: local function Select(self, uniquevalue, ...) Asa@0: self.filter = false Asa@0: local status = self.status or self.localstatus Asa@0: local groups = status.groups Asa@0: for i = 1, select('#', ...) do Asa@0: groups[BuildUniqueValue(select(i, ...))] = true Asa@0: end Asa@0: status.selected = uniquevalue Asa@0: self:RefreshTree() Asa@0: self:Fire("OnGroupSelected", uniquevalue) Asa@0: end Asa@0: Asa@0: local function SelectByPath(self, ...) Asa@0: self:Select(BuildUniqueValue(...), ...) Asa@0: end Asa@0: Asa@0: --Selects a tree node by UniqueValue Asa@0: local function SelectByValue(self, uniquevalue) Asa@0: self:Select(uniquevalue, ("\001"):split(uniquevalue)) Asa@0: end Asa@0: Asa@0: Asa@0: local function ShowScroll(self, show) Asa@0: self.showscroll = show Asa@0: if show then Asa@0: self.scrollbar:Show() Asa@0: if self.buttons[1] then Asa@0: self.buttons[1]:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",-22,-10) Asa@0: end Asa@0: else Asa@0: self.scrollbar:Hide() Asa@0: if self.buttons[1] then Asa@0: self.buttons[1]:SetPoint("TOPRIGHT", self.treeframe,"TOPRIGHT",0,-10) Asa@0: end Asa@0: end Asa@0: end Asa@0: Asa@0: local function OnWidthSet(self, width) Asa@0: local content = self.content Asa@0: local treeframe = self.treeframe Asa@0: local status = self.status or self.localstatus Asa@0: status.fullwidth = width Asa@0: Asa@0: local contentwidth = width - status.treewidth - 20 Asa@0: if contentwidth < 0 then Asa@0: contentwidth = 0 Asa@0: end Asa@0: content:SetWidth(contentwidth) Asa@0: content.width = contentwidth Asa@0: Asa@0: local maxtreewidth = math_min(400, width - 50) Asa@0: Asa@0: if maxtreewidth > 100 and status.treewidth > maxtreewidth then Asa@0: self:SetTreeWidth(maxtreewidth, status.treesizable) Asa@0: end Asa@0: treeframe:SetMaxResize(maxtreewidth,1600) Asa@0: end Asa@0: Asa@0: Asa@0: local function OnHeightSet(self, height) Asa@0: local content = self.content Asa@0: local contentheight = height - 20 Asa@0: if contentheight < 0 then Asa@0: contentheight = 0 Asa@0: end Asa@0: content:SetHeight(contentheight) Asa@0: content.height = contentheight Asa@0: end Asa@0: Asa@0: Asa@0: local function TreeOnMouseWheel(this, delta) Asa@0: local self = this.obj Asa@0: if self.showscroll then Asa@0: local scrollbar = self.scrollbar Asa@0: local min, max = scrollbar:GetMinMaxValues() Asa@0: local value = scrollbar:GetValue() Asa@0: local newvalue = math_min(max,math_max(min,value - delta)) Asa@0: if value ~= newvalue then Asa@0: scrollbar:SetValue(newvalue) Asa@0: end Asa@0: end Asa@0: end Asa@0: Asa@0: local function SetTreeWidth(self, treewidth, resizable) Asa@0: if not resizable then Asa@0: if type(treewidth) == 'number' then Asa@0: resizable = false Asa@0: elseif type(treewidth) == 'boolean' then Asa@0: resizable = treewidth Asa@0: treewidth = DEFAULT_TREE_WIDTH Asa@0: else Asa@0: resizable = false Asa@0: treewidth = DEFAULT_TREE_WIDTH Asa@0: end Asa@0: end Asa@0: self.treeframe:SetWidth(treewidth) Asa@0: self.dragger:EnableMouse(resizable) Asa@0: Asa@0: local status = self.status or self.localstatus Asa@0: status.treewidth = treewidth Asa@0: status.treesizable = resizable Asa@0: Asa@0: -- recalculate the content width Asa@0: if status.fullwidth then Asa@0: self:OnWidthSet(status.fullwidth) Asa@0: end Asa@0: end Asa@0: Asa@0: local function draggerLeave(this) Asa@0: this:SetBackdropColor(1, 1, 1, 0) Asa@0: end Asa@0: Asa@0: local function draggerEnter(this) Asa@0: this:SetBackdropColor(1, 1, 1, 0.8) Asa@0: end Asa@0: Asa@0: local function draggerDown(this) Asa@0: local treeframe = this:GetParent() Asa@0: treeframe:StartSizing("RIGHT") Asa@0: end Asa@0: Asa@0: local function draggerUp(this) Asa@0: local treeframe = this:GetParent() Asa@0: local self = treeframe.obj Asa@0: local frame = treeframe:GetParent() Asa@0: treeframe:StopMovingOrSizing() Asa@0: --treeframe:SetScript("OnUpdate", nil) Asa@0: treeframe:SetUserPlaced(false) Asa@0: --Without this :GetHeight will get stuck on the current height, causing the tree contents to not resize Asa@0: treeframe:SetHeight(0) Asa@0: treeframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) Asa@0: treeframe:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) Asa@0: Asa@0: local status = self.status or self.localstatus Asa@0: status.treewidth = treeframe:GetWidth() Asa@0: Asa@0: treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth()) Asa@0: -- recalculate the content width Asa@0: treeframe.obj:OnWidthSet(status.fullwidth) Asa@0: -- update the layout of the content Asa@0: treeframe.obj:DoLayout() Asa@0: end Asa@0: Asa@0: local function LayoutFinished(self, width, height) Asa@0: if self.noAutoHeight then return end Asa@0: self:SetHeight((height or 0) + 20) Asa@0: end Asa@0: Asa@0: local createdcount = 0 Asa@0: local function Constructor() Asa@0: local frame = CreateFrame("Frame",nil,UIParent) Asa@0: local self = {} Asa@0: self.type = Type Asa@0: self.lines = {} Asa@0: self.levels = {} Asa@0: self.buttons = {} Asa@0: self.hasChildren = {} Asa@0: self.localstatus = {} Asa@0: self.localstatus.groups = {} Asa@0: self.filter = false Asa@0: Asa@0: local treeframe = CreateFrame("Frame",nil,frame) Asa@0: treeframe.obj = self Asa@0: treeframe:SetPoint("TOPLEFT",frame,"TOPLEFT",0,0) Asa@0: treeframe:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0) Asa@0: treeframe:SetWidth(DEFAULT_TREE_WIDTH) Asa@0: treeframe:SetScript("OnUpdate",FirstFrameUpdate) Asa@0: treeframe:SetScript("OnSizeChanged",ResizeUpdate) Asa@0: Asa@0: treeframe:EnableMouseWheel(true) Asa@0: treeframe:SetScript("OnMouseWheel", TreeOnMouseWheel) Asa@0: treeframe:SetBackdrop(PaneBackdrop) Asa@0: treeframe:SetBackdropColor(0.1,0.1,0.1,0.5) Asa@0: treeframe:SetBackdropBorderColor(0.4,0.4,0.4) Asa@0: Asa@0: treeframe:SetResizable(true) Asa@0: treeframe:SetMinResize(100, 1) Asa@0: treeframe:SetMaxResize(400,1600) Asa@0: local dragger = CreateFrame("Frame", nil, treeframe) Asa@0: dragger:SetWidth(8) Asa@0: dragger:SetPoint("TOP", treeframe, "TOPRIGHT") Asa@0: dragger:SetPoint("BOTTOM", treeframe, "BOTTOMRIGHT") Asa@0: dragger:SetBackdrop(DraggerBackdrop) Asa@0: dragger:SetBackdropColor(1, 1, 1, 0) Asa@0: dragger:SetScript("OnMouseDown", draggerDown) Asa@0: dragger:SetScript("OnMouseUp", draggerUp) Asa@0: dragger:SetScript("OnEnter", draggerEnter) Asa@0: dragger:SetScript("OnLeave", draggerLeave) Asa@0: Asa@0: self.dragger = dragger Asa@0: self.treeframe = treeframe Asa@0: self.OnRelease = OnRelease Asa@0: self.OnAcquire = OnAcquire Asa@0: Asa@0: self.SetTree = SetTree Asa@0: self.SetTreeWidth = SetTreeWidth Asa@0: self.RefreshTree = RefreshTree Asa@0: self.SetStatusTable = SetStatusTable Asa@0: self.BuildLevel = BuildLevel Asa@0: self.CreateButton = CreateButton Asa@0: self.SetSelected = SetSelected Asa@0: self.ShowScroll = ShowScroll Asa@0: self.SetStatusTable = SetStatusTable Asa@0: self.Select = Select Asa@0: self.SelectByValue = SelectByValue Asa@0: self.SelectByPath = SelectByPath Asa@0: self.OnWidthSet = OnWidthSet Asa@0: self.OnHeightSet = OnHeightSet Asa@0: self.EnableButtonTooltips = EnableButtonTooltips Asa@0: --self.Filter = Filter Asa@0: self.LayoutFinished = LayoutFinished Asa@0: Asa@0: self.frame = frame Asa@0: frame.obj = self Asa@0: Asa@0: createdcount = createdcount + 1 Asa@0: local scrollbar = CreateFrame("Slider",("AceConfigDialogTreeGroup%dScrollBar"):format(createdcount),treeframe,"UIPanelScrollBarTemplate") Asa@0: self.scrollbar = scrollbar Asa@0: local scrollbg = scrollbar:CreateTexture(nil,"BACKGROUND") Asa@0: scrollbg:SetAllPoints(scrollbar) Asa@0: scrollbg:SetTexture(0,0,0,0.4) Asa@0: scrollbar.obj = self Asa@0: self.noupdate = true Asa@0: scrollbar:SetPoint("TOPRIGHT",treeframe,"TOPRIGHT",-10,-26) Asa@0: scrollbar:SetPoint("BOTTOMRIGHT",treeframe,"BOTTOMRIGHT",-10,26) Asa@0: scrollbar:SetScript("OnValueChanged", OnScrollValueChanged) Asa@0: scrollbar:SetMinMaxValues(0,0) Asa@0: self.localstatus.scrollvalue = 0 Asa@0: scrollbar:SetValueStep(1) Asa@0: scrollbar:SetValue(0) Asa@0: scrollbar:SetWidth(16) Asa@0: self.noupdate = nil Asa@0: Asa@0: local border = CreateFrame("Frame",nil,frame) Asa@0: self.border = border Asa@0: border:SetPoint("TOPLEFT",treeframe,"TOPRIGHT", 0,0) Asa@0: border:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0) Asa@0: Asa@0: border:SetBackdrop(PaneBackdrop) Asa@0: border:SetBackdropColor(0.1,0.1,0.1,0.5) Asa@0: border:SetBackdropBorderColor(0.4,0.4,0.4) Asa@0: Asa@0: --Container Support Asa@0: local content = CreateFrame("Frame",nil,border) Asa@0: self.content = content Asa@0: content.obj = self Asa@0: content:SetPoint("TOPLEFT",border,"TOPLEFT",10,-10) Asa@0: content:SetPoint("BOTTOMRIGHT",border,"BOTTOMRIGHT",-10,10) Asa@0: Asa@0: AceGUI:RegisterAsContainer(self) Asa@0: --AceGUI:RegisterAsWidget(self) Asa@0: return self Asa@0: end Asa@0: Asa@0: AceGUI:RegisterWidgetType(Type,Constructor,Version) Asa@0: end