annotate libs/Tablet-2.0/Tablet-2.0.lua @ 1:c11ca1d8ed91

Version 0.1
author Flick <flickerstreak@gmail.com>
date Tue, 20 Mar 2007 21:03:57 +0000
parents
children
rev   line source
flickerstreak@1 1 --[[
flickerstreak@1 2 Name: Tablet-2.0
flickerstreak@1 3 Revision: $Rev: 19577 $
flickerstreak@1 4 Author(s): ckknight (ckknight@gmail.com)
flickerstreak@1 5 Website: http://ckknight.wowinterface.com/
flickerstreak@1 6 Documentation: http://www.wowace.com/index.php/Tablet-2.0
flickerstreak@1 7 SVN: http://svn.wowace.com/wowace/trunk/TabletLib/Tablet-2.0
flickerstreak@1 8 Description: A library to provide an efficient, featureful tooltip-style display.
flickerstreak@1 9 Dependencies: AceLibrary, (optional) Dewdrop-2.0
flickerstreak@1 10 ]]
flickerstreak@1 11
flickerstreak@1 12 local MAJOR_VERSION = "Tablet-2.0"
flickerstreak@1 13 local MINOR_VERSION = "$Revision: 19577 $"
flickerstreak@1 14
flickerstreak@1 15 if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
flickerstreak@1 16 if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
flickerstreak@1 17
flickerstreak@1 18 local DEBUG = false
flickerstreak@1 19
flickerstreak@1 20 local SCROLL_UP = "Scroll up"
flickerstreak@1 21 local SCROLL_DOWN = "Scroll down"
flickerstreak@1 22 local HINT = "Hint"
flickerstreak@1 23 local DETACH = "Detach"
flickerstreak@1 24 local DETACH_DESC = "Detach the tablet from its source."
flickerstreak@1 25 local SIZE = "Size"
flickerstreak@1 26 local SIZE_DESC = "Scale the tablet."
flickerstreak@1 27 local CLOSE_MENU = "Close menu"
flickerstreak@1 28 local CLOSE_MENU_DESC = "Close the menu."
flickerstreak@1 29 local COLOR = "Background color"
flickerstreak@1 30 local COLOR_DESC = "Set the background color."
flickerstreak@1 31 local LOCK = "Lock"
flickerstreak@1 32 local LOCK_DESC = "Lock the tablet in its current position. Alt+Right-click for menu or Alt+drag to drag it when locked."
flickerstreak@1 33
flickerstreak@1 34 if GetLocale() == "deDE" then
flickerstreak@1 35 SCROLL_UP = "Hochscrollen"
flickerstreak@1 36 SCROLL_DOWN = "Runterscrollen"
flickerstreak@1 37 HINT = "Hinweis"
flickerstreak@1 38 DETACH = "L\195\182sen"
flickerstreak@1 39 DETACH_DESC = "L\195\182st den Tooltip aus seiner Verankerung."
flickerstreak@1 40 SIZE = "Gr\195\182\195\159e"
flickerstreak@1 41 SIZE_DESC = "Gr\195\182\195\159e des Tooltips \195\164ndern."
flickerstreak@1 42 CLOSE_MENU = "Menu schlie\195\159en"
flickerstreak@1 43 CLOSE_MENU_DESC = "Schlie\195\159t das Menu."
flickerstreak@1 44 COLOR = "Hintergrundfarbe"
flickerstreak@1 45 COLOR_DESC = "Hintergrundfarbe setzen."
flickerstreak@1 46 LOCK = "Sperren"
flickerstreak@1 47 LOCK_DESC = "Sperrt die aktuelle Position vom Tooltip. Alt+Rechts-klick f\195\188rs Men\195\188 oder Alt+Verschieben f\195\188rs verschieben wenn es gesperrt ist."
flickerstreak@1 48 elseif GetLocale() == "koKR" then
flickerstreak@1 49 SCROLL_UP = "위로 스크롤"
flickerstreak@1 50 SCROLL_DOWN = "아래로 스크롤"
flickerstreak@1 51 HINT = "힌트"
flickerstreak@1 52 DETACH = "분리"
flickerstreak@1 53 DETACH_DESC = "테이블을 분리합니다."
flickerstreak@1 54 SIZE = "크기"
flickerstreak@1 55 SIZE_DESC = "테이블의 크기입니다."
flickerstreak@1 56 CLOSE_MENU = "메뉴 닫기"
flickerstreak@1 57 CLOSE_MENU_DESC = "메뉴를 닫습니다."
flickerstreak@1 58 COLOR = "배경 색상"
flickerstreak@1 59 COLOR_DESC = "배경 색상을 설정합니다."
flickerstreak@1 60 LOCK = "고정"
flickerstreak@1 61 LOCK_DESC = "현재 위치에 테이블을 고정합니다. 알트+우클릭 : 메뉴열기, 알트+드래그 : 고정된것을 드래그합니다."
flickerstreak@1 62 elseif GetLocale() == "zhCN" then
flickerstreak@1 63 SCROLL_UP = "向上翻转"
flickerstreak@1 64 SCROLL_DOWN = "向上翻转"
flickerstreak@1 65 HINT = "提示"
flickerstreak@1 66 DETACH = "分离"
flickerstreak@1 67 DETACH_DESC = "分离菜单为独立提示."
flickerstreak@1 68 SIZE = "尺寸"
flickerstreak@1 69 SIZE_DESC = "缩放菜单显示尺寸."
flickerstreak@1 70 CLOSE_MENU = "关闭菜单"
flickerstreak@1 71 CLOSE_MENU_DESC = "关闭菜单"
flickerstreak@1 72 COLOR = "背景颜色"
flickerstreak@1 73 COLOR_DESC = "设置菜单背景颜色."
flickerstreak@1 74 LOCK = "锁定"
flickerstreak@1 75 LOCK_DESC = "锁定菜单当前位置. alt+右键 将显示选项, alt+拖动 可以移动已锁定的菜单."
flickerstreak@1 76 elseif GetLocale() == "zhTW" then
flickerstreak@1 77 SCROLL_UP = "向上翻轉"
flickerstreak@1 78 SCROLL_DOWN = "向上翻轉"
flickerstreak@1 79 HINT = "提示"
flickerstreak@1 80 DETACH = "分離"
flickerstreak@1 81 DETACH_DESC = "分離選單為獨立提示。"
flickerstreak@1 82 SIZE = "尺寸"
flickerstreak@1 83 SIZE_DESC = "縮放選單顯示尺寸。"
flickerstreak@1 84 CLOSE_MENU = "關閉選單"
flickerstreak@1 85 CLOSE_MENU_DESC = "關閉選單"
flickerstreak@1 86 COLOR = "背景顏色"
flickerstreak@1 87 COLOR_DESC = "設置選單背景顏色。"
flickerstreak@1 88 LOCK = "鎖定"
flickerstreak@1 89 LOCK_DESC = "鎖定選單目前位置. Alt+右鍵 將顯示選項,Alt+拖動 可以移動已鎖定的選單。"
flickerstreak@1 90 elseif GetLocale() == "frFR" then
flickerstreak@1 91 SCROLL_UP = "Parcourir vers le haut"
flickerstreak@1 92 SCROLL_DOWN = "Parcourir vers le bas"
flickerstreak@1 93 HINT = "Astuce"
flickerstreak@1 94 DETACH = "D\195\169tacher"
flickerstreak@1 95 DETACH_DESC = "Permet de d\195\169tacher le tableau de sa source."
flickerstreak@1 96 SIZE = "Taille"
flickerstreak@1 97 SIZE_DESC = "Permet de changer l'\195\169chelle du tableau."
flickerstreak@1 98 CLOSE_MENU = "Fermer le menu"
flickerstreak@1 99 CLOSE_MENU_DESC = "Ferme ce menu."
flickerstreak@1 100 COLOR = "Couleur du fond"
flickerstreak@1 101 COLOR_DESC = "Permet de d\195\169finir la couleur du fond."
flickerstreak@1 102 LOCK = "Bloquer"
flickerstreak@1 103 LOCK_DESC = "Bloque le tableau \195\160 sa position actuelle. Alt+clic-droit pour le menu ou Alt+glisser pour le d\195\169placer quand il est bloqu\195\169."
flickerstreak@1 104 end
flickerstreak@1 105
flickerstreak@1 106 local start = GetTime()
flickerstreak@1 107 local wrap
flickerstreak@1 108 local GetProfileInfo
flickerstreak@1 109 if DEBUG then
flickerstreak@1 110 local tree = {}
flickerstreak@1 111 local treeMemories = {}
flickerstreak@1 112 local treeTimes = {}
flickerstreak@1 113 local memories = {}
flickerstreak@1 114 local times = {}
flickerstreak@1 115 function wrap(value, name)
flickerstreak@1 116 if type(value) == "function" then
flickerstreak@1 117 local oldFunction = value
flickerstreak@1 118 memories[name] = 0
flickerstreak@1 119 times[name] = 0
flickerstreak@1 120 return function(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60)
flickerstreak@1 121 local pos = table.getn(tree)
flickerstreak@1 122 table.insert(tree, name)
flickerstreak@1 123 table.insert(treeMemories, 0)
flickerstreak@1 124 table.insert(treeTimes, 0)
flickerstreak@1 125 local t, mem = GetTime(), gcinfo()
flickerstreak@1 126 local r1, r2, r3, r4, r5, r6, r7, r8 = oldFunction(self, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, a53, a54, a55, a56, a57, a58, a59, a60)
flickerstreak@1 127 mem, t = gcinfo() - mem, GetTime() - t
flickerstreak@1 128 if pos > 0 then
flickerstreak@1 129 treeMemories[pos] = treeMemories[pos] + mem
flickerstreak@1 130 treeTimes[pos] = treeTimes[pos] + t
flickerstreak@1 131 end
flickerstreak@1 132 local otherMem = table.remove(treeMemories)
flickerstreak@1 133 if mem - otherMem > 0 then
flickerstreak@1 134 memories[name] = memories[name] + mem - otherMem
flickerstreak@1 135 end
flickerstreak@1 136 times[name] = times[name] + t - table.remove(treeTimes)
flickerstreak@1 137 table.remove(tree)
flickerstreak@1 138 return r1, r2, r3, r4, r5, r6, r7, r8
flickerstreak@1 139 end
flickerstreak@1 140 end
flickerstreak@1 141 end
flickerstreak@1 142
flickerstreak@1 143 function GetProfileInfo()
flickerstreak@1 144 return GetTime() - start, times, memories
flickerstreak@1 145 end
flickerstreak@1 146 else
flickerstreak@1 147 function wrap(value)
flickerstreak@1 148 return value
flickerstreak@1 149 end
flickerstreak@1 150 end
flickerstreak@1 151
flickerstreak@1 152 local MIN_TOOLTIP_SIZE = 200
flickerstreak@1 153 local TESTSTRING_EXTRA_WIDTH = 5
flickerstreak@1 154 local Tablet = {}
flickerstreak@1 155 local function getsecond(_, value)
flickerstreak@1 156 return value
flickerstreak@1 157 end
flickerstreak@1 158 local Dewdrop = nil
flickerstreak@1 159 local CleanCategoryPool
flickerstreak@1 160 local pool = {}
flickerstreak@1 161
flickerstreak@1 162 local function del(t)
flickerstreak@1 163 if t then
flickerstreak@1 164 for k in pairs(t) do
flickerstreak@1 165 t[k] = nil
flickerstreak@1 166 end
flickerstreak@1 167 setmetatable(t, nil)
flickerstreak@1 168 pool[t] = true
flickerstreak@1 169 end
flickerstreak@1 170 end
flickerstreak@1 171
flickerstreak@1 172 local new
flickerstreak@1 173
flickerstreak@1 174 local function copy(parent)
flickerstreak@1 175 local t = next(pool) or {}
flickerstreak@1 176 pool[t] = nil
flickerstreak@1 177 if parent then
flickerstreak@1 178 for k,v in pairs(parent) do
flickerstreak@1 179 t[k] = v
flickerstreak@1 180 end
flickerstreak@1 181 setmetatable(t, getmetatable(parent))
flickerstreak@1 182 end
flickerstreak@1 183 return t
flickerstreak@1 184 end
flickerstreak@1 185
flickerstreak@1 186 function new(...)
flickerstreak@1 187 local t = next(pool) or {}
flickerstreak@1 188 pool[t] = nil
flickerstreak@1 189
flickerstreak@1 190 for i = 1, select('#', ...), 2 do
flickerstreak@1 191 local k = select(i, ...)
flickerstreak@1 192 if k then
flickerstreak@1 193 t[k] = select(i+1, ...)
flickerstreak@1 194 else
flickerstreak@1 195 break
flickerstreak@1 196 end
flickerstreak@1 197 end
flickerstreak@1 198 return t
flickerstreak@1 199 end
flickerstreak@1 200
flickerstreak@1 201 local tmp
flickerstreak@1 202 tmp = setmetatable({}, {__index = function(self, key)
flickerstreak@1 203 local t = {}
flickerstreak@1 204 tmp[key] = function(...)
flickerstreak@1 205 for k in pairs(t) do
flickerstreak@1 206 t[k] = nil
flickerstreak@1 207 end
flickerstreak@1 208 for i = 1, select('#', ...), 2 do
flickerstreak@1 209 local k = select(i, ...)
flickerstreak@1 210 if k then
flickerstreak@1 211 t[k] = select(i+1, ...)
flickerstreak@1 212 else
flickerstreak@1 213 break
flickerstreak@1 214 end
flickerstreak@1 215 end
flickerstreak@1 216 return t
flickerstreak@1 217 end
flickerstreak@1 218 return tmp[key]
flickerstreak@1 219 end})
flickerstreak@1 220
flickerstreak@1 221 local headerSize, normalSize
flickerstreak@1 222 if GameTooltipHeaderText then
flickerstreak@1 223 _,headerSize = GameTooltipHeaderText:GetFont()
flickerstreak@1 224 else
flickerstreak@1 225 headerSize = 14
flickerstreak@1 226 end
flickerstreak@1 227 if GameTooltipText then
flickerstreak@1 228 _,normalSize = GameTooltipText:GetFont()
flickerstreak@1 229 else
flickerstreak@1 230 normalSize = 12
flickerstreak@1 231 end
flickerstreak@1 232 local tooltip
flickerstreak@1 233 local testString
flickerstreak@1 234 local TabletData = {}
flickerstreak@1 235 local Category = {}
flickerstreak@1 236 local Line = {}
flickerstreak@1 237 do
flickerstreak@1 238 local TabletData_mt = { __index = TabletData }
flickerstreak@1 239 function TabletData:new(tablet)
flickerstreak@1 240 if not testString then
flickerstreak@1 241 testString = UIParent:CreateFontString()
flickerstreak@1 242 testString:Hide()
flickerstreak@1 243 end
flickerstreak@1 244 local self = new()
flickerstreak@1 245 self.categories = new()
flickerstreak@1 246 self.id = 0
flickerstreak@1 247 self.width = 0--(MIN_TOOLTIP_SIZE - 20)*tablet.fontSizePercent
flickerstreak@1 248 self.tablet = tablet
flickerstreak@1 249 self.title = "Title"
flickerstreak@1 250 self.titleR, self.titleG, self.titleB = nil, nil, nil
flickerstreak@1 251 setmetatable(self, TabletData_mt)
flickerstreak@1 252 return self
flickerstreak@1 253 end
flickerstreak@1 254
flickerstreak@1 255 function TabletData:del()
flickerstreak@1 256 for k, v in ipairs(self.categories) do
flickerstreak@1 257 v:del()
flickerstreak@1 258 end
flickerstreak@1 259 del(self.categories)
flickerstreak@1 260 del(self)
flickerstreak@1 261 end
flickerstreak@1 262
flickerstreak@1 263 function TabletData:Display()
flickerstreak@1 264 if self.tablet == tooltip or self.tablet.registration.showTitleWhenDetached then
flickerstreak@1 265 local info = new(
flickerstreak@1 266 'hideBlankLine', true,
flickerstreak@1 267 'text', self.title,
flickerstreak@1 268 'justify', "CENTER",
flickerstreak@1 269 'font', GameTooltipHeaderText,
flickerstreak@1 270 'isTitle', true
flickerstreak@1 271 )
flickerstreak@1 272 if self.titleR then
flickerstreak@1 273 info.textR = self.titleR
flickerstreak@1 274 info.textG = self.titleG
flickerstreak@1 275 info.textB = self.titleB
flickerstreak@1 276 end
flickerstreak@1 277 self:AddCategory(info, 1)
flickerstreak@1 278 del(info)
flickerstreak@1 279 end
flickerstreak@1 280 if self.tablet == tooltip or self.tablet.registration.showHintWhenDetached then
flickerstreak@1 281 if self.hint then
flickerstreak@1 282 self:AddCategory(nil):AddLine(
flickerstreak@1 283 'text', HINT .. ": " .. self.hint,
flickerstreak@1 284 'textR', 0,
flickerstreak@1 285 'textG', 1,
flickerstreak@1 286 'textB', 0,
flickerstreak@1 287 'wrap', true
flickerstreak@1 288 )
flickerstreak@1 289 end
flickerstreak@1 290 end
flickerstreak@1 291
flickerstreak@1 292 local tabletData = self.tabletData
flickerstreak@1 293 local width
flickerstreak@1 294 for k, v in ipairs(self.categories) do
flickerstreak@1 295 if v.columns <= 2 then
flickerstreak@1 296 width = v.x1
flickerstreak@1 297 else
flickerstreak@1 298 width = v.x1 + v.x2 + v.x3 + v.x4 + v.x5 + v.x6 + (v.columns - 1) * 20
flickerstreak@1 299 end
flickerstreak@1 300 if self.width < width then
flickerstreak@1 301 self.width = width
flickerstreak@1 302 end
flickerstreak@1 303 end
flickerstreak@1 304
flickerstreak@1 305 local good = false
flickerstreak@1 306 local lastTitle = true
flickerstreak@1 307 for k, v in ipairs(self.categories) do
flickerstreak@1 308 if lastTitle then
flickerstreak@1 309 v.hideBlankLine = true
flickerstreak@1 310 lastTitle = false
flickerstreak@1 311 end
flickerstreak@1 312 if v:Display(self.tablet) then
flickerstreak@1 313 good = true
flickerstreak@1 314 end
flickerstreak@1 315 if v.isTitle then
flickerstreak@1 316 lastTitle = true
flickerstreak@1 317 end
flickerstreak@1 318 end
flickerstreak@1 319 if not good then
flickerstreak@1 320 if self.tablet == tooltip or not self.tablet.registration.hideWhenEmpty then
flickerstreak@1 321 local width
flickerstreak@1 322 local info = new(
flickerstreak@1 323 'hideBlankLine', true,
flickerstreak@1 324 'text', self.title,
flickerstreak@1 325 'justify', "CENTER",
flickerstreak@1 326 'font', GameTooltipHeaderText,
flickerstreak@1 327 'isTitle', true
flickerstreak@1 328 )
flickerstreak@1 329 local cat = self:AddCategory(info)
flickerstreak@1 330 del(info)
flickerstreak@1 331 self.width = self.categories[table.getn(self.categories)].x1
flickerstreak@1 332 cat:Display(self.tablet)
flickerstreak@1 333 else
flickerstreak@1 334 self.tablet:__Hide()
flickerstreak@1 335 self.tablet.tmpHidden = true
flickerstreak@1 336 end
flickerstreak@1 337 else
flickerstreak@1 338 self.tablet:__Show()
flickerstreak@1 339 self.tablet.tmpHidden = nil
flickerstreak@1 340 end
flickerstreak@1 341 end
flickerstreak@1 342
flickerstreak@1 343 function TabletData:AddCategory(info, index)
flickerstreak@1 344 local made = false
flickerstreak@1 345 if not info then
flickerstreak@1 346 made = true
flickerstreak@1 347 info = new()
flickerstreak@1 348 end
flickerstreak@1 349 local cat = Category:new(self, info)
flickerstreak@1 350 if index then
flickerstreak@1 351 table.insert(self.categories, index, cat)
flickerstreak@1 352 else
flickerstreak@1 353 table.insert(self.categories, cat)
flickerstreak@1 354 end
flickerstreak@1 355 if made then
flickerstreak@1 356 del(info)
flickerstreak@1 357 end
flickerstreak@1 358 return cat
flickerstreak@1 359 end
flickerstreak@1 360
flickerstreak@1 361 function TabletData:SetHint(hint)
flickerstreak@1 362 self.hint = hint
flickerstreak@1 363 end
flickerstreak@1 364
flickerstreak@1 365 function TabletData:SetTitle(title)
flickerstreak@1 366 self.title = title or "Title"
flickerstreak@1 367 end
flickerstreak@1 368
flickerstreak@1 369 function TabletData:SetTitleColor(r, g, b)
flickerstreak@1 370 self.titleR = r
flickerstreak@1 371 self.titleG = g
flickerstreak@1 372 self.titleB = b
flickerstreak@1 373 end
flickerstreak@1 374 end
flickerstreak@1 375 do
flickerstreak@1 376 local Category_mt = { __index = Category }
flickerstreak@1 377 function Category:new(tabletData, info, superCategory)
flickerstreak@1 378 local self = copy(info)
flickerstreak@1 379 if superCategory and not self.noInherit then
flickerstreak@1 380 self.superCategory = superCategory.superCategory
flickerstreak@1 381 for k, v in pairs(superCategory) do
flickerstreak@1 382 if string.find(k, "^child_") then
flickerstreak@1 383 local k = strsub(k, 7)
flickerstreak@1 384 if self[k] == nil then
flickerstreak@1 385 self[k] = v
flickerstreak@1 386 end
flickerstreak@1 387 end
flickerstreak@1 388 end
flickerstreak@1 389 self.columns = superCategory.columns
flickerstreak@1 390 else
flickerstreak@1 391 self.superCategory = self
flickerstreak@1 392 end
flickerstreak@1 393 self.tabletData = tabletData
flickerstreak@1 394 self.lines = new()
flickerstreak@1 395 if not self.columns then
flickerstreak@1 396 self.columns = 1
flickerstreak@1 397 end
flickerstreak@1 398 self.x1 = 0
flickerstreak@1 399 self.x2 = 0
flickerstreak@1 400 self.x3 = 0
flickerstreak@1 401 self.x4 = 0
flickerstreak@1 402 self.x5 = 0
flickerstreak@1 403 self.x6 = 0
flickerstreak@1 404 setmetatable(self, Category_mt)
flickerstreak@1 405 self.lastWasTitle = nil
flickerstreak@1 406 if self.text or self.text2 or self.text3 or self.text4 or self.text5 or self.text6 then
flickerstreak@1 407 local x = new(
flickerstreak@1 408 'category', category,
flickerstreak@1 409 'text', self.text,
flickerstreak@1 410 'textR', self.textR or 1,
flickerstreak@1 411 'textG', self.textG or 1,
flickerstreak@1 412 'textB', self.textB or 1,
flickerstreak@1 413 'fakeChild', true,
flickerstreak@1 414 'func', self.func,
flickerstreak@1 415 'arg1', self.arg1,
flickerstreak@1 416 'arg2', self.arg2,
flickerstreak@1 417 'arg3', self.arg3,
flickerstreak@1 418 'hasCheck', self.hasCheck,
flickerstreak@1 419 'checked', self.checked,
flickerstreak@1 420 'checkIcon', self.checkIcon,
flickerstreak@1 421 'isRadio', self.isRadio,
flickerstreak@1 422 'font', self.font,
flickerstreak@1 423 'size', self.size,
flickerstreak@1 424 'wrap', self.wrap,
flickerstreak@1 425 'catStart', true,
flickerstreak@1 426 'indentation', self.indentation,
flickerstreak@1 427 'noInherit', true,
flickerstreak@1 428 'justify', self.justify,
flickerstreak@1 429 'justify2', self.justify2,
flickerstreak@1 430 'justify3', self.justify3,
flickerstreak@1 431 'justify4', self.justify4,
flickerstreak@1 432 'justify5', self.justify5,
flickerstreak@1 433 'justify6', self.justify6
flickerstreak@1 434 )
flickerstreak@1 435 if self.isTitle then
flickerstreak@1 436 x.textR = self.textR or 1
flickerstreak@1 437 x.textG = self.textG or 0.823529
flickerstreak@1 438 x.textB = self.textB or 0
flickerstreak@1 439 else
flickerstreak@1 440 x.textR = self.textR or 1
flickerstreak@1 441 x.textG = self.textG or 1
flickerstreak@1 442 x.textB = self.textB or 1
flickerstreak@1 443 end
flickerstreak@1 444 x.text2 = self.text2
flickerstreak@1 445 x.text3 = self.text3
flickerstreak@1 446 x.text4 = self.text4
flickerstreak@1 447 x.text5 = self.text5
flickerstreak@1 448 x.text6 = self.text6
flickerstreak@1 449 x.text2R = self.text2R or self.textR2 or 1
flickerstreak@1 450 x.text2G = self.text2G or self.textG2 or 1
flickerstreak@1 451 x.text2B = self.text2B or self.textB2 or 1
flickerstreak@1 452 x.text3R = self.text3R or self.textR3 or 1
flickerstreak@1 453 x.text3G = self.text3G or self.textG3 or 1
flickerstreak@1 454 x.text3B = self.text3B or self.textB3 or 1
flickerstreak@1 455 x.text4R = self.text4R or self.textR4 or 1
flickerstreak@1 456 x.text4G = self.text4G or self.textG4 or 1
flickerstreak@1 457 x.text4B = self.text4B or self.textB4 or 1
flickerstreak@1 458 x.text5R = self.text5R or self.textR5 or 1
flickerstreak@1 459 x.text5G = self.text5G or self.textG5 or 1
flickerstreak@1 460 x.text5B = self.text5B or self.textB5 or 1
flickerstreak@1 461 x.text6R = self.text6R or self.textR6 or 1
flickerstreak@1 462 x.text6G = self.text6G or self.textG6 or 1
flickerstreak@1 463 x.text6B = self.text6B or self.textB6 or 1
flickerstreak@1 464 x.font2 = self.font2
flickerstreak@1 465 x.font3 = self.font3
flickerstreak@1 466 x.font4 = self.font4
flickerstreak@1 467 x.font5 = self.font5
flickerstreak@1 468 x.font6 = self.font6
flickerstreak@1 469 x.size2 = self.size2
flickerstreak@1 470 x.size3 = self.size3
flickerstreak@1 471 x.size4 = self.size4
flickerstreak@1 472 x.size5 = self.size5
flickerstreak@1 473 x.size6 = self.size6
flickerstreak@1 474 self:AddLine(x)
flickerstreak@1 475 del(x)
flickerstreak@1 476 self.lastWasTitle = true
flickerstreak@1 477 end
flickerstreak@1 478 return self
flickerstreak@1 479 end
flickerstreak@1 480
flickerstreak@1 481 function Category:del()
flickerstreak@1 482 local prev = garbageLine
flickerstreak@1 483 for k, v in pairs(self.lines) do
flickerstreak@1 484 v:del()
flickerstreak@1 485 end
flickerstreak@1 486 del(self.lines)
flickerstreak@1 487 del(self)
flickerstreak@1 488 end
flickerstreak@1 489
flickerstreak@1 490 function Category:AddLine(...)
flickerstreak@1 491 self.lastWasTitle = nil
flickerstreak@1 492 local line
flickerstreak@1 493 local k1 = ...
flickerstreak@1 494 if type(k1) == "table" then
flickerstreak@1 495 local k2 = select(2, ...)
flickerstreak@1 496 Line:new(self, k1, k2)
flickerstreak@1 497 else
flickerstreak@1 498 local info = new(...)
flickerstreak@1 499 Line:new(self, info)
flickerstreak@1 500 info = del(info)
flickerstreak@1 501 end
flickerstreak@1 502 end
flickerstreak@1 503
flickerstreak@1 504 function Category:AddCategory(...)
flickerstreak@1 505 local lastWasTitle = self.lastWasTitle
flickerstreak@1 506 self.lastWasTitle = nil
flickerstreak@1 507 local info
flickerstreak@1 508 local k1 = ...
flickerstreak@1 509 if type(k1) == "table" then
flickerstreak@1 510 info = k1
flickerstreak@1 511 else
flickerstreak@1 512 info = new(...)
flickerstreak@1 513 end
flickerstreak@1 514 if lastWasTitle or table.getn(self.lines) == 0 then
flickerstreak@1 515 info.hideBlankLine = true
flickerstreak@1 516 end
flickerstreak@1 517 local cat = Category:new(self.tabletData, info, self)
flickerstreak@1 518 table.insert(self.lines, cat)
flickerstreak@1 519 if info ~= k1 then
flickerstreak@1 520 info = del(info)
flickerstreak@1 521 end
flickerstreak@1 522 return cat
flickerstreak@1 523 end
flickerstreak@1 524
flickerstreak@1 525 function Category:HasChildren()
flickerstreak@1 526 local hasChildren = false
flickerstreak@1 527 for k, v in ipairs(self.lines) do
flickerstreak@1 528 if v.HasChildren then
flickerstreak@1 529 if v:HasChildren() then
flickerstreak@1 530 return true
flickerstreak@1 531 end
flickerstreak@1 532 end
flickerstreak@1 533 if not v.fakeChild then
flickerstreak@1 534 return true
flickerstreak@1 535 end
flickerstreak@1 536 end
flickerstreak@1 537 return false
flickerstreak@1 538 end
flickerstreak@1 539
flickerstreak@1 540 local lastWasTitle = false
flickerstreak@1 541 function Category:Display(tablet)
flickerstreak@1 542 if not self.isTitle and not self.showWithoutChildren and not self:HasChildren() then
flickerstreak@1 543 return false
flickerstreak@1 544 end
flickerstreak@1 545 if not self.hideBlankLine and not lastWasTitle then
flickerstreak@1 546 local info = new(
flickerstreak@1 547 'blank', true,
flickerstreak@1 548 'fakeChild', true
flickerstreak@1 549 )
flickerstreak@1 550 self:AddLine(info, 1)
flickerstreak@1 551 del(info)
flickerstreak@1 552 end
flickerstreak@1 553 local good = false
flickerstreak@1 554 if table.getn(self.lines) > 0 then
flickerstreak@1 555 self.tabletData.id = self.tabletData.id + 1
flickerstreak@1 556 self.id = self.tabletData.id
flickerstreak@1 557 for k, v in ipairs(self.lines) do
flickerstreak@1 558 if v:Display(tablet) then
flickerstreak@1 559 good = true
flickerstreak@1 560 end
flickerstreak@1 561 end
flickerstreak@1 562 end
flickerstreak@1 563 lastWasTitle = self.isTitle
flickerstreak@1 564 return good
flickerstreak@1 565 end
flickerstreak@1 566 end
flickerstreak@1 567 do
flickerstreak@1 568 local Line_mt = { __index = Line }
flickerstreak@1 569 function Line:new(category, info, position)
flickerstreak@1 570 local self = copy(info)
flickerstreak@1 571 if not info.noInherit then
flickerstreak@1 572 for k, v in pairs(category) do
flickerstreak@1 573 if string.find(k, "^child_") then
flickerstreak@1 574 local k = strsub(k, 7)
flickerstreak@1 575 if self[k] == nil then
flickerstreak@1 576 self[k] = v
flickerstreak@1 577 end
flickerstreak@1 578 end
flickerstreak@1 579 end
flickerstreak@1 580 end
flickerstreak@1 581 self.category = category
flickerstreak@1 582 if position then
flickerstreak@1 583 table.insert(category.lines, position, self)
flickerstreak@1 584 else
flickerstreak@1 585 table.insert(category.lines, self)
flickerstreak@1 586 end
flickerstreak@1 587 setmetatable(self, Line_mt)
flickerstreak@1 588 local columns = category.columns
flickerstreak@1 589 if columns == 1 then
flickerstreak@1 590 if not self.justify then
flickerstreak@1 591 self.justify = "LEFT"
flickerstreak@1 592 end
flickerstreak@1 593 elseif columns == 2 then
flickerstreak@1 594 self.justify = "LEFT"
flickerstreak@1 595 self.justify2 = "RIGHT"
flickerstreak@1 596 if self.wrap then
flickerstreak@1 597 self.wrap2 = false
flickerstreak@1 598 end
flickerstreak@1 599 elseif columns == 3 then
flickerstreak@1 600 if not self.justify then
flickerstreak@1 601 self.justify = "LEFT"
flickerstreak@1 602 end
flickerstreak@1 603 if not self.justify2 then
flickerstreak@1 604 self.justify2 = "CENTER"
flickerstreak@1 605 end
flickerstreak@1 606 if not self.justify3 then
flickerstreak@1 607 self.justify3 = "RIGHT"
flickerstreak@1 608 end
flickerstreak@1 609 if self.wrap then
flickerstreak@1 610 self.wrap2 = false
flickerstreak@1 611 self.wrap3 = false
flickerstreak@1 612 elseif self.wrap2 then
flickerstreak@1 613 self.wrap3 = false
flickerstreak@1 614 end
flickerstreak@1 615 elseif columns == 4 then
flickerstreak@1 616 if not self.justify then
flickerstreak@1 617 self.justify = "LEFT"
flickerstreak@1 618 end
flickerstreak@1 619 if not self.justify2 then
flickerstreak@1 620 self.justify2 = "CENTER"
flickerstreak@1 621 end
flickerstreak@1 622 if not self.justify3 then
flickerstreak@1 623 self.justify3 = "CENTER"
flickerstreak@1 624 end
flickerstreak@1 625 if not self.justify4 then
flickerstreak@1 626 self.justify4 = "RIGHT"
flickerstreak@1 627 end
flickerstreak@1 628 if self.wrap then
flickerstreak@1 629 self.wrap2 = false
flickerstreak@1 630 self.wrap3 = false
flickerstreak@1 631 self.wrap4 = false
flickerstreak@1 632 elseif self.wrap2 then
flickerstreak@1 633 self.wrap3 = false
flickerstreak@1 634 self.wrap4 = false
flickerstreak@1 635 elseif self.wrap3 then
flickerstreak@1 636 self.wrap4 = false
flickerstreak@1 637 end
flickerstreak@1 638 elseif columns == 5 then
flickerstreak@1 639 if not self.justify then
flickerstreak@1 640 self.justify = "LEFT"
flickerstreak@1 641 end
flickerstreak@1 642 if not self.justify2 then
flickerstreak@1 643 self.justify2 = "CENTER"
flickerstreak@1 644 end
flickerstreak@1 645 if not self.justify3 then
flickerstreak@1 646 self.justify3 = "CENTER"
flickerstreak@1 647 end
flickerstreak@1 648 if not self.justify4 then
flickerstreak@1 649 self.justify4 = "CENTER"
flickerstreak@1 650 end
flickerstreak@1 651 if not self.justify5 then
flickerstreak@1 652 self.justify5 = "RIGHT"
flickerstreak@1 653 end
flickerstreak@1 654 if self.wrap then
flickerstreak@1 655 self.wrap2 = false
flickerstreak@1 656 self.wrap3 = false
flickerstreak@1 657 self.wrap4 = false
flickerstreak@1 658 self.wrap5 = false
flickerstreak@1 659 elseif self.wrap2 then
flickerstreak@1 660 self.wrap3 = false
flickerstreak@1 661 self.wrap4 = false
flickerstreak@1 662 self.wrap5 = false
flickerstreak@1 663 elseif self.wrap3 then
flickerstreak@1 664 self.wrap4 = false
flickerstreak@1 665 self.wrap5 = false
flickerstreak@1 666 elseif self.wrap4 then
flickerstreak@1 667 self.wrap5 = false
flickerstreak@1 668 end
flickerstreak@1 669 elseif columns == 6 then
flickerstreak@1 670 if not self.justify then
flickerstreak@1 671 self.justify = "LEFT"
flickerstreak@1 672 end
flickerstreak@1 673 if not self.justify2 then
flickerstreak@1 674 self.justify2 = "CENTER"
flickerstreak@1 675 end
flickerstreak@1 676 if not self.justify3 then
flickerstreak@1 677 self.justify3 = "CENTER"
flickerstreak@1 678 end
flickerstreak@1 679 if not self.justify4 then
flickerstreak@1 680 self.justify4 = "CENTER"
flickerstreak@1 681 end
flickerstreak@1 682 if not self.justify5 then
flickerstreak@1 683 self.justify5 = "CENTER"
flickerstreak@1 684 end
flickerstreak@1 685 if not self.justify6 then
flickerstreak@1 686 self.justify6 = "RIGHT"
flickerstreak@1 687 end
flickerstreak@1 688 if self.wrap then
flickerstreak@1 689 self.wrap2 = false
flickerstreak@1 690 self.wrap3 = false
flickerstreak@1 691 self.wrap4 = false
flickerstreak@1 692 self.wrap5 = false
flickerstreak@1 693 self.wrap6 = false
flickerstreak@1 694 elseif self.wrap2 then
flickerstreak@1 695 self.wrap3 = false
flickerstreak@1 696 self.wrap4 = false
flickerstreak@1 697 self.wrap5 = false
flickerstreak@1 698 self.wrap6 = false
flickerstreak@1 699 elseif self.wrap3 then
flickerstreak@1 700 self.wrap4 = false
flickerstreak@1 701 self.wrap5 = false
flickerstreak@1 702 self.wrap6 = false
flickerstreak@1 703 elseif self.wrap4 then
flickerstreak@1 704 self.wrap5 = false
flickerstreak@1 705 self.wrap6 = false
flickerstreak@1 706 elseif self.wrap5 then
flickerstreak@1 707 self.wrap6 = false
flickerstreak@1 708 end
flickerstreak@1 709 end
flickerstreak@1 710 if self.textR2 then
flickerstreak@1 711 self.text2R, self.textR2 = self.text2R or self.textR2
flickerstreak@1 712 self.text2G, self.textG2 = self.text2G or self.textG2
flickerstreak@1 713 self.text2B, self.textB2 = self.text2B or self.textB2
flickerstreak@1 714 if self.textR3 then
flickerstreak@1 715 self.text3R, self.textR3 = self.text3R or self.textR3
flickerstreak@1 716 self.text3G, self.textG3 = self.text3G or self.textG3
flickerstreak@1 717 self.text3B, self.textB3 = self.text3B or self.textB3
flickerstreak@1 718 if self.textR4 then
flickerstreak@1 719 self.text4R, self.textR4 = self.text4R or self.textR4
flickerstreak@1 720 self.text4G, self.textG4 = self.text4G or self.textG4
flickerstreak@1 721 self.text4B, self.textB4 = self.text4B or self.textB4
flickerstreak@1 722 if self.textR5 then
flickerstreak@1 723 self.text5R, self.textR5 = self.text5R or self.textR5
flickerstreak@1 724 self.text5G, self.textG5 = self.text5G or self.textG5
flickerstreak@1 725 self.text5B, self.textB5 = self.text5B or self.textB5
flickerstreak@1 726 if self.textR5 then
flickerstreak@1 727 self.text6R, self.textR6 = self.text6R or self.textR6
flickerstreak@1 728 self.text6G, self.textG6 = self.text6G or self.textG6
flickerstreak@1 729 self.text6B, self.textB6 = self.text6B or self.textB6
flickerstreak@1 730 end
flickerstreak@1 731 end
flickerstreak@1 732 end
flickerstreak@1 733 end
flickerstreak@1 734 end
flickerstreak@1 735 if not self.indentation or self.indentation < 0 then
flickerstreak@1 736 self.indentation = 0
flickerstreak@1 737 end
flickerstreak@1 738 if not self.font then
flickerstreak@1 739 self.font = GameTooltipText
flickerstreak@1 740 end
flickerstreak@1 741 if not self.font2 then
flickerstreak@1 742 self.font2 = self.font
flickerstreak@1 743 end
flickerstreak@1 744 if not self.font3 then
flickerstreak@1 745 self.font3 = self.font
flickerstreak@1 746 end
flickerstreak@1 747 if not self.font4 then
flickerstreak@1 748 self.font4 = self.font
flickerstreak@1 749 end
flickerstreak@1 750 if not self.font5 then
flickerstreak@1 751 self.font5 = self.font
flickerstreak@1 752 end
flickerstreak@1 753 if not self.font6 then
flickerstreak@1 754 self.font6 = self.font
flickerstreak@1 755 end
flickerstreak@1 756 if not self.size then
flickerstreak@1 757 _,self.size = self.font:GetFont()
flickerstreak@1 758 end
flickerstreak@1 759 if not self.size2 then
flickerstreak@1 760 _,self.size2 = self.font2:GetFont()
flickerstreak@1 761 end
flickerstreak@1 762 if not self.size3 then
flickerstreak@1 763 _,self.size3 = self.font3:GetFont()
flickerstreak@1 764 end
flickerstreak@1 765 if not self.size4 then
flickerstreak@1 766 _,self.size4 = self.font4:GetFont()
flickerstreak@1 767 end
flickerstreak@1 768 if not self.size5 then
flickerstreak@1 769 _,self.size5 = self.font5:GetFont()
flickerstreak@1 770 end
flickerstreak@1 771 if not self.size6 then
flickerstreak@1 772 _,self.size6 = self.font6:GetFont()
flickerstreak@1 773 end
flickerstreak@1 774
flickerstreak@1 775 local fontSizePercent = category.tabletData.tablet.fontSizePercent
flickerstreak@1 776 local w = 0
flickerstreak@1 777 self.checkWidth = 0
flickerstreak@1 778 if self.text then
flickerstreak@1 779 if not self.wrap then
flickerstreak@1 780 testString:SetWidth(0)
flickerstreak@1 781 testString:SetFontObject(self.font)
flickerstreak@1 782 local font,_,flags = testString:GetFont()
flickerstreak@1 783 testString:SetFont(font, self.size * fontSizePercent, flags)
flickerstreak@1 784 testString:SetText(self.text)
flickerstreak@1 785 local checkWidth = self.hasCheck and self.size * fontSizePercent or 0
flickerstreak@1 786 self.checkWidth = checkWidth
flickerstreak@1 787 w = testString:GetWidth() + self.indentation * fontSizePercent + checkWidth + TESTSTRING_EXTRA_WIDTH
flickerstreak@1 788 if category.superCategory.x1 < w then
flickerstreak@1 789 category.superCategory.x1 = w
flickerstreak@1 790 end
flickerstreak@1 791 else
flickerstreak@1 792 if columns == 1 then
flickerstreak@1 793 testString:SetWidth(0)
flickerstreak@1 794 testString:SetFontObject(self.font)
flickerstreak@1 795 local font,_,flags = testString:GetFont()
flickerstreak@1 796 testString:SetFont(font, self.size * fontSizePercent, flags)
flickerstreak@1 797 testString:SetText(self.text)
flickerstreak@1 798 local checkWidth = self.hasCheck and self.size * fontSizePercent or 0
flickerstreak@1 799 self.checkWidth = checkWidth
flickerstreak@1 800 w = testString:GetWidth() + self.indentation * fontSizePercent + checkWidth + TESTSTRING_EXTRA_WIDTH
flickerstreak@1 801 if w > (MIN_TOOLTIP_SIZE - 20) * fontSizePercent then
flickerstreak@1 802 w = (MIN_TOOLTIP_SIZE - 20) * fontSizePercent
flickerstreak@1 803 end
flickerstreak@1 804 else
flickerstreak@1 805 w = MIN_TOOLTIP_SIZE * fontSizePercent / 2
flickerstreak@1 806 end
flickerstreak@1 807 if category.superCategory.x1 < w then
flickerstreak@1 808 category.superCategory.x1 = w
flickerstreak@1 809 end
flickerstreak@1 810 end
flickerstreak@1 811 end
flickerstreak@1 812 if columns == 2 and self.text2 then
flickerstreak@1 813 if not self.wrap2 then
flickerstreak@1 814 testString:SetWidth(0)
flickerstreak@1 815 testString:SetFontObject(self.font2)
flickerstreak@1 816 local font,_,flags = testString:GetFont()
flickerstreak@1 817 testString:SetFont(font, self.size2 * fontSizePercent, flags)
flickerstreak@1 818 testString:SetText(self.text2)
flickerstreak@1 819 w = w + 40 * fontSizePercent + testString:GetWidth() + TESTSTRING_EXTRA_WIDTH
flickerstreak@1 820 if category.superCategory.x1 < w then
flickerstreak@1 821 category.superCategory.x1 = w
flickerstreak@1 822 end
flickerstreak@1 823 else
flickerstreak@1 824 w = w + 40 * fontSizePercent + MIN_TOOLTIP_SIZE * fontSizePercent / 2
flickerstreak@1 825 if category.superCategory.x1 < w then
flickerstreak@1 826 category.superCategory.x1 = w
flickerstreak@1 827 end
flickerstreak@1 828 end
flickerstreak@1 829 elseif columns >= 3 then
flickerstreak@1 830 if self.text2 then
flickerstreak@1 831 if not self.wrap2 then
flickerstreak@1 832 testString:SetWidth(0)
flickerstreak@1 833 testString:SetFontObject(self.font2)
flickerstreak@1 834 local font,_,flags = testString:GetFont()
flickerstreak@1 835 testString:SetFont(font, self.size2 * fontSizePercent, flags)
flickerstreak@1 836 testString:SetText(self.text2)
flickerstreak@1 837 local w = testString:GetWidth() + TESTSTRING_EXTRA_WIDTH
flickerstreak@1 838 if category.superCategory.x2 < w then
flickerstreak@1 839 category.superCategory.x2 = w
flickerstreak@1 840 end
flickerstreak@1 841 else
flickerstreak@1 842 local w = MIN_TOOLTIP_SIZE / 2
flickerstreak@1 843 if category.superCategory.x2 < w then
flickerstreak@1 844 category.superCategory.x2 = w
flickerstreak@1 845 end
flickerstreak@1 846 end
flickerstreak@1 847 end
flickerstreak@1 848 if self.text3 then
flickerstreak@1 849 if not self.wrap3 then
flickerstreak@1 850 testString:SetWidth(0)
flickerstreak@1 851 testString:SetFontObject(self.font3)
flickerstreak@1 852 local font,_,flags = testString:GetFont()
flickerstreak@1 853 testString:SetFont(font, self.size3 * fontSizePercent, flags)
flickerstreak@1 854 testString:SetText(self.text3)
flickerstreak@1 855 local w = testString:GetWidth() + TESTSTRING_EXTRA_WIDTH
flickerstreak@1 856 if category.superCategory.x3 < w then
flickerstreak@1 857 category.superCategory.x3 = w
flickerstreak@1 858 end
flickerstreak@1 859 else
flickerstreak@1 860 local w = MIN_TOOLTIP_SIZE / 2
flickerstreak@1 861 if category.superCategory.x3 < w then
flickerstreak@1 862 category.superCategory.x3 = w
flickerstreak@1 863 end
flickerstreak@1 864 end
flickerstreak@1 865 end
flickerstreak@1 866 if columns >= 4 then
flickerstreak@1 867 if self.text4 then
flickerstreak@1 868 if not self.wrap4 then
flickerstreak@1 869 testString:SetWidth(0)
flickerstreak@1 870 testString:SetFontObject(self.font4)
flickerstreak@1 871 local font,_,flags = testString:GetFont()
flickerstreak@1 872 testString:SetFont(font, self.size4 * fontSizePercent, flags)
flickerstreak@1 873 testString:SetText(self.text4)
flickerstreak@1 874 w = testString:GetWidth() + TESTSTRING_EXTRA_WIDTH
flickerstreak@1 875 if category.superCategory.x4 < w then
flickerstreak@1 876 category.superCategory.x4 = w
flickerstreak@1 877 end
flickerstreak@1 878 else
flickerstreak@1 879 local w = MIN_TOOLTIP_SIZE / 2
flickerstreak@1 880 if category.superCategory.x4 < w then
flickerstreak@1 881 category.superCategory.x4 = w
flickerstreak@1 882 end
flickerstreak@1 883 end
flickerstreak@1 884 end
flickerstreak@1 885 if columns >= 5 then
flickerstreak@1 886 if self.text5 then
flickerstreak@1 887 if not self.wrap5 then
flickerstreak@1 888 testString:SetWidth(0)
flickerstreak@1 889 testString:SetFontObject(self.font5)
flickerstreak@1 890 local font,_,flags = testString:GetFont()
flickerstreak@1 891 testString:SetFont(font, self.size5 * fontSizePercent, flags)
flickerstreak@1 892 testString:SetText(self.text5)
flickerstreak@1 893 w = testString:GetWidth() + TESTSTRING_EXTRA_WIDTH
flickerstreak@1 894 if category.superCategory.x5 < w then
flickerstreak@1 895 category.superCategory.x5 = w
flickerstreak@1 896 end
flickerstreak@1 897 else
flickerstreak@1 898 local w = MIN_TOOLTIP_SIZE / 2
flickerstreak@1 899 if category.superCategory.x5 < w then
flickerstreak@1 900 category.superCategory.x5 = w
flickerstreak@1 901 end
flickerstreak@1 902 end
flickerstreak@1 903 end
flickerstreak@1 904 if columns >= 6 then
flickerstreak@1 905 if self.text6 then
flickerstreak@1 906 if not self.wrap6 then
flickerstreak@1 907 testString:SetWidth(0)
flickerstreak@1 908 testString:SetFontObject(self.font6)
flickerstreak@1 909 local font,_,flags = testString:GetFont()
flickerstreak@1 910 testString:SetFont(font, self.size6 * fontSizePercent, flags)
flickerstreak@1 911 testString:SetText(self.text6)
flickerstreak@1 912 w = testString:GetWidth() + TESTSTRING_EXTRA_WIDTH
flickerstreak@1 913 if category.superCategory.x6 < w then
flickerstreak@1 914 category.superCategory.x6 = w
flickerstreak@1 915 end
flickerstreak@1 916 else
flickerstreak@1 917 local w = MIN_TOOLTIP_SIZE / 2
flickerstreak@1 918 if category.superCategory.x6 < w then
flickerstreak@1 919 category.superCategory.x6 = w
flickerstreak@1 920 end
flickerstreak@1 921 end
flickerstreak@1 922 end
flickerstreak@1 923 end
flickerstreak@1 924 end
flickerstreak@1 925 end
flickerstreak@1 926 end
flickerstreak@1 927 return self
flickerstreak@1 928 end
flickerstreak@1 929
flickerstreak@1 930 function Line:del()
flickerstreak@1 931 del(self)
flickerstreak@1 932 end
flickerstreak@1 933
flickerstreak@1 934 function Line:Display(tablet)
flickerstreak@1 935 tablet:AddLine(self)
flickerstreak@1 936 return true
flickerstreak@1 937 end
flickerstreak@1 938 end
flickerstreak@1 939
flickerstreak@1 940 local function button_OnEnter()
flickerstreak@1 941 if type(this.self:GetScript("OnEnter")) == "function" then
flickerstreak@1 942 this.self:GetScript("OnEnter")()
flickerstreak@1 943 end
flickerstreak@1 944 this.highlight:Show()
flickerstreak@1 945 end
flickerstreak@1 946
flickerstreak@1 947 local function button_OnLeave()
flickerstreak@1 948 if type(this.self:GetScript("OnLeave")) == "function" then
flickerstreak@1 949 this.self:GetScript("OnLeave")()
flickerstreak@1 950 end
flickerstreak@1 951 this.highlight:Hide()
flickerstreak@1 952 end
flickerstreak@1 953
flickerstreak@1 954 local function NewLine(self)
flickerstreak@1 955 if self.maxLines <= self.numLines then
flickerstreak@1 956 self.maxLines = self.maxLines + 1
flickerstreak@1 957 local button = CreateFrame("Button", nil, self)
flickerstreak@1 958 button.indentation = 0
flickerstreak@1 959 local check = button:CreateTexture(nil, "ARTWORK")
flickerstreak@1 960 local left = button:CreateFontString(nil, "ARTWORK")
flickerstreak@1 961 local right = button:CreateFontString(nil, "ARTWORK")
flickerstreak@1 962 local third = button:CreateFontString(nil, "ARTWORK")
flickerstreak@1 963 local fourth = button:CreateFontString(nil, "ARTWORK")
flickerstreak@1 964 local fifth = button:CreateFontString(nil, "ARTWORK")
flickerstreak@1 965 local sixth = button:CreateFontString(nil, "ARTWORK")
flickerstreak@1 966 local highlight = button:CreateTexture(nil, "BACKGROUND")
flickerstreak@1 967 highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
flickerstreak@1 968 button.highlight = highlight
flickerstreak@1 969 highlight:SetBlendMode("ADD")
flickerstreak@1 970 highlight:SetAllPoints(button)
flickerstreak@1 971 highlight:Hide()
flickerstreak@1 972 table.insert(self.buttons, button)
flickerstreak@1 973 table.insert(self.checks, check)
flickerstreak@1 974 table.insert(self.lefts, left)
flickerstreak@1 975 table.insert(self.rights, right)
flickerstreak@1 976 table.insert(self.thirds, third)
flickerstreak@1 977 table.insert(self.fourths, fourth)
flickerstreak@1 978 table.insert(self.fifths, fifth)
flickerstreak@1 979 table.insert(self.sixths, sixth)
flickerstreak@1 980 left:SetWidth(0)
flickerstreak@1 981 if self.maxLines == 1 then
flickerstreak@1 982 left:SetFontObject(GameTooltipHeaderText)
flickerstreak@1 983 right:SetFontObject(GameTooltipHeaderText)
flickerstreak@1 984 third:SetFontObject(GameTooltipHeaderText)
flickerstreak@1 985 fourth:SetFontObject(GameTooltipHeaderText)
flickerstreak@1 986 fifth:SetFontObject(GameTooltipHeaderText)
flickerstreak@1 987 sixth:SetFontObject(GameTooltipHeaderText)
flickerstreak@1 988 left:SetJustifyH("CENTER")
flickerstreak@1 989 button:SetPoint("TOPLEFT", self, "TOPLEFT", 8, -10)
flickerstreak@1 990 else
flickerstreak@1 991 left:SetFontObject(GameTooltipText)
flickerstreak@1 992 right:SetFontObject(GameTooltipText)
flickerstreak@1 993 third:SetFontObject(GameTooltipText)
flickerstreak@1 994 fourth:SetFontObject(GameTooltipText)
flickerstreak@1 995 fifth:SetFontObject(GameTooltipText)
flickerstreak@1 996 sixth:SetFontObject(GameTooltipText)
flickerstreak@1 997 button:SetPoint("TOPLEFT", self.buttons[self.maxLines - 1], "BOTTOMLEFT", 0, -2)
flickerstreak@1 998 end
flickerstreak@1 999 button:SetScript("OnEnter", button_OnEnter)
flickerstreak@1 1000 button:SetScript("OnLeave", button_OnLeave)
flickerstreak@1 1001 button.check = check
flickerstreak@1 1002 button.self = self
flickerstreak@1 1003 button:SetPoint("RIGHT", self, "RIGHT", -12, 0)
flickerstreak@1 1004 check.shown = false
flickerstreak@1 1005 check:SetPoint("TOPLEFT", button, "TOPLEFT")
flickerstreak@1 1006 left:SetPoint("TOPLEFT", check, "TOPLEFT")
flickerstreak@1 1007 right:SetPoint("TOPLEFT", left, "TOPRIGHT", 40 * self.fontSizePercent, 0)
flickerstreak@1 1008 third:SetPoint("TOPLEFT", right, "TOPRIGHT", 20 * self.fontSizePercent, 0)
flickerstreak@1 1009 fourth:SetPoint("TOPLEFT", third, "TOPRIGHT", 20 * self.fontSizePercent, 0)
flickerstreak@1 1010 fifth:SetPoint("TOPLEFT", fourth, "TOPRIGHT", 20 * self.fontSizePercent, 0)
flickerstreak@1 1011 sixth:SetPoint("TOPLEFT", fifth, "TOPRIGHT", 20 * self.fontSizePercent, 0)
flickerstreak@1 1012 right:SetJustifyH("RIGHT")
flickerstreak@1 1013 local _,size = GameTooltipText:GetFont()
flickerstreak@1 1014 check:SetHeight(size * 1.5)
flickerstreak@1 1015 check:SetWidth(size * 1.5)
flickerstreak@1 1016 check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
flickerstreak@1 1017 check:SetAlpha(0)
flickerstreak@1 1018 if not button.clicked then
flickerstreak@1 1019 button:SetScript("OnMouseWheel", self:GetScript("OnMouseWheel"))
flickerstreak@1 1020 button:EnableMouseWheel(true)
flickerstreak@1 1021 button:Hide()
flickerstreak@1 1022 end
flickerstreak@1 1023 check:Show()
flickerstreak@1 1024 left:Hide()
flickerstreak@1 1025 right:Hide()
flickerstreak@1 1026 third:Hide()
flickerstreak@1 1027 fourth:Hide()
flickerstreak@1 1028 fifth:Hide()
flickerstreak@1 1029 sixth:Hide()
flickerstreak@1 1030 end
flickerstreak@1 1031 end
flickerstreak@1 1032 NewLine = wrap(NewLine, "NewLine")
flickerstreak@1 1033
flickerstreak@1 1034 local function GetMaxLinesPerScreen(self)
flickerstreak@1 1035 if self == tooltip then
flickerstreak@1 1036 return floor(50 / self.fontSizePercent)
flickerstreak@1 1037 else
flickerstreak@1 1038 return floor(30 / self.fontSizePercent)
flickerstreak@1 1039 end
flickerstreak@1 1040 end
flickerstreak@1 1041 GetMaxLinesPerScreen = wrap(GetMaxLinesPerScreen, "GetMaxLinesPerScreen")
flickerstreak@1 1042
flickerstreak@1 1043 local detachedTooltips = {}
flickerstreak@1 1044 local AcquireDetachedFrame, ReleaseDetachedFrame
flickerstreak@1 1045 local function AcquireFrame(self, registration, data, detachedData)
flickerstreak@1 1046 if not detachedData then
flickerstreak@1 1047 detachedData = data
flickerstreak@1 1048 end
flickerstreak@1 1049 if tooltip then
flickerstreak@1 1050 tooltip.data = data
flickerstreak@1 1051 tooltip.detachedData = detachedData
flickerstreak@1 1052 local fontSizePercent = tooltip.data and tooltip.data.fontSizePercent or 1
flickerstreak@1 1053 local transparency = tooltip.data and tooltip.data.transparency or 0.75
flickerstreak@1 1054 local r = tooltip.data and tooltip.data.r or 0
flickerstreak@1 1055 local g = tooltip.data and tooltip.data.g or 0
flickerstreak@1 1056 local b = tooltip.data and tooltip.data.b or 0
flickerstreak@1 1057 tooltip:SetFontSizePercent(fontSizePercent)
flickerstreak@1 1058 tooltip:SetTransparency(transparency)
flickerstreak@1 1059 tooltip:SetColor(r, g, b)
flickerstreak@1 1060 else
flickerstreak@1 1061 tooltip = CreateFrame("Frame", "Tablet20Frame", UIParent)
flickerstreak@1 1062 self.tooltip = tooltip
flickerstreak@1 1063 tooltip.data = data
flickerstreak@1 1064 tooltip.detachedData = detachedData
flickerstreak@1 1065 tooltip:EnableMouse(true)
flickerstreak@1 1066 tooltip:EnableMouseWheel(true)
flickerstreak@1 1067 tooltip:SetFrameStrata("TOOLTIP")
flickerstreak@1 1068 tooltip:SetFrameLevel(10)
flickerstreak@1 1069 local backdrop = new(
flickerstreak@1 1070 'bgFile', "Interface\\Buttons\\WHITE8X8",
flickerstreak@1 1071 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
flickerstreak@1 1072 'tile', true,
flickerstreak@1 1073 'tileSize', 16,
flickerstreak@1 1074 'edgeSize', 16,
flickerstreak@1 1075 'insets', new(
flickerstreak@1 1076 'left', 5,
flickerstreak@1 1077 'right', 5,
flickerstreak@1 1078 'top', 5,
flickerstreak@1 1079 'bottom', 5
flickerstreak@1 1080 )
flickerstreak@1 1081 )
flickerstreak@1 1082 tooltip:SetBackdrop(backdrop)
flickerstreak@1 1083 del(backdrop.insets)
flickerstreak@1 1084 del(backdrop)
flickerstreak@1 1085 tooltip:SetBackdropColor(0, 0, 0, 1)
flickerstreak@1 1086
flickerstreak@1 1087 tooltip.numLines = 0
flickerstreak@1 1088 tooltip.owner = nil
flickerstreak@1 1089 tooltip.fontSizePercent = tooltip.data and tooltip.data.fontSizePercent or 1
flickerstreak@1 1090 tooltip.maxLines = 0
flickerstreak@1 1091 tooltip.buttons = {}
flickerstreak@1 1092 tooltip.checks = {}
flickerstreak@1 1093 tooltip.lefts = {}
flickerstreak@1 1094 tooltip.rights = {}
flickerstreak@1 1095 tooltip.thirds = {}
flickerstreak@1 1096 tooltip.fourths = {}
flickerstreak@1 1097 tooltip.fifths = {}
flickerstreak@1 1098 tooltip.sixths = {}
flickerstreak@1 1099 tooltip.transparency = tooltip.data and tooltip.data.transparency or 0.75
flickerstreak@1 1100 tooltip:SetBackdropColor(0, 0, 0, tooltip.transparency)
flickerstreak@1 1101 tooltip:SetBackdropBorderColor(1, 1, 1, tooltip.transparency)
flickerstreak@1 1102 tooltip.scroll = 0
flickerstreak@1 1103
flickerstreak@1 1104 tooltip:SetScript("OnUpdate", function()
flickerstreak@1 1105 if not tooltip.updating and not tooltip.enteredFrame then
flickerstreak@1 1106 tooltip.scroll = 0
flickerstreak@1 1107 tooltip:Hide()
flickerstreak@1 1108 tooltip.registration.tooltip = nil
flickerstreak@1 1109 tooltip.registration = nil
flickerstreak@1 1110 end
flickerstreak@1 1111 end)
flickerstreak@1 1112
flickerstreak@1 1113 tooltip:SetScript("OnEnter", function()
flickerstreak@1 1114 if tooltip.clickable then
flickerstreak@1 1115 tooltip.enteredFrame = true
flickerstreak@1 1116 end
flickerstreak@1 1117 end)
flickerstreak@1 1118
flickerstreak@1 1119 tooltip:SetScript("OnLeave", function()
flickerstreak@1 1120 if not tooltip.updating then
flickerstreak@1 1121 tooltip.enteredFrame = false
flickerstreak@1 1122 end
flickerstreak@1 1123 end)
flickerstreak@1 1124
flickerstreak@1 1125 tooltip:SetScript("OnMouseWheel", function()
flickerstreak@1 1126 tooltip.updating = true
flickerstreak@1 1127 tooltip:Scroll(arg1 < 0)
flickerstreak@1 1128 tooltip.updating = false
flickerstreak@1 1129 end)
flickerstreak@1 1130
flickerstreak@1 1131 NewLine(tooltip)
flickerstreak@1 1132
flickerstreak@1 1133 tooltip.scrollUp = tooltip:CreateFontString(nil, "ARTWORK")
flickerstreak@1 1134 tooltip.scrollUp:SetPoint("TOPLEFT", tooltip.buttons[1], "BOTTOMLEFT", 0, -2)
flickerstreak@1 1135 tooltip.scrollUp:SetPoint("RIGHT", tooltip, "RIGHT", 0, -10)
flickerstreak@1 1136 tooltip.scrollUp:SetFontObject(GameTooltipText)
flickerstreak@1 1137 tooltip.scrollUp:Hide()
flickerstreak@1 1138 local font,_,flags = tooltip.scrollUp:GetFont()
flickerstreak@1 1139 tooltip.scrollUp:SetFont(font, normalSize * tooltip.fontSizePercent, flags)
flickerstreak@1 1140 tooltip.scrollUp:SetJustifyH("CENTER")
flickerstreak@1 1141 tooltip.scrollUp:SetTextColor(1, 0.823529, 0)
flickerstreak@1 1142 tooltip.scrollUp:SetText(" ")
flickerstreak@1 1143
flickerstreak@1 1144 tooltip.scrollDown = tooltip:CreateFontString(nil, "ARTWORK")
flickerstreak@1 1145 tooltip.scrollDown:SetPoint("TOPLEFT", tooltip.buttons[1], "BOTTOMLEFT", 0, -2)
flickerstreak@1 1146 tooltip.scrollDown:SetPoint("RIGHT", tooltip, "RIGHT", 0, -10)
flickerstreak@1 1147 tooltip.scrollDown:SetFontObject(GameTooltipText)
flickerstreak@1 1148 tooltip.scrollDown:Hide()
flickerstreak@1 1149 local font,_,flags = tooltip.scrollUp:GetFont()
flickerstreak@1 1150 tooltip.scrollDown:SetFont(font, normalSize * tooltip.fontSizePercent, flags)
flickerstreak@1 1151 tooltip.scrollDown:SetJustifyH("CENTER")
flickerstreak@1 1152 tooltip.scrollDown:SetTextColor(1, 0.823529, 0)
flickerstreak@1 1153 tooltip.scrollDown:SetText(" ")
flickerstreak@1 1154
flickerstreak@1 1155 function tooltip:SetOwner(o)
flickerstreak@1 1156 self:Hide(o)
flickerstreak@1 1157 self.owner = o
flickerstreak@1 1158 end
flickerstreak@1 1159 tooltip.SetOwner = wrap(tooltip.SetOwner, "tooltip:SetOwner")
flickerstreak@1 1160
flickerstreak@1 1161 function tooltip:IsOwned(o)
flickerstreak@1 1162 return self.owner == o
flickerstreak@1 1163 end
flickerstreak@1 1164 tooltip.IsOwned = wrap(tooltip.IsOwned, "tooltip:IsOwned")
flickerstreak@1 1165
flickerstreak@1 1166 function tooltip:ClearLines(hide)
flickerstreak@1 1167 CleanCategoryPool(self)
flickerstreak@1 1168 for i = 1, self.numLines do
flickerstreak@1 1169 local button = self.buttons[i]
flickerstreak@1 1170 local check = self.checks[i]
flickerstreak@1 1171 if not button.clicked or hide then
flickerstreak@1 1172 button:Hide()
flickerstreak@1 1173 end
flickerstreak@1 1174 check.shown = false
flickerstreak@1 1175 check:SetAlpha(0)
flickerstreak@1 1176 end
flickerstreak@1 1177 self.numLines = 0
flickerstreak@1 1178 end
flickerstreak@1 1179 tooltip.ClearLines = wrap(tooltip.ClearLines, "tooltip:ClearLines")
flickerstreak@1 1180
flickerstreak@1 1181 function tooltip:NumLines()
flickerstreak@1 1182 return self.numLines
flickerstreak@1 1183 end
flickerstreak@1 1184
flickerstreak@1 1185 local lastWidth
flickerstreak@1 1186 local old_tooltip_Hide = tooltip.Hide
flickerstreak@1 1187 tooltip.__Hide = old_tooltip_Hide
flickerstreak@1 1188 function tooltip:Hide(newOwner)
flickerstreak@1 1189 if self == tooltip or newOwner == nil then
flickerstreak@1 1190 old_tooltip_Hide(self)
flickerstreak@1 1191 end
flickerstreak@1 1192 self:ClearLines(true)
flickerstreak@1 1193 self.owner = nil
flickerstreak@1 1194 self.lastWidth = nil
flickerstreak@1 1195 self.tmpHidden = nil
flickerstreak@1 1196 end
flickerstreak@1 1197 tooltip.Hide = wrap(tooltip.Hide, "tooltip:Hide")
flickerstreak@1 1198
flickerstreak@1 1199 local old_tooltip_Show = tooltip.Show
flickerstreak@1 1200 tooltip.__Show = old_tooltip_Show
flickerstreak@1 1201 function tooltip:Show(tabletData)
flickerstreak@1 1202 if self.owner == nil or self.notInUse then
flickerstreak@1 1203 return
flickerstreak@1 1204 end
flickerstreak@1 1205 if not self.tmpHidden then
flickerstreak@1 1206 old_tooltip_Show(self)
flickerstreak@1 1207 end
flickerstreak@1 1208
flickerstreak@1 1209 local maxWidth = tabletData and tabletData.width or self:GetWidth() - 20
flickerstreak@1 1210 local hasWrap = false
flickerstreak@1 1211 local screenWidth = GetScreenWidth()
flickerstreak@1 1212 local scrollMax = self.numLines
flickerstreak@1 1213 if scrollMax > GetMaxLinesPerScreen(self) + self.scroll then
flickerstreak@1 1214 scrollMax = GetMaxLinesPerScreen(self) + self.scroll
flickerstreak@1 1215 end
flickerstreak@1 1216 local numColumns
flickerstreak@1 1217
flickerstreak@1 1218 local height = 20
flickerstreak@1 1219 if scrollMax ~= self.numLines then
flickerstreak@1 1220 self.scrollDown:SetWidth(maxWidth)
flickerstreak@1 1221 height = height + self.scrollDown:GetHeight() + 2
flickerstreak@1 1222 end
flickerstreak@1 1223 if self.scroll ~= 0 then
flickerstreak@1 1224 self.scrollUp:SetWidth(maxWidth)
flickerstreak@1 1225 height = height + self.scrollUp:GetHeight() + 2
flickerstreak@1 1226 end
flickerstreak@1 1227 self:SetWidth(maxWidth + 20)
flickerstreak@1 1228
flickerstreak@1 1229 local tmp = self.scroll + 1
flickerstreak@1 1230 if tmp ~= 1 then
flickerstreak@1 1231 tmp = tmp + 1
flickerstreak@1 1232 end
flickerstreak@1 1233 for i = 1, self.numLines do
flickerstreak@1 1234 if i < tmp or i > scrollMax or (i == scrollMax and i ~= self.numLines) then
flickerstreak@1 1235 self.buttons[i]:ClearAllPoints()
flickerstreak@1 1236 self.buttons[i]:Hide()
flickerstreak@1 1237 else
flickerstreak@1 1238 local button = self.buttons[i]
flickerstreak@1 1239 local left = self.lefts[i]
flickerstreak@1 1240 local right = self.rights[i]
flickerstreak@1 1241 local check = self.checks[i]
flickerstreak@1 1242 button:SetWidth(maxWidth)
flickerstreak@1 1243 button:SetHeight(math.max(left:GetHeight(), right:GetHeight()))
flickerstreak@1 1244 height = height + button:GetHeight() + 2
flickerstreak@1 1245 if i == self.scroll + 1 then
flickerstreak@1 1246 button:SetPoint("TOPLEFT", self, "TOPLEFT", 10, -10)
flickerstreak@1 1247 else
flickerstreak@1 1248 button:SetPoint("TOPLEFT", self.buttons[i - 1], "BOTTOMLEFT", 0, -2)
flickerstreak@1 1249 end
flickerstreak@1 1250 if button.clicked then
flickerstreak@1 1251 check:SetPoint("TOPLEFT", button, "TOPLEFT", button.indentation * self.fontSizePercent + (check.width - check:GetWidth()) / 2 + 1, -1)
flickerstreak@1 1252 else
flickerstreak@1 1253 check:SetPoint("TOPLEFT", button, "TOPLEFT", button.indentation * self.fontSizePercent + (check.width - check:GetWidth()) / 2, 0)
flickerstreak@1 1254 end
flickerstreak@1 1255 button:Show()
flickerstreak@1 1256 end
flickerstreak@1 1257 end
flickerstreak@1 1258 if self.scroll ~= 0 then
flickerstreak@1 1259 self.scrollUp:SetPoint("TOPLEFT", self, "TOPLEFT", 10, -10)
flickerstreak@1 1260 self.buttons[self.scroll + 2]:SetPoint("TOPLEFT", self.scrollUp, "BOTTOMLEFT", 0, -2)
flickerstreak@1 1261 self.scrollUp:SetText(SCROLL_UP .. " (" .. self.scroll + 2 .. " / " .. self.numLines .. ")")
flickerstreak@1 1262 self.scrollUp:Show()
flickerstreak@1 1263 else
flickerstreak@1 1264 self.scrollUp:Hide()
flickerstreak@1 1265 end
flickerstreak@1 1266 if scrollMax ~= self.numLines and self.buttons[scrollMax - 1] then
flickerstreak@1 1267 self.scrollDown:SetPoint("TOPLEFT", self.buttons[scrollMax - 1], "BOTTOMLEFT", 0, -2)
flickerstreak@1 1268 self.scrollDown:SetText(SCROLL_DOWN .. " (" .. scrollMax - 1 .. " / " .. self.numLines .. ")")
flickerstreak@1 1269 self.scrollDown:Show()
flickerstreak@1 1270 else
flickerstreak@1 1271 self.scrollDown:Hide()
flickerstreak@1 1272 end
flickerstreak@1 1273 self:SetHeight(height)
flickerstreak@1 1274 end
flickerstreak@1 1275 tooltip.Show = wrap(tooltip.Show, "tooltip:Show")
flickerstreak@1 1276
flickerstreak@1 1277 local lastMouseDown
flickerstreak@1 1278 local function button_OnClick()
flickerstreak@1 1279 if this.self:HasScript("OnClick") and type(this.self:GetScript("OnClick")) == "function" then
flickerstreak@1 1280 this.self:GetScript("OnClick")()
flickerstreak@1 1281 end
flickerstreak@1 1282 if arg1 == "RightButton" then
flickerstreak@1 1283 if this.self:HasScript("OnClick") and type(this.self:GetScript("OnClick")) == "function" then
flickerstreak@1 1284 this.self:GetScript("OnClick")()
flickerstreak@1 1285 end
flickerstreak@1 1286 elseif arg1 == "LeftButton" then
flickerstreak@1 1287 if this.self.preventClick == nil or GetTime() > this.self.preventClick and GetTime() < lastMouseDown + 0.5 then
flickerstreak@1 1288 this.self.preventClick = nil
flickerstreak@1 1289 this.self.updating = true
flickerstreak@1 1290 this.self.preventRefresh = true
flickerstreak@1 1291 this.func(this.a1, this.a2, this.a3)
flickerstreak@1 1292 if this.self and this.self.registration then
flickerstreak@1 1293 this.self.preventRefresh = false
flickerstreak@1 1294 this.self:children()
flickerstreak@1 1295 this.self.updating = false
flickerstreak@1 1296 end
flickerstreak@1 1297 end
flickerstreak@1 1298 end
flickerstreak@1 1299 end
flickerstreak@1 1300 local function button_OnMouseUp()
flickerstreak@1 1301 if this.self:HasScript("OnMouseUp") and type(this.self:GetScript("OnMouseUp")) == "function" then
flickerstreak@1 1302 this.self:GetScript("OnMouseUp")()
flickerstreak@1 1303 end
flickerstreak@1 1304 if arg1 ~= "RightButton" then
flickerstreak@1 1305 if this.clicked then
flickerstreak@1 1306 local a,b,c,d,e = this.check:GetPoint(1)
flickerstreak@1 1307 this.check:SetPoint(a,b,c,d-1,e+1)
flickerstreak@1 1308 this.clicked = false
flickerstreak@1 1309 end
flickerstreak@1 1310 end
flickerstreak@1 1311 end
flickerstreak@1 1312 local function button_OnMouseDown()
flickerstreak@1 1313 if this.self:HasScript("OnMouseDown") and type(this.self:GetScript("OnMouseDown")) == "function" then
flickerstreak@1 1314 this.self:GetScript("OnMouseDown")()
flickerstreak@1 1315 end
flickerstreak@1 1316 lastMouseDown = GetTime()
flickerstreak@1 1317 if arg1 ~= "RightButton" then
flickerstreak@1 1318 local a,b,c,d,e = this.check:GetPoint(1)
flickerstreak@1 1319 this.check:SetPoint(a,b,c,d+1,e-1)
flickerstreak@1 1320 this.clicked = true
flickerstreak@1 1321 end
flickerstreak@1 1322 end
flickerstreak@1 1323 function tooltip:AddLine(info)
flickerstreak@1 1324 local category = info.category.superCategory
flickerstreak@1 1325 local maxWidth = category.tabletData.width
flickerstreak@1 1326 local text = info.blank and "\n" or info.text
flickerstreak@1 1327 local id = info.id
flickerstreak@1 1328 local func = info.func
flickerstreak@1 1329 local checked = info.checked
flickerstreak@1 1330 local isRadio = info.isRadio
flickerstreak@1 1331 local checkTexture = info.checkTexture
flickerstreak@1 1332 local fontSizePercent = self.fontSizePercent
flickerstreak@1 1333 if not info.font then
flickerstreak@1 1334 info.font = GameTooltipText
flickerstreak@1 1335 end
flickerstreak@1 1336 if not info.size then
flickerstreak@1 1337 _,info.size = info.font:GetFont()
flickerstreak@1 1338 end
flickerstreak@1 1339 local catStart = false
flickerstreak@1 1340 local columns = category and category.columns or 1
flickerstreak@1 1341 local x1, x2, x3, x4, x5, x6
flickerstreak@1 1342 if category then
flickerstreak@1 1343 x1, x2, x3, x4, x5, x6 = category.x1, category.x2, category.x3, category.x4, category.x5, category.x6
flickerstreak@1 1344 else
flickerstreak@1 1345 x1, x2, x3, x4, x5, x6 = 0, 0, 0, 0, 0, 0
flickerstreak@1 1346 end
flickerstreak@1 1347 if info.isTitle then
flickerstreak@1 1348 justAddedTitle = true
flickerstreak@1 1349 end
flickerstreak@1 1350
flickerstreak@1 1351 self.numLines = self.numLines + 1
flickerstreak@1 1352 NewLine(self)
flickerstreak@1 1353 self.lefts[self.numLines]:Show()
flickerstreak@1 1354 self.buttons[self.numLines]:Show()
flickerstreak@1 1355 num = self.numLines
flickerstreak@1 1356
flickerstreak@1 1357 local button = self.buttons[num]
flickerstreak@1 1358 button.indentation = info.indentation
flickerstreak@1 1359 local left = self.lefts[num]
flickerstreak@1 1360 local right = self.rights[num]
flickerstreak@1 1361 local third = self.thirds[num]
flickerstreak@1 1362 local fourth = self.fourths[num]
flickerstreak@1 1363 local fifth = self.fifths[num]
flickerstreak@1 1364 local sixth = self.sixths[num]
flickerstreak@1 1365 local check = self.checks[num]
flickerstreak@1 1366 do -- if columns >= 1 then
flickerstreak@1 1367 left:SetFontObject(info.font)
flickerstreak@1 1368 left:SetText(text)
flickerstreak@1 1369 left:Show()
flickerstreak@1 1370 if info.textR and info.textG and info.textB then
flickerstreak@1 1371 left:SetTextColor(info.textR, info.textG, info.textB)
flickerstreak@1 1372 else
flickerstreak@1 1373 left:SetTextColor(1, 0.823529, 0)
flickerstreak@1 1374 end
flickerstreak@1 1375 local a,_,b = left:GetFont()
flickerstreak@1 1376 left:SetFont(a, info.size * fontSizePercent, b)
flickerstreak@1 1377 left:SetJustifyH(info.justify)
flickerstreak@1 1378 if columns < 2 then
flickerstreak@1 1379 right:SetText(nil)
flickerstreak@1 1380 right:Hide()
flickerstreak@1 1381 right:SetPoint("TOPLEFT", left, "TOPRIGHT", 40 * fontSizePercent, 0)
flickerstreak@1 1382 right:SetPoint("TOPRIGHT", button, "TOPRIGHT", -5, 0)
flickerstreak@1 1383 third:SetText(nil)
flickerstreak@1 1384 third:Hide()
flickerstreak@1 1385 fourth:SetText(nil)
flickerstreak@1 1386 fourth:Hide()
flickerstreak@1 1387 fifth:SetText(nil)
flickerstreak@1 1388 fifth:Hide()
flickerstreak@1 1389 sixth:SetText(nil)
flickerstreak@1 1390 sixth:Hide()
flickerstreak@1 1391 else
flickerstreak@1 1392 right:SetFontObject(info.font2)
flickerstreak@1 1393 right:SetText(info.text2)
flickerstreak@1 1394 right:Show()
flickerstreak@1 1395 if info.text2R and info.text2G and info.text2B then
flickerstreak@1 1396 right:SetTextColor(info.text2R, info.text2G, info.text2B)
flickerstreak@1 1397 else
flickerstreak@1 1398 right:SetTextColor(1, 0.823529, 0)
flickerstreak@1 1399 end
flickerstreak@1 1400 local a,_,b = right:GetFont()
flickerstreak@1 1401 right:SetFont(a, info.size2 * fontSizePercent, b)
flickerstreak@1 1402 right:SetJustifyH(info.justify2)
flickerstreak@1 1403 if columns < 3 then
flickerstreak@1 1404 right:SetPoint("TOPLEFT", left, "TOPRIGHT", 40 * fontSizePercent, 0)
flickerstreak@1 1405 right:SetPoint("TOPRIGHT", button, "TOPRIGHT", -5, 0)
flickerstreak@1 1406 third:SetText(nil)
flickerstreak@1 1407 third:Hide()
flickerstreak@1 1408 fourth:SetText(nil)
flickerstreak@1 1409 fourth:Hide()
flickerstreak@1 1410 fifth:SetText(nil)
flickerstreak@1 1411 fifth:Hide()
flickerstreak@1 1412 sixth:SetText(nil)
flickerstreak@1 1413 sixth:Hide()
flickerstreak@1 1414 else
flickerstreak@1 1415 third:SetFontObject(info.font3)
flickerstreak@1 1416 third:SetText(info.text3)
flickerstreak@1 1417 third:Show()
flickerstreak@1 1418 if info.text3R and info.text3G and info.text3B then
flickerstreak@1 1419 third:SetTextColor(info.text3R, info.text3G, info.text3B)
flickerstreak@1 1420 else
flickerstreak@1 1421 third:SetTextColor(1, 0.823529, 0)
flickerstreak@1 1422 end
flickerstreak@1 1423 local a,_,b = third:GetFont()
flickerstreak@1 1424 third:SetFont(a, info.size3 * fontSizePercent, b)
flickerstreak@1 1425 right:ClearAllPoints()
flickerstreak@1 1426 right:SetPoint("TOPLEFT", left, "TOPRIGHT", 20 * fontSizePercent, 0)
flickerstreak@1 1427 third:SetJustifyH(info.justify3)
flickerstreak@1 1428 if columns < 4 then
flickerstreak@1 1429 fourth:SetText(nil)
flickerstreak@1 1430 fourth:Hide()
flickerstreak@1 1431 fifth:SetText(nil)
flickerstreak@1 1432 fifth:Hide()
flickerstreak@1 1433 sixth:SetText(nil)
flickerstreak@1 1434 sixth:Hide()
flickerstreak@1 1435 else
flickerstreak@1 1436 fourth:SetFontObject(info.font4)
flickerstreak@1 1437 fourth:SetText(info.text4)
flickerstreak@1 1438 fourth:Show()
flickerstreak@1 1439 if info.text4R and info.text4G and info.text4B then
flickerstreak@1 1440 fourth:SetTextColor(info.text4R, info.text4G, info.text4B)
flickerstreak@1 1441 else
flickerstreak@1 1442 fourth:SetTextColor(1, 0.823529, 0)
flickerstreak@1 1443 end
flickerstreak@1 1444 local a,_,b = fourth:GetFont()
flickerstreak@1 1445 fourth:SetFont(a, info.size4 * fontSizePercent, b)
flickerstreak@1 1446 fourth:SetJustifyH(info.justify4)
flickerstreak@1 1447 if columns < 5 then
flickerstreak@1 1448 fifth:SetText(nil)
flickerstreak@1 1449 fifth:Hide()
flickerstreak@1 1450 sixth:SetText(nil)
flickerstreak@1 1451 sixth:Hide()
flickerstreak@1 1452 else
flickerstreak@1 1453 fifth:SetFontObject(info.font5)
flickerstreak@1 1454 fifth:SetText(info.text5)
flickerstreak@1 1455 fifth:Show()
flickerstreak@1 1456 if info.text5R and info.text5G and info.text5B then
flickerstreak@1 1457 fifth:SetTextColor(info.text5R, info.text5G, info.text5B)
flickerstreak@1 1458 else
flickerstreak@1 1459 fifth:SetTextColor(1, 0.823529, 0)
flickerstreak@1 1460 end
flickerstreak@1 1461 local a,_,b = fourth:GetFont()
flickerstreak@1 1462 fifth:SetFont(a, info.size5 * fontSizePercent, b)
flickerstreak@1 1463 fifth:SetJustifyH(info.justify5)
flickerstreak@1 1464 if columns < 6 then
flickerstreak@1 1465 sixth:SetText(nil)
flickerstreak@1 1466 sixth:Hide()
flickerstreak@1 1467 else
flickerstreak@1 1468 sixth:SetFontObject(info.font6)
flickerstreak@1 1469 sixth:SetText(info.text6)
flickerstreak@1 1470 sixth:Show()
flickerstreak@1 1471 if info.text5R and info.text6G and info.text6B then
flickerstreak@1 1472 sixth:SetTextColor(info.text6R, info.text6G, info.text6B)
flickerstreak@1 1473 else
flickerstreak@1 1474 sixth:SetTextColor(1, 0.823529, 0)
flickerstreak@1 1475 end
flickerstreak@1 1476 local a,_,b = fourth:GetFont()
flickerstreak@1 1477 sixth:SetFont(a, info.size6 * fontSizePercent, b)
flickerstreak@1 1478 sixth:SetJustifyH(info.justify6)
flickerstreak@1 1479 end
flickerstreak@1 1480 end
flickerstreak@1 1481 end
flickerstreak@1 1482 end
flickerstreak@1 1483 end
flickerstreak@1 1484 end
flickerstreak@1 1485
flickerstreak@1 1486 check:SetWidth(info.size)
flickerstreak@1 1487 check:SetHeight(info.size)
flickerstreak@1 1488 check.width = info.size
flickerstreak@1 1489 if info.hasCheck then
flickerstreak@1 1490 check.shown = true
flickerstreak@1 1491 check:Show()
flickerstreak@1 1492 if isRadio then
flickerstreak@1 1493 check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton")
flickerstreak@1 1494 if info.checked then
flickerstreak@1 1495 check:SetAlpha(1)
flickerstreak@1 1496 check:SetTexCoord(0.25, 0.5, 0, 1)
flickerstreak@1 1497 else
flickerstreak@1 1498 check:SetAlpha(self.transparency)
flickerstreak@1 1499 check:SetTexCoord(0, 0.25, 0, 1)
flickerstreak@1 1500 end
flickerstreak@1 1501 else
flickerstreak@1 1502 if info.checkIcon then
flickerstreak@1 1503 check:SetTexture(info.checkIcon)
flickerstreak@1 1504 if string.sub(info.checkIcon, 1, 16) == "Interface\\Icons\\" then
flickerstreak@1 1505 check:SetTexCoord(0.05, 0.95, 0.05, 0.95)
flickerstreak@1 1506 else
flickerstreak@1 1507 check:SetTexCoord(0, 1, 0, 1)
flickerstreak@1 1508 end
flickerstreak@1 1509 else
flickerstreak@1 1510 check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
flickerstreak@1 1511 check:SetWidth(info.size * 1.5)
flickerstreak@1 1512 check:SetHeight(info.size * 1.5)
flickerstreak@1 1513 check.width = info.size * 1.2
flickerstreak@1 1514 check:SetTexCoord(0, 1, 0, 1)
flickerstreak@1 1515 end
flickerstreak@1 1516 check:SetAlpha(info.checked and 1 or 0)
flickerstreak@1 1517 end
flickerstreak@1 1518 left:SetPoint("TOPLEFT", check, "TOPLEFT", check.width, 0)
flickerstreak@1 1519 else
flickerstreak@1 1520 left:SetPoint("TOPLEFT", check, "TOPLEFT")
flickerstreak@1 1521 end
flickerstreak@1 1522 if columns == 1 then
flickerstreak@1 1523 left:SetWidth(maxWidth)
flickerstreak@1 1524 elseif columns == 2 then
flickerstreak@1 1525 left:SetWidth(0)
flickerstreak@1 1526 right:SetWidth(0)
flickerstreak@1 1527 if info.wrap then
flickerstreak@1 1528 left:SetWidth(maxWidth - right:GetWidth() - 40 * fontSizePercent)
flickerstreak@1 1529 elseif info.wrap2 then
flickerstreak@1 1530 right:SetWidth(maxWidth - left:GetWidth() - 40 * fontSizePercent)
flickerstreak@1 1531 end
flickerstreak@1 1532 right:ClearAllPoints()
flickerstreak@1 1533 right:SetPoint("TOPRIGHT", button, "TOPRIGHT", 0, 0)
flickerstreak@1 1534 if not info.text2 then
flickerstreak@1 1535 left:SetJustifyH(info.justify or "LEFT")
flickerstreak@1 1536 end
flickerstreak@1 1537 elseif columns == 3 then
flickerstreak@1 1538 left:SetWidth(x1 - info.checkWidth)
flickerstreak@1 1539 right:SetWidth(x2)
flickerstreak@1 1540 third:SetWidth(x3)
flickerstreak@1 1541 right:ClearAllPoints()
flickerstreak@1 1542 local num = (category.tabletData.width - x1 - x2 - x3) / 2
flickerstreak@1 1543 right:SetPoint("TOPLEFT", left, "TOPRIGHT", num, 0)
flickerstreak@1 1544 third:SetPoint("TOPLEFT", right, "TOPRIGHT", num, 0)
flickerstreak@1 1545 elseif columns == 4 then
flickerstreak@1 1546 left:SetWidth(x1 - info.checkWidth)
flickerstreak@1 1547 right:SetWidth(x2)
flickerstreak@1 1548 third:SetWidth(x3)
flickerstreak@1 1549 fourth:SetWidth(x4)
flickerstreak@1 1550 local num = (category.tabletData.width - x1 - x2 - x3 - x4) / 3
flickerstreak@1 1551 right:SetPoint("TOPLEFT", left, "TOPRIGHT", num, 0)
flickerstreak@1 1552 third:SetPoint("TOPLEFT", right, "TOPRIGHT", num, 0)
flickerstreak@1 1553 fourth:SetPoint("TOPLEFT", third, "TOPRIGHT", num, 0)
flickerstreak@1 1554 elseif columns == 5 then
flickerstreak@1 1555 left:SetWidth(x1 - info.checkWidth)
flickerstreak@1 1556 right:SetWidth(x2)
flickerstreak@1 1557 third:SetWidth(x3)
flickerstreak@1 1558 fourth:SetWidth(x4)
flickerstreak@1 1559 fifth:SetWidth(x5)
flickerstreak@1 1560 local num = (category.tabletData.width - x1 - x2 - x3 - x4 - x5) / 4
flickerstreak@1 1561 right:SetPoint("TOPLEFT", left, "TOPRIGHT", num, 0)
flickerstreak@1 1562 third:SetPoint("TOPLEFT", right, "TOPRIGHT", num, 0)
flickerstreak@1 1563 fourth:SetPoint("TOPLEFT", third, "TOPRIGHT", num, 0)
flickerstreak@1 1564 fifth:SetPoint("TOPLEFT", fourth, "TOPRIGHT", num, 0)
flickerstreak@1 1565 elseif columns == 6 then
flickerstreak@1 1566 left:SetWidth(x1 - info.checkWidth)
flickerstreak@1 1567 right:SetWidth(x2)
flickerstreak@1 1568 third:SetWidth(x3)
flickerstreak@1 1569 fourth:SetWidth(x4)
flickerstreak@1 1570 fifth:SetWidth(x5)
flickerstreak@1 1571 sixth:SetWidth(x6)
flickerstreak@1 1572 local num = (category.tabletData.width - x1 - x2 - x3 - x4 - x5 - x6) / 5
flickerstreak@1 1573 right:SetPoint("TOPLEFT", left, "TOPRIGHT", num, 0)
flickerstreak@1 1574 third:SetPoint("TOPLEFT", right, "TOPRIGHT", num, 0)
flickerstreak@1 1575 fourth:SetPoint("TOPLEFT", third, "TOPRIGHT", num, 0)
flickerstreak@1 1576 fifth:SetPoint("TOPLEFT", fourth, "TOPRIGHT", num, 0)
flickerstreak@1 1577 sixth:SetPoint("TOPLEFT", fifth, "TOPRIGHT", num, 0)
flickerstreak@1 1578 end
flickerstreak@1 1579 if not self.locked or IsAltKeyDown() then
flickerstreak@1 1580 local func = info.func
flickerstreak@1 1581 if func then
flickerstreak@1 1582 if type(func) == "string" then
flickerstreak@1 1583 Tablet:assert(type(info.arg1) == "table", "Cannot call method " .. info.func .. " on a non-table")
flickerstreak@1 1584 func = info.arg1[func]
flickerstreak@1 1585 Tablet:assert(type(func) == "function", "Method " .. info.func .. " nonexistant")
flickerstreak@1 1586 end
flickerstreak@1 1587 Tablet:assert(type(func) == "function", "func must be a function or method")
flickerstreak@1 1588 button.func = func
flickerstreak@1 1589 button.a1 = info.arg1
flickerstreak@1 1590 button.a2 = info.arg2
flickerstreak@1 1591 button.a3 = info.arg3
flickerstreak@1 1592 button.self = self
flickerstreak@1 1593 button:SetScript("OnMouseUp", button_OnMouseUp)
flickerstreak@1 1594 button:SetScript("OnMouseDown", button_OnMouseDown)
flickerstreak@1 1595 button:SetScript("OnClick", button_OnClick)
flickerstreak@1 1596 if button.clicked then
flickerstreak@1 1597 button:SetButtonState("PUSHED")
flickerstreak@1 1598 end
flickerstreak@1 1599 button:EnableMouse(true)
flickerstreak@1 1600 else
flickerstreak@1 1601 button:SetScript("OnMouseDown", nil)
flickerstreak@1 1602 button:SetScript("OnMouseUp", nil)
flickerstreak@1 1603 button:SetScript("OnClick", nil)
flickerstreak@1 1604 button:EnableMouse(false)
flickerstreak@1 1605 end
flickerstreak@1 1606 else
flickerstreak@1 1607 button:SetScript("OnMouseDown", nil)
flickerstreak@1 1608 button:SetScript("OnMouseUp", nil)
flickerstreak@1 1609 button:SetScript("OnClick", nil)
flickerstreak@1 1610 button:EnableMouse(false)
flickerstreak@1 1611 end
flickerstreak@1 1612 end
flickerstreak@1 1613 tooltip.AddLine = wrap(tooltip.AddLine, "tooltip:AddLine")
flickerstreak@1 1614
flickerstreak@1 1615 function tooltip:SetFontSizePercent(percent)
flickerstreak@1 1616 local data, detachedData = self.data, self.detachedData
flickerstreak@1 1617 if detachedData and detachedData.detached then
flickerstreak@1 1618 data = detachedData
flickerstreak@1 1619 end
flickerstreak@1 1620 local lastSize = self.fontSizePercent
flickerstreak@1 1621 percent = tonumber(percent) or 1
flickerstreak@1 1622 if percent < 0.25 then
flickerstreak@1 1623 percent = 0.25
flickerstreak@1 1624 elseif percent > 4 then
flickerstreak@1 1625 percent = 4
flickerstreak@1 1626 end
flickerstreak@1 1627 self.fontSizePercent = percent
flickerstreak@1 1628 if data then
flickerstreak@1 1629 data.fontSizePercent = percent
flickerstreak@1 1630 end
flickerstreak@1 1631 self.scrollUp:SetFont(font, normalSize * self.fontSizePercent, flags)
flickerstreak@1 1632 self.scrollDown:SetFont(font, normalSize * self.fontSizePercent, flags)
flickerstreak@1 1633 local ratio = self.fontSizePercent / lastSize
flickerstreak@1 1634 for i = 1, self.numLines do
flickerstreak@1 1635 local left = self.lefts[i]
flickerstreak@1 1636 local right = self.rights[i]
flickerstreak@1 1637 local third = self.thirds[i]
flickerstreak@1 1638 local fourth = self.fourths[i]
flickerstreak@1 1639 local fifth = self.fifths[i]
flickerstreak@1 1640 local sixth = self.sixths[i]
flickerstreak@1 1641 local check = self.checks[i]
flickerstreak@1 1642 local font, size, flags = left:GetFont()
flickerstreak@1 1643 left:SetFont(font, size * ratio, flags)
flickerstreak@1 1644 font, size, flags = right:GetFont()
flickerstreak@1 1645 right:SetFont(font, size * ratio, flags)
flickerstreak@1 1646 font, size, flags = third:GetFont()
flickerstreak@1 1647 third:SetFont(font, size * ratio, flags)
flickerstreak@1 1648 font, size, flags = fourth:GetFont()
flickerstreak@1 1649 fourth:SetFont(font, size * ratio, flags)
flickerstreak@1 1650 font, size, flags = fifth:GetFont()
flickerstreak@1 1651 fifth:SetFont(font, size * ratio, flags)
flickerstreak@1 1652 font, size, flags = sixth:GetFont()
flickerstreak@1 1653 sixth:SetFont(font, size * ratio, flags)
flickerstreak@1 1654 check.width = check.width * ratio
flickerstreak@1 1655 check:SetWidth(check:GetWidth() * ratio)
flickerstreak@1 1656 check:SetHeight(check:GetHeight() * ratio)
flickerstreak@1 1657 end
flickerstreak@1 1658 self:SetWidth((self:GetWidth() - 51) * ratio + 51)
flickerstreak@1 1659 self:SetHeight((self:GetHeight() - 51) * ratio + 51)
flickerstreak@1 1660 if self:IsShown() and self.children then
flickerstreak@1 1661 self:children()
flickerstreak@1 1662 self:Show()
flickerstreak@1 1663 end
flickerstreak@1 1664 end
flickerstreak@1 1665 tooltip.SetFontSizePercent = wrap(tooltip.SetFontSizePercent, "tooltip:SetFontSizePercent")
flickerstreak@1 1666
flickerstreak@1 1667 function tooltip:GetFontSizePercent()
flickerstreak@1 1668 return self.fontSizePercent
flickerstreak@1 1669 end
flickerstreak@1 1670
flickerstreak@1 1671 function tooltip:SetTransparency(alpha)
flickerstreak@1 1672 local data, detachedData = self.data, self.detachedData
flickerstreak@1 1673 if detachedData and detachedData.detached then
flickerstreak@1 1674 data = detachedData
flickerstreak@1 1675 end
flickerstreak@1 1676 self.transparency = alpha
flickerstreak@1 1677 if data then
flickerstreak@1 1678 data.transparency = alpha ~= 0.75 and alpha or nil
flickerstreak@1 1679 end
flickerstreak@1 1680 self:SetBackdropColor(self.r or 0, self.g or 0, self.b or 0, alpha)
flickerstreak@1 1681 self:SetBackdropBorderColor(1, 1, 1, alpha)
flickerstreak@1 1682 end
flickerstreak@1 1683 tooltip.SetTransparency = wrap(tooltip.SetTransparency, "tooltip:SetTransparency")
flickerstreak@1 1684
flickerstreak@1 1685 function tooltip:GetTransparency()
flickerstreak@1 1686 return self.transparency
flickerstreak@1 1687 end
flickerstreak@1 1688
flickerstreak@1 1689 function tooltip:SetColor(r, g, b)
flickerstreak@1 1690 local data, detachedData = self.data, self.detachedData
flickerstreak@1 1691 if detachedData and detachedData.detached then
flickerstreak@1 1692 data = detachedData
flickerstreak@1 1693 end
flickerstreak@1 1694 self.r = r
flickerstreak@1 1695 self.g = g
flickerstreak@1 1696 self.b = b
flickerstreak@1 1697 if data then
flickerstreak@1 1698 data.r = r ~= 0 and r or nil
flickerstreak@1 1699 data.g = g ~= 0 and g or nil
flickerstreak@1 1700 data.b = b ~= 0 and b or nil
flickerstreak@1 1701 end
flickerstreak@1 1702 self:SetBackdropColor(r or 0, g or 0, b or 0, self.transparency)
flickerstreak@1 1703 self:SetBackdropBorderColor(1, 1, 1, self.transparency)
flickerstreak@1 1704 end
flickerstreak@1 1705 tooltip.SetColor = wrap(tooltip.SetColor, "tooltip:SetColor")
flickerstreak@1 1706
flickerstreak@1 1707 function tooltip:GetColor()
flickerstreak@1 1708 return self.r, self.g, self.b
flickerstreak@1 1709 end
flickerstreak@1 1710
flickerstreak@1 1711 function tooltip:Scroll(down)
flickerstreak@1 1712 if down then
flickerstreak@1 1713 if IsShiftKeyDown() then
flickerstreak@1 1714 self.scroll = self.numLines - GetMaxLinesPerScreen(self)
flickerstreak@1 1715 else
flickerstreak@1 1716 self.scroll = self.scroll + 3
flickerstreak@1 1717 end
flickerstreak@1 1718 else
flickerstreak@1 1719 if IsShiftKeyDown() then
flickerstreak@1 1720 self.scroll = 0
flickerstreak@1 1721 else
flickerstreak@1 1722 self.scroll = self.scroll - 3
flickerstreak@1 1723 end
flickerstreak@1 1724 end
flickerstreak@1 1725 if self.scroll > self.numLines - GetMaxLinesPerScreen(self) then
flickerstreak@1 1726 self.scroll = self.numLines - GetMaxLinesPerScreen(self)
flickerstreak@1 1727 end
flickerstreak@1 1728 if self.scroll < 0 then
flickerstreak@1 1729 self.scroll = 0
flickerstreak@1 1730 end
flickerstreak@1 1731 if self:IsShown() then
flickerstreak@1 1732 self:Show()
flickerstreak@1 1733 end
flickerstreak@1 1734 end
flickerstreak@1 1735 tooltip.Scroll = wrap(tooltip.Scroll, "tooltip:Scroll")
flickerstreak@1 1736
flickerstreak@1 1737 function tooltip.Detach(tooltip)
flickerstreak@1 1738 local owner = tooltip.owner
flickerstreak@1 1739 tooltip:Hide()
flickerstreak@1 1740 self:assert(tooltip.detachedData, "You cannot detach if detachedData is not present")
flickerstreak@1 1741 tooltip.detachedData.detached = true
flickerstreak@1 1742 local detached = AcquireDetachedFrame(self, tooltip.registration, tooltip.data, tooltip.detachedData)
flickerstreak@1 1743
flickerstreak@1 1744 detached.menu, tooltip.menu = tooltip.menu, nil
flickerstreak@1 1745 detached.children = tooltip.children
flickerstreak@1 1746 tooltip.children = nil
flickerstreak@1 1747 detached:SetOwner(owner)
flickerstreak@1 1748 detached:children()
flickerstreak@1 1749 detached:Show()
flickerstreak@1 1750 end
flickerstreak@1 1751 tooltip.Detach = wrap(tooltip.Detach, "tooltip:Detach")
flickerstreak@1 1752
flickerstreak@1 1753 end
flickerstreak@1 1754
flickerstreak@1 1755 tooltip.registration = registration
flickerstreak@1 1756 registration.tooltip = tooltip
flickerstreak@1 1757 return tooltip
flickerstreak@1 1758 end
flickerstreak@1 1759 AcquireFrame = wrap(AcquireFrame, "AcquireFrame")
flickerstreak@1 1760
flickerstreak@1 1761 function ReleaseDetachedFrame(self, data, detachedData)
flickerstreak@1 1762 if not detachedData then
flickerstreak@1 1763 detachedData = data
flickerstreak@1 1764 end
flickerstreak@1 1765 for _, detached in ipairs(detachedTooltips) do
flickerstreak@1 1766 if detached.detachedData == detachedData then
flickerstreak@1 1767 detached.notInUse = true
flickerstreak@1 1768 detached:Hide()
flickerstreak@1 1769 detached.registration.tooltip = nil
flickerstreak@1 1770 detached.registration = nil
flickerstreak@1 1771 end
flickerstreak@1 1772 end
flickerstreak@1 1773 end
flickerstreak@1 1774 ReleaseDetachedFrame = wrap(ReleaseDetachedFrame, "ReleaseDetachedFrame")
flickerstreak@1 1775
flickerstreak@1 1776 local StartCheckingAlt, StopCheckingAlt
flickerstreak@1 1777 do
flickerstreak@1 1778 local frame
flickerstreak@1 1779 function StartCheckingAlt(func)
flickerstreak@1 1780 if not frame then
flickerstreak@1 1781 frame = CreateFrame("Frame")
flickerstreak@1 1782 frame:SetScript("OnEvent", function(this, _, modifier)
flickerstreak@1 1783 if modifier == "ALT" then
flickerstreak@1 1784 this.func()
flickerstreak@1 1785 end
flickerstreak@1 1786 end)
flickerstreak@1 1787 end
flickerstreak@1 1788 frame:RegisterEvent("MODIFIER_STATE_CHANGED")
flickerstreak@1 1789 frame.func = func
flickerstreak@1 1790 end
flickerstreak@1 1791 function StopCheckingAlt()
flickerstreak@1 1792 if frame then
flickerstreak@1 1793 frame:UnregisterEvent("MODIFIER_STATE_CHANGED")
flickerstreak@1 1794 end
flickerstreak@1 1795 end
flickerstreak@1 1796 end
flickerstreak@1 1797
flickerstreak@1 1798 function AcquireDetachedFrame(self, registration, data, detachedData)
flickerstreak@1 1799 if not detachedData then
flickerstreak@1 1800 detachedData = data
flickerstreak@1 1801 end
flickerstreak@1 1802 for _, detached in ipairs(detachedTooltips) do
flickerstreak@1 1803 if detached.notInUse then
flickerstreak@1 1804 detached.data = data
flickerstreak@1 1805 detached.detachedData = detachedData
flickerstreak@1 1806 detached.notInUse = nil
flickerstreak@1 1807 local fontSizePercent = detachedData.fontSizePercent or 1
flickerstreak@1 1808 local transparency = detachedData.transparency or 0.75
flickerstreak@1 1809 local r = detachedData.r or 0
flickerstreak@1 1810 local g = detachedData.g or 0
flickerstreak@1 1811 local b = detachedData.b or 0
flickerstreak@1 1812 detached:SetFontSizePercent(fontSizePercent)
flickerstreak@1 1813 detached:SetTransparency(transparency)
flickerstreak@1 1814 detached:SetColor(r, g, b)
flickerstreak@1 1815 detached:ClearAllPoints()
flickerstreak@1 1816 detached:SetPoint(detachedData.anchor or "CENTER", UIParent, detachedData.anchor or "CENTER", detachedData.offsetx or 0, detachedData.offsety or 0)
flickerstreak@1 1817 detached.registration = registration
flickerstreak@1 1818 registration.tooltip = detached
flickerstreak@1 1819 return detached
flickerstreak@1 1820 end
flickerstreak@1 1821 end
flickerstreak@1 1822
flickerstreak@1 1823 if not Dewdrop and AceLibrary:HasInstance("Dewdrop-2.0") then
flickerstreak@1 1824 Dewdrop = AceLibrary("Dewdrop-2.0")
flickerstreak@1 1825 end
flickerstreak@1 1826 StartCheckingAlt(function()
flickerstreak@1 1827 for _, detached in ipairs(detachedTooltips) do
flickerstreak@1 1828 if detached:IsShown() and detached.locked then
flickerstreak@1 1829 detached:EnableMouse(IsAltKeyDown())
flickerstreak@1 1830 detached:children()
flickerstreak@1 1831 if detached.moving then
flickerstreak@1 1832 local a1 = arg1
flickerstreak@1 1833 arg1 = "LeftButton"
flickerstreak@1 1834 if type(detached:GetScript("OnMouseUp")) == "function" then
flickerstreak@1 1835 detached:GetScript("OnMouseUp")()
flickerstreak@1 1836 end
flickerstreak@1 1837 arg1 = a1
flickerstreak@1 1838 end
flickerstreak@1 1839 end
flickerstreak@1 1840 end
flickerstreak@1 1841 end)
flickerstreak@1 1842 if not tooltip then
flickerstreak@1 1843 AcquireFrame(self, {})
flickerstreak@1 1844 end
flickerstreak@1 1845 local detached = CreateFrame("Frame", "Tablet20DetachedFrame" .. (table.getn(detachedTooltips) + 1), UIParent)
flickerstreak@1 1846 table.insert(detachedTooltips, detached)
flickerstreak@1 1847 detached.notInUse = true
flickerstreak@1 1848 detached:EnableMouse(not data.locked)
flickerstreak@1 1849 detached:EnableMouseWheel(true)
flickerstreak@1 1850 detached:SetMovable(true)
flickerstreak@1 1851 detached:SetPoint(data.anchor or "CENTER", UIParent, data.anchor or "CENTER", data.offsetx or 0, data.offsety or 0)
flickerstreak@1 1852
flickerstreak@1 1853 detached.numLines = 0
flickerstreak@1 1854 detached.owner = nil
flickerstreak@1 1855 detached.fontSizePercent = 1
flickerstreak@1 1856 detached.maxLines = 0
flickerstreak@1 1857 detached.buttons = {}
flickerstreak@1 1858 detached.checks = {}
flickerstreak@1 1859 detached.lefts = {}
flickerstreak@1 1860 detached.rights = {}
flickerstreak@1 1861 detached.thirds = {}
flickerstreak@1 1862 detached.fourths = {}
flickerstreak@1 1863 detached.fifths = {}
flickerstreak@1 1864 detached.sixths = {}
flickerstreak@1 1865 detached.transparency = 0.75
flickerstreak@1 1866 detached.r = 0
flickerstreak@1 1867 detached.g = 0
flickerstreak@1 1868 detached.b = 0
flickerstreak@1 1869 detached:SetFrameStrata("BACKGROUND")
flickerstreak@1 1870 detached:SetBackdrop(tmp.a(
flickerstreak@1 1871 'bgFile', "Interface\\Buttons\\WHITE8X8",
flickerstreak@1 1872 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
flickerstreak@1 1873 'tile', true,
flickerstreak@1 1874 'tileSize', 16,
flickerstreak@1 1875 'edgeSize', 16,
flickerstreak@1 1876 'insets', tmp.b(
flickerstreak@1 1877 'left', 5,
flickerstreak@1 1878 'right', 5,
flickerstreak@1 1879 'top', 5,
flickerstreak@1 1880 'bottom', 5
flickerstreak@1 1881 )
flickerstreak@1 1882 ))
flickerstreak@1 1883 detached.locked = detachedData.locked
flickerstreak@1 1884 detached.scroll = 0
flickerstreak@1 1885 detached:EnableMouse(not detached.locked)
flickerstreak@1 1886
flickerstreak@1 1887 local width = GetScreenWidth()
flickerstreak@1 1888 local height = GetScreenHeight()
flickerstreak@1 1889 detached:SetScript("OnMouseDown", function()
flickerstreak@1 1890 if arg1 == "LeftButton" then
flickerstreak@1 1891 detached:StartMoving()
flickerstreak@1 1892 detached.moving = true
flickerstreak@1 1893 end
flickerstreak@1 1894 end)
flickerstreak@1 1895
flickerstreak@1 1896 detached:SetScript("OnMouseUp", function()
flickerstreak@1 1897 if arg1 == "LeftButton" then
flickerstreak@1 1898 detached:StopMovingOrSizing()
flickerstreak@1 1899 detached.moving = nil
flickerstreak@1 1900 local anchor
flickerstreak@1 1901 local offsetx
flickerstreak@1 1902 local offsety
flickerstreak@1 1903 if detached:GetTop() + detached:GetBottom() < height then
flickerstreak@1 1904 anchor = "BOTTOM"
flickerstreak@1 1905 offsety = detached:GetBottom()
flickerstreak@1 1906 if offsety < 0 then
flickerstreak@1 1907 offsety = 0
flickerstreak@1 1908 end
flickerstreak@1 1909 if offsety < MainMenuBar:GetTop() and MainMenuBar:IsVisible() then
flickerstreak@1 1910 offsety = MainMenuBar:GetTop()
flickerstreak@1 1911 end
flickerstreak@1 1912 local top = 0
flickerstreak@1 1913 if FuBar then
flickerstreak@1 1914 for i = 1, FuBar:GetNumPanels() do
flickerstreak@1 1915 local panel = FuBar:GetPanel(i)
flickerstreak@1 1916 if panel:GetAttachPoint() == "BOTTOM" then
flickerstreak@1 1917 if panel.frame:GetTop() > top then
flickerstreak@1 1918 top = panel.frame:GetTop()
flickerstreak@1 1919 break
flickerstreak@1 1920 end
flickerstreak@1 1921 end
flickerstreak@1 1922 end
flickerstreak@1 1923 end
flickerstreak@1 1924 if offsety < top then
flickerstreak@1 1925 offsety = top
flickerstreak@1 1926 end
flickerstreak@1 1927 else
flickerstreak@1 1928 anchor = "TOP"
flickerstreak@1 1929 offsety = detached:GetTop() - height
flickerstreak@1 1930 if offsety > 0 then
flickerstreak@1 1931 offsety = 0
flickerstreak@1 1932 end
flickerstreak@1 1933 local bottom = GetScreenHeight()
flickerstreak@1 1934 if FuBar then
flickerstreak@1 1935 for i = 1, FuBar:GetNumPanels() do
flickerstreak@1 1936 local panel = FuBar:GetPanel(i)
flickerstreak@1 1937 if panel:GetAttachPoint() == "TOP" then
flickerstreak@1 1938 if panel.frame:GetBottom() < bottom then
flickerstreak@1 1939 bottom = panel.frame:GetBottom()
flickerstreak@1 1940 break
flickerstreak@1 1941 end
flickerstreak@1 1942 end
flickerstreak@1 1943 end
flickerstreak@1 1944 end
flickerstreak@1 1945 bottom = bottom - GetScreenHeight()
flickerstreak@1 1946 if offsety > bottom then
flickerstreak@1 1947 offsety = bottom
flickerstreak@1 1948 end
flickerstreak@1 1949 end
flickerstreak@1 1950 if detached:GetLeft() + detached:GetRight() < width * 2 / 3 then
flickerstreak@1 1951 anchor = anchor .. "LEFT"
flickerstreak@1 1952 offsetx = detached:GetLeft()
flickerstreak@1 1953 if offsetx < 0 then
flickerstreak@1 1954 offsetx = 0
flickerstreak@1 1955 end
flickerstreak@1 1956 elseif detached:GetLeft() + detached:GetRight() < width * 4 / 3 then
flickerstreak@1 1957 if anchor == "" then
flickerstreak@1 1958 anchor = "CENTER"
flickerstreak@1 1959 end
flickerstreak@1 1960 offsetx = (detached:GetLeft() + detached:GetRight() - GetScreenWidth()) / 2
flickerstreak@1 1961 else
flickerstreak@1 1962 anchor = anchor .. "RIGHT"
flickerstreak@1 1963 offsetx = detached:GetRight() - width
flickerstreak@1 1964 if offsetx > 0 then
flickerstreak@1 1965 offsetx = 0
flickerstreak@1 1966 end
flickerstreak@1 1967 end
flickerstreak@1 1968 detached:ClearAllPoints()
flickerstreak@1 1969 detached:SetPoint(anchor, UIParent, anchor, offsetx, offsety)
flickerstreak@1 1970 local t = detached.detachedData
flickerstreak@1 1971 if t.anchor ~= anchor or math.abs(t.offsetx - offsetx) > 8 or math.abs(t.offsety - offsety) > 8 then
flickerstreak@1 1972 detached.preventClick = GetTime() + 0.05
flickerstreak@1 1973 end
flickerstreak@1 1974 t.anchor = anchor
flickerstreak@1 1975 t.offsetx = offsetx
flickerstreak@1 1976 t.offsety = offsety
flickerstreak@1 1977 detached:Show()
flickerstreak@1 1978 end
flickerstreak@1 1979 end)
flickerstreak@1 1980
flickerstreak@1 1981 if Dewdrop then
flickerstreak@1 1982 Dewdrop:Register(detached,
flickerstreak@1 1983 'children', function(level, value)
flickerstreak@1 1984 if not detached.registration then
flickerstreak@1 1985 return
flickerstreak@1 1986 end
flickerstreak@1 1987 if detached.menu then
flickerstreak@1 1988 detached.menu(level, value)
flickerstreak@1 1989 if level == 1 then
flickerstreak@1 1990 Dewdrop:AddLine()
flickerstreak@1 1991 end
flickerstreak@1 1992 end
flickerstreak@1 1993 if level == 1 then
flickerstreak@1 1994 if not detached.registration.cantAttach then
flickerstreak@1 1995 Dewdrop:AddLine(
flickerstreak@1 1996 'text', DETACH,
flickerstreak@1 1997 'tooltipTitle', DETACH,
flickerstreak@1 1998 'tooltipText', DETACH_DESC,
flickerstreak@1 1999 'checked', true,
flickerstreak@1 2000 'arg1', detached,
flickerstreak@1 2001 'func', "Attach",
flickerstreak@1 2002 'closeWhenClicked', true
flickerstreak@1 2003 )
flickerstreak@1 2004 end
flickerstreak@1 2005 Dewdrop:AddLine(
flickerstreak@1 2006 'text', LOCK,
flickerstreak@1 2007 'tooltipTitle', LOCK,
flickerstreak@1 2008 'tooltipText', LOCK_DESC,
flickerstreak@1 2009 'checked', detached:IsLocked(),
flickerstreak@1 2010 'arg1', detached,
flickerstreak@1 2011 'func', "Lock",
flickerstreak@1 2012 'closeWhenClicked', not detached:IsLocked()
flickerstreak@1 2013 )
flickerstreak@1 2014 Dewdrop:AddLine(
flickerstreak@1 2015 'text', COLOR,
flickerstreak@1 2016 'tooltipTitle', COLOR,
flickerstreak@1 2017 'tooltipText', COLOR_DESC,
flickerstreak@1 2018 'hasColorSwatch', true,
flickerstreak@1 2019 'r', detached.r,
flickerstreak@1 2020 'g', detached.g,
flickerstreak@1 2021 'b', detached.b,
flickerstreak@1 2022 'hasOpacity', true,
flickerstreak@1 2023 'opacity', detached.transparency,
flickerstreak@1 2024 'colorFunc', function(r, g, b, a)
flickerstreak@1 2025 detached:SetColor(r, g, b)
flickerstreak@1 2026 detached:SetTransparency(a)
flickerstreak@1 2027 end
flickerstreak@1 2028 )
flickerstreak@1 2029 Dewdrop:AddLine(
flickerstreak@1 2030 'text', SIZE,
flickerstreak@1 2031 'tooltipTitle', SIZE,
flickerstreak@1 2032 'tooltipText', SIZE_DESC,
flickerstreak@1 2033 'hasArrow', true,
flickerstreak@1 2034 'hasSlider', true,
flickerstreak@1 2035 'sliderFunc', function(value)
flickerstreak@1 2036 detached:SetFontSizePercent(value)
flickerstreak@1 2037 end,
flickerstreak@1 2038 'sliderMax', 2,
flickerstreak@1 2039 'sliderMin', 0.5,
flickerstreak@1 2040 'sliderStep', 0.05,
flickerstreak@1 2041 'sliderIsPercent', true,
flickerstreak@1 2042 'sliderValue', detached:GetFontSizePercent()
flickerstreak@1 2043 )
flickerstreak@1 2044 Dewdrop:AddLine(
flickerstreak@1 2045 'text', CLOSE_MENU,
flickerstreak@1 2046 'tooltipTitle', CLOSE_MENU,
flickerstreak@1 2047 'tooltipText', CLOSE_MENU_DESC,
flickerstreak@1 2048 'func', function()
flickerstreak@1 2049 Dewdrop:Close()
flickerstreak@1 2050 end
flickerstreak@1 2051 )
flickerstreak@1 2052 end
flickerstreak@1 2053 end,
flickerstreak@1 2054 'point', function()
flickerstreak@1 2055 local x, y = detached:GetCenter()
flickerstreak@1 2056 if x < GetScreenWidth() / 2 then
flickerstreak@1 2057 if y < GetScreenHeight() / 2 then
flickerstreak@1 2058 return "BOTTOMLEFT", "BOTTOMRIGHT"
flickerstreak@1 2059 else
flickerstreak@1 2060 return "TOPLEFT", "TOPRIGHT"
flickerstreak@1 2061 end
flickerstreak@1 2062 else
flickerstreak@1 2063 if y < GetScreenHeight() / 2 then
flickerstreak@1 2064 return "BOTTOMRIGHT", "BOTTOMLEFT"
flickerstreak@1 2065 else
flickerstreak@1 2066 return "TOPRIGHT", "TOPLEFT"
flickerstreak@1 2067 end
flickerstreak@1 2068 end
flickerstreak@1 2069 end
flickerstreak@1 2070 )
flickerstreak@1 2071 end
flickerstreak@1 2072
flickerstreak@1 2073 NewLine(detached)
flickerstreak@1 2074
flickerstreak@1 2075 detached.scrollUp = detached:CreateFontString(nil, "ARTWORK")
flickerstreak@1 2076 detached.scrollUp:SetPoint("TOPLEFT", detached.buttons[1], "BOTTOMLEFT", 0, -2)
flickerstreak@1 2077 detached.scrollUp:SetPoint("RIGHT", detached, "RIGHT", 0, -10)
flickerstreak@1 2078 detached.scrollUp:SetFontObject(GameTooltipText)
flickerstreak@1 2079 detached.scrollUp:Hide()
flickerstreak@1 2080 local font,_,flags = detached.scrollUp:GetFont()
flickerstreak@1 2081 detached.scrollUp:SetFont(font, normalSize * detached.fontSizePercent, flags)
flickerstreak@1 2082 detached.scrollUp:SetJustifyH("CENTER")
flickerstreak@1 2083 detached.scrollUp:SetTextColor(1, 0.823529, 0)
flickerstreak@1 2084 detached.scrollUp:SetText(" ")
flickerstreak@1 2085
flickerstreak@1 2086 detached.scrollDown = detached:CreateFontString(nil, "ARTWORK")
flickerstreak@1 2087 detached.scrollDown:SetPoint("TOPLEFT", detached.buttons[1], "BOTTOMLEFT", 0, -2)
flickerstreak@1 2088 detached.scrollDown:SetPoint("RIGHT", detached, "RIGHT", 0, -10)
flickerstreak@1 2089 detached.scrollDown:SetFontObject(GameTooltipText)
flickerstreak@1 2090 detached.scrollDown:Hide()
flickerstreak@1 2091 local font,_,flags = detached.scrollUp:GetFont()
flickerstreak@1 2092 detached.scrollDown:SetFont(font, normalSize * detached.fontSizePercent, flags)
flickerstreak@1 2093 detached.scrollDown:SetJustifyH("CENTER")
flickerstreak@1 2094 detached.scrollDown:SetTextColor(1, 0.823529, 0)
flickerstreak@1 2095 detached.scrollDown:SetText(" ")
flickerstreak@1 2096
flickerstreak@1 2097 detached:SetScript("OnMouseWheel", function()
flickerstreak@1 2098 detached:Scroll(arg1 < 0)
flickerstreak@1 2099 end)
flickerstreak@1 2100
flickerstreak@1 2101 detached.SetTransparency = tooltip.SetTransparency
flickerstreak@1 2102 detached.GetTransparency = tooltip.GetTransparency
flickerstreak@1 2103 detached.SetColor = tooltip.SetColor
flickerstreak@1 2104 detached.GetColor = tooltip.GetColor
flickerstreak@1 2105 detached.SetFontSizePercent = tooltip.SetFontSizePercent
flickerstreak@1 2106 detached.GetFontSizePercent = tooltip.GetFontSizePercent
flickerstreak@1 2107 detached.SetOwner = tooltip.SetOwner
flickerstreak@1 2108 detached.IsOwned = tooltip.IsOwned
flickerstreak@1 2109 detached.ClearLines = tooltip.ClearLines
flickerstreak@1 2110 detached.NumLines = tooltip.NumLines
flickerstreak@1 2111 detached.__Hide = detached.Hide
flickerstreak@1 2112 detached.__Show = detached.Show
flickerstreak@1 2113 detached.Hide = tooltip.Hide
flickerstreak@1 2114 detached.Show = tooltip.Show
flickerstreak@1 2115 local old_IsShown = detached.IsShown
flickerstreak@1 2116 function detached:IsShown()
flickerstreak@1 2117 if self.tmpHidden then
flickerstreak@1 2118 return true
flickerstreak@1 2119 else
flickerstreak@1 2120 return old_IsShown(self)
flickerstreak@1 2121 end
flickerstreak@1 2122 end
flickerstreak@1 2123 detached.AddLine = tooltip.AddLine
flickerstreak@1 2124 detached.Scroll = tooltip.Scroll
flickerstreak@1 2125 function detached:IsLocked()
flickerstreak@1 2126 return self.locked
flickerstreak@1 2127 end
flickerstreak@1 2128 function detached:Lock()
flickerstreak@1 2129 self:EnableMouse(self.locked)
flickerstreak@1 2130 self.locked = not self.locked
flickerstreak@1 2131 self.detachedData.locked = self.locked or nil
flickerstreak@1 2132 self:children()
flickerstreak@1 2133 end
flickerstreak@1 2134
flickerstreak@1 2135 function detached.Attach(detached)
flickerstreak@1 2136 self:assert(detached, "Detached tooltip not given.")
flickerstreak@1 2137 self:assert(detached.AddLine, "detached argument not a Tooltip.")
flickerstreak@1 2138 self:assert(detached.owner, "Detached tooltip has no owner.")
flickerstreak@1 2139 self:assert(not detached.notInUse, "Detached tooltip not in use.")
flickerstreak@1 2140 detached.menu = nil
flickerstreak@1 2141 detached.detachedData.detached = nil
flickerstreak@1 2142 detached:SetOwner(nil)
flickerstreak@1 2143 detached.notInUse = TRUE
flickerstreak@1 2144 end
flickerstreak@1 2145
flickerstreak@1 2146 return AcquireDetachedFrame(self, registration, data, detachedData)
flickerstreak@1 2147 end
flickerstreak@1 2148 AcquireDetachedFrame = wrap(AcquireDetachedFrame, "AcquireDetachedFrame")
flickerstreak@1 2149
flickerstreak@1 2150 function Tablet:Close(parent)
flickerstreak@1 2151 if not parent then
flickerstreak@1 2152 if tooltip and tooltip:IsShown() then
flickerstreak@1 2153 tooltip:Hide()
flickerstreak@1 2154 tooltip.registration.tooltip = nil
flickerstreak@1 2155 tooltip.registration = nil
flickerstreak@1 2156 tooltip.enteredFrame = false
flickerstreak@1 2157 end
flickerstreak@1 2158 return
flickerstreak@1 2159 else
flickerstreak@1 2160 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2161 end
flickerstreak@1 2162 local info = self.registry[parent]
flickerstreak@1 2163 self:assert(info, "You cannot close a tablet with an unregistered parent frame.")
flickerstreak@1 2164 local data = info.data
flickerstreak@1 2165 local detachedData = info.detachedData
flickerstreak@1 2166 if detachedData and detachedData.detached then
flickerstreak@1 2167 ReleaseDetachedFrame(self, data, detachedData)
flickerstreak@1 2168 elseif tooltip.data == data then
flickerstreak@1 2169 tooltip:Hide()
flickerstreak@1 2170 tooltip.registration.tooltip = nil
flickerstreak@1 2171 tooltip.registration = nil
flickerstreak@1 2172 end
flickerstreak@1 2173 tooltip.enteredFrame = false
flickerstreak@1 2174 end
flickerstreak@1 2175 Tablet.Close = wrap(Tablet.Close, "Tablet:Close")
flickerstreak@1 2176
flickerstreak@1 2177 local currentFrame
flickerstreak@1 2178 local currentTabletData
flickerstreak@1 2179
flickerstreak@1 2180 function Tablet:Open(fakeParent, parent)
flickerstreak@1 2181 self:argCheck(fakeParent, 2, "table", "string")
flickerstreak@1 2182 self:argCheck(parent, 3, "nil", "table", "string")
flickerstreak@1 2183 if not parent then
flickerstreak@1 2184 parent = fakeParent
flickerstreak@1 2185 end
flickerstreak@1 2186 local info = self.registry[parent]
flickerstreak@1 2187 self:assert(info, "You cannot open a tablet with an unregistered parent frame.")
flickerstreak@1 2188 self:Close()
flickerstreak@1 2189 local data = info.data
flickerstreak@1 2190 local detachedData = info.detachedData
flickerstreak@1 2191 local children = info.children
flickerstreak@1 2192 if not children then
flickerstreak@1 2193 return
flickerstreak@1 2194 end
flickerstreak@1 2195 local frame = AcquireFrame(self, info, data, detachedData)
flickerstreak@1 2196 frame.clickable = info.clickable
flickerstreak@1 2197 frame.menu = info.menu
flickerstreak@1 2198 local children = info.children
flickerstreak@1 2199 function frame:children()
flickerstreak@1 2200 if not self.preventRefresh then
flickerstreak@1 2201 currentFrame = self
flickerstreak@1 2202 currentTabletData = TabletData:new(self)
flickerstreak@1 2203 self:ClearLines()
flickerstreak@1 2204 if children then
flickerstreak@1 2205 children()
flickerstreak@1 2206 end
flickerstreak@1 2207 currentTabletData:Display(currentFrame)
flickerstreak@1 2208 self:Show(currentTabletData)
flickerstreak@1 2209 currentTabletData:del()
flickerstreak@1 2210 currentTabletData = nil
flickerstreak@1 2211 currentFrame = nil
flickerstreak@1 2212 end
flickerstreak@1 2213 end
flickerstreak@1 2214 frame:SetOwner(fakeParent)
flickerstreak@1 2215 frame:children()
flickerstreak@1 2216 local point = info.point
flickerstreak@1 2217 local relativePoint = info.relativePoint
flickerstreak@1 2218 if type(point) == "function" then
flickerstreak@1 2219 local b
flickerstreak@1 2220 point, b = point(fakeParent)
flickerstreak@1 2221 if b then
flickerstreak@1 2222 relativePoint = b
flickerstreak@1 2223 end
flickerstreak@1 2224 end
flickerstreak@1 2225 if type(relativePoint) == "function" then
flickerstreak@1 2226 relativePoint = relativePoint(fakeParent)
flickerstreak@1 2227 end
flickerstreak@1 2228 if not point then
flickerstreak@1 2229 point = "CENTER"
flickerstreak@1 2230 end
flickerstreak@1 2231 if not relativePoint then
flickerstreak@1 2232 relativePoint = point
flickerstreak@1 2233 end
flickerstreak@1 2234 frame:ClearAllPoints()
flickerstreak@1 2235 if type(parent) ~= "string" then
flickerstreak@1 2236 frame:SetPoint(point, fakeParent, relativePoint)
flickerstreak@1 2237 end
flickerstreak@1 2238 local offsetx = 0
flickerstreak@1 2239 local offsety = 0
flickerstreak@1 2240 if frame:GetBottom() and frame:GetLeft() then
flickerstreak@1 2241 if frame:GetRight() > GetScreenWidth() then
flickerstreak@1 2242 offsetx = frame:GetRight() - GetScreenWidth()
flickerstreak@1 2243 elseif frame:GetLeft() < 0 then
flickerstreak@1 2244 offsetx = -frame:GetLeft()
flickerstreak@1 2245 end
flickerstreak@1 2246 local ratio = GetScreenWidth() / GetScreenHeight()
flickerstreak@1 2247 if ratio >= 2.4 and frame:GetRight() > GetScreenWidth() / 2 and frame:GetLeft() < GetScreenWidth() / 2 then
flickerstreak@1 2248 if frame:GetCenter() < GetScreenWidth() / 2 then
flickerstreak@1 2249 offsetx = frame:GetRight() - GetScreenWidth() / 2
flickerstreak@1 2250 else
flickerstreak@1 2251 offsetx = frame:GetLeft() - GetScreenWidth() / 2
flickerstreak@1 2252 end
flickerstreak@1 2253 end
flickerstreak@1 2254 if frame:GetBottom() < 0 then
flickerstreak@1 2255 offsety = frame:GetBottom()
flickerstreak@1 2256 elseif frame:GetTop() and frame:GetTop() > GetScreenHeight() then
flickerstreak@1 2257 offsety = frame:GetTop() - GetScreenHeight()
flickerstreak@1 2258 end
flickerstreak@1 2259 if MainMenuBar:IsVisible() and frame:GetBottom() < MainMenuBar:GetTop() and offsety < frame:GetBottom() - MainMenuBar:GetTop() then
flickerstreak@1 2260 offsety = frame:GetBottom() - MainMenuBar:GetTop()
flickerstreak@1 2261 end
flickerstreak@1 2262
flickerstreak@1 2263 if FuBar then
flickerstreak@1 2264 local top = 0
flickerstreak@1 2265 if FuBar then
flickerstreak@1 2266 for i = 1, FuBar:GetNumPanels() do
flickerstreak@1 2267 local panel = FuBar:GetPanel(i)
flickerstreak@1 2268 if panel:GetAttachPoint() == "BOTTOM" then
flickerstreak@1 2269 if panel.frame:GetTop() and panel.frame:GetTop() > top then
flickerstreak@1 2270 top = panel.frame:GetTop()
flickerstreak@1 2271 break
flickerstreak@1 2272 end
flickerstreak@1 2273 end
flickerstreak@1 2274 end
flickerstreak@1 2275 end
flickerstreak@1 2276 if frame:GetBottom() < top and offsety < frame:GetBottom() - top then
flickerstreak@1 2277 offsety = frame:GetBottom() - top
flickerstreak@1 2278 end
flickerstreak@1 2279 local bottom = GetScreenHeight()
flickerstreak@1 2280 if FuBar then
flickerstreak@1 2281 for i = 1, FuBar:GetNumPanels() do
flickerstreak@1 2282 local panel = FuBar:GetPanel(i)
flickerstreak@1 2283 if panel:GetAttachPoint() == "TOP" then
flickerstreak@1 2284 if panel.frame:GetBottom() and panel.frame:GetBottom() < bottom then
flickerstreak@1 2285 bottom = panel.frame:GetBottom()
flickerstreak@1 2286 break
flickerstreak@1 2287 end
flickerstreak@1 2288 end
flickerstreak@1 2289 end
flickerstreak@1 2290 end
flickerstreak@1 2291 if frame:GetTop() > bottom and offsety < frame:GetTop() - bottom then
flickerstreak@1 2292 offsety = frame:GetTop() - bottom
flickerstreak@1 2293 end
flickerstreak@1 2294 end
flickerstreak@1 2295 end
flickerstreak@1 2296 if type(fakeParent) ~= "string" then
flickerstreak@1 2297 frame:SetPoint(point, fakeParent, relativePoint, -offsetx, -offsety)
flickerstreak@1 2298 end
flickerstreak@1 2299
flickerstreak@1 2300 if detachedData and (info.cantAttach or detachedData.detached) and frame == tooltip then
flickerstreak@1 2301 detachedData.detached = false
flickerstreak@1 2302 frame:Detach()
flickerstreak@1 2303 end
flickerstreak@1 2304 if (not detachedData or not detachedData.detached) and GetMouseFocus() == fakeParent then
flickerstreak@1 2305 self.tooltip.enteredFrame = true
flickerstreak@1 2306 end
flickerstreak@1 2307 end
flickerstreak@1 2308 Tablet.Open = wrap(Tablet.Open, "Tablet:Open")
flickerstreak@1 2309
flickerstreak@1 2310 function Tablet:Register(parent, ...)
flickerstreak@1 2311 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2312 if self.registry[parent] then
flickerstreak@1 2313 self:Unregister(parent)
flickerstreak@1 2314 end
flickerstreak@1 2315 local info
flickerstreak@1 2316 local k1 = ...
flickerstreak@1 2317 if type(k1) == "table" and k1[0] then
flickerstreak@1 2318 self:assert(type(self.registry[k1]) == "table", "Other parent not registered")
flickerstreak@1 2319 info = copy(self.registry[k1])
flickerstreak@1 2320 local v1 = select(2, ...)
flickerstreak@1 2321 if type(v1) == "function" then
flickerstreak@1 2322 info.point = v1
flickerstreak@1 2323 info.relativePoint = nil
flickerstreak@1 2324 end
flickerstreak@1 2325 else
flickerstreak@1 2326 info = new(...)
flickerstreak@1 2327 end
flickerstreak@1 2328 self.registry[parent] = info
flickerstreak@1 2329 info.data = info.data or info.detachedData or {}
flickerstreak@1 2330 info.detachedData = info.detachedData or info.data
flickerstreak@1 2331 local data = info.data
flickerstreak@1 2332 local detachedData = info.detachedData
flickerstreak@1 2333 if not self.onceRegistered[parent] and type(parent) == "table" and type(parent.SetScript) == "function" and not info.dontHook then
flickerstreak@1 2334 if not Dewdrop and AceLibrary:HasInstance("Dewdrop-2.0") then
flickerstreak@1 2335 Dewdrop = AceLibrary("Dewdrop-2.0")
flickerstreak@1 2336 end
flickerstreak@1 2337 local script = parent:GetScript("OnEnter")
flickerstreak@1 2338 parent:SetScript("OnEnter", function()
flickerstreak@1 2339 if script then
flickerstreak@1 2340 script()
flickerstreak@1 2341 end
flickerstreak@1 2342 if self.registry[parent] then
flickerstreak@1 2343 if (not data or not detachedData.detached) and (Dewdrop and not Dewdrop:IsOpen(parent) or true) then
flickerstreak@1 2344 self:Open(parent)
flickerstreak@1 2345 self.tooltip.enteredFrame = true
flickerstreak@1 2346 end
flickerstreak@1 2347 end
flickerstreak@1 2348 end)
flickerstreak@1 2349 local script = parent:GetScript("OnLeave")
flickerstreak@1 2350 parent:SetScript("OnLeave", function()
flickerstreak@1 2351 if script then
flickerstreak@1 2352 script()
flickerstreak@1 2353 end
flickerstreak@1 2354 if self.registry[parent] then
flickerstreak@1 2355 if self.tooltip and (not data or not detachedData or not detachedData.detached) then
flickerstreak@1 2356 self.tooltip.enteredFrame = false
flickerstreak@1 2357 end
flickerstreak@1 2358 end
flickerstreak@1 2359 end)
flickerstreak@1 2360 if parent:HasScript("OnMouseDown") then
flickerstreak@1 2361 local script = parent:GetScript("OnMouseDown")
flickerstreak@1 2362 parent:SetScript("OnMouseDown", function()
flickerstreak@1 2363 if script then
flickerstreak@1 2364 script()
flickerstreak@1 2365 end
flickerstreak@1 2366 if self.registry[parent] and self.registry[parent].tooltip and self.registry[parent].tooltip == self.tooltip then
flickerstreak@1 2367 self.tooltip:Hide()
flickerstreak@1 2368 end
flickerstreak@1 2369 end)
flickerstreak@1 2370 end
flickerstreak@1 2371 if parent:HasScript("OnMouseWheel") then
flickerstreak@1 2372 local script = parent:GetScript("OnMouseWheel")
flickerstreak@1 2373 parent:SetScript("OnMouseWheel", function()
flickerstreak@1 2374 if script then
flickerstreak@1 2375 script()
flickerstreak@1 2376 end
flickerstreak@1 2377 if self.registry[parent] and self.registry[parent].tooltip then
flickerstreak@1 2378 self.registry[parent].tooltip:Scroll(arg1 < 0)
flickerstreak@1 2379 end
flickerstreak@1 2380 end)
flickerstreak@1 2381 end
flickerstreak@1 2382 end
flickerstreak@1 2383 self.onceRegistered[parent] = true
flickerstreak@1 2384 if GetMouseFocus() == parent then
flickerstreak@1 2385 self:Open(parent)
flickerstreak@1 2386 end
flickerstreak@1 2387 end
flickerstreak@1 2388 Tablet.Register = wrap(Tablet.Register, "Tablet:Register")
flickerstreak@1 2389
flickerstreak@1 2390 function Tablet:Unregister(parent)
flickerstreak@1 2391 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2392 self:assert(self.registry[parent], "You cannot unregister a parent frame if it has not been registered already.")
flickerstreak@1 2393 self.registry[parent] = nil
flickerstreak@1 2394 end
flickerstreak@1 2395 Tablet.Unregister = wrap(Tablet.Unregister, "Tablet:Unregister")
flickerstreak@1 2396
flickerstreak@1 2397 function Tablet:IsRegistered(parent)
flickerstreak@1 2398 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2399 return self.registry[parent] and true
flickerstreak@1 2400 end
flickerstreak@1 2401 Tablet.IsRegistered = wrap(Tablet.IsRegistered, "Tablet:IsRegistered")
flickerstreak@1 2402
flickerstreak@1 2403 local _id = 0
flickerstreak@1 2404 local addedCategory
flickerstreak@1 2405 local currentCategoryInfo
flickerstreak@1 2406 local depth = 0
flickerstreak@1 2407 local categoryPool = {}
flickerstreak@1 2408 function CleanCategoryPool(self)
flickerstreak@1 2409 for k,v in pairs(categoryPool) do
flickerstreak@1 2410 del(v)
flickerstreak@1 2411 categoryPool[k] = nil
flickerstreak@1 2412 end
flickerstreak@1 2413 _id = 0
flickerstreak@1 2414 end
flickerstreak@1 2415
flickerstreak@1 2416 function Tablet:AddCategory(...)
flickerstreak@1 2417 self:assert(currentFrame, "You must add categories in within a registration.")
flickerstreak@1 2418 local info = new(...)
flickerstreak@1 2419 local cat = currentTabletData:AddCategory(info)
flickerstreak@1 2420 info = del(info)
flickerstreak@1 2421 return cat
flickerstreak@1 2422 end
flickerstreak@1 2423 Tablet.AddCategory = wrap(Tablet.AddCategory, "Tablet:AddCategory")
flickerstreak@1 2424
flickerstreak@1 2425 function Tablet:SetHint(text)
flickerstreak@1 2426 self:assert(currentFrame, "You must set hint within a registration.")
flickerstreak@1 2427 self:assert(not currentCategoryInfo, "You cannot set hint in a category.")
flickerstreak@1 2428 currentTabletData:SetHint(text)
flickerstreak@1 2429 end
flickerstreak@1 2430 Tablet.SetHint = wrap(Tablet.SetHint, "Tablet:SetHint")
flickerstreak@1 2431
flickerstreak@1 2432 function Tablet:SetTitle(text)
flickerstreak@1 2433 self:assert(currentFrame, "You must set title within a registration")
flickerstreak@1 2434 self:assert(not currentCategoryInfo, "You cannot set title in a category.")
flickerstreak@1 2435 currentTabletData:SetTitle(text)
flickerstreak@1 2436 end
flickerstreak@1 2437 Tablet.SetTitle = wrap(Tablet.SetTitle, "Tablet:SetTitle")
flickerstreak@1 2438
flickerstreak@1 2439 function Tablet:SetTitleColor(r, g, b)
flickerstreak@1 2440 self:assert(currentFrame, "You must set title color within a registration")
flickerstreak@1 2441 self:assert(not currentCategoryInfo, "You cannot set title color in a category.")
flickerstreak@1 2442 self:argCheck(r, 2, "number")
flickerstreak@1 2443 self:argCheck(g, 3, "number")
flickerstreak@1 2444 self:argCheck(b, 4, "number")
flickerstreak@1 2445 currentTabletData:SetTitleColor(r, g, b)
flickerstreak@1 2446 end
flickerstreak@1 2447 Tablet.SetTitleColor = wrap(Tablet.SetTitleColor, "Tablet:SetTitleColor")
flickerstreak@1 2448
flickerstreak@1 2449 function Tablet:GetNormalFontSize()
flickerstreak@1 2450 return normalSize
flickerstreak@1 2451 end
flickerstreak@1 2452
flickerstreak@1 2453 function Tablet:GetHeaderFontSize()
flickerstreak@1 2454 return headerSize
flickerstreak@1 2455 end
flickerstreak@1 2456
flickerstreak@1 2457 function Tablet:GetNormalFontObject()
flickerstreak@1 2458 return GameTooltipText
flickerstreak@1 2459 end
flickerstreak@1 2460
flickerstreak@1 2461 function Tablet:GetHeaderFontObject()
flickerstreak@1 2462 return GameTooltipHeaderText
flickerstreak@1 2463 end
flickerstreak@1 2464
flickerstreak@1 2465 function Tablet:SetFontSizePercent(parent, percent)
flickerstreak@1 2466 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2467 local info = self.registry[parent]
flickerstreak@1 2468 if info then
flickerstreak@1 2469 if info.tooltip then
flickerstreak@1 2470 info.tooltip:SetFontSizePercent(percent)
flickerstreak@1 2471 else
flickerstreak@1 2472 local data = info.data
flickerstreak@1 2473 local detachedData = info.detachedData
flickerstreak@1 2474 if detachedData.detached then
flickerstreak@1 2475 detachedData.fontSizePercent = percent
flickerstreak@1 2476 else
flickerstreak@1 2477 data.fontSizePercent = percent
flickerstreak@1 2478 end
flickerstreak@1 2479 end
flickerstreak@1 2480 elseif type(parent) == "table" then
flickerstreak@1 2481 parent.fontSizePercent = percent
flickerstreak@1 2482 else
flickerstreak@1 2483 self:assert(false, "You cannot change font size with an unregistered parent frame.")
flickerstreak@1 2484 end
flickerstreak@1 2485 end
flickerstreak@1 2486 Tablet.SetFontSizePercent = wrap(Tablet.SetFontSizePercent, "Tablet:SetFontSizePercent")
flickerstreak@1 2487
flickerstreak@1 2488 function Tablet:GetFontSizePercent(parent)
flickerstreak@1 2489 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2490 local info = self.registry[parent]
flickerstreak@1 2491 if info then
flickerstreak@1 2492 local data = info.data
flickerstreak@1 2493 local detachedData = info.detachedData
flickerstreak@1 2494 if detachedData.detached then
flickerstreak@1 2495 return detachedData.fontSizePercent or 1
flickerstreak@1 2496 else
flickerstreak@1 2497 return data.fontSizePercent or 1
flickerstreak@1 2498 end
flickerstreak@1 2499 elseif type(parent) == "table" then
flickerstreak@1 2500 return parent.fontSizePercent or 1
flickerstreak@1 2501 else
flickerstreak@1 2502 self:assert(false, "You cannot check font size with an unregistered parent frame.")
flickerstreak@1 2503 end
flickerstreak@1 2504 end
flickerstreak@1 2505 Tablet.GetFontSizePercent = wrap(Tablet.GetFontSizePercent, "Tablet:GetFontSizePercent")
flickerstreak@1 2506
flickerstreak@1 2507 function Tablet:SetTransparency(parent, percent)
flickerstreak@1 2508 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2509 local info = self.registry[parent]
flickerstreak@1 2510 if info then
flickerstreak@1 2511 if info.tooltip then
flickerstreak@1 2512 info.tooltip:SetTransparency(percent)
flickerstreak@1 2513 else
flickerstreak@1 2514 local data = info.data
flickerstreak@1 2515 local detachedData = info.detachedData
flickerstreak@1 2516 if detachedData.detached then
flickerstreak@1 2517 detachedData.transparency = percent
flickerstreak@1 2518 elseif data then
flickerstreak@1 2519 data.transparency = percent
flickerstreak@1 2520 end
flickerstreak@1 2521 end
flickerstreak@1 2522 elseif type(parent) == "table" then
flickerstreak@1 2523 parent.transparency = percent
flickerstreak@1 2524 else
flickerstreak@1 2525 self:assert(false, "You cannot change transparency with an unregistered parent frame.")
flickerstreak@1 2526 end
flickerstreak@1 2527 end
flickerstreak@1 2528 Tablet.SetTransparency = wrap(Tablet.SetTransparency, "Tablet:SetTransparency")
flickerstreak@1 2529
flickerstreak@1 2530 function Tablet:GetTransparency(parent)
flickerstreak@1 2531 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2532 local info = self.registry[parent]
flickerstreak@1 2533 if info then
flickerstreak@1 2534 local data = info.data
flickerstreak@1 2535 local detachedData = info.detachedData
flickerstreak@1 2536 if detachedData.detached then
flickerstreak@1 2537 return detachedData.transparency or 0.75
flickerstreak@1 2538 else
flickerstreak@1 2539 return data.transparency or 0.75
flickerstreak@1 2540 end
flickerstreak@1 2541 elseif type(parent) == "table" then
flickerstreak@1 2542 return parent.transparency or 0.75
flickerstreak@1 2543 else
flickerstreak@1 2544 self:assert(parent, "You must provide a parent frame to check transparency")
flickerstreak@1 2545 end
flickerstreak@1 2546 end
flickerstreak@1 2547 Tablet.GetTransparency = wrap(Tablet.GetTransparency, "Tablet:GetTransparency")
flickerstreak@1 2548
flickerstreak@1 2549 function Tablet:SetColor(parent, r, g, b)
flickerstreak@1 2550 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2551 local info = self.registry[parent]
flickerstreak@1 2552 if info then
flickerstreak@1 2553 if info.tooltip then
flickerstreak@1 2554 info.tooltip:SetColor(r, g, b)
flickerstreak@1 2555 else
flickerstreak@1 2556 local data = info.data
flickerstreak@1 2557 local detachedData = info.detachedData
flickerstreak@1 2558 if detachedData.detached then
flickerstreak@1 2559 detachedData.r = r
flickerstreak@1 2560 detachedData.g = g
flickerstreak@1 2561 detachedData.b = b
flickerstreak@1 2562 else
flickerstreak@1 2563 data.r = r
flickerstreak@1 2564 data.g = g
flickerstreak@1 2565 data.b = b
flickerstreak@1 2566 end
flickerstreak@1 2567 end
flickerstreak@1 2568 elseif type(parent) == "table" then
flickerstreak@1 2569 parent.r = r
flickerstreak@1 2570 parent.g = g
flickerstreak@1 2571 parent.b = b
flickerstreak@1 2572 else
flickerstreak@1 2573 self:assert(false, "You cannot change color with an unregistered parent frame.")
flickerstreak@1 2574 end
flickerstreak@1 2575 end
flickerstreak@1 2576 Tablet.SetColor = wrap(Tablet.SetColor, "Tablet:SetColor")
flickerstreak@1 2577
flickerstreak@1 2578 function Tablet:GetColor(parent)
flickerstreak@1 2579 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2580 local info = self.registry[parent]
flickerstreak@1 2581 if info then
flickerstreak@1 2582 local data = info.data
flickerstreak@1 2583 local detachedData = info.detachedData
flickerstreak@1 2584 if detachedData.detached then
flickerstreak@1 2585 return detachedData.r or 0, detachedData.g or 0, detachedData.b or 0
flickerstreak@1 2586 else
flickerstreak@1 2587 return data.r or 0, data.g or 0, data.b or 0
flickerstreak@1 2588 end
flickerstreak@1 2589 elseif type(parent) == "table" then
flickerstreak@1 2590 return parent.r or 0, parent.g or 0, parent.b or 0
flickerstreak@1 2591 else
flickerstreak@1 2592 self:assert(parent, "You must provide a parent frame to check color")
flickerstreak@1 2593 end
flickerstreak@1 2594 end
flickerstreak@1 2595 Tablet.GetColor = wrap(Tablet.GetColor, "Tablet:GetColor")
flickerstreak@1 2596
flickerstreak@1 2597 function Tablet:Detach(parent)
flickerstreak@1 2598 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2599 local info = self.registry[parent]
flickerstreak@1 2600 self:assert(info, "You cannot detach tablet with an unregistered parent frame.")
flickerstreak@1 2601 self:assert(info.detachedData, "You cannot detach tablet without a data field.")
flickerstreak@1 2602 if info.tooltip and info.tooltip == tooltip then
flickerstreak@1 2603 tooltip:Detach()
flickerstreak@1 2604 else
flickerstreak@1 2605 info.detachedData.detached = true
flickerstreak@1 2606 local detached = AcquireDetachedFrame(self, info, info.data, info.detachedData)
flickerstreak@1 2607
flickerstreak@1 2608 detached.menu = info.menu
flickerstreak@1 2609 local children = info.children
flickerstreak@1 2610 function detached:children()
flickerstreak@1 2611 if not self.preventRefresh then
flickerstreak@1 2612 currentFrame = self
flickerstreak@1 2613 currentTabletData = TabletData:new(self)
flickerstreak@1 2614 self:ClearLines()
flickerstreak@1 2615 if children then
flickerstreak@1 2616 children()
flickerstreak@1 2617 end
flickerstreak@1 2618 currentTabletData:Display(currentFrame)
flickerstreak@1 2619 self:Show(currentTabletData)
flickerstreak@1 2620 currentTabletData:del()
flickerstreak@1 2621 currentTabletData = nil
flickerstreak@1 2622 currentFrame = nil
flickerstreak@1 2623 end
flickerstreak@1 2624 end
flickerstreak@1 2625 detached:SetOwner(parent)
flickerstreak@1 2626 detached:children()
flickerstreak@1 2627 end
flickerstreak@1 2628 end
flickerstreak@1 2629 Tablet.Detach = wrap(Tablet.Detach, "Tablet:Detach")
flickerstreak@1 2630
flickerstreak@1 2631 function Tablet:Attach(parent)
flickerstreak@1 2632 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2633 local info = self.registry[parent]
flickerstreak@1 2634 self:assert(info, "You cannot detach tablet with an unregistered parent frame.")
flickerstreak@1 2635 self:assert(info.detachedData, "You cannot attach tablet without a data field.")
flickerstreak@1 2636 if info.tooltip and info.tooltip ~= tooltip then
flickerstreak@1 2637 info.tooltip:Attach()
flickerstreak@1 2638 else
flickerstreak@1 2639 info.detachedData.detached = false
flickerstreak@1 2640 end
flickerstreak@1 2641 end
flickerstreak@1 2642 Tablet.Attach = wrap(Tablet.Attach, "Tablet:Attach")
flickerstreak@1 2643
flickerstreak@1 2644 function Tablet:IsAttached(parent)
flickerstreak@1 2645 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2646 local info = self.registry[parent]
flickerstreak@1 2647 self:assert(info, "You cannot check tablet with an unregistered parent frame.")
flickerstreak@1 2648 return not info.detachedData or not info.detachedData.detached
flickerstreak@1 2649 end
flickerstreak@1 2650 Tablet.IsAttached = wrap(Tablet.IsAttached, "Tablet:IsAttached")
flickerstreak@1 2651
flickerstreak@1 2652 function Tablet:Refresh(parent)
flickerstreak@1 2653 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2654 local info = self.registry[parent]
flickerstreak@1 2655 self:assert(info, "You cannot refresh tablet with an unregistered parent frame.")
flickerstreak@1 2656 local tt = info.tooltip
flickerstreak@1 2657 if tt and not tt.preventRefresh and tt:IsShown() then
flickerstreak@1 2658 tt.updating = true
flickerstreak@1 2659 tt:children()
flickerstreak@1 2660 tt.updating = false
flickerstreak@1 2661 end
flickerstreak@1 2662 end
flickerstreak@1 2663 Tablet.Refresh = wrap(Tablet.Refresh, "Tablet:Refresh")
flickerstreak@1 2664
flickerstreak@1 2665 function Tablet:IsLocked(parent)
flickerstreak@1 2666 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2667 local info = self.registry[parent]
flickerstreak@1 2668 self:assert(info, "You cannot detach tablet with an unregistered parent frame.")
flickerstreak@1 2669 return info.detachedData and info.detachedData.locked
flickerstreak@1 2670 end
flickerstreak@1 2671 Tablet.IsLocked = wrap(Tablet.IsLocked, "Tablet:IsLocked")
flickerstreak@1 2672
flickerstreak@1 2673 function Tablet:ToggleLocked(parent)
flickerstreak@1 2674 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2675 local info = self.registry[parent]
flickerstreak@1 2676 self:assert(info, "You cannot detach tablet with an unregistered parent frame.")
flickerstreak@1 2677 if info.tooltip and info.tooltip ~= tooltip then
flickerstreak@1 2678 info.tooltip:Lock()
flickerstreak@1 2679 elseif info.detachedData then
flickerstreak@1 2680 info.detachedData.locked = info.detachedData.locked
flickerstreak@1 2681 end
flickerstreak@1 2682 end
flickerstreak@1 2683 Tablet.ToggleLocked = wrap(Tablet.ToggleLocked, "Tablet:ToggleLocked")
flickerstreak@1 2684
flickerstreak@1 2685 function Tablet:UpdateDetachedData(parent, detachedData)
flickerstreak@1 2686 self:argCheck(parent, 2, "table", "string")
flickerstreak@1 2687 local info = self.registry[parent]
flickerstreak@1 2688 self:assert(info, "You cannot detach tablet with an unregistered parent frame.")
flickerstreak@1 2689 self:argCheck(detachedData, 3, "table")
flickerstreak@1 2690 if info.data == info.detachedData then
flickerstreak@1 2691 info.data = detachedData
flickerstreak@1 2692 end
flickerstreak@1 2693 info.detachedData = detachedData
flickerstreak@1 2694 if info.detachedData.detached then
flickerstreak@1 2695 self:Detach(parent)
flickerstreak@1 2696 elseif info.tooltip and info.tooltip.owner then
flickerstreak@1 2697 self:Attach(parent)
flickerstreak@1 2698 end
flickerstreak@1 2699 end
flickerstreak@1 2700 Tablet.UpdateDetachedData = wrap(Tablet.UpdateDetachedData, "Tablet:UpdateDetachedData")
flickerstreak@1 2701
flickerstreak@1 2702 if DEBUG then
flickerstreak@1 2703 function Tablet:ListProfileInfo()
flickerstreak@1 2704 local duration, times, memories = GetProfileInfo()
flickerstreak@1 2705 self:assert(duration and times and memories)
flickerstreak@1 2706 local t = new()
flickerstreak@1 2707 for method in pairs(memories) do
flickerstreak@1 2708 table.insert(t, method)
flickerstreak@1 2709 end
flickerstreak@1 2710 table.sort(t, function(alpha, bravo)
flickerstreak@1 2711 if memories[alpha] ~= memories[bravo] then
flickerstreak@1 2712 return memories[alpha] < memories[bravo]
flickerstreak@1 2713 elseif times[alpha] ~= times[bravo] then
flickerstreak@1 2714 return times[alpha] < times[bravo]
flickerstreak@1 2715 else
flickerstreak@1 2716 return alpha < bravo
flickerstreak@1 2717 end
flickerstreak@1 2718 end)
flickerstreak@1 2719 local memory = 0
flickerstreak@1 2720 local time = 0
flickerstreak@1 2721 for _,method in ipairs(t) do
flickerstreak@1 2722 DEFAULT_CHAT_FRAME:AddMessage(format("%s || %.3f s || %.3f%% || %d KiB", method, times[method], times[method] / duration * 100, memories[method]))
flickerstreak@1 2723 memory = memory + memories[method]
flickerstreak@1 2724 time = time + times[method]
flickerstreak@1 2725 end
flickerstreak@1 2726 DEFAULT_CHAT_FRAME:AddMessage(format("%s || %.3f s || %.3f%% || %d KiB", "Total", time, time / duration * 100, memory))
flickerstreak@1 2727 del(t)
flickerstreak@1 2728 end
flickerstreak@1 2729 SLASH_TABLET1 = "/tablet"
flickerstreak@1 2730 SLASH_TABLET2 = "/tabletlib"
flickerstreak@1 2731 SlashCmdList["TABLET"] = function(msg)
flickerstreak@1 2732 TabletLib:GetInstance(MAJOR_VERSION):ListProfileInfo()
flickerstreak@1 2733 end
flickerstreak@1 2734 end
flickerstreak@1 2735
flickerstreak@1 2736 local function activate(self, oldLib, oldDeactivate)
flickerstreak@1 2737 Tablet = self
flickerstreak@1 2738 if oldLib then
flickerstreak@1 2739 self.registry = oldLib.registry
flickerstreak@1 2740 self.onceRegistered = oldLib.onceRegistered
flickerstreak@1 2741 self.tooltip = oldLib.tooltip
flickerstreak@1 2742 else
flickerstreak@1 2743 self.registry = {}
flickerstreak@1 2744 self.onceRegistered = {}
flickerstreak@1 2745 end
flickerstreak@1 2746
flickerstreak@1 2747 tooltip = self.tooltip
flickerstreak@1 2748
flickerstreak@1 2749 if oldDeactivate then
flickerstreak@1 2750 oldDeactivate(oldLib)
flickerstreak@1 2751 end
flickerstreak@1 2752 end
flickerstreak@1 2753
flickerstreak@1 2754 local function deactivate(self)
flickerstreak@1 2755 StopCheckingAlt()
flickerstreak@1 2756 end
flickerstreak@1 2757
flickerstreak@1 2758 AceLibrary:Register(Tablet, MAJOR_VERSION, MINOR_VERSION, activate, deactivate)