Mercurial > wow > breuesk
changeset 38:7bfbff27a3d7
"Working" list display using a TreeGroup control. There's a small limitation where I can't accurately detect which subtree is open unless the user has made a selection in that tab. Not sure I love that.
Loot lists are displayed with colored names. People not in the raid are grayed out.
author | John@Doomsday |
---|---|
date | Wed, 14 Mar 2012 08:31:31 -0400 |
parents | 6362fe301d43 |
children | ecef0cba2913 |
files | Core.lua Gui.lua |
diffstat | 2 files changed, 155 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/Core.lua Tue Mar 13 23:17:18 2012 -0400 +++ b/Core.lua Wed Mar 14 08:31:31 2012 -0400 @@ -31,7 +31,6 @@ bsk = LibStub("AceAddon-3.0"):NewAddon("bsk","AceConsole-3.0", "AceHook-3.0", "AceComm-3.0", "AceSerializer-3.0") local L = LibStub("AceLocale-3.0"):GetLocale("bsk", false) -local AceGUI = LibStub("AceGUI-3.0") function bsk:OnInitialize() @@ -46,6 +45,7 @@ function bsk:OnEnable() bsk:CreateWorkingStateFromChanges(self.db.profile.changes) + bsk:CreateGUI() end function bsk:HandleCommand(paramIn) @@ -171,6 +171,8 @@ bsk:RenameList(param[2],param[3]) elseif param[1] == "selfdestruct" then bsk:SelfDestruct() + else + bsk:CreateGUI() end --if self.frame == nil then
--- a/Gui.lua Tue Mar 13 23:17:18 2012 -0400 +++ b/Gui.lua Wed Mar 14 08:31:31 2012 -0400 @@ -1,3 +1,4 @@ +local AceGUI = LibStub("AceGUI-3.0") local ChangeTab = function(container, event, group) container:ReleaseChildren() @@ -12,19 +13,122 @@ button:SetWidth(200) container:AddChild(button) elseif group == "tab1" then + --local leftGroup = AceGUI:Create("InlineGroup") + --leftGroup:SetFullHeight() + --leftGroup:SetWidth(200) + + local rightGroup = AceGUI:Create("InlineGroup") + rightGroup:SetTitle("title") + --rightGroup:SetWidth(600) + --rightGroup:SetHeight(200) + rightGroup.width = 'fill' + --rightGroup:SetFullWidth() + --rightGroup.alignoffset = 25 + rightGroup:SetLayout("Flow") + + --local desc = AceGUI:Create("Label") + --desc:SetText("This is Tab 1") + --desc:SetFullWidth(true) + --container:AddChild(desc) + local icon = AceGUI:Create("Icon") + icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]]) + local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size + icon:SetWidth(sz,sz) + icon:SetHeight(sz,sz) + icon:SetImageSize(sz,sz) + icon:SetCallback("OnEnter", function(widget) GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); GameTooltip:SetHyperlink("item:16846:0:0:0:0:0:0:0"); GameTooltip:Show() end ) + icon:SetCallback("OnLeave", function(widget) GameTooltip:Hide() end ) + rightGroup:AddChild(icon) + + for i=1,12 do + icon = AceGUI:Create("Icon") + icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]]) + local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size + icon:SetWidth(sz,sz) + icon:SetHeight(sz,sz) + icon:SetImageSize(sz,sz) + icon:SetCallback("OnEnter", function(widget) GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); GameTooltip:SetHyperlink("item:16846:0:0:0:0:0:0:0"); GameTooltip:Show() end ) + icon:SetCallback("OnLeave", function(widget) GameTooltip:Hide() end ) + rightGroup:AddChild(icon) + end + local item2 = {string="item2!", color = {r=1,g=0,b=0.5} } - local itemList = {"Item1", item2, "Item3", "Item4"} + local itemList = {"Item1", "item2", "Item3", "Item4"} + for i=5,29 do + table.insert(itemList,"Item"..i) + end - local myMultiSelect = AceGUI:Create("MultiSelect") - myMultiSelect:SetLabel("My Multi Select") - myMultiSelect:SetWidth(200) - myMultiSelect:SetHeight(400) - myMultiSelect:SetItemList(itemList) - myMultiSelect:SetMultiSelect(false) - container:AddChild(myMultiSelect) + local colorize = function(str,color) + if str==nil or str=="" then return "" end + if type(color) == "table" then + color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b) + end + if color == nil then return str end + return "|cff"..tostring(color or "ffffff")..str.."|r" + end + local tree = {} + for i,v in pairs(bsk.lists) do + local entry = {value=i,text=v.name} + if getn(v) > 0 then + entry.children = {} + for x,y in ipairs(v) do + local p = bsk.persons[y.id] + local line = {value=y.id,text=p.main,icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]} + line.iconCoords=CLASS_ICON_TCOORDS[p.class] + bsk:PopulateRaidList() -- todo: this should be elsewhere + if not bsk.raidIdP[y.id] and not bsk.reserveIdP[y.id] then + line.disabled = true + else + line.text=colorize(line.text,RAID_CLASS_COLORS[p.class]) + end + table.insert(entry.children,line) + end + else + entry.disabled=true + end + table.insert(tree,entry) + end + local treegroup = AceGUI:Create("TreeGroup") + treegroup:SetTree(tree) + treegroup:EnableButtonTooltips(false) + treegroup:SetFullWidth(true) + treegroup:SetFullHeight(true) + treegroup:SetAutoAdjustHeight(false) + + treegroup:SetCallback("OnGroupSelected", function(widget,_,uniquevalue) bsk:Print("OGS: uniquevalue: "..uniquevalue) + end) + treegroup:SetCallback("OnClick", function(widget,_,uniquevalue) bsk:Print("Onclick: uniquevalue: " .. uniquevalue) end) + treegroup:SetCallback("OnButtonEnter", function(widget,_,value) bsk:Print("OnButtonEnter: value: " .. value) end) + + container:AddChild(treegroup) + + local scroller = AceGUI:Create("ScrollFrame") + scroller:SetLayout("List") + scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why + scroller:SetFullHeight(true) + scroller:SetFullWidth(true) + + local label = AceGUI:Create("InteractiveLabel") + label:SetText("fucking hell\n") + scroller:AddChild(label) + scroller:AddChild(rightGroup) + --widget:ReleaseChildren() + --widget:SetLayout("List") + --widget:AddChild(scroller) + treegroup:AddChild(scroller) end end +--local myhook = function(tooltip, spellid) +--tooltip:AddLine("MSS was here", 1, 1, 1) +--tooltip:Show() +--end +--if GameTooltip:GetScript("OnTooltipSetSpell") then +--GameTooltip:HookScript("OnTooltipSetSpell", myhook) +--else +--GameTooltip:SetScript("OnTooltipSetSpell", myhook) +--end + function bsk:CreateGUI() -- Create a container frame @@ -33,36 +137,48 @@ self.frame:SetTitle("BSK") self.frame:SetLayout("Flow") self.frame:SetHeight(700) - self.frame:SetWidth(350) - local tab = AceGUI:Create("TabGroup") - tab:SetLayout("Flow") - tab:SetTabs( - { - { - text="Tab 1", - value="tab1" - }, + self.frame:SetWidth(700) - { - text="Tab 2", - value="tab2" - }, - { - text="Tab 3", - value="tab3" - }, - { - text="Tab 4", - value="tab4" - } - } - ) - tab.width = "fill" - tab.height = "fill" + --local opts = + --{ + + --} - tab:SetCallback("OnGroupSelected",ChangeTab) - tab:SelectTab("tab1") - self.frame:AddChild(tab) + + + + + + --local tab = AceGUI:Create("TabGroup") + --tab:SetLayout("Flow") + --tab:SetTabs( + -- { + -- { + -- text="Tab 1", + -- value="tab1" + -- }, + + -- { + -- text="Tab 2", + -- value="tab2" + -- }, + -- { + -- text="Tab 3", + -- value="tab3" + -- }, + -- { + -- text="Tab 4", + -- value="tab4" + -- } + -- } + --) + --tab.width = "fill" + --tab.height = "fill" + + --tab:SetCallback("OnGroupSelected",ChangeTab) + --tab:SelectTab("tab1") + --self.frame:AddChild(tab) + ChangeTab(self.frame,0,"tab1") -- Create a button --local btn = AceGUI:Create("Button")