comparison Gui.lua @ 40:90622848932b

Converted the tree to a dropdown + tree and the results are pretty good
author John@Doomsday
date Wed, 14 Mar 2012 10:13:48 -0400
parents 7bfbff27a3d7
children 72055fc7e115
comparison
equal deleted inserted replaced
39:ecef0cba2913 40:90622848932b
64 color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b) 64 color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b)
65 end 65 end
66 if color == nil then return str end 66 if color == nil then return str end
67 return "|cff"..tostring(color or "ffffff")..str.."|r" 67 return "|cff"..tostring(color or "ffffff")..str.."|r"
68 end 68 end
69 local tree = {} 69 local pull = {}
70 local ltemp = 0
70 for i,v in pairs(bsk.lists) do 71 for i,v in pairs(bsk.lists) do
71 local entry = {value=i,text=v.name} 72 pull[i] = v.name
72 if getn(v) > 0 then 73 --local entry = {value=i,text=v.name}
73 entry.children = {} 74 if ltemp == 0 and getn(v) > 0 then
74 for x,y in ipairs(v) do 75 ltemp = i
75 local p = bsk.persons[y.id] 76 end
76 local line = {value=y.id,text=p.main,icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]} 77 end
77 line.iconCoords=CLASS_ICON_TCOORDS[p.class] 78
78 bsk:PopulateRaidList() -- todo: this should be elsewhere 79 bsk:PopulateRaidList() -- todo: this should be elsewhere
79 if not bsk.raidIdP[y.id] and not bsk.reserveIdP[y.id] then 80
80 line.disabled = true 81
81 else 82 bsk.scroller = AceGUI:Create("ScrollFrame")
82 line.text=colorize(line.text,RAID_CLASS_COLORS[p.class]) 83 bsk.scroller:SetLayout("List")
83 end 84 bsk.scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why
84 table.insert(entry.children,line) 85 bsk.scroller:SetFullHeight(true)
85 end 86 bsk.scroller:SetFullWidth(true)
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 87
111 local label = AceGUI:Create("InteractiveLabel") 88 local label = AceGUI:Create("InteractiveLabel")
112 label:SetText("fucking hell\n") 89 label:SetText("fucking hell\n")
113 scroller:AddChild(label) 90 bsk.scroller:AddChild(label)
114 scroller:AddChild(rightGroup) 91 bsk.scroller:AddChild(rightGroup)
115 --widget:ReleaseChildren() 92
116 --widget:SetLayout("List") 93 bsk.treecontrol = AceGUI:Create("TreeGroup")
117 --widget:AddChild(scroller) 94 bsk.treecontrol:EnableButtonTooltips(false)
118 treegroup:AddChild(scroller) 95 bsk.treecontrol:SetFullWidth(true)
96 bsk.treecontrol:SetFullHeight(true)
97 bsk.treecontrol:SetAutoAdjustHeight(false)
98
99 bsk.treecontrol:AddChild(bsk.scroller)
100
101 local pulldown = AceGUI:Create("Dropdown")
102 pulldown:SetWidth(175)
103 pulldown:SetList(pull)
104 for i,v in pairs(bsk.lists) do
105 if getn(v) == 0 then
106 pulldown:SetItemDisabled(i,true)
107 end
108 end
109 local ovc = function(_,_,value)
110 --bsk.treecontrol:ReleaseChildren()
111 local tree = {}
112 for x,y in ipairs(bsk.lists[value]) do
113 local p = bsk.persons[y.id]
114 local line = {value=y.id,text=p.main,icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]}
115 line.iconCoords=CLASS_ICON_TCOORDS[p.class]
116 if not bsk.raidIdP[y.id] and not bsk.reserveIdP[y.id] then
117 line.disabled = true
118 else
119 line.text=colorize(line.text,RAID_CLASS_COLORS[p.class])
120 end
121 table.insert(tree,line)
122 end
123 bsk.treecontrol:SetTree(tree)
124 end
125 pulldown:SetCallback("OnValueChanged", ovc)
126 if ltemp > 0 then pulldown:SetValue(ltemp); ovc(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged
127
128 container:AddChild(pulldown)
129 container:AddChild(bsk.treecontrol)
130
131 --pulldown:EnableButtonTooltips(false)
132 --pulldown:SetFullWidth(true)
133 --pulldown:SetFullHeight(true)
134 --pulldown:SetAutoAdjustHeight(false)
135
136 --pulldown:SetCallback("OnGroupSelected", function(widget,_,uniquevalue) bsk:Print("OGS: uniquevalue: "..uniquevalue)
137 --end)
138 --pulldown:SetCallback("OnClick", function(widget,_,uniquevalue) bsk:Print("Onclick: uniquevalue: " .. uniquevalue) end)
139 --pulldown:SetCallback("OnButtonEnter", function(widget,_,value) bsk:Print("OnButtonEnter: value: " .. value) end)
140
141
119 end 142 end
120 end 143 end
121 144
122 --local myhook = function(tooltip, spellid) 145 --local myhook = function(tooltip, spellid)
123 --tooltip:AddLine("MSS was here", 1, 1, 1) 146 --tooltip:AddLine("MSS was here", 1, 1, 1)