annotate Gui.lua @ 41:dc9bfacca238

Lint
author John@Yosemite-PC
date Wed, 14 Mar 2012 22:06:19 -0400
parents 90622848932b
children 72055fc7e115
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@40 69 local pull = {}
John@40 70 local ltemp = 0
John@38 71 for i,v in pairs(bsk.lists) do
John@40 72 pull[i] = v.name
John@40 73 --local entry = {value=i,text=v.name}
John@40 74 if ltemp == 0 and getn(v) > 0 then
John@40 75 ltemp = i
John@38 76 end
John@38 77 end
John@38 78
John@40 79 bsk:PopulateRaidList() -- todo: this should be elsewhere
John@38 80
John@38 81
John@40 82 bsk.scroller = AceGUI:Create("ScrollFrame")
John@40 83 bsk.scroller:SetLayout("List")
John@40 84 bsk.scroller:SetHeight(0) -- prevents a nasty graphical bug, dont ask me why
John@40 85 bsk.scroller:SetFullHeight(true)
John@40 86 bsk.scroller:SetFullWidth(true)
John@38 87
John@38 88 local label = AceGUI:Create("InteractiveLabel")
John@38 89 label:SetText("fucking hell\n")
John@40 90 bsk.scroller:AddChild(label)
John@40 91 bsk.scroller:AddChild(rightGroup)
John@40 92
John@40 93 bsk.treecontrol = AceGUI:Create("TreeGroup")
John@40 94 bsk.treecontrol:EnableButtonTooltips(false)
John@40 95 bsk.treecontrol:SetFullWidth(true)
John@40 96 bsk.treecontrol:SetFullHeight(true)
John@40 97 bsk.treecontrol:SetAutoAdjustHeight(false)
John@40 98
John@40 99 bsk.treecontrol:AddChild(bsk.scroller)
John@40 100
John@40 101 local pulldown = AceGUI:Create("Dropdown")
John@40 102 pulldown:SetWidth(175)
John@40 103 pulldown:SetList(pull)
John@40 104 for i,v in pairs(bsk.lists) do
John@40 105 if getn(v) == 0 then
John@40 106 pulldown:SetItemDisabled(i,true)
John@40 107 end
John@40 108 end
John@40 109 local ovc = function(_,_,value)
John@40 110 --bsk.treecontrol:ReleaseChildren()
John@40 111 local tree = {}
John@40 112 for x,y in ipairs(bsk.lists[value]) do
John@40 113 local p = bsk.persons[y.id]
John@40 114 local line = {value=y.id,text=p.main,icon=[[Interface\Glues\CharacterCreate\UI-CharacterCreate-Classes]]}
John@40 115 line.iconCoords=CLASS_ICON_TCOORDS[p.class]
John@40 116 if not bsk.raidIdP[y.id] and not bsk.reserveIdP[y.id] then
John@40 117 line.disabled = true
John@40 118 else
John@40 119 line.text=colorize(line.text,RAID_CLASS_COLORS[p.class])
John@40 120 end
John@40 121 table.insert(tree,line)
John@40 122 end
John@40 123 bsk.treecontrol:SetTree(tree)
John@40 124 end
John@40 125 pulldown:SetCallback("OnValueChanged", ovc)
John@40 126 if ltemp > 0 then pulldown:SetValue(ltemp); ovc(nil,nil,ltemp) end -- sadly, SetValue doesn't fire a OnValueChanged
John@40 127
John@40 128 container:AddChild(pulldown)
John@40 129 container:AddChild(bsk.treecontrol)
John@40 130
John@40 131 --pulldown:EnableButtonTooltips(false)
John@40 132 --pulldown:SetFullWidth(true)
John@40 133 --pulldown:SetFullHeight(true)
John@40 134 --pulldown:SetAutoAdjustHeight(false)
John@40 135
John@40 136 --pulldown:SetCallback("OnGroupSelected", function(widget,_,uniquevalue) bsk:Print("OGS: uniquevalue: "..uniquevalue)
John@40 137 --end)
John@40 138 --pulldown:SetCallback("OnClick", function(widget,_,uniquevalue) bsk:Print("Onclick: uniquevalue: " .. uniquevalue) end)
John@40 139 --pulldown:SetCallback("OnButtonEnter", function(widget,_,value) bsk:Print("OnButtonEnter: value: " .. value) end)
John@40 140
John@40 141
John@1 142 end
John@1 143 end
John@1 144
John@38 145 --local myhook = function(tooltip, spellid)
John@38 146 --tooltip:AddLine("MSS was here", 1, 1, 1)
John@38 147 --tooltip:Show()
John@38 148 --end
John@38 149 --if GameTooltip:GetScript("OnTooltipSetSpell") then
John@38 150 --GameTooltip:HookScript("OnTooltipSetSpell", myhook)
John@38 151 --else
John@38 152 --GameTooltip:SetScript("OnTooltipSetSpell", myhook)
John@38 153 --end
John@38 154
John@1 155 function bsk:CreateGUI()
John@1 156
John@1 157 -- Create a container frame
John@1 158 self.frame = AceGUI:Create("Frame")
John@1 159 self.frame:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
John@1 160 self.frame:SetTitle("BSK")
John@1 161 self.frame:SetLayout("Flow")
John@1 162 self.frame:SetHeight(700)
John@38 163 self.frame:SetWidth(700)
John@1 164
John@38 165 --local opts =
John@38 166 --{
John@38 167
John@38 168 --}
John@1 169
John@38 170
John@38 171
John@38 172
John@38 173
John@38 174
John@38 175 --local tab = AceGUI:Create("TabGroup")
John@38 176 --tab:SetLayout("Flow")
John@38 177 --tab:SetTabs(
John@38 178 -- {
John@38 179 -- {
John@38 180 -- text="Tab 1",
John@38 181 -- value="tab1"
John@38 182 -- },
John@38 183
John@38 184 -- {
John@38 185 -- text="Tab 2",
John@38 186 -- value="tab2"
John@38 187 -- },
John@38 188 -- {
John@38 189 -- text="Tab 3",
John@38 190 -- value="tab3"
John@38 191 -- },
John@38 192 -- {
John@38 193 -- text="Tab 4",
John@38 194 -- value="tab4"
John@38 195 -- }
John@38 196 -- }
John@38 197 --)
John@38 198 --tab.width = "fill"
John@38 199 --tab.height = "fill"
John@38 200
John@38 201 --tab:SetCallback("OnGroupSelected",ChangeTab)
John@38 202 --tab:SelectTab("tab1")
John@38 203 --self.frame:AddChild(tab)
John@38 204 ChangeTab(self.frame,0,"tab1")
John@1 205
John@1 206 -- Create a button
John@1 207 --local btn = AceGUI:Create("Button")
John@1 208 --btn:SetWidth(170)
John@1 209 --btn:SetText("Button !")
John@1 210 --btn:SetCallback("OnClick", function() print("Click!") end)
John@1 211 -- Add the button to the container
John@1 212 --self.frame:AddChild(btn)
John@1 213 end
John@1 214
John@1 215