flickerstreak@1: --[[ flickerstreak@1: Name: Tablet-2.0 flickerstreak@1: Revision: $Rev: 19577 $ flickerstreak@1: Author(s): ckknight (ckknight@gmail.com) flickerstreak@1: Website: http://ckknight.wowinterface.com/ flickerstreak@1: Documentation: http://www.wowace.com/index.php/Tablet-2.0 flickerstreak@1: SVN: http://svn.wowace.com/wowace/trunk/TabletLib/Tablet-2.0 flickerstreak@1: Description: A library to provide an efficient, featureful tooltip-style display. flickerstreak@1: Dependencies: AceLibrary, (optional) Dewdrop-2.0 flickerstreak@1: ]] flickerstreak@1: flickerstreak@1: local MAJOR_VERSION = "Tablet-2.0" flickerstreak@1: local MINOR_VERSION = "$Revision: 19577 $" flickerstreak@1: flickerstreak@1: if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end flickerstreak@1: if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end flickerstreak@1: flickerstreak@1: local DEBUG = false flickerstreak@1: flickerstreak@1: local SCROLL_UP = "Scroll up" flickerstreak@1: local SCROLL_DOWN = "Scroll down" flickerstreak@1: local HINT = "Hint" flickerstreak@1: local DETACH = "Detach" flickerstreak@1: local DETACH_DESC = "Detach the tablet from its source." flickerstreak@1: local SIZE = "Size" flickerstreak@1: local SIZE_DESC = "Scale the tablet." flickerstreak@1: local CLOSE_MENU = "Close menu" flickerstreak@1: local CLOSE_MENU_DESC = "Close the menu." flickerstreak@1: local COLOR = "Background color" flickerstreak@1: local COLOR_DESC = "Set the background color." flickerstreak@1: local LOCK = "Lock" flickerstreak@1: 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: flickerstreak@1: if GetLocale() == "deDE" then flickerstreak@1: SCROLL_UP = "Hochscrollen" flickerstreak@1: SCROLL_DOWN = "Runterscrollen" flickerstreak@1: HINT = "Hinweis" flickerstreak@1: DETACH = "L\195\182sen" flickerstreak@1: DETACH_DESC = "L\195\182st den Tooltip aus seiner Verankerung." flickerstreak@1: SIZE = "Gr\195\182\195\159e" flickerstreak@1: SIZE_DESC = "Gr\195\182\195\159e des Tooltips \195\164ndern." flickerstreak@1: CLOSE_MENU = "Menu schlie\195\159en" flickerstreak@1: CLOSE_MENU_DESC = "Schlie\195\159t das Menu." flickerstreak@1: COLOR = "Hintergrundfarbe" flickerstreak@1: COLOR_DESC = "Hintergrundfarbe setzen." flickerstreak@1: LOCK = "Sperren" flickerstreak@1: 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: elseif GetLocale() == "koKR" then flickerstreak@1: SCROLL_UP = "위로 스크롤" flickerstreak@1: SCROLL_DOWN = "아래로 스크롤" flickerstreak@1: HINT = "힌트" flickerstreak@1: DETACH = "분리" flickerstreak@1: DETACH_DESC = "테이블을 분리합니다." flickerstreak@1: SIZE = "크기" flickerstreak@1: SIZE_DESC = "테이블의 크기입니다." flickerstreak@1: CLOSE_MENU = "메뉴 닫기" flickerstreak@1: CLOSE_MENU_DESC = "메뉴를 닫습니다." flickerstreak@1: COLOR = "배경 색상" flickerstreak@1: COLOR_DESC = "배경 색상을 설정합니다." flickerstreak@1: LOCK = "고정" flickerstreak@1: LOCK_DESC = "현재 위치에 테이블을 고정합니다. 알트+우클릭 : 메뉴열기, 알트+드래그 : 고정된것을 드래그합니다." flickerstreak@1: elseif GetLocale() == "zhCN" then flickerstreak@1: SCROLL_UP = "向上翻转" flickerstreak@1: SCROLL_DOWN = "向上翻转" flickerstreak@1: HINT = "提示" flickerstreak@1: DETACH = "分离" flickerstreak@1: DETACH_DESC = "分离菜单为独立提示." flickerstreak@1: SIZE = "尺寸" flickerstreak@1: SIZE_DESC = "缩放菜单显示尺寸." flickerstreak@1: CLOSE_MENU = "关闭菜单" flickerstreak@1: CLOSE_MENU_DESC = "关闭菜单" flickerstreak@1: COLOR = "背景颜色" flickerstreak@1: COLOR_DESC = "设置菜单背景颜色." flickerstreak@1: LOCK = "锁定" flickerstreak@1: LOCK_DESC = "锁定菜单当前位置. alt+右键 将显示选项, alt+拖动 可以移动已锁定的菜单." flickerstreak@1: elseif GetLocale() == "zhTW" then flickerstreak@1: SCROLL_UP = "向上翻轉" flickerstreak@1: SCROLL_DOWN = "向上翻轉" flickerstreak@1: HINT = "提示" flickerstreak@1: DETACH = "分離" flickerstreak@1: DETACH_DESC = "分離選單為獨立提示。" flickerstreak@1: SIZE = "尺寸" flickerstreak@1: SIZE_DESC = "縮放選單顯示尺寸。" flickerstreak@1: CLOSE_MENU = "關閉選單" flickerstreak@1: CLOSE_MENU_DESC = "關閉選單" flickerstreak@1: COLOR = "背景顏色" flickerstreak@1: COLOR_DESC = "設置選單背景顏色。" flickerstreak@1: LOCK = "鎖定" flickerstreak@1: LOCK_DESC = "鎖定選單目前位置. Alt+右鍵 將顯示選項,Alt+拖動 可以移動已鎖定的選單。" flickerstreak@1: elseif GetLocale() == "frFR" then flickerstreak@1: SCROLL_UP = "Parcourir vers le haut" flickerstreak@1: SCROLL_DOWN = "Parcourir vers le bas" flickerstreak@1: HINT = "Astuce" flickerstreak@1: DETACH = "D\195\169tacher" flickerstreak@1: DETACH_DESC = "Permet de d\195\169tacher le tableau de sa source." flickerstreak@1: SIZE = "Taille" flickerstreak@1: SIZE_DESC = "Permet de changer l'\195\169chelle du tableau." flickerstreak@1: CLOSE_MENU = "Fermer le menu" flickerstreak@1: CLOSE_MENU_DESC = "Ferme ce menu." flickerstreak@1: COLOR = "Couleur du fond" flickerstreak@1: COLOR_DESC = "Permet de d\195\169finir la couleur du fond." flickerstreak@1: LOCK = "Bloquer" flickerstreak@1: 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: end flickerstreak@1: flickerstreak@1: local start = GetTime() flickerstreak@1: local wrap flickerstreak@1: local GetProfileInfo flickerstreak@1: if DEBUG then flickerstreak@1: local tree = {} flickerstreak@1: local treeMemories = {} flickerstreak@1: local treeTimes = {} flickerstreak@1: local memories = {} flickerstreak@1: local times = {} flickerstreak@1: function wrap(value, name) flickerstreak@1: if type(value) == "function" then flickerstreak@1: local oldFunction = value flickerstreak@1: memories[name] = 0 flickerstreak@1: times[name] = 0 flickerstreak@1: 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: local pos = table.getn(tree) flickerstreak@1: table.insert(tree, name) flickerstreak@1: table.insert(treeMemories, 0) flickerstreak@1: table.insert(treeTimes, 0) flickerstreak@1: local t, mem = GetTime(), gcinfo() flickerstreak@1: 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: mem, t = gcinfo() - mem, GetTime() - t flickerstreak@1: if pos > 0 then flickerstreak@1: treeMemories[pos] = treeMemories[pos] + mem flickerstreak@1: treeTimes[pos] = treeTimes[pos] + t flickerstreak@1: end flickerstreak@1: local otherMem = table.remove(treeMemories) flickerstreak@1: if mem - otherMem > 0 then flickerstreak@1: memories[name] = memories[name] + mem - otherMem flickerstreak@1: end flickerstreak@1: times[name] = times[name] + t - table.remove(treeTimes) flickerstreak@1: table.remove(tree) flickerstreak@1: return r1, r2, r3, r4, r5, r6, r7, r8 flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: function GetProfileInfo() flickerstreak@1: return GetTime() - start, times, memories flickerstreak@1: end flickerstreak@1: else flickerstreak@1: function wrap(value) flickerstreak@1: return value flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local MIN_TOOLTIP_SIZE = 200 flickerstreak@1: local TESTSTRING_EXTRA_WIDTH = 5 flickerstreak@1: local Tablet = {} flickerstreak@1: local function getsecond(_, value) flickerstreak@1: return value flickerstreak@1: end flickerstreak@1: local Dewdrop = nil flickerstreak@1: local CleanCategoryPool flickerstreak@1: local pool = {} flickerstreak@1: flickerstreak@1: local function del(t) flickerstreak@1: if t then flickerstreak@1: for k in pairs(t) do flickerstreak@1: t[k] = nil flickerstreak@1: end flickerstreak@1: setmetatable(t, nil) flickerstreak@1: pool[t] = true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local new flickerstreak@1: flickerstreak@1: local function copy(parent) flickerstreak@1: local t = next(pool) or {} flickerstreak@1: pool[t] = nil flickerstreak@1: if parent then flickerstreak@1: for k,v in pairs(parent) do flickerstreak@1: t[k] = v flickerstreak@1: end flickerstreak@1: setmetatable(t, getmetatable(parent)) flickerstreak@1: end flickerstreak@1: return t flickerstreak@1: end flickerstreak@1: flickerstreak@1: function new(...) flickerstreak@1: local t = next(pool) or {} flickerstreak@1: pool[t] = nil flickerstreak@1: flickerstreak@1: for i = 1, select('#', ...), 2 do flickerstreak@1: local k = select(i, ...) flickerstreak@1: if k then flickerstreak@1: t[k] = select(i+1, ...) flickerstreak@1: else flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: return t flickerstreak@1: end flickerstreak@1: flickerstreak@1: local tmp flickerstreak@1: tmp = setmetatable({}, {__index = function(self, key) flickerstreak@1: local t = {} flickerstreak@1: tmp[key] = function(...) flickerstreak@1: for k in pairs(t) do flickerstreak@1: t[k] = nil flickerstreak@1: end flickerstreak@1: for i = 1, select('#', ...), 2 do flickerstreak@1: local k = select(i, ...) flickerstreak@1: if k then flickerstreak@1: t[k] = select(i+1, ...) flickerstreak@1: else flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: return t flickerstreak@1: end flickerstreak@1: return tmp[key] flickerstreak@1: end}) flickerstreak@1: flickerstreak@1: local headerSize, normalSize flickerstreak@1: if GameTooltipHeaderText then flickerstreak@1: _,headerSize = GameTooltipHeaderText:GetFont() flickerstreak@1: else flickerstreak@1: headerSize = 14 flickerstreak@1: end flickerstreak@1: if GameTooltipText then flickerstreak@1: _,normalSize = GameTooltipText:GetFont() flickerstreak@1: else flickerstreak@1: normalSize = 12 flickerstreak@1: end flickerstreak@1: local tooltip flickerstreak@1: local testString flickerstreak@1: local TabletData = {} flickerstreak@1: local Category = {} flickerstreak@1: local Line = {} flickerstreak@1: do flickerstreak@1: local TabletData_mt = { __index = TabletData } flickerstreak@1: function TabletData:new(tablet) flickerstreak@1: if not testString then flickerstreak@1: testString = UIParent:CreateFontString() flickerstreak@1: testString:Hide() flickerstreak@1: end flickerstreak@1: local self = new() flickerstreak@1: self.categories = new() flickerstreak@1: self.id = 0 flickerstreak@1: self.width = 0--(MIN_TOOLTIP_SIZE - 20)*tablet.fontSizePercent flickerstreak@1: self.tablet = tablet flickerstreak@1: self.title = "Title" flickerstreak@1: self.titleR, self.titleG, self.titleB = nil, nil, nil flickerstreak@1: setmetatable(self, TabletData_mt) flickerstreak@1: return self flickerstreak@1: end flickerstreak@1: flickerstreak@1: function TabletData:del() flickerstreak@1: for k, v in ipairs(self.categories) do flickerstreak@1: v:del() flickerstreak@1: end flickerstreak@1: del(self.categories) flickerstreak@1: del(self) flickerstreak@1: end flickerstreak@1: flickerstreak@1: function TabletData:Display() flickerstreak@1: if self.tablet == tooltip or self.tablet.registration.showTitleWhenDetached then flickerstreak@1: local info = new( flickerstreak@1: 'hideBlankLine', true, flickerstreak@1: 'text', self.title, flickerstreak@1: 'justify', "CENTER", flickerstreak@1: 'font', GameTooltipHeaderText, flickerstreak@1: 'isTitle', true flickerstreak@1: ) flickerstreak@1: if self.titleR then flickerstreak@1: info.textR = self.titleR flickerstreak@1: info.textG = self.titleG flickerstreak@1: info.textB = self.titleB flickerstreak@1: end flickerstreak@1: self:AddCategory(info, 1) flickerstreak@1: del(info) flickerstreak@1: end flickerstreak@1: if self.tablet == tooltip or self.tablet.registration.showHintWhenDetached then flickerstreak@1: if self.hint then flickerstreak@1: self:AddCategory(nil):AddLine( flickerstreak@1: 'text', HINT .. ": " .. self.hint, flickerstreak@1: 'textR', 0, flickerstreak@1: 'textG', 1, flickerstreak@1: 'textB', 0, flickerstreak@1: 'wrap', true flickerstreak@1: ) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local tabletData = self.tabletData flickerstreak@1: local width flickerstreak@1: for k, v in ipairs(self.categories) do flickerstreak@1: if v.columns <= 2 then flickerstreak@1: width = v.x1 flickerstreak@1: else flickerstreak@1: width = v.x1 + v.x2 + v.x3 + v.x4 + v.x5 + v.x6 + (v.columns - 1) * 20 flickerstreak@1: end flickerstreak@1: if self.width < width then flickerstreak@1: self.width = width flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local good = false flickerstreak@1: local lastTitle = true flickerstreak@1: for k, v in ipairs(self.categories) do flickerstreak@1: if lastTitle then flickerstreak@1: v.hideBlankLine = true flickerstreak@1: lastTitle = false flickerstreak@1: end flickerstreak@1: if v:Display(self.tablet) then flickerstreak@1: good = true flickerstreak@1: end flickerstreak@1: if v.isTitle then flickerstreak@1: lastTitle = true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if not good then flickerstreak@1: if self.tablet == tooltip or not self.tablet.registration.hideWhenEmpty then flickerstreak@1: local width flickerstreak@1: local info = new( flickerstreak@1: 'hideBlankLine', true, flickerstreak@1: 'text', self.title, flickerstreak@1: 'justify', "CENTER", flickerstreak@1: 'font', GameTooltipHeaderText, flickerstreak@1: 'isTitle', true flickerstreak@1: ) flickerstreak@1: local cat = self:AddCategory(info) flickerstreak@1: del(info) flickerstreak@1: self.width = self.categories[table.getn(self.categories)].x1 flickerstreak@1: cat:Display(self.tablet) flickerstreak@1: else flickerstreak@1: self.tablet:__Hide() flickerstreak@1: self.tablet.tmpHidden = true flickerstreak@1: end flickerstreak@1: else flickerstreak@1: self.tablet:__Show() flickerstreak@1: self.tablet.tmpHidden = nil flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: function TabletData:AddCategory(info, index) flickerstreak@1: local made = false flickerstreak@1: if not info then flickerstreak@1: made = true flickerstreak@1: info = new() flickerstreak@1: end flickerstreak@1: local cat = Category:new(self, info) flickerstreak@1: if index then flickerstreak@1: table.insert(self.categories, index, cat) flickerstreak@1: else flickerstreak@1: table.insert(self.categories, cat) flickerstreak@1: end flickerstreak@1: if made then flickerstreak@1: del(info) flickerstreak@1: end flickerstreak@1: return cat flickerstreak@1: end flickerstreak@1: flickerstreak@1: function TabletData:SetHint(hint) flickerstreak@1: self.hint = hint flickerstreak@1: end flickerstreak@1: flickerstreak@1: function TabletData:SetTitle(title) flickerstreak@1: self.title = title or "Title" flickerstreak@1: end flickerstreak@1: flickerstreak@1: function TabletData:SetTitleColor(r, g, b) flickerstreak@1: self.titleR = r flickerstreak@1: self.titleG = g flickerstreak@1: self.titleB = b flickerstreak@1: end flickerstreak@1: end flickerstreak@1: do flickerstreak@1: local Category_mt = { __index = Category } flickerstreak@1: function Category:new(tabletData, info, superCategory) flickerstreak@1: local self = copy(info) flickerstreak@1: if superCategory and not self.noInherit then flickerstreak@1: self.superCategory = superCategory.superCategory flickerstreak@1: for k, v in pairs(superCategory) do flickerstreak@1: if string.find(k, "^child_") then flickerstreak@1: local k = strsub(k, 7) flickerstreak@1: if self[k] == nil then flickerstreak@1: self[k] = v flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: self.columns = superCategory.columns flickerstreak@1: else flickerstreak@1: self.superCategory = self flickerstreak@1: end flickerstreak@1: self.tabletData = tabletData flickerstreak@1: self.lines = new() flickerstreak@1: if not self.columns then flickerstreak@1: self.columns = 1 flickerstreak@1: end flickerstreak@1: self.x1 = 0 flickerstreak@1: self.x2 = 0 flickerstreak@1: self.x3 = 0 flickerstreak@1: self.x4 = 0 flickerstreak@1: self.x5 = 0 flickerstreak@1: self.x6 = 0 flickerstreak@1: setmetatable(self, Category_mt) flickerstreak@1: self.lastWasTitle = nil flickerstreak@1: if self.text or self.text2 or self.text3 or self.text4 or self.text5 or self.text6 then flickerstreak@1: local x = new( flickerstreak@1: 'category', category, flickerstreak@1: 'text', self.text, flickerstreak@1: 'textR', self.textR or 1, flickerstreak@1: 'textG', self.textG or 1, flickerstreak@1: 'textB', self.textB or 1, flickerstreak@1: 'fakeChild', true, flickerstreak@1: 'func', self.func, flickerstreak@1: 'arg1', self.arg1, flickerstreak@1: 'arg2', self.arg2, flickerstreak@1: 'arg3', self.arg3, flickerstreak@1: 'hasCheck', self.hasCheck, flickerstreak@1: 'checked', self.checked, flickerstreak@1: 'checkIcon', self.checkIcon, flickerstreak@1: 'isRadio', self.isRadio, flickerstreak@1: 'font', self.font, flickerstreak@1: 'size', self.size, flickerstreak@1: 'wrap', self.wrap, flickerstreak@1: 'catStart', true, flickerstreak@1: 'indentation', self.indentation, flickerstreak@1: 'noInherit', true, flickerstreak@1: 'justify', self.justify, flickerstreak@1: 'justify2', self.justify2, flickerstreak@1: 'justify3', self.justify3, flickerstreak@1: 'justify4', self.justify4, flickerstreak@1: 'justify5', self.justify5, flickerstreak@1: 'justify6', self.justify6 flickerstreak@1: ) flickerstreak@1: if self.isTitle then flickerstreak@1: x.textR = self.textR or 1 flickerstreak@1: x.textG = self.textG or 0.823529 flickerstreak@1: x.textB = self.textB or 0 flickerstreak@1: else flickerstreak@1: x.textR = self.textR or 1 flickerstreak@1: x.textG = self.textG or 1 flickerstreak@1: x.textB = self.textB or 1 flickerstreak@1: end flickerstreak@1: x.text2 = self.text2 flickerstreak@1: x.text3 = self.text3 flickerstreak@1: x.text4 = self.text4 flickerstreak@1: x.text5 = self.text5 flickerstreak@1: x.text6 = self.text6 flickerstreak@1: x.text2R = self.text2R or self.textR2 or 1 flickerstreak@1: x.text2G = self.text2G or self.textG2 or 1 flickerstreak@1: x.text2B = self.text2B or self.textB2 or 1 flickerstreak@1: x.text3R = self.text3R or self.textR3 or 1 flickerstreak@1: x.text3G = self.text3G or self.textG3 or 1 flickerstreak@1: x.text3B = self.text3B or self.textB3 or 1 flickerstreak@1: x.text4R = self.text4R or self.textR4 or 1 flickerstreak@1: x.text4G = self.text4G or self.textG4 or 1 flickerstreak@1: x.text4B = self.text4B or self.textB4 or 1 flickerstreak@1: x.text5R = self.text5R or self.textR5 or 1 flickerstreak@1: x.text5G = self.text5G or self.textG5 or 1 flickerstreak@1: x.text5B = self.text5B or self.textB5 or 1 flickerstreak@1: x.text6R = self.text6R or self.textR6 or 1 flickerstreak@1: x.text6G = self.text6G or self.textG6 or 1 flickerstreak@1: x.text6B = self.text6B or self.textB6 or 1 flickerstreak@1: x.font2 = self.font2 flickerstreak@1: x.font3 = self.font3 flickerstreak@1: x.font4 = self.font4 flickerstreak@1: x.font5 = self.font5 flickerstreak@1: x.font6 = self.font6 flickerstreak@1: x.size2 = self.size2 flickerstreak@1: x.size3 = self.size3 flickerstreak@1: x.size4 = self.size4 flickerstreak@1: x.size5 = self.size5 flickerstreak@1: x.size6 = self.size6 flickerstreak@1: self:AddLine(x) flickerstreak@1: del(x) flickerstreak@1: self.lastWasTitle = true flickerstreak@1: end flickerstreak@1: return self flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Category:del() flickerstreak@1: local prev = garbageLine flickerstreak@1: for k, v in pairs(self.lines) do flickerstreak@1: v:del() flickerstreak@1: end flickerstreak@1: del(self.lines) flickerstreak@1: del(self) flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Category:AddLine(...) flickerstreak@1: self.lastWasTitle = nil flickerstreak@1: local line flickerstreak@1: local k1 = ... flickerstreak@1: if type(k1) == "table" then flickerstreak@1: local k2 = select(2, ...) flickerstreak@1: Line:new(self, k1, k2) flickerstreak@1: else flickerstreak@1: local info = new(...) flickerstreak@1: Line:new(self, info) flickerstreak@1: info = del(info) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Category:AddCategory(...) flickerstreak@1: local lastWasTitle = self.lastWasTitle flickerstreak@1: self.lastWasTitle = nil flickerstreak@1: local info flickerstreak@1: local k1 = ... flickerstreak@1: if type(k1) == "table" then flickerstreak@1: info = k1 flickerstreak@1: else flickerstreak@1: info = new(...) flickerstreak@1: end flickerstreak@1: if lastWasTitle or table.getn(self.lines) == 0 then flickerstreak@1: info.hideBlankLine = true flickerstreak@1: end flickerstreak@1: local cat = Category:new(self.tabletData, info, self) flickerstreak@1: table.insert(self.lines, cat) flickerstreak@1: if info ~= k1 then flickerstreak@1: info = del(info) flickerstreak@1: end flickerstreak@1: return cat flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Category:HasChildren() flickerstreak@1: local hasChildren = false flickerstreak@1: for k, v in ipairs(self.lines) do flickerstreak@1: if v.HasChildren then flickerstreak@1: if v:HasChildren() then flickerstreak@1: return true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if not v.fakeChild then flickerstreak@1: return true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: return false flickerstreak@1: end flickerstreak@1: flickerstreak@1: local lastWasTitle = false flickerstreak@1: function Category:Display(tablet) flickerstreak@1: if not self.isTitle and not self.showWithoutChildren and not self:HasChildren() then flickerstreak@1: return false flickerstreak@1: end flickerstreak@1: if not self.hideBlankLine and not lastWasTitle then flickerstreak@1: local info = new( flickerstreak@1: 'blank', true, flickerstreak@1: 'fakeChild', true flickerstreak@1: ) flickerstreak@1: self:AddLine(info, 1) flickerstreak@1: del(info) flickerstreak@1: end flickerstreak@1: local good = false flickerstreak@1: if table.getn(self.lines) > 0 then flickerstreak@1: self.tabletData.id = self.tabletData.id + 1 flickerstreak@1: self.id = self.tabletData.id flickerstreak@1: for k, v in ipairs(self.lines) do flickerstreak@1: if v:Display(tablet) then flickerstreak@1: good = true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: lastWasTitle = self.isTitle flickerstreak@1: return good flickerstreak@1: end flickerstreak@1: end flickerstreak@1: do flickerstreak@1: local Line_mt = { __index = Line } flickerstreak@1: function Line:new(category, info, position) flickerstreak@1: local self = copy(info) flickerstreak@1: if not info.noInherit then flickerstreak@1: for k, v in pairs(category) do flickerstreak@1: if string.find(k, "^child_") then flickerstreak@1: local k = strsub(k, 7) flickerstreak@1: if self[k] == nil then flickerstreak@1: self[k] = v flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: self.category = category flickerstreak@1: if position then flickerstreak@1: table.insert(category.lines, position, self) flickerstreak@1: else flickerstreak@1: table.insert(category.lines, self) flickerstreak@1: end flickerstreak@1: setmetatable(self, Line_mt) flickerstreak@1: local columns = category.columns flickerstreak@1: if columns == 1 then flickerstreak@1: if not self.justify then flickerstreak@1: self.justify = "LEFT" flickerstreak@1: end flickerstreak@1: elseif columns == 2 then flickerstreak@1: self.justify = "LEFT" flickerstreak@1: self.justify2 = "RIGHT" flickerstreak@1: if self.wrap then flickerstreak@1: self.wrap2 = false flickerstreak@1: end flickerstreak@1: elseif columns == 3 then flickerstreak@1: if not self.justify then flickerstreak@1: self.justify = "LEFT" flickerstreak@1: end flickerstreak@1: if not self.justify2 then flickerstreak@1: self.justify2 = "CENTER" flickerstreak@1: end flickerstreak@1: if not self.justify3 then flickerstreak@1: self.justify3 = "RIGHT" flickerstreak@1: end flickerstreak@1: if self.wrap then flickerstreak@1: self.wrap2 = false flickerstreak@1: self.wrap3 = false flickerstreak@1: elseif self.wrap2 then flickerstreak@1: self.wrap3 = false flickerstreak@1: end flickerstreak@1: elseif columns == 4 then flickerstreak@1: if not self.justify then flickerstreak@1: self.justify = "LEFT" flickerstreak@1: end flickerstreak@1: if not self.justify2 then flickerstreak@1: self.justify2 = "CENTER" flickerstreak@1: end flickerstreak@1: if not self.justify3 then flickerstreak@1: self.justify3 = "CENTER" flickerstreak@1: end flickerstreak@1: if not self.justify4 then flickerstreak@1: self.justify4 = "RIGHT" flickerstreak@1: end flickerstreak@1: if self.wrap then flickerstreak@1: self.wrap2 = false flickerstreak@1: self.wrap3 = false flickerstreak@1: self.wrap4 = false flickerstreak@1: elseif self.wrap2 then flickerstreak@1: self.wrap3 = false flickerstreak@1: self.wrap4 = false flickerstreak@1: elseif self.wrap3 then flickerstreak@1: self.wrap4 = false flickerstreak@1: end flickerstreak@1: elseif columns == 5 then flickerstreak@1: if not self.justify then flickerstreak@1: self.justify = "LEFT" flickerstreak@1: end flickerstreak@1: if not self.justify2 then flickerstreak@1: self.justify2 = "CENTER" flickerstreak@1: end flickerstreak@1: if not self.justify3 then flickerstreak@1: self.justify3 = "CENTER" flickerstreak@1: end flickerstreak@1: if not self.justify4 then flickerstreak@1: self.justify4 = "CENTER" flickerstreak@1: end flickerstreak@1: if not self.justify5 then flickerstreak@1: self.justify5 = "RIGHT" flickerstreak@1: end flickerstreak@1: if self.wrap then flickerstreak@1: self.wrap2 = false flickerstreak@1: self.wrap3 = false flickerstreak@1: self.wrap4 = false flickerstreak@1: self.wrap5 = false flickerstreak@1: elseif self.wrap2 then flickerstreak@1: self.wrap3 = false flickerstreak@1: self.wrap4 = false flickerstreak@1: self.wrap5 = false flickerstreak@1: elseif self.wrap3 then flickerstreak@1: self.wrap4 = false flickerstreak@1: self.wrap5 = false flickerstreak@1: elseif self.wrap4 then flickerstreak@1: self.wrap5 = false flickerstreak@1: end flickerstreak@1: elseif columns == 6 then flickerstreak@1: if not self.justify then flickerstreak@1: self.justify = "LEFT" flickerstreak@1: end flickerstreak@1: if not self.justify2 then flickerstreak@1: self.justify2 = "CENTER" flickerstreak@1: end flickerstreak@1: if not self.justify3 then flickerstreak@1: self.justify3 = "CENTER" flickerstreak@1: end flickerstreak@1: if not self.justify4 then flickerstreak@1: self.justify4 = "CENTER" flickerstreak@1: end flickerstreak@1: if not self.justify5 then flickerstreak@1: self.justify5 = "CENTER" flickerstreak@1: end flickerstreak@1: if not self.justify6 then flickerstreak@1: self.justify6 = "RIGHT" flickerstreak@1: end flickerstreak@1: if self.wrap then flickerstreak@1: self.wrap2 = false flickerstreak@1: self.wrap3 = false flickerstreak@1: self.wrap4 = false flickerstreak@1: self.wrap5 = false flickerstreak@1: self.wrap6 = false flickerstreak@1: elseif self.wrap2 then flickerstreak@1: self.wrap3 = false flickerstreak@1: self.wrap4 = false flickerstreak@1: self.wrap5 = false flickerstreak@1: self.wrap6 = false flickerstreak@1: elseif self.wrap3 then flickerstreak@1: self.wrap4 = false flickerstreak@1: self.wrap5 = false flickerstreak@1: self.wrap6 = false flickerstreak@1: elseif self.wrap4 then flickerstreak@1: self.wrap5 = false flickerstreak@1: self.wrap6 = false flickerstreak@1: elseif self.wrap5 then flickerstreak@1: self.wrap6 = false flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if self.textR2 then flickerstreak@1: self.text2R, self.textR2 = self.text2R or self.textR2 flickerstreak@1: self.text2G, self.textG2 = self.text2G or self.textG2 flickerstreak@1: self.text2B, self.textB2 = self.text2B or self.textB2 flickerstreak@1: if self.textR3 then flickerstreak@1: self.text3R, self.textR3 = self.text3R or self.textR3 flickerstreak@1: self.text3G, self.textG3 = self.text3G or self.textG3 flickerstreak@1: self.text3B, self.textB3 = self.text3B or self.textB3 flickerstreak@1: if self.textR4 then flickerstreak@1: self.text4R, self.textR4 = self.text4R or self.textR4 flickerstreak@1: self.text4G, self.textG4 = self.text4G or self.textG4 flickerstreak@1: self.text4B, self.textB4 = self.text4B or self.textB4 flickerstreak@1: if self.textR5 then flickerstreak@1: self.text5R, self.textR5 = self.text5R or self.textR5 flickerstreak@1: self.text5G, self.textG5 = self.text5G or self.textG5 flickerstreak@1: self.text5B, self.textB5 = self.text5B or self.textB5 flickerstreak@1: if self.textR5 then flickerstreak@1: self.text6R, self.textR6 = self.text6R or self.textR6 flickerstreak@1: self.text6G, self.textG6 = self.text6G or self.textG6 flickerstreak@1: self.text6B, self.textB6 = self.text6B or self.textB6 flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if not self.indentation or self.indentation < 0 then flickerstreak@1: self.indentation = 0 flickerstreak@1: end flickerstreak@1: if not self.font then flickerstreak@1: self.font = GameTooltipText flickerstreak@1: end flickerstreak@1: if not self.font2 then flickerstreak@1: self.font2 = self.font flickerstreak@1: end flickerstreak@1: if not self.font3 then flickerstreak@1: self.font3 = self.font flickerstreak@1: end flickerstreak@1: if not self.font4 then flickerstreak@1: self.font4 = self.font flickerstreak@1: end flickerstreak@1: if not self.font5 then flickerstreak@1: self.font5 = self.font flickerstreak@1: end flickerstreak@1: if not self.font6 then flickerstreak@1: self.font6 = self.font flickerstreak@1: end flickerstreak@1: if not self.size then flickerstreak@1: _,self.size = self.font:GetFont() flickerstreak@1: end flickerstreak@1: if not self.size2 then flickerstreak@1: _,self.size2 = self.font2:GetFont() flickerstreak@1: end flickerstreak@1: if not self.size3 then flickerstreak@1: _,self.size3 = self.font3:GetFont() flickerstreak@1: end flickerstreak@1: if not self.size4 then flickerstreak@1: _,self.size4 = self.font4:GetFont() flickerstreak@1: end flickerstreak@1: if not self.size5 then flickerstreak@1: _,self.size5 = self.font5:GetFont() flickerstreak@1: end flickerstreak@1: if not self.size6 then flickerstreak@1: _,self.size6 = self.font6:GetFont() flickerstreak@1: end flickerstreak@1: flickerstreak@1: local fontSizePercent = category.tabletData.tablet.fontSizePercent flickerstreak@1: local w = 0 flickerstreak@1: self.checkWidth = 0 flickerstreak@1: if self.text then flickerstreak@1: if not self.wrap then flickerstreak@1: testString:SetWidth(0) flickerstreak@1: testString:SetFontObject(self.font) flickerstreak@1: local font,_,flags = testString:GetFont() flickerstreak@1: testString:SetFont(font, self.size * fontSizePercent, flags) flickerstreak@1: testString:SetText(self.text) flickerstreak@1: local checkWidth = self.hasCheck and self.size * fontSizePercent or 0 flickerstreak@1: self.checkWidth = checkWidth flickerstreak@1: w = testString:GetWidth() + self.indentation * fontSizePercent + checkWidth + TESTSTRING_EXTRA_WIDTH flickerstreak@1: if category.superCategory.x1 < w then flickerstreak@1: category.superCategory.x1 = w flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if columns == 1 then flickerstreak@1: testString:SetWidth(0) flickerstreak@1: testString:SetFontObject(self.font) flickerstreak@1: local font,_,flags = testString:GetFont() flickerstreak@1: testString:SetFont(font, self.size * fontSizePercent, flags) flickerstreak@1: testString:SetText(self.text) flickerstreak@1: local checkWidth = self.hasCheck and self.size * fontSizePercent or 0 flickerstreak@1: self.checkWidth = checkWidth flickerstreak@1: w = testString:GetWidth() + self.indentation * fontSizePercent + checkWidth + TESTSTRING_EXTRA_WIDTH flickerstreak@1: if w > (MIN_TOOLTIP_SIZE - 20) * fontSizePercent then flickerstreak@1: w = (MIN_TOOLTIP_SIZE - 20) * fontSizePercent flickerstreak@1: end flickerstreak@1: else flickerstreak@1: w = MIN_TOOLTIP_SIZE * fontSizePercent / 2 flickerstreak@1: end flickerstreak@1: if category.superCategory.x1 < w then flickerstreak@1: category.superCategory.x1 = w flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if columns == 2 and self.text2 then flickerstreak@1: if not self.wrap2 then flickerstreak@1: testString:SetWidth(0) flickerstreak@1: testString:SetFontObject(self.font2) flickerstreak@1: local font,_,flags = testString:GetFont() flickerstreak@1: testString:SetFont(font, self.size2 * fontSizePercent, flags) flickerstreak@1: testString:SetText(self.text2) flickerstreak@1: w = w + 40 * fontSizePercent + testString:GetWidth() + TESTSTRING_EXTRA_WIDTH flickerstreak@1: if category.superCategory.x1 < w then flickerstreak@1: category.superCategory.x1 = w flickerstreak@1: end flickerstreak@1: else flickerstreak@1: w = w + 40 * fontSizePercent + MIN_TOOLTIP_SIZE * fontSizePercent / 2 flickerstreak@1: if category.superCategory.x1 < w then flickerstreak@1: category.superCategory.x1 = w flickerstreak@1: end flickerstreak@1: end flickerstreak@1: elseif columns >= 3 then flickerstreak@1: if self.text2 then flickerstreak@1: if not self.wrap2 then flickerstreak@1: testString:SetWidth(0) flickerstreak@1: testString:SetFontObject(self.font2) flickerstreak@1: local font,_,flags = testString:GetFont() flickerstreak@1: testString:SetFont(font, self.size2 * fontSizePercent, flags) flickerstreak@1: testString:SetText(self.text2) flickerstreak@1: local w = testString:GetWidth() + TESTSTRING_EXTRA_WIDTH flickerstreak@1: if category.superCategory.x2 < w then flickerstreak@1: category.superCategory.x2 = w flickerstreak@1: end flickerstreak@1: else flickerstreak@1: local w = MIN_TOOLTIP_SIZE / 2 flickerstreak@1: if category.superCategory.x2 < w then flickerstreak@1: category.superCategory.x2 = w flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if self.text3 then flickerstreak@1: if not self.wrap3 then flickerstreak@1: testString:SetWidth(0) flickerstreak@1: testString:SetFontObject(self.font3) flickerstreak@1: local font,_,flags = testString:GetFont() flickerstreak@1: testString:SetFont(font, self.size3 * fontSizePercent, flags) flickerstreak@1: testString:SetText(self.text3) flickerstreak@1: local w = testString:GetWidth() + TESTSTRING_EXTRA_WIDTH flickerstreak@1: if category.superCategory.x3 < w then flickerstreak@1: category.superCategory.x3 = w flickerstreak@1: end flickerstreak@1: else flickerstreak@1: local w = MIN_TOOLTIP_SIZE / 2 flickerstreak@1: if category.superCategory.x3 < w then flickerstreak@1: category.superCategory.x3 = w flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if columns >= 4 then flickerstreak@1: if self.text4 then flickerstreak@1: if not self.wrap4 then flickerstreak@1: testString:SetWidth(0) flickerstreak@1: testString:SetFontObject(self.font4) flickerstreak@1: local font,_,flags = testString:GetFont() flickerstreak@1: testString:SetFont(font, self.size4 * fontSizePercent, flags) flickerstreak@1: testString:SetText(self.text4) flickerstreak@1: w = testString:GetWidth() + TESTSTRING_EXTRA_WIDTH flickerstreak@1: if category.superCategory.x4 < w then flickerstreak@1: category.superCategory.x4 = w flickerstreak@1: end flickerstreak@1: else flickerstreak@1: local w = MIN_TOOLTIP_SIZE / 2 flickerstreak@1: if category.superCategory.x4 < w then flickerstreak@1: category.superCategory.x4 = w flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if columns >= 5 then flickerstreak@1: if self.text5 then flickerstreak@1: if not self.wrap5 then flickerstreak@1: testString:SetWidth(0) flickerstreak@1: testString:SetFontObject(self.font5) flickerstreak@1: local font,_,flags = testString:GetFont() flickerstreak@1: testString:SetFont(font, self.size5 * fontSizePercent, flags) flickerstreak@1: testString:SetText(self.text5) flickerstreak@1: w = testString:GetWidth() + TESTSTRING_EXTRA_WIDTH flickerstreak@1: if category.superCategory.x5 < w then flickerstreak@1: category.superCategory.x5 = w flickerstreak@1: end flickerstreak@1: else flickerstreak@1: local w = MIN_TOOLTIP_SIZE / 2 flickerstreak@1: if category.superCategory.x5 < w then flickerstreak@1: category.superCategory.x5 = w flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if columns >= 6 then flickerstreak@1: if self.text6 then flickerstreak@1: if not self.wrap6 then flickerstreak@1: testString:SetWidth(0) flickerstreak@1: testString:SetFontObject(self.font6) flickerstreak@1: local font,_,flags = testString:GetFont() flickerstreak@1: testString:SetFont(font, self.size6 * fontSizePercent, flags) flickerstreak@1: testString:SetText(self.text6) flickerstreak@1: w = testString:GetWidth() + TESTSTRING_EXTRA_WIDTH flickerstreak@1: if category.superCategory.x6 < w then flickerstreak@1: category.superCategory.x6 = w flickerstreak@1: end flickerstreak@1: else flickerstreak@1: local w = MIN_TOOLTIP_SIZE / 2 flickerstreak@1: if category.superCategory.x6 < w then flickerstreak@1: category.superCategory.x6 = w flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: return self flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Line:del() flickerstreak@1: del(self) flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Line:Display(tablet) flickerstreak@1: tablet:AddLine(self) flickerstreak@1: return true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function button_OnEnter() flickerstreak@1: if type(this.self:GetScript("OnEnter")) == "function" then flickerstreak@1: this.self:GetScript("OnEnter")() flickerstreak@1: end flickerstreak@1: this.highlight:Show() flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function button_OnLeave() flickerstreak@1: if type(this.self:GetScript("OnLeave")) == "function" then flickerstreak@1: this.self:GetScript("OnLeave")() flickerstreak@1: end flickerstreak@1: this.highlight:Hide() flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function NewLine(self) flickerstreak@1: if self.maxLines <= self.numLines then flickerstreak@1: self.maxLines = self.maxLines + 1 flickerstreak@1: local button = CreateFrame("Button", nil, self) flickerstreak@1: button.indentation = 0 flickerstreak@1: local check = button:CreateTexture(nil, "ARTWORK") flickerstreak@1: local left = button:CreateFontString(nil, "ARTWORK") flickerstreak@1: local right = button:CreateFontString(nil, "ARTWORK") flickerstreak@1: local third = button:CreateFontString(nil, "ARTWORK") flickerstreak@1: local fourth = button:CreateFontString(nil, "ARTWORK") flickerstreak@1: local fifth = button:CreateFontString(nil, "ARTWORK") flickerstreak@1: local sixth = button:CreateFontString(nil, "ARTWORK") flickerstreak@1: local highlight = button:CreateTexture(nil, "BACKGROUND") flickerstreak@1: highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") flickerstreak@1: button.highlight = highlight flickerstreak@1: highlight:SetBlendMode("ADD") flickerstreak@1: highlight:SetAllPoints(button) flickerstreak@1: highlight:Hide() flickerstreak@1: table.insert(self.buttons, button) flickerstreak@1: table.insert(self.checks, check) flickerstreak@1: table.insert(self.lefts, left) flickerstreak@1: table.insert(self.rights, right) flickerstreak@1: table.insert(self.thirds, third) flickerstreak@1: table.insert(self.fourths, fourth) flickerstreak@1: table.insert(self.fifths, fifth) flickerstreak@1: table.insert(self.sixths, sixth) flickerstreak@1: left:SetWidth(0) flickerstreak@1: if self.maxLines == 1 then flickerstreak@1: left:SetFontObject(GameTooltipHeaderText) flickerstreak@1: right:SetFontObject(GameTooltipHeaderText) flickerstreak@1: third:SetFontObject(GameTooltipHeaderText) flickerstreak@1: fourth:SetFontObject(GameTooltipHeaderText) flickerstreak@1: fifth:SetFontObject(GameTooltipHeaderText) flickerstreak@1: sixth:SetFontObject(GameTooltipHeaderText) flickerstreak@1: left:SetJustifyH("CENTER") flickerstreak@1: button:SetPoint("TOPLEFT", self, "TOPLEFT", 8, -10) flickerstreak@1: else flickerstreak@1: left:SetFontObject(GameTooltipText) flickerstreak@1: right:SetFontObject(GameTooltipText) flickerstreak@1: third:SetFontObject(GameTooltipText) flickerstreak@1: fourth:SetFontObject(GameTooltipText) flickerstreak@1: fifth:SetFontObject(GameTooltipText) flickerstreak@1: sixth:SetFontObject(GameTooltipText) flickerstreak@1: button:SetPoint("TOPLEFT", self.buttons[self.maxLines - 1], "BOTTOMLEFT", 0, -2) flickerstreak@1: end flickerstreak@1: button:SetScript("OnEnter", button_OnEnter) flickerstreak@1: button:SetScript("OnLeave", button_OnLeave) flickerstreak@1: button.check = check flickerstreak@1: button.self = self flickerstreak@1: button:SetPoint("RIGHT", self, "RIGHT", -12, 0) flickerstreak@1: check.shown = false flickerstreak@1: check:SetPoint("TOPLEFT", button, "TOPLEFT") flickerstreak@1: left:SetPoint("TOPLEFT", check, "TOPLEFT") flickerstreak@1: right:SetPoint("TOPLEFT", left, "TOPRIGHT", 40 * self.fontSizePercent, 0) flickerstreak@1: third:SetPoint("TOPLEFT", right, "TOPRIGHT", 20 * self.fontSizePercent, 0) flickerstreak@1: fourth:SetPoint("TOPLEFT", third, "TOPRIGHT", 20 * self.fontSizePercent, 0) flickerstreak@1: fifth:SetPoint("TOPLEFT", fourth, "TOPRIGHT", 20 * self.fontSizePercent, 0) flickerstreak@1: sixth:SetPoint("TOPLEFT", fifth, "TOPRIGHT", 20 * self.fontSizePercent, 0) flickerstreak@1: right:SetJustifyH("RIGHT") flickerstreak@1: local _,size = GameTooltipText:GetFont() flickerstreak@1: check:SetHeight(size * 1.5) flickerstreak@1: check:SetWidth(size * 1.5) flickerstreak@1: check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") flickerstreak@1: check:SetAlpha(0) flickerstreak@1: if not button.clicked then flickerstreak@1: button:SetScript("OnMouseWheel", self:GetScript("OnMouseWheel")) flickerstreak@1: button:EnableMouseWheel(true) flickerstreak@1: button:Hide() flickerstreak@1: end flickerstreak@1: check:Show() flickerstreak@1: left:Hide() flickerstreak@1: right:Hide() flickerstreak@1: third:Hide() flickerstreak@1: fourth:Hide() flickerstreak@1: fifth:Hide() flickerstreak@1: sixth:Hide() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: NewLine = wrap(NewLine, "NewLine") flickerstreak@1: flickerstreak@1: local function GetMaxLinesPerScreen(self) flickerstreak@1: if self == tooltip then flickerstreak@1: return floor(50 / self.fontSizePercent) flickerstreak@1: else flickerstreak@1: return floor(30 / self.fontSizePercent) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: GetMaxLinesPerScreen = wrap(GetMaxLinesPerScreen, "GetMaxLinesPerScreen") flickerstreak@1: flickerstreak@1: local detachedTooltips = {} flickerstreak@1: local AcquireDetachedFrame, ReleaseDetachedFrame flickerstreak@1: local function AcquireFrame(self, registration, data, detachedData) flickerstreak@1: if not detachedData then flickerstreak@1: detachedData = data flickerstreak@1: end flickerstreak@1: if tooltip then flickerstreak@1: tooltip.data = data flickerstreak@1: tooltip.detachedData = detachedData flickerstreak@1: local fontSizePercent = tooltip.data and tooltip.data.fontSizePercent or 1 flickerstreak@1: local transparency = tooltip.data and tooltip.data.transparency or 0.75 flickerstreak@1: local r = tooltip.data and tooltip.data.r or 0 flickerstreak@1: local g = tooltip.data and tooltip.data.g or 0 flickerstreak@1: local b = tooltip.data and tooltip.data.b or 0 flickerstreak@1: tooltip:SetFontSizePercent(fontSizePercent) flickerstreak@1: tooltip:SetTransparency(transparency) flickerstreak@1: tooltip:SetColor(r, g, b) flickerstreak@1: else flickerstreak@1: tooltip = CreateFrame("Frame", "Tablet20Frame", UIParent) flickerstreak@1: self.tooltip = tooltip flickerstreak@1: tooltip.data = data flickerstreak@1: tooltip.detachedData = detachedData flickerstreak@1: tooltip:EnableMouse(true) flickerstreak@1: tooltip:EnableMouseWheel(true) flickerstreak@1: tooltip:SetFrameStrata("TOOLTIP") flickerstreak@1: tooltip:SetFrameLevel(10) flickerstreak@1: local backdrop = new( flickerstreak@1: 'bgFile', "Interface\\Buttons\\WHITE8X8", flickerstreak@1: 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border", flickerstreak@1: 'tile', true, flickerstreak@1: 'tileSize', 16, flickerstreak@1: 'edgeSize', 16, flickerstreak@1: 'insets', new( flickerstreak@1: 'left', 5, flickerstreak@1: 'right', 5, flickerstreak@1: 'top', 5, flickerstreak@1: 'bottom', 5 flickerstreak@1: ) flickerstreak@1: ) flickerstreak@1: tooltip:SetBackdrop(backdrop) flickerstreak@1: del(backdrop.insets) flickerstreak@1: del(backdrop) flickerstreak@1: tooltip:SetBackdropColor(0, 0, 0, 1) flickerstreak@1: flickerstreak@1: tooltip.numLines = 0 flickerstreak@1: tooltip.owner = nil flickerstreak@1: tooltip.fontSizePercent = tooltip.data and tooltip.data.fontSizePercent or 1 flickerstreak@1: tooltip.maxLines = 0 flickerstreak@1: tooltip.buttons = {} flickerstreak@1: tooltip.checks = {} flickerstreak@1: tooltip.lefts = {} flickerstreak@1: tooltip.rights = {} flickerstreak@1: tooltip.thirds = {} flickerstreak@1: tooltip.fourths = {} flickerstreak@1: tooltip.fifths = {} flickerstreak@1: tooltip.sixths = {} flickerstreak@1: tooltip.transparency = tooltip.data and tooltip.data.transparency or 0.75 flickerstreak@1: tooltip:SetBackdropColor(0, 0, 0, tooltip.transparency) flickerstreak@1: tooltip:SetBackdropBorderColor(1, 1, 1, tooltip.transparency) flickerstreak@1: tooltip.scroll = 0 flickerstreak@1: flickerstreak@1: tooltip:SetScript("OnUpdate", function() flickerstreak@1: if not tooltip.updating and not tooltip.enteredFrame then flickerstreak@1: tooltip.scroll = 0 flickerstreak@1: tooltip:Hide() flickerstreak@1: tooltip.registration.tooltip = nil flickerstreak@1: tooltip.registration = nil flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: flickerstreak@1: tooltip:SetScript("OnEnter", function() flickerstreak@1: if tooltip.clickable then flickerstreak@1: tooltip.enteredFrame = true flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: flickerstreak@1: tooltip:SetScript("OnLeave", function() flickerstreak@1: if not tooltip.updating then flickerstreak@1: tooltip.enteredFrame = false flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: flickerstreak@1: tooltip:SetScript("OnMouseWheel", function() flickerstreak@1: tooltip.updating = true flickerstreak@1: tooltip:Scroll(arg1 < 0) flickerstreak@1: tooltip.updating = false flickerstreak@1: end) flickerstreak@1: flickerstreak@1: NewLine(tooltip) flickerstreak@1: flickerstreak@1: tooltip.scrollUp = tooltip:CreateFontString(nil, "ARTWORK") flickerstreak@1: tooltip.scrollUp:SetPoint("TOPLEFT", tooltip.buttons[1], "BOTTOMLEFT", 0, -2) flickerstreak@1: tooltip.scrollUp:SetPoint("RIGHT", tooltip, "RIGHT", 0, -10) flickerstreak@1: tooltip.scrollUp:SetFontObject(GameTooltipText) flickerstreak@1: tooltip.scrollUp:Hide() flickerstreak@1: local font,_,flags = tooltip.scrollUp:GetFont() flickerstreak@1: tooltip.scrollUp:SetFont(font, normalSize * tooltip.fontSizePercent, flags) flickerstreak@1: tooltip.scrollUp:SetJustifyH("CENTER") flickerstreak@1: tooltip.scrollUp:SetTextColor(1, 0.823529, 0) flickerstreak@1: tooltip.scrollUp:SetText(" ") flickerstreak@1: flickerstreak@1: tooltip.scrollDown = tooltip:CreateFontString(nil, "ARTWORK") flickerstreak@1: tooltip.scrollDown:SetPoint("TOPLEFT", tooltip.buttons[1], "BOTTOMLEFT", 0, -2) flickerstreak@1: tooltip.scrollDown:SetPoint("RIGHT", tooltip, "RIGHT", 0, -10) flickerstreak@1: tooltip.scrollDown:SetFontObject(GameTooltipText) flickerstreak@1: tooltip.scrollDown:Hide() flickerstreak@1: local font,_,flags = tooltip.scrollUp:GetFont() flickerstreak@1: tooltip.scrollDown:SetFont(font, normalSize * tooltip.fontSizePercent, flags) flickerstreak@1: tooltip.scrollDown:SetJustifyH("CENTER") flickerstreak@1: tooltip.scrollDown:SetTextColor(1, 0.823529, 0) flickerstreak@1: tooltip.scrollDown:SetText(" ") flickerstreak@1: flickerstreak@1: function tooltip:SetOwner(o) flickerstreak@1: self:Hide(o) flickerstreak@1: self.owner = o flickerstreak@1: end flickerstreak@1: tooltip.SetOwner = wrap(tooltip.SetOwner, "tooltip:SetOwner") flickerstreak@1: flickerstreak@1: function tooltip:IsOwned(o) flickerstreak@1: return self.owner == o flickerstreak@1: end flickerstreak@1: tooltip.IsOwned = wrap(tooltip.IsOwned, "tooltip:IsOwned") flickerstreak@1: flickerstreak@1: function tooltip:ClearLines(hide) flickerstreak@1: CleanCategoryPool(self) flickerstreak@1: for i = 1, self.numLines do flickerstreak@1: local button = self.buttons[i] flickerstreak@1: local check = self.checks[i] flickerstreak@1: if not button.clicked or hide then flickerstreak@1: button:Hide() flickerstreak@1: end flickerstreak@1: check.shown = false flickerstreak@1: check:SetAlpha(0) flickerstreak@1: end flickerstreak@1: self.numLines = 0 flickerstreak@1: end flickerstreak@1: tooltip.ClearLines = wrap(tooltip.ClearLines, "tooltip:ClearLines") flickerstreak@1: flickerstreak@1: function tooltip:NumLines() flickerstreak@1: return self.numLines flickerstreak@1: end flickerstreak@1: flickerstreak@1: local lastWidth flickerstreak@1: local old_tooltip_Hide = tooltip.Hide flickerstreak@1: tooltip.__Hide = old_tooltip_Hide flickerstreak@1: function tooltip:Hide(newOwner) flickerstreak@1: if self == tooltip or newOwner == nil then flickerstreak@1: old_tooltip_Hide(self) flickerstreak@1: end flickerstreak@1: self:ClearLines(true) flickerstreak@1: self.owner = nil flickerstreak@1: self.lastWidth = nil flickerstreak@1: self.tmpHidden = nil flickerstreak@1: end flickerstreak@1: tooltip.Hide = wrap(tooltip.Hide, "tooltip:Hide") flickerstreak@1: flickerstreak@1: local old_tooltip_Show = tooltip.Show flickerstreak@1: tooltip.__Show = old_tooltip_Show flickerstreak@1: function tooltip:Show(tabletData) flickerstreak@1: if self.owner == nil or self.notInUse then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: if not self.tmpHidden then flickerstreak@1: old_tooltip_Show(self) flickerstreak@1: end flickerstreak@1: flickerstreak@1: local maxWidth = tabletData and tabletData.width or self:GetWidth() - 20 flickerstreak@1: local hasWrap = false flickerstreak@1: local screenWidth = GetScreenWidth() flickerstreak@1: local scrollMax = self.numLines flickerstreak@1: if scrollMax > GetMaxLinesPerScreen(self) + self.scroll then flickerstreak@1: scrollMax = GetMaxLinesPerScreen(self) + self.scroll flickerstreak@1: end flickerstreak@1: local numColumns flickerstreak@1: flickerstreak@1: local height = 20 flickerstreak@1: if scrollMax ~= self.numLines then flickerstreak@1: self.scrollDown:SetWidth(maxWidth) flickerstreak@1: height = height + self.scrollDown:GetHeight() + 2 flickerstreak@1: end flickerstreak@1: if self.scroll ~= 0 then flickerstreak@1: self.scrollUp:SetWidth(maxWidth) flickerstreak@1: height = height + self.scrollUp:GetHeight() + 2 flickerstreak@1: end flickerstreak@1: self:SetWidth(maxWidth + 20) flickerstreak@1: flickerstreak@1: local tmp = self.scroll + 1 flickerstreak@1: if tmp ~= 1 then flickerstreak@1: tmp = tmp + 1 flickerstreak@1: end flickerstreak@1: for i = 1, self.numLines do flickerstreak@1: if i < tmp or i > scrollMax or (i == scrollMax and i ~= self.numLines) then flickerstreak@1: self.buttons[i]:ClearAllPoints() flickerstreak@1: self.buttons[i]:Hide() flickerstreak@1: else flickerstreak@1: local button = self.buttons[i] flickerstreak@1: local left = self.lefts[i] flickerstreak@1: local right = self.rights[i] flickerstreak@1: local check = self.checks[i] flickerstreak@1: button:SetWidth(maxWidth) flickerstreak@1: button:SetHeight(math.max(left:GetHeight(), right:GetHeight())) flickerstreak@1: height = height + button:GetHeight() + 2 flickerstreak@1: if i == self.scroll + 1 then flickerstreak@1: button:SetPoint("TOPLEFT", self, "TOPLEFT", 10, -10) flickerstreak@1: else flickerstreak@1: button:SetPoint("TOPLEFT", self.buttons[i - 1], "BOTTOMLEFT", 0, -2) flickerstreak@1: end flickerstreak@1: if button.clicked then flickerstreak@1: check:SetPoint("TOPLEFT", button, "TOPLEFT", button.indentation * self.fontSizePercent + (check.width - check:GetWidth()) / 2 + 1, -1) flickerstreak@1: else flickerstreak@1: check:SetPoint("TOPLEFT", button, "TOPLEFT", button.indentation * self.fontSizePercent + (check.width - check:GetWidth()) / 2, 0) flickerstreak@1: end flickerstreak@1: button:Show() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if self.scroll ~= 0 then flickerstreak@1: self.scrollUp:SetPoint("TOPLEFT", self, "TOPLEFT", 10, -10) flickerstreak@1: self.buttons[self.scroll + 2]:SetPoint("TOPLEFT", self.scrollUp, "BOTTOMLEFT", 0, -2) flickerstreak@1: self.scrollUp:SetText(SCROLL_UP .. " (" .. self.scroll + 2 .. " / " .. self.numLines .. ")") flickerstreak@1: self.scrollUp:Show() flickerstreak@1: else flickerstreak@1: self.scrollUp:Hide() flickerstreak@1: end flickerstreak@1: if scrollMax ~= self.numLines and self.buttons[scrollMax - 1] then flickerstreak@1: self.scrollDown:SetPoint("TOPLEFT", self.buttons[scrollMax - 1], "BOTTOMLEFT", 0, -2) flickerstreak@1: self.scrollDown:SetText(SCROLL_DOWN .. " (" .. scrollMax - 1 .. " / " .. self.numLines .. ")") flickerstreak@1: self.scrollDown:Show() flickerstreak@1: else flickerstreak@1: self.scrollDown:Hide() flickerstreak@1: end flickerstreak@1: self:SetHeight(height) flickerstreak@1: end flickerstreak@1: tooltip.Show = wrap(tooltip.Show, "tooltip:Show") flickerstreak@1: flickerstreak@1: local lastMouseDown flickerstreak@1: local function button_OnClick() flickerstreak@1: if this.self:HasScript("OnClick") and type(this.self:GetScript("OnClick")) == "function" then flickerstreak@1: this.self:GetScript("OnClick")() flickerstreak@1: end flickerstreak@1: if arg1 == "RightButton" then flickerstreak@1: if this.self:HasScript("OnClick") and type(this.self:GetScript("OnClick")) == "function" then flickerstreak@1: this.self:GetScript("OnClick")() flickerstreak@1: end flickerstreak@1: elseif arg1 == "LeftButton" then flickerstreak@1: if this.self.preventClick == nil or GetTime() > this.self.preventClick and GetTime() < lastMouseDown + 0.5 then flickerstreak@1: this.self.preventClick = nil flickerstreak@1: this.self.updating = true flickerstreak@1: this.self.preventRefresh = true flickerstreak@1: this.func(this.a1, this.a2, this.a3) flickerstreak@1: if this.self and this.self.registration then flickerstreak@1: this.self.preventRefresh = false flickerstreak@1: this.self:children() flickerstreak@1: this.self.updating = false flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local function button_OnMouseUp() flickerstreak@1: if this.self:HasScript("OnMouseUp") and type(this.self:GetScript("OnMouseUp")) == "function" then flickerstreak@1: this.self:GetScript("OnMouseUp")() flickerstreak@1: end flickerstreak@1: if arg1 ~= "RightButton" then flickerstreak@1: if this.clicked then flickerstreak@1: local a,b,c,d,e = this.check:GetPoint(1) flickerstreak@1: this.check:SetPoint(a,b,c,d-1,e+1) flickerstreak@1: this.clicked = false flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: local function button_OnMouseDown() flickerstreak@1: if this.self:HasScript("OnMouseDown") and type(this.self:GetScript("OnMouseDown")) == "function" then flickerstreak@1: this.self:GetScript("OnMouseDown")() flickerstreak@1: end flickerstreak@1: lastMouseDown = GetTime() flickerstreak@1: if arg1 ~= "RightButton" then flickerstreak@1: local a,b,c,d,e = this.check:GetPoint(1) flickerstreak@1: this.check:SetPoint(a,b,c,d+1,e-1) flickerstreak@1: this.clicked = true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: function tooltip:AddLine(info) flickerstreak@1: local category = info.category.superCategory flickerstreak@1: local maxWidth = category.tabletData.width flickerstreak@1: local text = info.blank and "\n" or info.text flickerstreak@1: local id = info.id flickerstreak@1: local func = info.func flickerstreak@1: local checked = info.checked flickerstreak@1: local isRadio = info.isRadio flickerstreak@1: local checkTexture = info.checkTexture flickerstreak@1: local fontSizePercent = self.fontSizePercent flickerstreak@1: if not info.font then flickerstreak@1: info.font = GameTooltipText flickerstreak@1: end flickerstreak@1: if not info.size then flickerstreak@1: _,info.size = info.font:GetFont() flickerstreak@1: end flickerstreak@1: local catStart = false flickerstreak@1: local columns = category and category.columns or 1 flickerstreak@1: local x1, x2, x3, x4, x5, x6 flickerstreak@1: if category then flickerstreak@1: x1, x2, x3, x4, x5, x6 = category.x1, category.x2, category.x3, category.x4, category.x5, category.x6 flickerstreak@1: else flickerstreak@1: x1, x2, x3, x4, x5, x6 = 0, 0, 0, 0, 0, 0 flickerstreak@1: end flickerstreak@1: if info.isTitle then flickerstreak@1: justAddedTitle = true flickerstreak@1: end flickerstreak@1: flickerstreak@1: self.numLines = self.numLines + 1 flickerstreak@1: NewLine(self) flickerstreak@1: self.lefts[self.numLines]:Show() flickerstreak@1: self.buttons[self.numLines]:Show() flickerstreak@1: num = self.numLines flickerstreak@1: flickerstreak@1: local button = self.buttons[num] flickerstreak@1: button.indentation = info.indentation flickerstreak@1: local left = self.lefts[num] flickerstreak@1: local right = self.rights[num] flickerstreak@1: local third = self.thirds[num] flickerstreak@1: local fourth = self.fourths[num] flickerstreak@1: local fifth = self.fifths[num] flickerstreak@1: local sixth = self.sixths[num] flickerstreak@1: local check = self.checks[num] flickerstreak@1: do -- if columns >= 1 then flickerstreak@1: left:SetFontObject(info.font) flickerstreak@1: left:SetText(text) flickerstreak@1: left:Show() flickerstreak@1: if info.textR and info.textG and info.textB then flickerstreak@1: left:SetTextColor(info.textR, info.textG, info.textB) flickerstreak@1: else flickerstreak@1: left:SetTextColor(1, 0.823529, 0) flickerstreak@1: end flickerstreak@1: local a,_,b = left:GetFont() flickerstreak@1: left:SetFont(a, info.size * fontSizePercent, b) flickerstreak@1: left:SetJustifyH(info.justify) flickerstreak@1: if columns < 2 then flickerstreak@1: right:SetText(nil) flickerstreak@1: right:Hide() flickerstreak@1: right:SetPoint("TOPLEFT", left, "TOPRIGHT", 40 * fontSizePercent, 0) flickerstreak@1: right:SetPoint("TOPRIGHT", button, "TOPRIGHT", -5, 0) flickerstreak@1: third:SetText(nil) flickerstreak@1: third:Hide() flickerstreak@1: fourth:SetText(nil) flickerstreak@1: fourth:Hide() flickerstreak@1: fifth:SetText(nil) flickerstreak@1: fifth:Hide() flickerstreak@1: sixth:SetText(nil) flickerstreak@1: sixth:Hide() flickerstreak@1: else flickerstreak@1: right:SetFontObject(info.font2) flickerstreak@1: right:SetText(info.text2) flickerstreak@1: right:Show() flickerstreak@1: if info.text2R and info.text2G and info.text2B then flickerstreak@1: right:SetTextColor(info.text2R, info.text2G, info.text2B) flickerstreak@1: else flickerstreak@1: right:SetTextColor(1, 0.823529, 0) flickerstreak@1: end flickerstreak@1: local a,_,b = right:GetFont() flickerstreak@1: right:SetFont(a, info.size2 * fontSizePercent, b) flickerstreak@1: right:SetJustifyH(info.justify2) flickerstreak@1: if columns < 3 then flickerstreak@1: right:SetPoint("TOPLEFT", left, "TOPRIGHT", 40 * fontSizePercent, 0) flickerstreak@1: right:SetPoint("TOPRIGHT", button, "TOPRIGHT", -5, 0) flickerstreak@1: third:SetText(nil) flickerstreak@1: third:Hide() flickerstreak@1: fourth:SetText(nil) flickerstreak@1: fourth:Hide() flickerstreak@1: fifth:SetText(nil) flickerstreak@1: fifth:Hide() flickerstreak@1: sixth:SetText(nil) flickerstreak@1: sixth:Hide() flickerstreak@1: else flickerstreak@1: third:SetFontObject(info.font3) flickerstreak@1: third:SetText(info.text3) flickerstreak@1: third:Show() flickerstreak@1: if info.text3R and info.text3G and info.text3B then flickerstreak@1: third:SetTextColor(info.text3R, info.text3G, info.text3B) flickerstreak@1: else flickerstreak@1: third:SetTextColor(1, 0.823529, 0) flickerstreak@1: end flickerstreak@1: local a,_,b = third:GetFont() flickerstreak@1: third:SetFont(a, info.size3 * fontSizePercent, b) flickerstreak@1: right:ClearAllPoints() flickerstreak@1: right:SetPoint("TOPLEFT", left, "TOPRIGHT", 20 * fontSizePercent, 0) flickerstreak@1: third:SetJustifyH(info.justify3) flickerstreak@1: if columns < 4 then flickerstreak@1: fourth:SetText(nil) flickerstreak@1: fourth:Hide() flickerstreak@1: fifth:SetText(nil) flickerstreak@1: fifth:Hide() flickerstreak@1: sixth:SetText(nil) flickerstreak@1: sixth:Hide() flickerstreak@1: else flickerstreak@1: fourth:SetFontObject(info.font4) flickerstreak@1: fourth:SetText(info.text4) flickerstreak@1: fourth:Show() flickerstreak@1: if info.text4R and info.text4G and info.text4B then flickerstreak@1: fourth:SetTextColor(info.text4R, info.text4G, info.text4B) flickerstreak@1: else flickerstreak@1: fourth:SetTextColor(1, 0.823529, 0) flickerstreak@1: end flickerstreak@1: local a,_,b = fourth:GetFont() flickerstreak@1: fourth:SetFont(a, info.size4 * fontSizePercent, b) flickerstreak@1: fourth:SetJustifyH(info.justify4) flickerstreak@1: if columns < 5 then flickerstreak@1: fifth:SetText(nil) flickerstreak@1: fifth:Hide() flickerstreak@1: sixth:SetText(nil) flickerstreak@1: sixth:Hide() flickerstreak@1: else flickerstreak@1: fifth:SetFontObject(info.font5) flickerstreak@1: fifth:SetText(info.text5) flickerstreak@1: fifth:Show() flickerstreak@1: if info.text5R and info.text5G and info.text5B then flickerstreak@1: fifth:SetTextColor(info.text5R, info.text5G, info.text5B) flickerstreak@1: else flickerstreak@1: fifth:SetTextColor(1, 0.823529, 0) flickerstreak@1: end flickerstreak@1: local a,_,b = fourth:GetFont() flickerstreak@1: fifth:SetFont(a, info.size5 * fontSizePercent, b) flickerstreak@1: fifth:SetJustifyH(info.justify5) flickerstreak@1: if columns < 6 then flickerstreak@1: sixth:SetText(nil) flickerstreak@1: sixth:Hide() flickerstreak@1: else flickerstreak@1: sixth:SetFontObject(info.font6) flickerstreak@1: sixth:SetText(info.text6) flickerstreak@1: sixth:Show() flickerstreak@1: if info.text5R and info.text6G and info.text6B then flickerstreak@1: sixth:SetTextColor(info.text6R, info.text6G, info.text6B) flickerstreak@1: else flickerstreak@1: sixth:SetTextColor(1, 0.823529, 0) flickerstreak@1: end flickerstreak@1: local a,_,b = fourth:GetFont() flickerstreak@1: sixth:SetFont(a, info.size6 * fontSizePercent, b) flickerstreak@1: sixth:SetJustifyH(info.justify6) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: check:SetWidth(info.size) flickerstreak@1: check:SetHeight(info.size) flickerstreak@1: check.width = info.size flickerstreak@1: if info.hasCheck then flickerstreak@1: check.shown = true flickerstreak@1: check:Show() flickerstreak@1: if isRadio then flickerstreak@1: check:SetTexture(info.checkIcon or "Interface\\Buttons\\UI-RadioButton") flickerstreak@1: if info.checked then flickerstreak@1: check:SetAlpha(1) flickerstreak@1: check:SetTexCoord(0.25, 0.5, 0, 1) flickerstreak@1: else flickerstreak@1: check:SetAlpha(self.transparency) flickerstreak@1: check:SetTexCoord(0, 0.25, 0, 1) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if info.checkIcon then flickerstreak@1: check:SetTexture(info.checkIcon) flickerstreak@1: if string.sub(info.checkIcon, 1, 16) == "Interface\\Icons\\" then flickerstreak@1: check:SetTexCoord(0.05, 0.95, 0.05, 0.95) flickerstreak@1: else flickerstreak@1: check:SetTexCoord(0, 1, 0, 1) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") flickerstreak@1: check:SetWidth(info.size * 1.5) flickerstreak@1: check:SetHeight(info.size * 1.5) flickerstreak@1: check.width = info.size * 1.2 flickerstreak@1: check:SetTexCoord(0, 1, 0, 1) flickerstreak@1: end flickerstreak@1: check:SetAlpha(info.checked and 1 or 0) flickerstreak@1: end flickerstreak@1: left:SetPoint("TOPLEFT", check, "TOPLEFT", check.width, 0) flickerstreak@1: else flickerstreak@1: left:SetPoint("TOPLEFT", check, "TOPLEFT") flickerstreak@1: end flickerstreak@1: if columns == 1 then flickerstreak@1: left:SetWidth(maxWidth) flickerstreak@1: elseif columns == 2 then flickerstreak@1: left:SetWidth(0) flickerstreak@1: right:SetWidth(0) flickerstreak@1: if info.wrap then flickerstreak@1: left:SetWidth(maxWidth - right:GetWidth() - 40 * fontSizePercent) flickerstreak@1: elseif info.wrap2 then flickerstreak@1: right:SetWidth(maxWidth - left:GetWidth() - 40 * fontSizePercent) flickerstreak@1: end flickerstreak@1: right:ClearAllPoints() flickerstreak@1: right:SetPoint("TOPRIGHT", button, "TOPRIGHT", 0, 0) flickerstreak@1: if not info.text2 then flickerstreak@1: left:SetJustifyH(info.justify or "LEFT") flickerstreak@1: end flickerstreak@1: elseif columns == 3 then flickerstreak@1: left:SetWidth(x1 - info.checkWidth) flickerstreak@1: right:SetWidth(x2) flickerstreak@1: third:SetWidth(x3) flickerstreak@1: right:ClearAllPoints() flickerstreak@1: local num = (category.tabletData.width - x1 - x2 - x3) / 2 flickerstreak@1: right:SetPoint("TOPLEFT", left, "TOPRIGHT", num, 0) flickerstreak@1: third:SetPoint("TOPLEFT", right, "TOPRIGHT", num, 0) flickerstreak@1: elseif columns == 4 then flickerstreak@1: left:SetWidth(x1 - info.checkWidth) flickerstreak@1: right:SetWidth(x2) flickerstreak@1: third:SetWidth(x3) flickerstreak@1: fourth:SetWidth(x4) flickerstreak@1: local num = (category.tabletData.width - x1 - x2 - x3 - x4) / 3 flickerstreak@1: right:SetPoint("TOPLEFT", left, "TOPRIGHT", num, 0) flickerstreak@1: third:SetPoint("TOPLEFT", right, "TOPRIGHT", num, 0) flickerstreak@1: fourth:SetPoint("TOPLEFT", third, "TOPRIGHT", num, 0) flickerstreak@1: elseif columns == 5 then flickerstreak@1: left:SetWidth(x1 - info.checkWidth) flickerstreak@1: right:SetWidth(x2) flickerstreak@1: third:SetWidth(x3) flickerstreak@1: fourth:SetWidth(x4) flickerstreak@1: fifth:SetWidth(x5) flickerstreak@1: local num = (category.tabletData.width - x1 - x2 - x3 - x4 - x5) / 4 flickerstreak@1: right:SetPoint("TOPLEFT", left, "TOPRIGHT", num, 0) flickerstreak@1: third:SetPoint("TOPLEFT", right, "TOPRIGHT", num, 0) flickerstreak@1: fourth:SetPoint("TOPLEFT", third, "TOPRIGHT", num, 0) flickerstreak@1: fifth:SetPoint("TOPLEFT", fourth, "TOPRIGHT", num, 0) flickerstreak@1: elseif columns == 6 then flickerstreak@1: left:SetWidth(x1 - info.checkWidth) flickerstreak@1: right:SetWidth(x2) flickerstreak@1: third:SetWidth(x3) flickerstreak@1: fourth:SetWidth(x4) flickerstreak@1: fifth:SetWidth(x5) flickerstreak@1: sixth:SetWidth(x6) flickerstreak@1: local num = (category.tabletData.width - x1 - x2 - x3 - x4 - x5 - x6) / 5 flickerstreak@1: right:SetPoint("TOPLEFT", left, "TOPRIGHT", num, 0) flickerstreak@1: third:SetPoint("TOPLEFT", right, "TOPRIGHT", num, 0) flickerstreak@1: fourth:SetPoint("TOPLEFT", third, "TOPRIGHT", num, 0) flickerstreak@1: fifth:SetPoint("TOPLEFT", fourth, "TOPRIGHT", num, 0) flickerstreak@1: sixth:SetPoint("TOPLEFT", fifth, "TOPRIGHT", num, 0) flickerstreak@1: end flickerstreak@1: if not self.locked or IsAltKeyDown() then flickerstreak@1: local func = info.func flickerstreak@1: if func then flickerstreak@1: if type(func) == "string" then flickerstreak@1: Tablet:assert(type(info.arg1) == "table", "Cannot call method " .. info.func .. " on a non-table") flickerstreak@1: func = info.arg1[func] flickerstreak@1: Tablet:assert(type(func) == "function", "Method " .. info.func .. " nonexistant") flickerstreak@1: end flickerstreak@1: Tablet:assert(type(func) == "function", "func must be a function or method") flickerstreak@1: button.func = func flickerstreak@1: button.a1 = info.arg1 flickerstreak@1: button.a2 = info.arg2 flickerstreak@1: button.a3 = info.arg3 flickerstreak@1: button.self = self flickerstreak@1: button:SetScript("OnMouseUp", button_OnMouseUp) flickerstreak@1: button:SetScript("OnMouseDown", button_OnMouseDown) flickerstreak@1: button:SetScript("OnClick", button_OnClick) flickerstreak@1: if button.clicked then flickerstreak@1: button:SetButtonState("PUSHED") flickerstreak@1: end flickerstreak@1: button:EnableMouse(true) flickerstreak@1: else flickerstreak@1: button:SetScript("OnMouseDown", nil) flickerstreak@1: button:SetScript("OnMouseUp", nil) flickerstreak@1: button:SetScript("OnClick", nil) flickerstreak@1: button:EnableMouse(false) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: button:SetScript("OnMouseDown", nil) flickerstreak@1: button:SetScript("OnMouseUp", nil) flickerstreak@1: button:SetScript("OnClick", nil) flickerstreak@1: button:EnableMouse(false) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: tooltip.AddLine = wrap(tooltip.AddLine, "tooltip:AddLine") flickerstreak@1: flickerstreak@1: function tooltip:SetFontSizePercent(percent) flickerstreak@1: local data, detachedData = self.data, self.detachedData flickerstreak@1: if detachedData and detachedData.detached then flickerstreak@1: data = detachedData flickerstreak@1: end flickerstreak@1: local lastSize = self.fontSizePercent flickerstreak@1: percent = tonumber(percent) or 1 flickerstreak@1: if percent < 0.25 then flickerstreak@1: percent = 0.25 flickerstreak@1: elseif percent > 4 then flickerstreak@1: percent = 4 flickerstreak@1: end flickerstreak@1: self.fontSizePercent = percent flickerstreak@1: if data then flickerstreak@1: data.fontSizePercent = percent flickerstreak@1: end flickerstreak@1: self.scrollUp:SetFont(font, normalSize * self.fontSizePercent, flags) flickerstreak@1: self.scrollDown:SetFont(font, normalSize * self.fontSizePercent, flags) flickerstreak@1: local ratio = self.fontSizePercent / lastSize flickerstreak@1: for i = 1, self.numLines do flickerstreak@1: local left = self.lefts[i] flickerstreak@1: local right = self.rights[i] flickerstreak@1: local third = self.thirds[i] flickerstreak@1: local fourth = self.fourths[i] flickerstreak@1: local fifth = self.fifths[i] flickerstreak@1: local sixth = self.sixths[i] flickerstreak@1: local check = self.checks[i] flickerstreak@1: local font, size, flags = left:GetFont() flickerstreak@1: left:SetFont(font, size * ratio, flags) flickerstreak@1: font, size, flags = right:GetFont() flickerstreak@1: right:SetFont(font, size * ratio, flags) flickerstreak@1: font, size, flags = third:GetFont() flickerstreak@1: third:SetFont(font, size * ratio, flags) flickerstreak@1: font, size, flags = fourth:GetFont() flickerstreak@1: fourth:SetFont(font, size * ratio, flags) flickerstreak@1: font, size, flags = fifth:GetFont() flickerstreak@1: fifth:SetFont(font, size * ratio, flags) flickerstreak@1: font, size, flags = sixth:GetFont() flickerstreak@1: sixth:SetFont(font, size * ratio, flags) flickerstreak@1: check.width = check.width * ratio flickerstreak@1: check:SetWidth(check:GetWidth() * ratio) flickerstreak@1: check:SetHeight(check:GetHeight() * ratio) flickerstreak@1: end flickerstreak@1: self:SetWidth((self:GetWidth() - 51) * ratio + 51) flickerstreak@1: self:SetHeight((self:GetHeight() - 51) * ratio + 51) flickerstreak@1: if self:IsShown() and self.children then flickerstreak@1: self:children() flickerstreak@1: self:Show() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: tooltip.SetFontSizePercent = wrap(tooltip.SetFontSizePercent, "tooltip:SetFontSizePercent") flickerstreak@1: flickerstreak@1: function tooltip:GetFontSizePercent() flickerstreak@1: return self.fontSizePercent flickerstreak@1: end flickerstreak@1: flickerstreak@1: function tooltip:SetTransparency(alpha) flickerstreak@1: local data, detachedData = self.data, self.detachedData flickerstreak@1: if detachedData and detachedData.detached then flickerstreak@1: data = detachedData flickerstreak@1: end flickerstreak@1: self.transparency = alpha flickerstreak@1: if data then flickerstreak@1: data.transparency = alpha ~= 0.75 and alpha or nil flickerstreak@1: end flickerstreak@1: self:SetBackdropColor(self.r or 0, self.g or 0, self.b or 0, alpha) flickerstreak@1: self:SetBackdropBorderColor(1, 1, 1, alpha) flickerstreak@1: end flickerstreak@1: tooltip.SetTransparency = wrap(tooltip.SetTransparency, "tooltip:SetTransparency") flickerstreak@1: flickerstreak@1: function tooltip:GetTransparency() flickerstreak@1: return self.transparency flickerstreak@1: end flickerstreak@1: flickerstreak@1: function tooltip:SetColor(r, g, b) flickerstreak@1: local data, detachedData = self.data, self.detachedData flickerstreak@1: if detachedData and detachedData.detached then flickerstreak@1: data = detachedData flickerstreak@1: end flickerstreak@1: self.r = r flickerstreak@1: self.g = g flickerstreak@1: self.b = b flickerstreak@1: if data then flickerstreak@1: data.r = r ~= 0 and r or nil flickerstreak@1: data.g = g ~= 0 and g or nil flickerstreak@1: data.b = b ~= 0 and b or nil flickerstreak@1: end flickerstreak@1: self:SetBackdropColor(r or 0, g or 0, b or 0, self.transparency) flickerstreak@1: self:SetBackdropBorderColor(1, 1, 1, self.transparency) flickerstreak@1: end flickerstreak@1: tooltip.SetColor = wrap(tooltip.SetColor, "tooltip:SetColor") flickerstreak@1: flickerstreak@1: function tooltip:GetColor() flickerstreak@1: return self.r, self.g, self.b flickerstreak@1: end flickerstreak@1: flickerstreak@1: function tooltip:Scroll(down) flickerstreak@1: if down then flickerstreak@1: if IsShiftKeyDown() then flickerstreak@1: self.scroll = self.numLines - GetMaxLinesPerScreen(self) flickerstreak@1: else flickerstreak@1: self.scroll = self.scroll + 3 flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if IsShiftKeyDown() then flickerstreak@1: self.scroll = 0 flickerstreak@1: else flickerstreak@1: self.scroll = self.scroll - 3 flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if self.scroll > self.numLines - GetMaxLinesPerScreen(self) then flickerstreak@1: self.scroll = self.numLines - GetMaxLinesPerScreen(self) flickerstreak@1: end flickerstreak@1: if self.scroll < 0 then flickerstreak@1: self.scroll = 0 flickerstreak@1: end flickerstreak@1: if self:IsShown() then flickerstreak@1: self:Show() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: tooltip.Scroll = wrap(tooltip.Scroll, "tooltip:Scroll") flickerstreak@1: flickerstreak@1: function tooltip.Detach(tooltip) flickerstreak@1: local owner = tooltip.owner flickerstreak@1: tooltip:Hide() flickerstreak@1: self:assert(tooltip.detachedData, "You cannot detach if detachedData is not present") flickerstreak@1: tooltip.detachedData.detached = true flickerstreak@1: local detached = AcquireDetachedFrame(self, tooltip.registration, tooltip.data, tooltip.detachedData) flickerstreak@1: flickerstreak@1: detached.menu, tooltip.menu = tooltip.menu, nil flickerstreak@1: detached.children = tooltip.children flickerstreak@1: tooltip.children = nil flickerstreak@1: detached:SetOwner(owner) flickerstreak@1: detached:children() flickerstreak@1: detached:Show() flickerstreak@1: end flickerstreak@1: tooltip.Detach = wrap(tooltip.Detach, "tooltip:Detach") flickerstreak@1: flickerstreak@1: end flickerstreak@1: flickerstreak@1: tooltip.registration = registration flickerstreak@1: registration.tooltip = tooltip flickerstreak@1: return tooltip flickerstreak@1: end flickerstreak@1: AcquireFrame = wrap(AcquireFrame, "AcquireFrame") flickerstreak@1: flickerstreak@1: function ReleaseDetachedFrame(self, data, detachedData) flickerstreak@1: if not detachedData then flickerstreak@1: detachedData = data flickerstreak@1: end flickerstreak@1: for _, detached in ipairs(detachedTooltips) do flickerstreak@1: if detached.detachedData == detachedData then flickerstreak@1: detached.notInUse = true flickerstreak@1: detached:Hide() flickerstreak@1: detached.registration.tooltip = nil flickerstreak@1: detached.registration = nil flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: ReleaseDetachedFrame = wrap(ReleaseDetachedFrame, "ReleaseDetachedFrame") flickerstreak@1: flickerstreak@1: local StartCheckingAlt, StopCheckingAlt flickerstreak@1: do flickerstreak@1: local frame flickerstreak@1: function StartCheckingAlt(func) flickerstreak@1: if not frame then flickerstreak@1: frame = CreateFrame("Frame") flickerstreak@1: frame:SetScript("OnEvent", function(this, _, modifier) flickerstreak@1: if modifier == "ALT" then flickerstreak@1: this.func() flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: end flickerstreak@1: frame:RegisterEvent("MODIFIER_STATE_CHANGED") flickerstreak@1: frame.func = func flickerstreak@1: end flickerstreak@1: function StopCheckingAlt() flickerstreak@1: if frame then flickerstreak@1: frame:UnregisterEvent("MODIFIER_STATE_CHANGED") flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: function AcquireDetachedFrame(self, registration, data, detachedData) flickerstreak@1: if not detachedData then flickerstreak@1: detachedData = data flickerstreak@1: end flickerstreak@1: for _, detached in ipairs(detachedTooltips) do flickerstreak@1: if detached.notInUse then flickerstreak@1: detached.data = data flickerstreak@1: detached.detachedData = detachedData flickerstreak@1: detached.notInUse = nil flickerstreak@1: local fontSizePercent = detachedData.fontSizePercent or 1 flickerstreak@1: local transparency = detachedData.transparency or 0.75 flickerstreak@1: local r = detachedData.r or 0 flickerstreak@1: local g = detachedData.g or 0 flickerstreak@1: local b = detachedData.b or 0 flickerstreak@1: detached:SetFontSizePercent(fontSizePercent) flickerstreak@1: detached:SetTransparency(transparency) flickerstreak@1: detached:SetColor(r, g, b) flickerstreak@1: detached:ClearAllPoints() flickerstreak@1: detached:SetPoint(detachedData.anchor or "CENTER", UIParent, detachedData.anchor or "CENTER", detachedData.offsetx or 0, detachedData.offsety or 0) flickerstreak@1: detached.registration = registration flickerstreak@1: registration.tooltip = detached flickerstreak@1: return detached flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: if not Dewdrop and AceLibrary:HasInstance("Dewdrop-2.0") then flickerstreak@1: Dewdrop = AceLibrary("Dewdrop-2.0") flickerstreak@1: end flickerstreak@1: StartCheckingAlt(function() flickerstreak@1: for _, detached in ipairs(detachedTooltips) do flickerstreak@1: if detached:IsShown() and detached.locked then flickerstreak@1: detached:EnableMouse(IsAltKeyDown()) flickerstreak@1: detached:children() flickerstreak@1: if detached.moving then flickerstreak@1: local a1 = arg1 flickerstreak@1: arg1 = "LeftButton" flickerstreak@1: if type(detached:GetScript("OnMouseUp")) == "function" then flickerstreak@1: detached:GetScript("OnMouseUp")() flickerstreak@1: end flickerstreak@1: arg1 = a1 flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: if not tooltip then flickerstreak@1: AcquireFrame(self, {}) flickerstreak@1: end flickerstreak@1: local detached = CreateFrame("Frame", "Tablet20DetachedFrame" .. (table.getn(detachedTooltips) + 1), UIParent) flickerstreak@1: table.insert(detachedTooltips, detached) flickerstreak@1: detached.notInUse = true flickerstreak@1: detached:EnableMouse(not data.locked) flickerstreak@1: detached:EnableMouseWheel(true) flickerstreak@1: detached:SetMovable(true) flickerstreak@1: detached:SetPoint(data.anchor or "CENTER", UIParent, data.anchor or "CENTER", data.offsetx or 0, data.offsety or 0) flickerstreak@1: flickerstreak@1: detached.numLines = 0 flickerstreak@1: detached.owner = nil flickerstreak@1: detached.fontSizePercent = 1 flickerstreak@1: detached.maxLines = 0 flickerstreak@1: detached.buttons = {} flickerstreak@1: detached.checks = {} flickerstreak@1: detached.lefts = {} flickerstreak@1: detached.rights = {} flickerstreak@1: detached.thirds = {} flickerstreak@1: detached.fourths = {} flickerstreak@1: detached.fifths = {} flickerstreak@1: detached.sixths = {} flickerstreak@1: detached.transparency = 0.75 flickerstreak@1: detached.r = 0 flickerstreak@1: detached.g = 0 flickerstreak@1: detached.b = 0 flickerstreak@1: detached:SetFrameStrata("BACKGROUND") flickerstreak@1: detached:SetBackdrop(tmp.a( flickerstreak@1: 'bgFile', "Interface\\Buttons\\WHITE8X8", flickerstreak@1: 'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border", flickerstreak@1: 'tile', true, flickerstreak@1: 'tileSize', 16, flickerstreak@1: 'edgeSize', 16, flickerstreak@1: 'insets', tmp.b( flickerstreak@1: 'left', 5, flickerstreak@1: 'right', 5, flickerstreak@1: 'top', 5, flickerstreak@1: 'bottom', 5 flickerstreak@1: ) flickerstreak@1: )) flickerstreak@1: detached.locked = detachedData.locked flickerstreak@1: detached.scroll = 0 flickerstreak@1: detached:EnableMouse(not detached.locked) flickerstreak@1: flickerstreak@1: local width = GetScreenWidth() flickerstreak@1: local height = GetScreenHeight() flickerstreak@1: detached:SetScript("OnMouseDown", function() flickerstreak@1: if arg1 == "LeftButton" then flickerstreak@1: detached:StartMoving() flickerstreak@1: detached.moving = true flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: flickerstreak@1: detached:SetScript("OnMouseUp", function() flickerstreak@1: if arg1 == "LeftButton" then flickerstreak@1: detached:StopMovingOrSizing() flickerstreak@1: detached.moving = nil flickerstreak@1: local anchor flickerstreak@1: local offsetx flickerstreak@1: local offsety flickerstreak@1: if detached:GetTop() + detached:GetBottom() < height then flickerstreak@1: anchor = "BOTTOM" flickerstreak@1: offsety = detached:GetBottom() flickerstreak@1: if offsety < 0 then flickerstreak@1: offsety = 0 flickerstreak@1: end flickerstreak@1: if offsety < MainMenuBar:GetTop() and MainMenuBar:IsVisible() then flickerstreak@1: offsety = MainMenuBar:GetTop() flickerstreak@1: end flickerstreak@1: local top = 0 flickerstreak@1: if FuBar then flickerstreak@1: for i = 1, FuBar:GetNumPanels() do flickerstreak@1: local panel = FuBar:GetPanel(i) flickerstreak@1: if panel:GetAttachPoint() == "BOTTOM" then flickerstreak@1: if panel.frame:GetTop() > top then flickerstreak@1: top = panel.frame:GetTop() flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if offsety < top then flickerstreak@1: offsety = top flickerstreak@1: end flickerstreak@1: else flickerstreak@1: anchor = "TOP" flickerstreak@1: offsety = detached:GetTop() - height flickerstreak@1: if offsety > 0 then flickerstreak@1: offsety = 0 flickerstreak@1: end flickerstreak@1: local bottom = GetScreenHeight() flickerstreak@1: if FuBar then flickerstreak@1: for i = 1, FuBar:GetNumPanels() do flickerstreak@1: local panel = FuBar:GetPanel(i) flickerstreak@1: if panel:GetAttachPoint() == "TOP" then flickerstreak@1: if panel.frame:GetBottom() < bottom then flickerstreak@1: bottom = panel.frame:GetBottom() flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: bottom = bottom - GetScreenHeight() flickerstreak@1: if offsety > bottom then flickerstreak@1: offsety = bottom flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if detached:GetLeft() + detached:GetRight() < width * 2 / 3 then flickerstreak@1: anchor = anchor .. "LEFT" flickerstreak@1: offsetx = detached:GetLeft() flickerstreak@1: if offsetx < 0 then flickerstreak@1: offsetx = 0 flickerstreak@1: end flickerstreak@1: elseif detached:GetLeft() + detached:GetRight() < width * 4 / 3 then flickerstreak@1: if anchor == "" then flickerstreak@1: anchor = "CENTER" flickerstreak@1: end flickerstreak@1: offsetx = (detached:GetLeft() + detached:GetRight() - GetScreenWidth()) / 2 flickerstreak@1: else flickerstreak@1: anchor = anchor .. "RIGHT" flickerstreak@1: offsetx = detached:GetRight() - width flickerstreak@1: if offsetx > 0 then flickerstreak@1: offsetx = 0 flickerstreak@1: end flickerstreak@1: end flickerstreak@1: detached:ClearAllPoints() flickerstreak@1: detached:SetPoint(anchor, UIParent, anchor, offsetx, offsety) flickerstreak@1: local t = detached.detachedData flickerstreak@1: if t.anchor ~= anchor or math.abs(t.offsetx - offsetx) > 8 or math.abs(t.offsety - offsety) > 8 then flickerstreak@1: detached.preventClick = GetTime() + 0.05 flickerstreak@1: end flickerstreak@1: t.anchor = anchor flickerstreak@1: t.offsetx = offsetx flickerstreak@1: t.offsety = offsety flickerstreak@1: detached:Show() flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: flickerstreak@1: if Dewdrop then flickerstreak@1: Dewdrop:Register(detached, flickerstreak@1: 'children', function(level, value) flickerstreak@1: if not detached.registration then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: if detached.menu then flickerstreak@1: detached.menu(level, value) flickerstreak@1: if level == 1 then flickerstreak@1: Dewdrop:AddLine() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if level == 1 then flickerstreak@1: if not detached.registration.cantAttach then flickerstreak@1: Dewdrop:AddLine( flickerstreak@1: 'text', DETACH, flickerstreak@1: 'tooltipTitle', DETACH, flickerstreak@1: 'tooltipText', DETACH_DESC, flickerstreak@1: 'checked', true, flickerstreak@1: 'arg1', detached, flickerstreak@1: 'func', "Attach", flickerstreak@1: 'closeWhenClicked', true flickerstreak@1: ) flickerstreak@1: end flickerstreak@1: Dewdrop:AddLine( flickerstreak@1: 'text', LOCK, flickerstreak@1: 'tooltipTitle', LOCK, flickerstreak@1: 'tooltipText', LOCK_DESC, flickerstreak@1: 'checked', detached:IsLocked(), flickerstreak@1: 'arg1', detached, flickerstreak@1: 'func', "Lock", flickerstreak@1: 'closeWhenClicked', not detached:IsLocked() flickerstreak@1: ) flickerstreak@1: Dewdrop:AddLine( flickerstreak@1: 'text', COLOR, flickerstreak@1: 'tooltipTitle', COLOR, flickerstreak@1: 'tooltipText', COLOR_DESC, flickerstreak@1: 'hasColorSwatch', true, flickerstreak@1: 'r', detached.r, flickerstreak@1: 'g', detached.g, flickerstreak@1: 'b', detached.b, flickerstreak@1: 'hasOpacity', true, flickerstreak@1: 'opacity', detached.transparency, flickerstreak@1: 'colorFunc', function(r, g, b, a) flickerstreak@1: detached:SetColor(r, g, b) flickerstreak@1: detached:SetTransparency(a) flickerstreak@1: end flickerstreak@1: ) flickerstreak@1: Dewdrop:AddLine( flickerstreak@1: 'text', SIZE, flickerstreak@1: 'tooltipTitle', SIZE, flickerstreak@1: 'tooltipText', SIZE_DESC, flickerstreak@1: 'hasArrow', true, flickerstreak@1: 'hasSlider', true, flickerstreak@1: 'sliderFunc', function(value) flickerstreak@1: detached:SetFontSizePercent(value) flickerstreak@1: end, flickerstreak@1: 'sliderMax', 2, flickerstreak@1: 'sliderMin', 0.5, flickerstreak@1: 'sliderStep', 0.05, flickerstreak@1: 'sliderIsPercent', true, flickerstreak@1: 'sliderValue', detached:GetFontSizePercent() flickerstreak@1: ) flickerstreak@1: Dewdrop:AddLine( flickerstreak@1: 'text', CLOSE_MENU, flickerstreak@1: 'tooltipTitle', CLOSE_MENU, flickerstreak@1: 'tooltipText', CLOSE_MENU_DESC, flickerstreak@1: 'func', function() flickerstreak@1: Dewdrop:Close() flickerstreak@1: end flickerstreak@1: ) flickerstreak@1: end flickerstreak@1: end, flickerstreak@1: 'point', function() flickerstreak@1: local x, y = detached:GetCenter() flickerstreak@1: if x < GetScreenWidth() / 2 then flickerstreak@1: if y < GetScreenHeight() / 2 then flickerstreak@1: return "BOTTOMLEFT", "BOTTOMRIGHT" flickerstreak@1: else flickerstreak@1: return "TOPLEFT", "TOPRIGHT" flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if y < GetScreenHeight() / 2 then flickerstreak@1: return "BOTTOMRIGHT", "BOTTOMLEFT" flickerstreak@1: else flickerstreak@1: return "TOPRIGHT", "TOPLEFT" flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: ) flickerstreak@1: end flickerstreak@1: flickerstreak@1: NewLine(detached) flickerstreak@1: flickerstreak@1: detached.scrollUp = detached:CreateFontString(nil, "ARTWORK") flickerstreak@1: detached.scrollUp:SetPoint("TOPLEFT", detached.buttons[1], "BOTTOMLEFT", 0, -2) flickerstreak@1: detached.scrollUp:SetPoint("RIGHT", detached, "RIGHT", 0, -10) flickerstreak@1: detached.scrollUp:SetFontObject(GameTooltipText) flickerstreak@1: detached.scrollUp:Hide() flickerstreak@1: local font,_,flags = detached.scrollUp:GetFont() flickerstreak@1: detached.scrollUp:SetFont(font, normalSize * detached.fontSizePercent, flags) flickerstreak@1: detached.scrollUp:SetJustifyH("CENTER") flickerstreak@1: detached.scrollUp:SetTextColor(1, 0.823529, 0) flickerstreak@1: detached.scrollUp:SetText(" ") flickerstreak@1: flickerstreak@1: detached.scrollDown = detached:CreateFontString(nil, "ARTWORK") flickerstreak@1: detached.scrollDown:SetPoint("TOPLEFT", detached.buttons[1], "BOTTOMLEFT", 0, -2) flickerstreak@1: detached.scrollDown:SetPoint("RIGHT", detached, "RIGHT", 0, -10) flickerstreak@1: detached.scrollDown:SetFontObject(GameTooltipText) flickerstreak@1: detached.scrollDown:Hide() flickerstreak@1: local font,_,flags = detached.scrollUp:GetFont() flickerstreak@1: detached.scrollDown:SetFont(font, normalSize * detached.fontSizePercent, flags) flickerstreak@1: detached.scrollDown:SetJustifyH("CENTER") flickerstreak@1: detached.scrollDown:SetTextColor(1, 0.823529, 0) flickerstreak@1: detached.scrollDown:SetText(" ") flickerstreak@1: flickerstreak@1: detached:SetScript("OnMouseWheel", function() flickerstreak@1: detached:Scroll(arg1 < 0) flickerstreak@1: end) flickerstreak@1: flickerstreak@1: detached.SetTransparency = tooltip.SetTransparency flickerstreak@1: detached.GetTransparency = tooltip.GetTransparency flickerstreak@1: detached.SetColor = tooltip.SetColor flickerstreak@1: detached.GetColor = tooltip.GetColor flickerstreak@1: detached.SetFontSizePercent = tooltip.SetFontSizePercent flickerstreak@1: detached.GetFontSizePercent = tooltip.GetFontSizePercent flickerstreak@1: detached.SetOwner = tooltip.SetOwner flickerstreak@1: detached.IsOwned = tooltip.IsOwned flickerstreak@1: detached.ClearLines = tooltip.ClearLines flickerstreak@1: detached.NumLines = tooltip.NumLines flickerstreak@1: detached.__Hide = detached.Hide flickerstreak@1: detached.__Show = detached.Show flickerstreak@1: detached.Hide = tooltip.Hide flickerstreak@1: detached.Show = tooltip.Show flickerstreak@1: local old_IsShown = detached.IsShown flickerstreak@1: function detached:IsShown() flickerstreak@1: if self.tmpHidden then flickerstreak@1: return true flickerstreak@1: else flickerstreak@1: return old_IsShown(self) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: detached.AddLine = tooltip.AddLine flickerstreak@1: detached.Scroll = tooltip.Scroll flickerstreak@1: function detached:IsLocked() flickerstreak@1: return self.locked flickerstreak@1: end flickerstreak@1: function detached:Lock() flickerstreak@1: self:EnableMouse(self.locked) flickerstreak@1: self.locked = not self.locked flickerstreak@1: self.detachedData.locked = self.locked or nil flickerstreak@1: self:children() flickerstreak@1: end flickerstreak@1: flickerstreak@1: function detached.Attach(detached) flickerstreak@1: self:assert(detached, "Detached tooltip not given.") flickerstreak@1: self:assert(detached.AddLine, "detached argument not a Tooltip.") flickerstreak@1: self:assert(detached.owner, "Detached tooltip has no owner.") flickerstreak@1: self:assert(not detached.notInUse, "Detached tooltip not in use.") flickerstreak@1: detached.menu = nil flickerstreak@1: detached.detachedData.detached = nil flickerstreak@1: detached:SetOwner(nil) flickerstreak@1: detached.notInUse = TRUE flickerstreak@1: end flickerstreak@1: flickerstreak@1: return AcquireDetachedFrame(self, registration, data, detachedData) flickerstreak@1: end flickerstreak@1: AcquireDetachedFrame = wrap(AcquireDetachedFrame, "AcquireDetachedFrame") flickerstreak@1: flickerstreak@1: function Tablet:Close(parent) flickerstreak@1: if not parent then flickerstreak@1: if tooltip and tooltip:IsShown() then flickerstreak@1: tooltip:Hide() flickerstreak@1: tooltip.registration.tooltip = nil flickerstreak@1: tooltip.registration = nil flickerstreak@1: tooltip.enteredFrame = false flickerstreak@1: end flickerstreak@1: return flickerstreak@1: else flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: end flickerstreak@1: local info = self.registry[parent] flickerstreak@1: self:assert(info, "You cannot close a tablet with an unregistered parent frame.") flickerstreak@1: local data = info.data flickerstreak@1: local detachedData = info.detachedData flickerstreak@1: if detachedData and detachedData.detached then flickerstreak@1: ReleaseDetachedFrame(self, data, detachedData) flickerstreak@1: elseif tooltip.data == data then flickerstreak@1: tooltip:Hide() flickerstreak@1: tooltip.registration.tooltip = nil flickerstreak@1: tooltip.registration = nil flickerstreak@1: end flickerstreak@1: tooltip.enteredFrame = false flickerstreak@1: end flickerstreak@1: Tablet.Close = wrap(Tablet.Close, "Tablet:Close") flickerstreak@1: flickerstreak@1: local currentFrame flickerstreak@1: local currentTabletData flickerstreak@1: flickerstreak@1: function Tablet:Open(fakeParent, parent) flickerstreak@1: self:argCheck(fakeParent, 2, "table", "string") flickerstreak@1: self:argCheck(parent, 3, "nil", "table", "string") flickerstreak@1: if not parent then flickerstreak@1: parent = fakeParent flickerstreak@1: end flickerstreak@1: local info = self.registry[parent] flickerstreak@1: self:assert(info, "You cannot open a tablet with an unregistered parent frame.") flickerstreak@1: self:Close() flickerstreak@1: local data = info.data flickerstreak@1: local detachedData = info.detachedData flickerstreak@1: local children = info.children flickerstreak@1: if not children then flickerstreak@1: return flickerstreak@1: end flickerstreak@1: local frame = AcquireFrame(self, info, data, detachedData) flickerstreak@1: frame.clickable = info.clickable flickerstreak@1: frame.menu = info.menu flickerstreak@1: local children = info.children flickerstreak@1: function frame:children() flickerstreak@1: if not self.preventRefresh then flickerstreak@1: currentFrame = self flickerstreak@1: currentTabletData = TabletData:new(self) flickerstreak@1: self:ClearLines() flickerstreak@1: if children then flickerstreak@1: children() flickerstreak@1: end flickerstreak@1: currentTabletData:Display(currentFrame) flickerstreak@1: self:Show(currentTabletData) flickerstreak@1: currentTabletData:del() flickerstreak@1: currentTabletData = nil flickerstreak@1: currentFrame = nil flickerstreak@1: end flickerstreak@1: end flickerstreak@1: frame:SetOwner(fakeParent) flickerstreak@1: frame:children() flickerstreak@1: local point = info.point flickerstreak@1: local relativePoint = info.relativePoint flickerstreak@1: if type(point) == "function" then flickerstreak@1: local b flickerstreak@1: point, b = point(fakeParent) flickerstreak@1: if b then flickerstreak@1: relativePoint = b flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if type(relativePoint) == "function" then flickerstreak@1: relativePoint = relativePoint(fakeParent) flickerstreak@1: end flickerstreak@1: if not point then flickerstreak@1: point = "CENTER" flickerstreak@1: end flickerstreak@1: if not relativePoint then flickerstreak@1: relativePoint = point flickerstreak@1: end flickerstreak@1: frame:ClearAllPoints() flickerstreak@1: if type(parent) ~= "string" then flickerstreak@1: frame:SetPoint(point, fakeParent, relativePoint) flickerstreak@1: end flickerstreak@1: local offsetx = 0 flickerstreak@1: local offsety = 0 flickerstreak@1: if frame:GetBottom() and frame:GetLeft() then flickerstreak@1: if frame:GetRight() > GetScreenWidth() then flickerstreak@1: offsetx = frame:GetRight() - GetScreenWidth() flickerstreak@1: elseif frame:GetLeft() < 0 then flickerstreak@1: offsetx = -frame:GetLeft() flickerstreak@1: end flickerstreak@1: local ratio = GetScreenWidth() / GetScreenHeight() flickerstreak@1: if ratio >= 2.4 and frame:GetRight() > GetScreenWidth() / 2 and frame:GetLeft() < GetScreenWidth() / 2 then flickerstreak@1: if frame:GetCenter() < GetScreenWidth() / 2 then flickerstreak@1: offsetx = frame:GetRight() - GetScreenWidth() / 2 flickerstreak@1: else flickerstreak@1: offsetx = frame:GetLeft() - GetScreenWidth() / 2 flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if frame:GetBottom() < 0 then flickerstreak@1: offsety = frame:GetBottom() flickerstreak@1: elseif frame:GetTop() and frame:GetTop() > GetScreenHeight() then flickerstreak@1: offsety = frame:GetTop() - GetScreenHeight() flickerstreak@1: end flickerstreak@1: if MainMenuBar:IsVisible() and frame:GetBottom() < MainMenuBar:GetTop() and offsety < frame:GetBottom() - MainMenuBar:GetTop() then flickerstreak@1: offsety = frame:GetBottom() - MainMenuBar:GetTop() flickerstreak@1: end flickerstreak@1: flickerstreak@1: if FuBar then flickerstreak@1: local top = 0 flickerstreak@1: if FuBar then flickerstreak@1: for i = 1, FuBar:GetNumPanels() do flickerstreak@1: local panel = FuBar:GetPanel(i) flickerstreak@1: if panel:GetAttachPoint() == "BOTTOM" then flickerstreak@1: if panel.frame:GetTop() and panel.frame:GetTop() > top then flickerstreak@1: top = panel.frame:GetTop() flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if frame:GetBottom() < top and offsety < frame:GetBottom() - top then flickerstreak@1: offsety = frame:GetBottom() - top flickerstreak@1: end flickerstreak@1: local bottom = GetScreenHeight() flickerstreak@1: if FuBar then flickerstreak@1: for i = 1, FuBar:GetNumPanels() do flickerstreak@1: local panel = FuBar:GetPanel(i) flickerstreak@1: if panel:GetAttachPoint() == "TOP" then flickerstreak@1: if panel.frame:GetBottom() and panel.frame:GetBottom() < bottom then flickerstreak@1: bottom = panel.frame:GetBottom() flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if frame:GetTop() > bottom and offsety < frame:GetTop() - bottom then flickerstreak@1: offsety = frame:GetTop() - bottom flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if type(fakeParent) ~= "string" then flickerstreak@1: frame:SetPoint(point, fakeParent, relativePoint, -offsetx, -offsety) flickerstreak@1: end flickerstreak@1: flickerstreak@1: if detachedData and (info.cantAttach or detachedData.detached) and frame == tooltip then flickerstreak@1: detachedData.detached = false flickerstreak@1: frame:Detach() flickerstreak@1: end flickerstreak@1: if (not detachedData or not detachedData.detached) and GetMouseFocus() == fakeParent then flickerstreak@1: self.tooltip.enteredFrame = true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.Open = wrap(Tablet.Open, "Tablet:Open") flickerstreak@1: flickerstreak@1: function Tablet:Register(parent, ...) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: if self.registry[parent] then flickerstreak@1: self:Unregister(parent) flickerstreak@1: end flickerstreak@1: local info flickerstreak@1: local k1 = ... flickerstreak@1: if type(k1) == "table" and k1[0] then flickerstreak@1: self:assert(type(self.registry[k1]) == "table", "Other parent not registered") flickerstreak@1: info = copy(self.registry[k1]) flickerstreak@1: local v1 = select(2, ...) flickerstreak@1: if type(v1) == "function" then flickerstreak@1: info.point = v1 flickerstreak@1: info.relativePoint = nil flickerstreak@1: end flickerstreak@1: else flickerstreak@1: info = new(...) flickerstreak@1: end flickerstreak@1: self.registry[parent] = info flickerstreak@1: info.data = info.data or info.detachedData or {} flickerstreak@1: info.detachedData = info.detachedData or info.data flickerstreak@1: local data = info.data flickerstreak@1: local detachedData = info.detachedData flickerstreak@1: if not self.onceRegistered[parent] and type(parent) == "table" and type(parent.SetScript) == "function" and not info.dontHook then flickerstreak@1: if not Dewdrop and AceLibrary:HasInstance("Dewdrop-2.0") then flickerstreak@1: Dewdrop = AceLibrary("Dewdrop-2.0") flickerstreak@1: end flickerstreak@1: local script = parent:GetScript("OnEnter") flickerstreak@1: parent:SetScript("OnEnter", function() flickerstreak@1: if script then flickerstreak@1: script() flickerstreak@1: end flickerstreak@1: if self.registry[parent] then flickerstreak@1: if (not data or not detachedData.detached) and (Dewdrop and not Dewdrop:IsOpen(parent) or true) then flickerstreak@1: self:Open(parent) flickerstreak@1: self.tooltip.enteredFrame = true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: local script = parent:GetScript("OnLeave") flickerstreak@1: parent:SetScript("OnLeave", function() flickerstreak@1: if script then flickerstreak@1: script() flickerstreak@1: end flickerstreak@1: if self.registry[parent] then flickerstreak@1: if self.tooltip and (not data or not detachedData or not detachedData.detached) then flickerstreak@1: self.tooltip.enteredFrame = false flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: if parent:HasScript("OnMouseDown") then flickerstreak@1: local script = parent:GetScript("OnMouseDown") flickerstreak@1: parent:SetScript("OnMouseDown", function() flickerstreak@1: if script then flickerstreak@1: script() flickerstreak@1: end flickerstreak@1: if self.registry[parent] and self.registry[parent].tooltip and self.registry[parent].tooltip == self.tooltip then flickerstreak@1: self.tooltip:Hide() flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: end flickerstreak@1: if parent:HasScript("OnMouseWheel") then flickerstreak@1: local script = parent:GetScript("OnMouseWheel") flickerstreak@1: parent:SetScript("OnMouseWheel", function() flickerstreak@1: if script then flickerstreak@1: script() flickerstreak@1: end flickerstreak@1: if self.registry[parent] and self.registry[parent].tooltip then flickerstreak@1: self.registry[parent].tooltip:Scroll(arg1 < 0) flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: self.onceRegistered[parent] = true flickerstreak@1: if GetMouseFocus() == parent then flickerstreak@1: self:Open(parent) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.Register = wrap(Tablet.Register, "Tablet:Register") flickerstreak@1: flickerstreak@1: function Tablet:Unregister(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: self:assert(self.registry[parent], "You cannot unregister a parent frame if it has not been registered already.") flickerstreak@1: self.registry[parent] = nil flickerstreak@1: end flickerstreak@1: Tablet.Unregister = wrap(Tablet.Unregister, "Tablet:Unregister") flickerstreak@1: flickerstreak@1: function Tablet:IsRegistered(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: return self.registry[parent] and true flickerstreak@1: end flickerstreak@1: Tablet.IsRegistered = wrap(Tablet.IsRegistered, "Tablet:IsRegistered") flickerstreak@1: flickerstreak@1: local _id = 0 flickerstreak@1: local addedCategory flickerstreak@1: local currentCategoryInfo flickerstreak@1: local depth = 0 flickerstreak@1: local categoryPool = {} flickerstreak@1: function CleanCategoryPool(self) flickerstreak@1: for k,v in pairs(categoryPool) do flickerstreak@1: del(v) flickerstreak@1: categoryPool[k] = nil flickerstreak@1: end flickerstreak@1: _id = 0 flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Tablet:AddCategory(...) flickerstreak@1: self:assert(currentFrame, "You must add categories in within a registration.") flickerstreak@1: local info = new(...) flickerstreak@1: local cat = currentTabletData:AddCategory(info) flickerstreak@1: info = del(info) flickerstreak@1: return cat flickerstreak@1: end flickerstreak@1: Tablet.AddCategory = wrap(Tablet.AddCategory, "Tablet:AddCategory") flickerstreak@1: flickerstreak@1: function Tablet:SetHint(text) flickerstreak@1: self:assert(currentFrame, "You must set hint within a registration.") flickerstreak@1: self:assert(not currentCategoryInfo, "You cannot set hint in a category.") flickerstreak@1: currentTabletData:SetHint(text) flickerstreak@1: end flickerstreak@1: Tablet.SetHint = wrap(Tablet.SetHint, "Tablet:SetHint") flickerstreak@1: flickerstreak@1: function Tablet:SetTitle(text) flickerstreak@1: self:assert(currentFrame, "You must set title within a registration") flickerstreak@1: self:assert(not currentCategoryInfo, "You cannot set title in a category.") flickerstreak@1: currentTabletData:SetTitle(text) flickerstreak@1: end flickerstreak@1: Tablet.SetTitle = wrap(Tablet.SetTitle, "Tablet:SetTitle") flickerstreak@1: flickerstreak@1: function Tablet:SetTitleColor(r, g, b) flickerstreak@1: self:assert(currentFrame, "You must set title color within a registration") flickerstreak@1: self:assert(not currentCategoryInfo, "You cannot set title color in a category.") flickerstreak@1: self:argCheck(r, 2, "number") flickerstreak@1: self:argCheck(g, 3, "number") flickerstreak@1: self:argCheck(b, 4, "number") flickerstreak@1: currentTabletData:SetTitleColor(r, g, b) flickerstreak@1: end flickerstreak@1: Tablet.SetTitleColor = wrap(Tablet.SetTitleColor, "Tablet:SetTitleColor") flickerstreak@1: flickerstreak@1: function Tablet:GetNormalFontSize() flickerstreak@1: return normalSize flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Tablet:GetHeaderFontSize() flickerstreak@1: return headerSize flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Tablet:GetNormalFontObject() flickerstreak@1: return GameTooltipText flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Tablet:GetHeaderFontObject() flickerstreak@1: return GameTooltipHeaderText flickerstreak@1: end flickerstreak@1: flickerstreak@1: function Tablet:SetFontSizePercent(parent, percent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: if info then flickerstreak@1: if info.tooltip then flickerstreak@1: info.tooltip:SetFontSizePercent(percent) flickerstreak@1: else flickerstreak@1: local data = info.data flickerstreak@1: local detachedData = info.detachedData flickerstreak@1: if detachedData.detached then flickerstreak@1: detachedData.fontSizePercent = percent flickerstreak@1: else flickerstreak@1: data.fontSizePercent = percent flickerstreak@1: end flickerstreak@1: end flickerstreak@1: elseif type(parent) == "table" then flickerstreak@1: parent.fontSizePercent = percent flickerstreak@1: else flickerstreak@1: self:assert(false, "You cannot change font size with an unregistered parent frame.") flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.SetFontSizePercent = wrap(Tablet.SetFontSizePercent, "Tablet:SetFontSizePercent") flickerstreak@1: flickerstreak@1: function Tablet:GetFontSizePercent(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: if info then flickerstreak@1: local data = info.data flickerstreak@1: local detachedData = info.detachedData flickerstreak@1: if detachedData.detached then flickerstreak@1: return detachedData.fontSizePercent or 1 flickerstreak@1: else flickerstreak@1: return data.fontSizePercent or 1 flickerstreak@1: end flickerstreak@1: elseif type(parent) == "table" then flickerstreak@1: return parent.fontSizePercent or 1 flickerstreak@1: else flickerstreak@1: self:assert(false, "You cannot check font size with an unregistered parent frame.") flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.GetFontSizePercent = wrap(Tablet.GetFontSizePercent, "Tablet:GetFontSizePercent") flickerstreak@1: flickerstreak@1: function Tablet:SetTransparency(parent, percent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: if info then flickerstreak@1: if info.tooltip then flickerstreak@1: info.tooltip:SetTransparency(percent) flickerstreak@1: else flickerstreak@1: local data = info.data flickerstreak@1: local detachedData = info.detachedData flickerstreak@1: if detachedData.detached then flickerstreak@1: detachedData.transparency = percent flickerstreak@1: elseif data then flickerstreak@1: data.transparency = percent flickerstreak@1: end flickerstreak@1: end flickerstreak@1: elseif type(parent) == "table" then flickerstreak@1: parent.transparency = percent flickerstreak@1: else flickerstreak@1: self:assert(false, "You cannot change transparency with an unregistered parent frame.") flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.SetTransparency = wrap(Tablet.SetTransparency, "Tablet:SetTransparency") flickerstreak@1: flickerstreak@1: function Tablet:GetTransparency(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: if info then flickerstreak@1: local data = info.data flickerstreak@1: local detachedData = info.detachedData flickerstreak@1: if detachedData.detached then flickerstreak@1: return detachedData.transparency or 0.75 flickerstreak@1: else flickerstreak@1: return data.transparency or 0.75 flickerstreak@1: end flickerstreak@1: elseif type(parent) == "table" then flickerstreak@1: return parent.transparency or 0.75 flickerstreak@1: else flickerstreak@1: self:assert(parent, "You must provide a parent frame to check transparency") flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.GetTransparency = wrap(Tablet.GetTransparency, "Tablet:GetTransparency") flickerstreak@1: flickerstreak@1: function Tablet:SetColor(parent, r, g, b) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: if info then flickerstreak@1: if info.tooltip then flickerstreak@1: info.tooltip:SetColor(r, g, b) flickerstreak@1: else flickerstreak@1: local data = info.data flickerstreak@1: local detachedData = info.detachedData flickerstreak@1: if detachedData.detached then flickerstreak@1: detachedData.r = r flickerstreak@1: detachedData.g = g flickerstreak@1: detachedData.b = b flickerstreak@1: else flickerstreak@1: data.r = r flickerstreak@1: data.g = g flickerstreak@1: data.b = b flickerstreak@1: end flickerstreak@1: end flickerstreak@1: elseif type(parent) == "table" then flickerstreak@1: parent.r = r flickerstreak@1: parent.g = g flickerstreak@1: parent.b = b flickerstreak@1: else flickerstreak@1: self:assert(false, "You cannot change color with an unregistered parent frame.") flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.SetColor = wrap(Tablet.SetColor, "Tablet:SetColor") flickerstreak@1: flickerstreak@1: function Tablet:GetColor(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: if info then flickerstreak@1: local data = info.data flickerstreak@1: local detachedData = info.detachedData flickerstreak@1: if detachedData.detached then flickerstreak@1: return detachedData.r or 0, detachedData.g or 0, detachedData.b or 0 flickerstreak@1: else flickerstreak@1: return data.r or 0, data.g or 0, data.b or 0 flickerstreak@1: end flickerstreak@1: elseif type(parent) == "table" then flickerstreak@1: return parent.r or 0, parent.g or 0, parent.b or 0 flickerstreak@1: else flickerstreak@1: self:assert(parent, "You must provide a parent frame to check color") flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.GetColor = wrap(Tablet.GetColor, "Tablet:GetColor") flickerstreak@1: flickerstreak@1: function Tablet:Detach(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: self:assert(info, "You cannot detach tablet with an unregistered parent frame.") flickerstreak@1: self:assert(info.detachedData, "You cannot detach tablet without a data field.") flickerstreak@1: if info.tooltip and info.tooltip == tooltip then flickerstreak@1: tooltip:Detach() flickerstreak@1: else flickerstreak@1: info.detachedData.detached = true flickerstreak@1: local detached = AcquireDetachedFrame(self, info, info.data, info.detachedData) flickerstreak@1: flickerstreak@1: detached.menu = info.menu flickerstreak@1: local children = info.children flickerstreak@1: function detached:children() flickerstreak@1: if not self.preventRefresh then flickerstreak@1: currentFrame = self flickerstreak@1: currentTabletData = TabletData:new(self) flickerstreak@1: self:ClearLines() flickerstreak@1: if children then flickerstreak@1: children() flickerstreak@1: end flickerstreak@1: currentTabletData:Display(currentFrame) flickerstreak@1: self:Show(currentTabletData) flickerstreak@1: currentTabletData:del() flickerstreak@1: currentTabletData = nil flickerstreak@1: currentFrame = nil flickerstreak@1: end flickerstreak@1: end flickerstreak@1: detached:SetOwner(parent) flickerstreak@1: detached:children() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.Detach = wrap(Tablet.Detach, "Tablet:Detach") flickerstreak@1: flickerstreak@1: function Tablet:Attach(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: self:assert(info, "You cannot detach tablet with an unregistered parent frame.") flickerstreak@1: self:assert(info.detachedData, "You cannot attach tablet without a data field.") flickerstreak@1: if info.tooltip and info.tooltip ~= tooltip then flickerstreak@1: info.tooltip:Attach() flickerstreak@1: else flickerstreak@1: info.detachedData.detached = false flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.Attach = wrap(Tablet.Attach, "Tablet:Attach") flickerstreak@1: flickerstreak@1: function Tablet:IsAttached(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: self:assert(info, "You cannot check tablet with an unregistered parent frame.") flickerstreak@1: return not info.detachedData or not info.detachedData.detached flickerstreak@1: end flickerstreak@1: Tablet.IsAttached = wrap(Tablet.IsAttached, "Tablet:IsAttached") flickerstreak@1: flickerstreak@1: function Tablet:Refresh(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: self:assert(info, "You cannot refresh tablet with an unregistered parent frame.") flickerstreak@1: local tt = info.tooltip flickerstreak@1: if tt and not tt.preventRefresh and tt:IsShown() then flickerstreak@1: tt.updating = true flickerstreak@1: tt:children() flickerstreak@1: tt.updating = false flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.Refresh = wrap(Tablet.Refresh, "Tablet:Refresh") flickerstreak@1: flickerstreak@1: function Tablet:IsLocked(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: self:assert(info, "You cannot detach tablet with an unregistered parent frame.") flickerstreak@1: return info.detachedData and info.detachedData.locked flickerstreak@1: end flickerstreak@1: Tablet.IsLocked = wrap(Tablet.IsLocked, "Tablet:IsLocked") flickerstreak@1: flickerstreak@1: function Tablet:ToggleLocked(parent) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: self:assert(info, "You cannot detach tablet with an unregistered parent frame.") flickerstreak@1: if info.tooltip and info.tooltip ~= tooltip then flickerstreak@1: info.tooltip:Lock() flickerstreak@1: elseif info.detachedData then flickerstreak@1: info.detachedData.locked = info.detachedData.locked flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.ToggleLocked = wrap(Tablet.ToggleLocked, "Tablet:ToggleLocked") flickerstreak@1: flickerstreak@1: function Tablet:UpdateDetachedData(parent, detachedData) flickerstreak@1: self:argCheck(parent, 2, "table", "string") flickerstreak@1: local info = self.registry[parent] flickerstreak@1: self:assert(info, "You cannot detach tablet with an unregistered parent frame.") flickerstreak@1: self:argCheck(detachedData, 3, "table") flickerstreak@1: if info.data == info.detachedData then flickerstreak@1: info.data = detachedData flickerstreak@1: end flickerstreak@1: info.detachedData = detachedData flickerstreak@1: if info.detachedData.detached then flickerstreak@1: self:Detach(parent) flickerstreak@1: elseif info.tooltip and info.tooltip.owner then flickerstreak@1: self:Attach(parent) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: Tablet.UpdateDetachedData = wrap(Tablet.UpdateDetachedData, "Tablet:UpdateDetachedData") flickerstreak@1: flickerstreak@1: if DEBUG then flickerstreak@1: function Tablet:ListProfileInfo() flickerstreak@1: local duration, times, memories = GetProfileInfo() flickerstreak@1: self:assert(duration and times and memories) flickerstreak@1: local t = new() flickerstreak@1: for method in pairs(memories) do flickerstreak@1: table.insert(t, method) flickerstreak@1: end flickerstreak@1: table.sort(t, function(alpha, bravo) flickerstreak@1: if memories[alpha] ~= memories[bravo] then flickerstreak@1: return memories[alpha] < memories[bravo] flickerstreak@1: elseif times[alpha] ~= times[bravo] then flickerstreak@1: return times[alpha] < times[bravo] flickerstreak@1: else flickerstreak@1: return alpha < bravo flickerstreak@1: end flickerstreak@1: end) flickerstreak@1: local memory = 0 flickerstreak@1: local time = 0 flickerstreak@1: for _,method in ipairs(t) do flickerstreak@1: DEFAULT_CHAT_FRAME:AddMessage(format("%s || %.3f s || %.3f%% || %d KiB", method, times[method], times[method] / duration * 100, memories[method])) flickerstreak@1: memory = memory + memories[method] flickerstreak@1: time = time + times[method] flickerstreak@1: end flickerstreak@1: DEFAULT_CHAT_FRAME:AddMessage(format("%s || %.3f s || %.3f%% || %d KiB", "Total", time, time / duration * 100, memory)) flickerstreak@1: del(t) flickerstreak@1: end flickerstreak@1: SLASH_TABLET1 = "/tablet" flickerstreak@1: SLASH_TABLET2 = "/tabletlib" flickerstreak@1: SlashCmdList["TABLET"] = function(msg) flickerstreak@1: TabletLib:GetInstance(MAJOR_VERSION):ListProfileInfo() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function activate(self, oldLib, oldDeactivate) flickerstreak@1: Tablet = self flickerstreak@1: if oldLib then flickerstreak@1: self.registry = oldLib.registry flickerstreak@1: self.onceRegistered = oldLib.onceRegistered flickerstreak@1: self.tooltip = oldLib.tooltip flickerstreak@1: else flickerstreak@1: self.registry = {} flickerstreak@1: self.onceRegistered = {} flickerstreak@1: end flickerstreak@1: flickerstreak@1: tooltip = self.tooltip flickerstreak@1: flickerstreak@1: if oldDeactivate then flickerstreak@1: oldDeactivate(oldLib) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function deactivate(self) flickerstreak@1: StopCheckingAlt() flickerstreak@1: end flickerstreak@1: flickerstreak@1: AceLibrary:Register(Tablet, MAJOR_VERSION, MINOR_VERSION, activate, deactivate)