yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: TreeGroup Container yellowfive@57: Container that uses a tree control to switch between groups. yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local Type, Version = "TreeGroup", 37 yellowfive@57: local AceGUI = LibStub and LibStub("AceGUI-3.0", true) yellowfive@57: if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end yellowfive@57: yellowfive@57: -- Lua APIs yellowfive@57: local next, pairs, ipairs, assert, type = next, pairs, ipairs, assert, type yellowfive@57: local math_min, math_max, floor = math.min, math.max, floor yellowfive@57: local select, tremove, unpack, tconcat = select, table.remove, unpack, table.concat yellowfive@57: yellowfive@57: -- WoW APIs yellowfive@57: local CreateFrame, UIParent = CreateFrame, UIParent yellowfive@57: yellowfive@57: -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded yellowfive@57: -- List them here for Mikk's FindGlobals script yellowfive@57: -- GLOBALS: GameTooltip, FONT_COLOR_CODE_CLOSE yellowfive@57: yellowfive@57: -- Recycling functions yellowfive@57: local new, del yellowfive@57: do yellowfive@57: local pool = setmetatable({},{__mode='k'}) yellowfive@57: function new() yellowfive@57: local t = next(pool) yellowfive@57: if t then yellowfive@57: pool[t] = nil yellowfive@57: return t yellowfive@57: else yellowfive@57: return {} yellowfive@57: end yellowfive@57: end yellowfive@57: function del(t) yellowfive@57: for k in pairs(t) do yellowfive@57: t[k] = nil yellowfive@57: end yellowfive@57: pool[t] = true yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@57: local DEFAULT_TREE_WIDTH = 175 yellowfive@57: local DEFAULT_TREE_SIZABLE = true yellowfive@57: yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Support functions yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local function GetButtonUniqueValue(line) yellowfive@57: local parent = line.parent yellowfive@57: if parent and parent.value then yellowfive@57: return GetButtonUniqueValue(parent).."\001"..line.value yellowfive@57: else yellowfive@57: return line.value yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@57: local function UpdateButton(button, treeline, selected, canExpand, isExpanded) yellowfive@57: local self = button.obj yellowfive@57: local toggle = button.toggle yellowfive@57: local frame = self.frame yellowfive@57: local text = treeline.text or "" yellowfive@57: local icon = treeline.icon yellowfive@57: local iconCoords = treeline.iconCoords yellowfive@57: local level = treeline.level yellowfive@57: local value = treeline.value yellowfive@57: local uniquevalue = treeline.uniquevalue yellowfive@57: local disabled = treeline.disabled yellowfive@57: yellowfive@57: button.treeline = treeline yellowfive@57: button.value = value yellowfive@57: button.uniquevalue = uniquevalue yellowfive@57: if selected then yellowfive@57: button:LockHighlight() yellowfive@57: button.selected = true yellowfive@57: else yellowfive@57: button:UnlockHighlight() yellowfive@57: button.selected = false yellowfive@57: end yellowfive@57: local normalTexture = button:GetNormalTexture() yellowfive@57: local line = button.line yellowfive@57: button.level = level yellowfive@57: if ( level == 1 ) then yellowfive@57: button:SetNormalFontObject("GameFontNormal") yellowfive@57: button:SetHighlightFontObject("GameFontHighlight") yellowfive@57: button.text:SetPoint("LEFT", (icon and 16 or 0) + 8, 2) yellowfive@57: else yellowfive@57: button:SetNormalFontObject("GameFontHighlightSmall") yellowfive@57: button:SetHighlightFontObject("GameFontHighlightSmall") yellowfive@57: button.text:SetPoint("LEFT", (icon and 16 or 0) + 8 * level, 2) yellowfive@57: end yellowfive@57: yellowfive@57: if disabled then yellowfive@57: button:EnableMouse(false) yellowfive@57: button.text:SetText("|cff808080"..text..FONT_COLOR_CODE_CLOSE) yellowfive@57: else yellowfive@57: button.text:SetText(text) yellowfive@57: button:EnableMouse(true) yellowfive@57: end yellowfive@57: yellowfive@57: if icon then yellowfive@57: button.icon:SetTexture(icon) yellowfive@57: button.icon:SetPoint("LEFT", 8 * level, (level == 1) and 0 or 1) yellowfive@57: else yellowfive@57: button.icon:SetTexture(nil) yellowfive@57: end yellowfive@57: yellowfive@57: if iconCoords then yellowfive@57: button.icon:SetTexCoord(unpack(iconCoords)) yellowfive@57: else yellowfive@57: button.icon:SetTexCoord(0, 1, 0, 1) yellowfive@57: end yellowfive@57: yellowfive@57: if canExpand then yellowfive@57: if not isExpanded then yellowfive@57: toggle:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-UP") yellowfive@57: toggle:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-DOWN") yellowfive@57: else yellowfive@57: toggle:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP") yellowfive@57: toggle:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN") yellowfive@57: end yellowfive@57: toggle:Show() yellowfive@57: else yellowfive@57: toggle:Hide() yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@57: local function ShouldDisplayLevel(tree) yellowfive@57: local result = false yellowfive@57: for k, v in ipairs(tree) do yellowfive@57: if v.children == nil and v.visible ~= false then yellowfive@57: result = true yellowfive@57: elseif v.children then yellowfive@57: result = result or ShouldDisplayLevel(v.children) yellowfive@57: end yellowfive@57: if result then return result end yellowfive@57: end yellowfive@57: return false yellowfive@57: end yellowfive@57: yellowfive@57: local function addLine(self, v, tree, level, parent) yellowfive@57: local line = new() yellowfive@57: line.value = v.value yellowfive@57: line.text = v.text yellowfive@57: line.icon = v.icon yellowfive@57: line.iconCoords = v.iconCoords yellowfive@57: line.disabled = v.disabled yellowfive@57: line.tree = tree yellowfive@57: line.level = level yellowfive@57: line.parent = parent yellowfive@57: line.visible = v.visible yellowfive@57: line.uniquevalue = GetButtonUniqueValue(line) yellowfive@57: if v.children then yellowfive@57: line.hasChildren = true yellowfive@57: else yellowfive@57: line.hasChildren = nil yellowfive@57: end yellowfive@57: self.lines[#self.lines+1] = line yellowfive@57: return line yellowfive@57: end yellowfive@57: yellowfive@57: --fire an update after one frame to catch the treeframes height yellowfive@57: local function FirstFrameUpdate(frame) yellowfive@57: local self = frame.obj yellowfive@57: frame:SetScript("OnUpdate", nil) yellowfive@57: self:RefreshTree() yellowfive@57: end yellowfive@57: yellowfive@57: local function BuildUniqueValue(...) yellowfive@57: local n = select('#', ...) yellowfive@57: if n == 1 then yellowfive@57: return ... yellowfive@57: else yellowfive@57: return (...).."\001"..BuildUniqueValue(select(2,...)) yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Scripts yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local function Expand_OnClick(frame) yellowfive@57: local button = frame.button yellowfive@57: local self = button.obj yellowfive@57: local status = (self.status or self.localstatus).groups yellowfive@57: status[button.uniquevalue] = not status[button.uniquevalue] yellowfive@57: self:RefreshTree() yellowfive@57: end yellowfive@57: yellowfive@57: local function Button_OnClick(frame) yellowfive@57: local self = frame.obj yellowfive@57: self:Fire("OnClick", frame.uniquevalue, frame.selected) yellowfive@57: if not frame.selected then yellowfive@57: self:SetSelected(frame.uniquevalue) yellowfive@57: frame.selected = true yellowfive@57: frame:LockHighlight() yellowfive@57: self:RefreshTree() yellowfive@57: end yellowfive@57: AceGUI:ClearFocus() yellowfive@57: end yellowfive@57: yellowfive@57: local function Button_OnDoubleClick(button) yellowfive@57: local self = button.obj yellowfive@57: local status = self.status or self.localstatus yellowfive@57: local status = (self.status or self.localstatus).groups yellowfive@57: status[button.uniquevalue] = not status[button.uniquevalue] yellowfive@57: self:RefreshTree() yellowfive@57: end yellowfive@57: yellowfive@57: local function Button_OnEnter(frame) yellowfive@57: local self = frame.obj yellowfive@57: self:Fire("OnButtonEnter", frame.uniquevalue, frame) yellowfive@57: yellowfive@57: if self.enabletooltips then yellowfive@57: GameTooltip:SetOwner(frame, "ANCHOR_NONE") yellowfive@57: GameTooltip:SetPoint("LEFT",frame,"RIGHT") yellowfive@57: GameTooltip:SetText(frame.text:GetText() or "", 1, .82, 0, true) yellowfive@57: yellowfive@57: GameTooltip:Show() yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@57: local function Button_OnLeave(frame) yellowfive@57: local self = frame.obj yellowfive@57: self:Fire("OnButtonLeave", frame.uniquevalue, frame) yellowfive@57: yellowfive@57: if self.enabletooltips then yellowfive@57: GameTooltip:Hide() yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@57: local function OnScrollValueChanged(frame, value) yellowfive@57: if frame.obj.noupdate then return end yellowfive@57: local self = frame.obj yellowfive@57: local status = self.status or self.localstatus yellowfive@57: status.scrollvalue = floor(value + 0.5) yellowfive@57: self:RefreshTree() yellowfive@57: AceGUI:ClearFocus() yellowfive@57: end yellowfive@57: yellowfive@57: local function Tree_OnSizeChanged(frame) yellowfive@57: frame.obj:RefreshTree() yellowfive@57: end yellowfive@57: yellowfive@57: local function Tree_OnMouseWheel(frame, delta) yellowfive@57: local self = frame.obj yellowfive@57: if self.showscroll then yellowfive@57: local scrollbar = self.scrollbar yellowfive@57: local min, max = scrollbar:GetMinMaxValues() yellowfive@57: local value = scrollbar:GetValue() yellowfive@57: local newvalue = math_min(max,math_max(min,value - delta)) yellowfive@57: if value ~= newvalue then yellowfive@57: scrollbar:SetValue(newvalue) yellowfive@57: end yellowfive@57: end yellowfive@57: end yellowfive@57: yellowfive@57: local function Dragger_OnLeave(frame) yellowfive@57: frame:SetBackdropColor(1, 1, 1, 0) yellowfive@57: end yellowfive@57: yellowfive@57: local function Dragger_OnEnter(frame) yellowfive@57: frame:SetBackdropColor(1, 1, 1, 0.8) yellowfive@57: end yellowfive@57: yellowfive@57: local function Dragger_OnMouseDown(frame) yellowfive@57: local treeframe = frame:GetParent() yellowfive@57: treeframe:StartSizing("RIGHT") yellowfive@57: end yellowfive@57: yellowfive@57: local function Dragger_OnMouseUp(frame) yellowfive@57: local treeframe = frame:GetParent() yellowfive@57: local self = treeframe.obj yellowfive@57: local frame = treeframe:GetParent() yellowfive@57: treeframe:StopMovingOrSizing() yellowfive@57: --treeframe:SetScript("OnUpdate", nil) yellowfive@57: treeframe:SetUserPlaced(false) yellowfive@57: --Without this :GetHeight will get stuck on the current height, causing the tree contents to not resize yellowfive@57: treeframe:SetHeight(0) yellowfive@57: treeframe:SetPoint("TOPLEFT", frame, "TOPLEFT",0,0) yellowfive@57: treeframe:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT",0,0) yellowfive@57: yellowfive@57: local status = self.status or self.localstatus yellowfive@57: status.treewidth = treeframe:GetWidth() yellowfive@57: yellowfive@57: treeframe.obj:Fire("OnTreeResize",treeframe:GetWidth()) yellowfive@57: -- recalculate the content width yellowfive@57: treeframe.obj:OnWidthSet(status.fullwidth) yellowfive@57: -- update the layout of the content yellowfive@57: treeframe.obj:DoLayout() yellowfive@57: end yellowfive@57: yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Methods yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local methods = { yellowfive@57: ["OnAcquire"] = function(self) yellowfive@57: self:SetTreeWidth(DEFAULT_TREE_WIDTH, DEFAULT_TREE_SIZABLE) yellowfive@57: self:EnableButtonTooltips(true) yellowfive@57: end, yellowfive@57: yellowfive@57: ["OnRelease"] = function(self) yellowfive@57: self.status = nil yellowfive@57: for k, v in pairs(self.localstatus) do yellowfive@57: if k == "groups" then yellowfive@57: for k2 in pairs(v) do yellowfive@57: v[k2] = nil yellowfive@57: end yellowfive@57: else yellowfive@57: self.localstatus[k] = nil yellowfive@57: end yellowfive@57: end yellowfive@57: self.localstatus.scrollvalue = 0 yellowfive@57: self.localstatus.treewidth = DEFAULT_TREE_WIDTH yellowfive@57: self.localstatus.treesizable = DEFAULT_TREE_SIZABLE yellowfive@57: end, yellowfive@57: yellowfive@57: ["EnableButtonTooltips"] = function(self, enable) yellowfive@57: self.enabletooltips = enable yellowfive@57: end, yellowfive@57: yellowfive@57: ["CreateButton"] = function(self) yellowfive@57: local num = AceGUI:GetNextWidgetNum("TreeGroupButton") yellowfive@57: local button = CreateFrame("Button", ("AceGUI30TreeButton%d"):format(num), self.treeframe, "OptionsListButtonTemplate") yellowfive@57: button.obj = self yellowfive@57: yellowfive@57: local icon = button:CreateTexture(nil, "OVERLAY") yellowfive@57: icon:SetWidth(14) yellowfive@57: icon:SetHeight(14) yellowfive@57: button.icon = icon yellowfive@57: yellowfive@57: button:SetScript("OnClick",Button_OnClick) yellowfive@57: button:SetScript("OnDoubleClick", Button_OnDoubleClick) yellowfive@57: button:SetScript("OnEnter",Button_OnEnter) yellowfive@57: button:SetScript("OnLeave",Button_OnLeave) yellowfive@57: yellowfive@57: button.toggle.button = button yellowfive@57: button.toggle:SetScript("OnClick",Expand_OnClick) yellowfive@57: yellowfive@57: return button yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetStatusTable"] = function(self, status) yellowfive@57: assert(type(status) == "table") yellowfive@57: self.status = status yellowfive@57: if not status.groups then yellowfive@57: status.groups = {} yellowfive@57: end yellowfive@57: if not status.scrollvalue then yellowfive@57: status.scrollvalue = 0 yellowfive@57: end yellowfive@57: if not status.treewidth then yellowfive@57: status.treewidth = DEFAULT_TREE_WIDTH yellowfive@57: end yellowfive@57: if status.treesizable == nil then yellowfive@57: status.treesizable = DEFAULT_TREE_SIZABLE yellowfive@57: end yellowfive@57: self:SetTreeWidth(status.treewidth,status.treesizable) yellowfive@57: self:RefreshTree() yellowfive@57: end, yellowfive@57: yellowfive@57: --sets the tree to be displayed yellowfive@57: ["SetTree"] = function(self, tree, filter) yellowfive@57: self.filter = filter yellowfive@57: if tree then yellowfive@57: assert(type(tree) == "table") yellowfive@57: end yellowfive@57: self.tree = tree yellowfive@57: self:RefreshTree() yellowfive@57: end, yellowfive@57: yellowfive@57: ["BuildLevel"] = function(self, tree, level, parent) yellowfive@57: local groups = (self.status or self.localstatus).groups yellowfive@57: local hasChildren = self.hasChildren yellowfive@57: yellowfive@57: for i, v in ipairs(tree) do yellowfive@57: if v.children then yellowfive@57: if not self.filter or ShouldDisplayLevel(v.children) then yellowfive@57: local line = addLine(self, v, tree, level, parent) yellowfive@57: if groups[line.uniquevalue] then yellowfive@57: self:BuildLevel(v.children, level+1, line) yellowfive@57: end yellowfive@57: end yellowfive@57: elseif v.visible ~= false or not self.filter then yellowfive@57: addLine(self, v, tree, level, parent) yellowfive@57: end yellowfive@57: end yellowfive@57: end, yellowfive@57: yellowfive@57: ["RefreshTree"] = function(self,scrollToSelection) yellowfive@57: local buttons = self.buttons yellowfive@57: local lines = self.lines yellowfive@57: yellowfive@57: for i, v in ipairs(buttons) do yellowfive@57: v:Hide() yellowfive@57: end yellowfive@57: while lines[1] do yellowfive@57: local t = tremove(lines) yellowfive@57: for k in pairs(t) do yellowfive@57: t[k] = nil yellowfive@57: end yellowfive@57: del(t) yellowfive@57: end yellowfive@57: yellowfive@57: if not self.tree then return end yellowfive@57: --Build the list of visible entries from the tree and status tables yellowfive@57: local status = self.status or self.localstatus yellowfive@57: local groupstatus = status.groups yellowfive@57: local tree = self.tree yellowfive@57: yellowfive@57: local treeframe = self.treeframe yellowfive@57: yellowfive@57: status.scrollToSelection = status.scrollToSelection or scrollToSelection -- needs to be cached in case the control hasn't been drawn yet (code bails out below) yellowfive@57: yellowfive@57: self:BuildLevel(tree, 1) yellowfive@57: yellowfive@57: local numlines = #lines yellowfive@57: yellowfive@57: local maxlines = (floor(((self.treeframe:GetHeight()or 0) - 20 ) / 18)) yellowfive@57: if maxlines <= 0 then return end yellowfive@57: yellowfive@57: local first, last yellowfive@57: yellowfive@57: scrollToSelection = status.scrollToSelection yellowfive@57: status.scrollToSelection = nil yellowfive@57: yellowfive@57: if numlines <= maxlines then yellowfive@57: --the whole tree fits in the frame yellowfive@57: status.scrollvalue = 0 yellowfive@57: self:ShowScroll(false) yellowfive@57: first, last = 1, numlines yellowfive@57: else yellowfive@57: self:ShowScroll(true) yellowfive@57: --scrolling will be needed yellowfive@57: self.noupdate = true yellowfive@57: self.scrollbar:SetMinMaxValues(0, numlines - maxlines) yellowfive@57: --check if we are scrolled down too far yellowfive@57: if numlines - status.scrollvalue < maxlines then yellowfive@57: status.scrollvalue = numlines - maxlines yellowfive@57: end yellowfive@57: self.noupdate = nil yellowfive@57: first, last = status.scrollvalue+1, status.scrollvalue + maxlines yellowfive@57: --show selection? yellowfive@57: if scrollToSelection and status.selected then yellowfive@57: local show yellowfive@57: for i,line in ipairs(lines) do -- find the line number yellowfive@57: if line.uniquevalue==status.selected then yellowfive@57: show=i yellowfive@57: end yellowfive@57: end yellowfive@57: if not show then yellowfive@57: -- selection was deleted or something? yellowfive@57: elseif show>=first and show<=last then yellowfive@57: -- all good yellowfive@57: else yellowfive@57: -- scrolling needed! yellowfive@57: if show 100 and status.treewidth > maxtreewidth then yellowfive@57: self:SetTreeWidth(maxtreewidth, status.treesizable) yellowfive@57: end yellowfive@57: treeframe:SetMaxResize(maxtreewidth, 1600) yellowfive@57: end, yellowfive@57: yellowfive@57: ["OnHeightSet"] = function(self, height) yellowfive@57: local content = self.content yellowfive@57: local contentheight = height - 20 yellowfive@57: if contentheight < 0 then yellowfive@57: contentheight = 0 yellowfive@57: end yellowfive@57: content:SetHeight(contentheight) yellowfive@57: content.height = contentheight yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetTreeWidth"] = function(self, treewidth, resizable) yellowfive@57: if not resizable then yellowfive@57: if type(treewidth) == 'number' then yellowfive@57: resizable = false yellowfive@57: elseif type(treewidth) == 'boolean' then yellowfive@57: resizable = treewidth yellowfive@57: treewidth = DEFAULT_TREE_WIDTH yellowfive@57: else yellowfive@57: resizable = false yellowfive@57: treewidth = DEFAULT_TREE_WIDTH yellowfive@57: end yellowfive@57: end yellowfive@57: self.treeframe:SetWidth(treewidth) yellowfive@57: self.dragger:EnableMouse(resizable) yellowfive@57: yellowfive@57: local status = self.status or self.localstatus yellowfive@57: status.treewidth = treewidth yellowfive@57: status.treesizable = resizable yellowfive@57: yellowfive@57: -- recalculate the content width yellowfive@57: if status.fullwidth then yellowfive@57: self:OnWidthSet(status.fullwidth) yellowfive@57: end yellowfive@57: end, yellowfive@57: yellowfive@57: ["GetTreeWidth"] = function(self) yellowfive@57: local status = self.status or self.localstatus yellowfive@57: return status.treewidth or DEFAULT_TREE_WIDTH yellowfive@57: end, yellowfive@57: yellowfive@57: ["LayoutFinished"] = function(self, width, height) yellowfive@57: if self.noAutoHeight then return end yellowfive@57: self:SetHeight((height or 0) + 20) yellowfive@57: end yellowfive@57: } yellowfive@57: yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Constructor yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local PaneBackdrop = { yellowfive@57: bgFile = "Interface\\ChatFrame\\ChatFrameBackground", yellowfive@57: edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", yellowfive@57: tile = true, tileSize = 16, edgeSize = 16, yellowfive@57: insets = { left = 3, right = 3, top = 5, bottom = 3 } yellowfive@57: } yellowfive@57: yellowfive@57: local DraggerBackdrop = { yellowfive@57: bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", yellowfive@57: edgeFile = nil, yellowfive@57: tile = true, tileSize = 16, edgeSize = 0, yellowfive@57: insets = { left = 3, right = 3, top = 7, bottom = 7 } yellowfive@57: } yellowfive@57: yellowfive@57: local function Constructor() yellowfive@57: local num = AceGUI:GetNextWidgetNum(Type) yellowfive@57: local frame = CreateFrame("Frame", nil, UIParent) yellowfive@57: yellowfive@57: local treeframe = CreateFrame("Frame", nil, frame) yellowfive@57: treeframe:SetPoint("TOPLEFT") yellowfive@57: treeframe:SetPoint("BOTTOMLEFT") yellowfive@57: treeframe:SetWidth(DEFAULT_TREE_WIDTH) yellowfive@57: treeframe:EnableMouseWheel(true) yellowfive@57: treeframe:SetBackdrop(PaneBackdrop) yellowfive@57: treeframe:SetBackdropColor(0.1, 0.1, 0.1, 0.5) yellowfive@57: treeframe:SetBackdropBorderColor(0.4, 0.4, 0.4) yellowfive@57: treeframe:SetResizable(true) yellowfive@57: treeframe:SetMinResize(100, 1) yellowfive@57: treeframe:SetMaxResize(400, 1600) yellowfive@57: treeframe:SetScript("OnUpdate", FirstFrameUpdate) yellowfive@57: treeframe:SetScript("OnSizeChanged", Tree_OnSizeChanged) yellowfive@57: treeframe:SetScript("OnMouseWheel", Tree_OnMouseWheel) yellowfive@57: yellowfive@57: local dragger = CreateFrame("Frame", nil, treeframe) yellowfive@57: dragger:SetWidth(8) yellowfive@57: dragger:SetPoint("TOP", treeframe, "TOPRIGHT") yellowfive@57: dragger:SetPoint("BOTTOM", treeframe, "BOTTOMRIGHT") yellowfive@57: dragger:SetBackdrop(DraggerBackdrop) yellowfive@57: dragger:SetBackdropColor(1, 1, 1, 0) yellowfive@57: dragger:SetScript("OnEnter", Dragger_OnEnter) yellowfive@57: dragger:SetScript("OnLeave", Dragger_OnLeave) yellowfive@57: dragger:SetScript("OnMouseDown", Dragger_OnMouseDown) yellowfive@57: dragger:SetScript("OnMouseUp", Dragger_OnMouseUp) yellowfive@57: yellowfive@57: local scrollbar = CreateFrame("Slider", ("AceConfigDialogTreeGroup%dScrollBar"):format(num), treeframe, "UIPanelScrollBarTemplate") yellowfive@57: scrollbar:SetScript("OnValueChanged", nil) yellowfive@57: scrollbar:SetPoint("TOPRIGHT", -10, -26) yellowfive@57: scrollbar:SetPoint("BOTTOMRIGHT", -10, 26) yellowfive@57: scrollbar:SetMinMaxValues(0,0) yellowfive@57: scrollbar:SetValueStep(1) yellowfive@57: scrollbar:SetValue(0) yellowfive@57: scrollbar:SetWidth(16) yellowfive@57: scrollbar:SetScript("OnValueChanged", OnScrollValueChanged) yellowfive@57: yellowfive@57: local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND") yellowfive@57: scrollbg:SetAllPoints(scrollbar) yellowfive@57: scrollbg:SetTexture(0,0,0,0.4) yellowfive@57: yellowfive@57: local border = CreateFrame("Frame",nil,frame) yellowfive@57: border:SetPoint("TOPLEFT", treeframe, "TOPRIGHT") yellowfive@57: border:SetPoint("BOTTOMRIGHT") yellowfive@57: border:SetBackdrop(PaneBackdrop) yellowfive@57: border:SetBackdropColor(0.1, 0.1, 0.1, 0.5) yellowfive@57: border:SetBackdropBorderColor(0.4, 0.4, 0.4) yellowfive@57: yellowfive@57: --Container Support yellowfive@57: local content = CreateFrame("Frame", nil, border) yellowfive@57: content:SetPoint("TOPLEFT", 10, -10) yellowfive@57: content:SetPoint("BOTTOMRIGHT", -10, 10) yellowfive@57: yellowfive@57: local widget = { yellowfive@57: frame = frame, yellowfive@57: lines = {}, yellowfive@57: levels = {}, yellowfive@57: buttons = {}, yellowfive@57: hasChildren = {}, yellowfive@57: localstatus = { groups = {}, scrollvalue = 0 }, yellowfive@57: filter = false, yellowfive@57: treeframe = treeframe, yellowfive@57: dragger = dragger, yellowfive@57: scrollbar = scrollbar, yellowfive@57: border = border, yellowfive@57: content = content, yellowfive@57: type = Type yellowfive@57: } yellowfive@57: for method, func in pairs(methods) do yellowfive@57: widget[method] = func yellowfive@57: end yellowfive@57: treeframe.obj, dragger.obj, scrollbar.obj = widget, widget, widget yellowfive@57: yellowfive@57: return AceGUI:RegisterAsContainer(widget) yellowfive@57: end yellowfive@57: yellowfive@57: AceGUI:RegisterWidgetType(Type, Constructor, Version)