annotate Gui.lua @ 42:72055fc7e115

A lot of work to reign in namespacing (inspiration: WIM)
author John@Doomsday
date Thu, 15 Mar 2012 08:47:41 -0400
parents 90622848932b
children 4109683c3172
rev   line source
John@38 1 local AceGUI = LibStub("AceGUI-3.0")
John@42 2 local bsk=bsk
John@42 3 local _G=_G
John@42 4 local table=table
John@42 5 local pairs=pairs
John@42 6 local ipairs=ipairs
John@42 7 local string=string
John@42 8 local tostring=tostring
John@42 9 local type=type
John@42 10 local getn=getn
John@42 11 setfenv(1,bsk)
John@1 12
John@1 13 local ChangeTab = function(container, event, group)
John@1 14 container:ReleaseChildren()
John@1 15 if group == "tab2" then
John@1 16 local desc = AceGUI:Create("Label")
John@1 17 desc:SetText("This is Tab 1")
John@1 18 desc:SetFullWidth(true)
John@1 19 container:AddChild(desc)
John@1 20
John@1 21 local button = AceGUI:Create("Button")
John@1 22 button:SetText("Tab 1 Button")
John@1 23 button:SetWidth(200)
John@1 24 container:AddChild(button)
John@1 25 elseif group == "tab1" then
John@38 26 --local leftGroup = AceGUI:Create("InlineGroup")
John@38 27 --leftGroup:SetFullHeight()
John@38 28 --leftGroup:SetWidth(200)
John@38 29
John@38 30 local rightGroup = AceGUI:Create("InlineGroup")
John@38 31 rightGroup:SetTitle("title")
John@38 32 --rightGroup:SetWidth(600)
John@38 33 --rightGroup:SetHeight(200)
John@38 34 rightGroup.width = 'fill'
John@38 35 --rightGroup:SetFullWidth()
John@38 36 --rightGroup.alignoffset = 25
John@38 37 rightGroup:SetLayout("Flow")
John@38 38
John@38 39 --local desc = AceGUI:Create("Label")
John@38 40 --desc:SetText("This is Tab 1")
John@38 41 --desc:SetFullWidth(true)
John@38 42 --container:AddChild(desc)
John@38 43 local icon = AceGUI:Create("Icon")
John@38 44 icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]])
John@38 45 local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size
John@38 46 icon:SetWidth(sz,sz)
John@38 47 icon:SetHeight(sz,sz)
John@38 48 icon:SetImageSize(sz,sz)
John@42 49 icon:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); _G.GameTooltip:SetHyperlink("item:16846:0:0:0:0:0:0:0"); _G.GameTooltip:Show() end )
John@42 50 icon:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
John@38 51 rightGroup:AddChild(icon)
John@38 52
John@38 53 for i=1,12 do
John@38 54 icon = AceGUI:Create("Icon")
John@38 55 icon:SetImage([[Interface\Icons\INV_Misc_PocketWatch_01]])
John@38 56 local sz = 64 * icon.frame:GetEffectiveScale() -- 64 matches the character frame icon size
John@38 57 icon:SetWidth(sz,sz)
John@38 58 icon:SetHeight(sz,sz)
John@38 59 icon:SetImageSize(sz,sz)
John@42 60 icon:SetCallback("OnEnter", function(widget) _G.GameTooltip:SetOwner(widget.frame,"ANCHOR_RIGHT"); _G.GameTooltip:SetHyperlink("item:16846:0:0:0:0:0:0:0"); _G.GameTooltip:Show() end )
John@42 61 icon:SetCallback("OnLeave", function(widget) _G.GameTooltip:Hide() end )
John@38 62 rightGroup:AddChild(icon)
John@38 63 end
John@38 64
John@1 65 local item2 = {string="item2!", color = {r=1,g=0,b=0.5} }
John@38 66 local itemList = {"Item1", "item2", "Item3", "Item4"}
John@38 67 for i=5,29 do
John@38 68 table.insert(itemList,"Item"..i)
John@38 69 end
John@1 70
John@38 71 local colorize = function(str,color)
John@38 72 if str==nil or str=="" then return "" end
John@38 73 if type(color) == "table" then
John@38 74 color = string.format("%02x%02x%02x",255*color.r,255*color.g,255*color.b)
John@38 75 end
John@38 76 if color == nil then return str end
John@38 77 return "|cff"..tostring(color or "ffffff")..str.."|r"
John@38 78 end
John@40 79 local pull = {}
John@40 80 local ltemp = 0
John@42 81 for i,v in pairs(lists) do
John@40 82 pull[i] = v.name
John@40 83 --local entry = {value=i,text=v.name}
John@40 84 if ltemp == 0 and getn(v) > 0 then
John@40 85 ltemp = i
John@38 86 end
John@38 87 end
John@38 88
John@42 89 PopulateRaidList() -- todo: this should be elsewhere
John@38 90
John@38 91
John@42 92 scroller = AceGUI:Create("ScrollFrame")
John@42 93 scroller:SetLayout("List")
John@42 94 scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why
John@42 95 scroller:SetFullHeight(true)
John@42 96 scroller:SetFullWidth(true)
John@38 97
John@38 98 local label = AceGUI:Create("InteractiveLabel")
John@38 99 label:SetText("fucking hell\n")
John@42 100 scroller:AddChild(label)
John@42 101 scroller:AddChild(rightGroup)
John@40 102
John@42 103 treecontrol = AceGUI:Create("TreeGroup")
John@42 104 treecontrol:EnableButtonTooltips(false)
John@42 105 treecontrol:SetFullWidth(true)
John@42 106 treecontrol:SetFullHeight(true)
John@42 107 treecontrol:SetAutoAdjustHeight(false)
John@40 108
John@42 109 treecontrol:AddChild(scroller)
John@40 110
John@40 111 local pulldown = AceGUI:Create("Dropdown")
John@40 112 pulldown:SetWidth(175)
John@40 113 pulldown:SetList(pull)
John@42 114 for i,v in pairs(lists) do
John@40 115 if getn(v) == 0 then
John@40 116 pulldown:SetItemDisabled(i,true)
John@40 117 end
John@40 118 end
John@40 119 local ovc = function(_,_,value)
John@42 120 --treecontrol:ReleaseChildren()
John@40 121 local tree = {}
John@42 122 for x,y in ipairs(lists[value]) do
John@42 123 local p = persons[y.id]
John@40 124 local line = {value=y.id,text=p.main,icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]}
John@42 125 line.iconCoords=_G.CLASS_ICON_TCOORDS[p.class]
John@42 126 if not raidIdP[y.id] and not reserveIdP[y.id] then
John@40 127 line.disabled = true
John@40 128 else
John@42 129 line.text=colorize(line.text,_G.RAID_CLASS_COLORS[p.class])
John@40 130 end
John@40 131 table.insert(tree,line)
John@40 132 end
John@42 133 treecontrol:SetTree(tree)
John@40 134 end
John@40 135 pulldown:SetCallback("OnValueChanged", ovc)
John@40 136 if ltemp > 0 then pulldown:SetValue(ltemp); ovc(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged
John@40 137
John@40 138 container:AddChild(pulldown)
John@42 139 container:AddChild(treecontrol)
John@40 140
John@40 141 --pulldown:EnableButtonTooltips(false)
John@40 142 --pulldown:SetFullWidth(true)
John@40 143 --pulldown:SetFullHeight(true)
John@40 144 --pulldown:SetAutoAdjustHeight(false)
John@40 145
John@40 146 --pulldown:SetCallback("OnGroupSelected", function(widget,_,uniquevalue) bsk:Print("OGS: uniquevalue: "..uniquevalue)
John@40 147 --end)
John@40 148 --pulldown:SetCallback("OnClick", function(widget,_,uniquevalue) bsk:Print("Onclick: uniquevalue: " .. uniquevalue) end)
John@40 149 --pulldown:SetCallback("OnButtonEnter", function(widget,_,value) bsk:Print("OnButtonEnter: value: " .. value) end)
John@40 150
John@40 151
John@1 152 end
John@1 153 end
John@1 154
John@38 155 --local myhook = function(tooltip, spellid)
John@38 156 --tooltip:AddLine("MSS was here", 1, 1, 1)
John@38 157 --tooltip:Show()
John@38 158 --end
John@38 159 --if GameTooltip:GetScript("OnTooltipSetSpell") then
John@38 160 --GameTooltip:HookScript("OnTooltipSetSpell", myhook)
John@38 161 --else
John@38 162 --GameTooltip:SetScript("OnTooltipSetSpell", myhook)
John@38 163 --end
John@38 164
John@42 165 function CreateGUI()
John@1 166
John@1 167 -- Create a container frame
John@42 168 frame = AceGUI:Create("Frame")
John@42 169 frame:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
John@42 170 frame:SetTitle("BSK")
John@42 171 frame:SetLayout("Flow")
John@42 172 frame:SetHeight(700)
John@42 173 frame:SetWidth(700)
John@1 174
John@38 175 --local opts =
John@38 176 --{
John@38 177
John@38 178 --}
John@1 179
John@38 180
John@38 181
John@38 182
John@38 183
John@38 184
John@38 185 --local tab = AceGUI:Create("TabGroup")
John@38 186 --tab:SetLayout("Flow")
John@38 187 --tab:SetTabs(
John@38 188 -- {
John@38 189 -- {
John@38 190 -- text="Tab 1",
John@38 191 -- value="tab1"
John@38 192 -- },
John@38 193
John@38 194 -- {
John@38 195 -- text="Tab 2",
John@38 196 -- value="tab2"
John@38 197 -- },
John@38 198 -- {
John@38 199 -- text="Tab 3",
John@38 200 -- value="tab3"
John@38 201 -- },
John@38 202 -- {
John@38 203 -- text="Tab 4",
John@38 204 -- value="tab4"
John@38 205 -- }
John@38 206 -- }
John@38 207 --)
John@38 208 --tab.width = "fill"
John@38 209 --tab.height = "fill"
John@38 210
John@38 211 --tab:SetCallback("OnGroupSelected",ChangeTab)
John@38 212 --tab:SelectTab("tab1")
John@42 213 --frame:AddChild(tab)
John@42 214 ChangeTab(frame,0,"tab1")
John@1 215
John@1 216 -- Create a button
John@1 217 --local btn = AceGUI:Create("Button")
John@1 218 --btn:SetWidth(170)
John@1 219 --btn:SetText("Button !")
John@42 220 --btn:SetCallback("OnClick", function() bsk:print("Click!") end)
John@1 221 -- Add the button to the container
John@42 222 --frame:AddChild(btn)
John@1 223 end
John@1 224
John@1 225