annotate Gui.lua @ 39:ecef0cba2913

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