comparison Gui.lua @ 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 21c58930f74e
children 90622848932b
comparison
equal deleted inserted replaced
37:6362fe301d43 38:7bfbff27a3d7
1 local AceGUI = LibStub("AceGUI-3.0")
1 2
2 local ChangeTab = function(container, event, group) 3 local ChangeTab = function(container, event, group)
3 container:ReleaseChildren() 4 container:ReleaseChildren()
4 if group == "tab2" then 5 if group == "tab2" then
5 local desc = AceGUI:Create("Label") 6 local desc = AceGUI:Create("Label")
10 local button = AceGUI:Create("Button") 11 local button = AceGUI:Create("Button")
11 button:SetText("Tab 1 Button") 12 button:SetText("Tab 1 Button")
12 button:SetWidth(200) 13 button:SetWidth(200)
13 container:AddChild(button) 14 container:AddChild(button)
14 elseif group == "tab1" then 15 elseif group == "tab1" then
16 --local leftGroup = AceGUI:Create("InlineGroup")
17 --leftGroup:SetFullHeight()
18 --leftGroup:SetWidth(200)
19
20 local rightGroup = AceGUI:Create("InlineGroup")
21 rightGroup:SetTitle("title")
22 --rightGroup:SetWidth(600)
23 --rightGroup:SetHeight(200)
24 rightGroup.width = 'fill'
25 --rightGroup:SetFullWidth()
26 --rightGroup.alignoffset = 25
27 rightGroup:SetLayout("Flow")
28
29 --local desc = AceGUI:Create("Label")
30 --desc:SetText("This is Tab 1")
31 --desc:SetFullWidth(true)
32 --container:AddChild(desc)
33 local icon = AceGUI:Create("Icon")
34 icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]])
35 local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size
36 icon:SetWidth(sz,sz)
37 icon:SetHeight(sz,sz)
38 icon:SetImageSize(sz,sz)
39 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 )
40 icon:SetCallback("OnLeave", function(widget) GameTooltip:Hide() end )
41 rightGroup:AddChild(icon)
42
43 for i=1,12 do
44 icon = AceGUI:Create("Icon")
45 icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]])
46 local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size
47 icon:SetWidth(sz,sz)
48 icon:SetHeight(sz,sz)
49 icon:SetImageSize(sz,sz)
50 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 )
51 icon:SetCallback("OnLeave", function(widget) GameTooltip:Hide() end )
52 rightGroup:AddChild(icon)
53 end
54
15 local item2 = {string="item2!", color = {r=1,g=0,b=0.5} } 55 local item2 = {string="item2!", color = {r=1,g=0,b=0.5} }
16 local itemList = {"Item1", item2, "Item3", "Item4"} 56 local itemList = {"Item1", "item2", "Item3", "Item4"}
57 for i=5,29 do
58 table.insert(itemList,"Item"..i)
59 end
17 60
18 local myMultiSelect = AceGUI:Create("MultiSelect") 61 local colorize = function(str,color)
19 myMultiSelect:SetLabel("My Multi Select") 62 if str==nil or str=="" then return "" end
20 myMultiSelect:SetWidth(200) 63 if type(color) == "table" then
21 myMultiSelect:SetHeight(400) 64 color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b)
22 myMultiSelect:SetItemList(itemList) 65 end
23 myMultiSelect:SetMultiSelect(false) 66 if color == nil then return str end
24 container:AddChild(myMultiSelect) 67 return "|cff"..tostring(color or "ffffff")..str.."|r"
68 end
69 local tree = {}
70 for i,v in pairs(bsk.lists) do
71 local entry = {value=i,text=v.name}
72 if getn(v) > 0 then
73 entry.children = {}
74 for x,y in ipairs(v) do
75 local p = bsk.persons[y.id]
76 local line = {value=y.id,text=p.main,icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]}
77 line.iconCoords=CLASS_ICON_TCOORDS[p.class]
78 bsk:PopulateRaidList() -- todo: this should be elsewhere
79 if not bsk.raidIdP[y.id] and not bsk.reserveIdP[y.id] then
80 line.disabled = true
81 else
82 line.text=colorize(line.text,RAID_CLASS_COLORS[p.class])
83 end
84 table.insert(entry.children,line)
85 end
86 else
87 entry.disabled=true
88 end
89 table.insert(tree,entry)
90 end
91 local treegroup = AceGUI:Create("TreeGroup")
92 treegroup:SetTree(tree)
93 treegroup:EnableButtonTooltips(false)
94 treegroup:SetFullWidth(true)
95 treegroup:SetFullHeight(true)
96 treegroup:SetAutoAdjustHeight(false)
97
98 treegroup:SetCallback("OnGroupSelected", function(widget,_,uniquevalue) bsk:Print("OGS: uniquevalue: "..uniquevalue)
99 end)
100 treegroup:SetCallback("OnClick", function(widget,_,uniquevalue) bsk:Print("Onclick: uniquevalue: " .. uniquevalue) end)
101 treegroup:SetCallback("OnButtonEnter", function(widget,_,value) bsk:Print("OnButtonEnter: value: " .. value) end)
102
103 container:AddChild(treegroup)
104
105 local scroller = AceGUI:Create("ScrollFrame")
106 scroller:SetLayout("List")
107 scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why
108 scroller:SetFullHeight(true)
109 scroller:SetFullWidth(true)
110
111 local label = AceGUI:Create("InteractiveLabel")
112 label:SetText("fucking hell\n")
113 scroller:AddChild(label)
114 scroller:AddChild(rightGroup)
115 --widget:ReleaseChildren()
116 --widget:SetLayout("List")
117 --widget:AddChild(scroller)
118 treegroup:AddChild(scroller)
25 end 119 end
26 end 120 end
121
122 --local myhook = function(tooltip, spellid)
123 --tooltip:AddLine("MSS was here", 1, 1, 1)
124 --tooltip:Show()
125 --end
126 --if GameTooltip:GetScript("OnTooltipSetSpell") then
127 --GameTooltip:HookScript("OnTooltipSetSpell", myhook)
128 --else
129 --GameTooltip:SetScript("OnTooltipSetSpell", myhook)
130 --end
27 131
28 function bsk:CreateGUI() 132 function bsk:CreateGUI()
29 133
30 -- Create a container frame 134 -- Create a container frame
31 self.frame = AceGUI:Create("Frame") 135 self.frame = AceGUI:Create("Frame")
32 self.frame:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end) 136 self.frame:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
33 self.frame:SetTitle("BSK") 137 self.frame:SetTitle("BSK")
34 self.frame:SetLayout("Flow") 138 self.frame:SetLayout("Flow")
35 self.frame:SetHeight(700) 139 self.frame:SetHeight(700)
36 self.frame:SetWidth(350) 140 self.frame:SetWidth(700)
37 local tab = AceGUI:Create("TabGroup")
38 tab:SetLayout("Flow")
39 tab:SetTabs(
40 {
41 {
42 text="Tab 1",
43 value="tab1"
44 },
45 141
46 { 142 --local opts =
47 text="Tab 2", 143 --{
48 value="tab2" 144
49 }, 145 --}
50 {
51 text="Tab 3",
52 value="tab3"
53 },
54 {
55 text="Tab 4",
56 value="tab4"
57 }
58 }
59 )
60 tab.width = "fill"
61 tab.height = "fill"
62 146
63 tab:SetCallback("OnGroupSelected",ChangeTab) 147
64 tab:SelectTab("tab1") 148
65 self.frame:AddChild(tab) 149
150
151
152 --local tab = AceGUI:Create("TabGroup")
153 --tab:SetLayout("Flow")
154 --tab:SetTabs(
155 -- {
156 -- {
157 -- text="Tab 1",
158 -- value="tab1"
159 -- },
160
161 -- {
162 -- text="Tab 2",
163 -- value="tab2"
164 -- },
165 -- {
166 -- text="Tab 3",
167 -- value="tab3"
168 -- },
169 -- {
170 -- text="Tab 4",
171 -- value="tab4"
172 -- }
173 -- }
174 --)
175 --tab.width = "fill"
176 --tab.height = "fill"
177
178 --tab:SetCallback("OnGroupSelected",ChangeTab)
179 --tab:SelectTab("tab1")
180 --self.frame:AddChild(tab)
181 ChangeTab(self.frame,0,"tab1")
66 182
67 -- Create a button 183 -- Create a button
68 --local btn = AceGUI:Create("Button") 184 --local btn = AceGUI:Create("Button")
69 --btn:SetWidth(170) 185 --btn:SetWidth(170)
70 --btn:SetText("Button !") 186 --btn:SetText("Button !")