WoWInterface SVN RecapFu

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk/FuBar_RecapFu/libs/Tablet-2.0
    from Rev 2 to Rev 3
    Reverse comparison

Rev 2 → Rev 3

Tablet-2.0.lua
1,6 → 1,6
--[[
Name: Tablet-2.0
Revision: $Rev: 30695 $
Revision: $Rev: 216 $
Author(s): ckknight (ckknight@gmail.com)
Website: http://ckknight.wowinterface.com/
Documentation: http://www.wowace.com/index.php/Tablet-2.0
11,7 → 11,7
]]
 
local MAJOR_VERSION = "Tablet-2.0"
local MINOR_VERSION = tonumber(("$Revision: 30695 $"):sub(12, -3))
local MINOR_VERSION = 90000 + tonumber(("$Revision: 216 $"):match("(%d+)"))
 
if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
75,19 → 75,19
LOCK = "锁定"
LOCK_DESC = "锁定菜单当前位置. alt+右键 将显示选项, alt+拖动 可以移动已锁定的菜单."
elseif GetLocale() == "zhTW" then
SCROLL_UP = "向上翻轉"
SCROLL_DOWN = "向上翻轉"
SCROLL_UP = "向上翻捲"
SCROLL_DOWN = "向上翻捲"
HINT = "提示"
DETACH = "分離"
DETACH_DESC = "分離選單為獨立提示。"
SIZE = "尺寸"
SIZE_DESC = "縮放選單顯示尺寸。"
CLOSE_MENU = "關閉選單"
CLOSE_MENU_DESC = "關閉選單"
CLOSE_MENU_DESC = "關閉選單。"
COLOR = "背景顏色"
COLOR_DESC = "設置選單背景顏色。"
COLOR_DESC = "設定選單背景顏色。"
LOCK = "鎖定"
LOCK_DESC = "鎖定選單目前位置. Alt+右鍵 將顯示選項,Alt+拖動 可以移動已鎖定的選單。"
LOCK_DESC = "鎖定選單目前位置設定。Alt-右鍵將顯示選項,Alt-拖動可以移動已鎖定的選單。"
elseif GetLocale() == "frFR" then
SCROLL_UP = "Parcourir vers le haut"
SCROLL_DOWN = "Parcourir vers le bas"
116,6 → 116,20
COLOR_DESC = "Establece el color de fondo"
LOCK = "Bloquear"
LOCK_DESC = "Bloquea el tooltip en su posici\195\179n actual. Clic+Alt para el men\195\186 y arrastra+Alt para arrastrarlo cuando est\195\161 bloqueado"
elseif GetLocale() == "ruRU" then
SCROLL_UP = "Прокрутка вверх"
SCROLL_DOWN = "Прокрутка вниз"
HINT = "Совет"
DETACH = "Отделить"
DETACH_DESC = "Отделить планшет от его источника."
SIZE = "Размер"
SIZE_DESC = "Масштаб планшета."
CLOSE_MENU = "Закрыть меню"
CLOSE_MENU_DESC = "Закрыть меню."
COLOR = "Цвет фона"
COLOR_DESC = "Установить цвет фона."
LOCK = "Зафиксировать"
LOCK_DESC = "Зафиксировать планшет в его текущем позиции. Alt+ПКМ для меню или Alt+перетаскивание для перетаскивания когда планшет зафиксирован."
end
 
local start = GetTime()
168,12 → 182,13
if UIParent:IsShown() then
return UIParent
end
local f = GetFullScreenFrame()
local f = GetUIPanel("fullscreen")
if f and f:IsShown() then
return f
end
return nil
end
GetMainFrame = wrap(GetMainFrame, "GetMainFrame")
 
local MIN_TOOLTIP_SIZE = 200
local TESTSTRING_EXTRA_WIDTH = 8
183,20 → 198,23
local pool = {}
 
local function del(t)
if t then
for k in pairs(t) do
t[k] = nil
end
setmetatable(t, nil)
pool[t] = true
setmetatable(t, nil)
for k in pairs(t) do
t[k] = nil
end
t[''] = true
t[''] = nil
pool[t] = true
return nil
end
 
local new
 
local function copy(parent)
local t = next(pool) or {}
pool[t] = nil
local t = next(pool)
if not t then
t = {}
else
pool[t] = nil
end
if parent then
for k,v in pairs(parent) do
t[k] = v
206,9 → 224,13
return t
end
 
function new(...)
local t = next(pool) or {}
pool[t] = nil
local function new(...)
local t = next(pool)
if not t then
t = {}
else
pool[t] = nil
end
 
for i = 1, select('#', ...), 2 do
local k = select(i, ...)
243,12 → 265,12
 
local headerSize, normalSize
if GameTooltipHeaderText then
_,headerSize = GameTooltipHeaderText:GetFont()
headerSize = select(2,GameTooltipHeaderText:GetFont())
else
headerSize = 14
end
if GameTooltipText then
_,normalSize = GameTooltipText:GetFont()
normalSize = select(2,GameTooltipText:GetFont())
else
normalSize = 12
end
268,6 → 290,7
testString:SetText(text)
return testString:GetStringWidth()-- + TESTSTRING_EXTRA_WIDTH
end
getTestWidth = wrap(getTestWidth, "getTestWidth")
do
local TabletData_mt = { __index = TabletData }
function TabletData:new(tablet)
282,6 → 305,7
setmetatable(self, TabletData_mt)
return self
end
TabletData.new = wrap(TabletData.new, "TabletData:new")
 
function TabletData:checkMinWidth()
local min = self.minWidth or MIN_TOOLTIP_SIZE
290,6 → 314,7
self.width = width
end
end
TabletData.checkMinWidth = wrap(TabletData.checkMinWidth, "TabletData:checkMinWidth")
 
function TabletData:del()
for k, v in ipairs(self.categories) do
298,6 → 323,7
del(self.categories)
del(self)
end
TabletData.del = wrap(TabletData.del, "TabletData:del")
 
function TabletData:Display()
if self.title and (self.tablet == tooltip or self.tablet.registration.showTitleWhenDetached) then
381,6 → 407,7
self.tablet.tmpHidden = nil
end
end
TabletData.Display = wrap(TabletData.Display, "TabletData:Display")
 
function TabletData:AddCategory(info, index)
local made = false
399,20 → 426,24
end
return cat
end
TabletData.AddCategory = wrap(TabletData.AddCategory, "TabletData:AddCategory")
 
function TabletData:SetHint(hint)
self.hint = hint
end
TabletData.SetHint = wrap(TabletData.SetHint, "TabletData:SetHint")
 
function TabletData:SetTitle(title)
self.title = title or "Title"
end
TabletData.SetTitle = wrap(TabletData.SetTitle, "TabletData:SetTitle")
 
function TabletData:SetTitleColor(r, g, b)
self.titleR = r
self.titleG = g
self.titleB = b
end
TabletData.SetTitleColor = wrap(TabletData.SetTitleColor, "TabletData:SetTitleColor")
end
do
local Category_mt = { __index = Category }
421,7 → 452,7
if superCategory and not self.noInherit then
self.superCategory = superCategory.superCategory
for k, v in pairs(superCategory) do
if string.find(k, "^child_") then
if k:find("^child_") then
local k = strsub(k, 7)
if self[k] == nil then
self[k] = v
520,7 → 551,7
x['size' .. i] = self['size' .. i]
x['justify' .. i] = self['justify' .. i]
end
if self.checkIcon and string.find(self.checkIcon, "^Interface\\Icons\\") then
if self.checkIcon and self.checkIcon:find("^Interface\\Icons\\") then
x.checkCoordLeft = self.checkCoordLeft or 0.05
x.checkCoordRight = self.checkCoordRight or 0.95
x.checkCoordTop = self.checkCoordTop or 0.05
540,6 → 571,7
end
return self
end
Category.new = wrap(Category.new, "Category:new")
 
function Category:del()
local prev = garbageLine
549,6 → 581,7
del(self.lines)
del(self)
end
Category.del = wrap(Category.del, "Category:del")
 
function Category:AddLine(...)
self.lastWasTitle = nil
563,6 → 596,7
info = del(info)
end
end
Category.AddLine = wrap(Category.AddLine, "Category:AddLine")
 
function Category:AddCategory(...)
local lastWasTitle = self.lastWasTitle
584,6 → 618,7
end
return cat
end
Category.AddCategory = wrap(Category.AddCategory, "Category:AddCategory")
 
function Category:HasChildren()
local hasChildren = false
599,6 → 634,7
end
return false
end
Category.HasChildren = wrap(Category.HasChildren, "Category:HasChildren")
 
local lastWasTitle = false
function Category:Display(tablet)
608,7 → 644,8
if not self.hideBlankLine and not lastWasTitle then
local info = new(
'blank', true,
'fakeChild', true
'fakeChild', true,
'noInherit', true
)
self:AddLine(info, 1)
del(info)
626,6 → 663,7
lastWasTitle = self.isTitle
return good
end
Category.Display = wrap(Category.Display, "Category:Display")
end
do
local Line_mt = { __index = Line }
633,7 → 671,7
local self = copy(info)
if not info.noInherit then
for k, v in pairs(category) do
if string.find(k, "^child_") then
if k:find("^child_") then
local k = strsub(k, 7)
if self[k] == nil then
self[k] = v
703,14 → 741,14
end
end
if not self.size then
_,self.size = self.font:GetFont()
self.size = select(2,self.font:GetFont())
end
for i = 2, columns do
if not self['size' .. i] then
_,self['size' .. i] = self['font' .. i]:GetFont()
self['size' .. i] = select(2,self['font' .. i]:GetFont())
end
end
if self.checkIcon and string.find(self.checkIcon, "^Interface\\Icons\\") then
if self.checkIcon and self.checkIcon:find("^Interface\\Icons\\") then
if not self.checkCoordLeft then
self.checkCoordLeft = 0.05
end
827,15 → 865,18
end
return self
end
Line.new = wrap(Line.new, "Line:new")
 
function Line:del()
del(self)
end
Line.del = wrap(Line.del, "Line:del")
 
function Line:Display(tablet)
tablet:AddLine(self)
return true
end
Line.Display = wrap(Line.Display, "Line:Display")
end
 
local fake_ipairs
856,6 → 897,7
end
return iter, tmp, 0
end
fake_ipairs = wrap(fake_ipairs, "fake_ipairs")
end
 
local function argunpack(t, key, i)
867,7 → 909,8
if v then
return v, argunpack(t, key, i+1)
end
end
end
argunpack = wrap(argunpack, "argunpack")
 
 
local delstring, newstring
881,6 → 924,7
t:SetParent(UIParent)
return nil
end
delstring = wrap(delstring, "delstring")
function newstring(parent)
if #cache ~= 0 then
local t = cache[#cache]
892,6 → 936,7
local t = parent:CreateFontString(nil, "ARTWORK")
return t
end
newstring = wrap(newstring, "newstring")
end
 
local function button_OnEnter(this, ...)
905,7 → 950,8
geterrorhandler()(ret)
end
end
end
end
button_OnEnter = wrap(button_OnEnter, "button_OnEnter")
 
local function button_OnLeave(this, ...)
if type(this.self:GetScript("OnLeave")) == "function" then
919,6 → 965,7
end
end
end
button_OnLeave = wrap(button_OnLeave, "button_OnLeave")
local lastMouseDown
local function button_OnClick(this, arg1, ...)
if this.self:HasScript("OnClick") and type(this.self:GetScript("OnClick")) == "function" then
945,6 → 992,7
end
end
end
button_OnClick = wrap(button_OnClick, "button_OnClick")
local function button_OnMouseUp(this, arg1, ...)
if this.self:HasScript("OnMouseUp") and type(this.self:GetScript("OnMouseUp")) == "function" then
this.self:GetScript("OnMouseUp")(this.self, arg1, ...)
957,6 → 1005,7
end
end
end
button_OnMouseUp = wrap(button_OnMouseUp, "button_OnMouseUp")
local function button_OnMouseDown(this, arg1, ...)
if this.self:HasScript("OnMouseDown") and type(this.self:GetScript("OnMouseDown")) == "function" then
this.self:GetScript("OnMouseDown")(this.self, arg1, ...)
968,18 → 1017,21
this.clicked = true
end
end
button_OnMouseDown = wrap(button_OnMouseDown, "button_OnMouseDown")
local function button_OnDragStart(this, ...)
local parent = this:GetParent() and this:GetParent().tablet
if parent:GetScript("OnDragStart") then
return parent:GetScript("OnDragStart")(parent, ...)
end
end
button_OnDragStart = wrap(button_OnDragStart, "button_OnDragStart")
local function button_OnDragStop(this, ...)
local parent = this:GetParent() and this:GetParent().tablet
if parent:GetScript("OnDragStop") then
return parent:GetScript("OnDragStop")(parent, ...)
end
end
button_OnDragStop = wrap(button_OnDragStop, "button_OnDragStop")
 
local num_buttons = 0
local function NewLine(self)
1018,7 → 1070,7
check.shown = false
check:SetPoint("TOPLEFT", button, "TOPLEFT")
col1:SetPoint("TOPLEFT", check, "TOPLEFT")
local _,size = GameTooltipText:GetFont()
local size = select(2,GameTooltipText:GetFont())
check:SetHeight(size * 1.5)
check:SetWidth(size * 1.5)
check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
1051,7 → 1103,7
elseif c:find("^BOTTOM") then
top = b:GetBottom()
else
_,top = b:GetCenter()
top = select(2,b:GetCenter())
end
if top then
top = top + e
1062,7 → 1114,7
elseif c:find("^BOTTOM") then
bottom = b:GetBottom()
else
_,bottom = b:GetCenter()
bottom = select(2,b:GetCenter())
end
if bottom then
bottom = bottom + e
1075,6 → 1127,7
end
end
end
RecalculateTabletHeight = wrap(RecalculateTabletHeight, "RecalculateTabletHeight")
 
local function GetTooltipHeight(self)
RecalculateTabletHeight(self)
1362,7 → 1415,7
info.font = GameTooltipText
end
if not info.size then
_,info.size = info.font:GetFont()
info.size = select(2,info.font:GetFont())
end
local catStart = false
local columns = category and category.columns or 1
1534,6 → 1587,7
button.func = nil
button.onEnterFunc = nil
button.onLeaveFunc = nil
button:SetFrameLevel(12) -- hack suggested on forum. Added 06/17/2007. (hC)
if not self.locked or IsAltKeyDown() then
local func = info.func
if func then
1846,7 → 1900,7
if not frame then
frame = CreateFrame("Frame")
frame:SetScript("OnEvent", function(this, _, modifier)
if modifier == "ALT" then
if modifier == "LALT" or modifier == "RALT" then
this.func()
end
end)
1854,11 → 1908,13
frame:RegisterEvent("MODIFIER_STATE_CHANGED")
frame.func = func
end
StartCheckingAlt = wrap(StartCheckingAlt, "StartCheckingAlt")
function StopCheckingAlt()
if frame then
frame:UnregisterEvent("MODIFIER_STATE_CHANGED")
end
end
StopCheckingAlt = wrap(StopCheckingAlt, "StopCheckingAlt")
end
 
function AcquireDetachedFrame(self, registration, data, detachedData)
1957,7 → 2013,7
detached.r = 0
detached.g = 0
detached.b = 0
detached:SetFrameStrata(registration.strata or "BACKGROUND")
detached:SetFrameStrata(registration and registration.strata or "BACKGROUND")
detached:SetBackdrop(tmp.a(
'bgFile', "Interface\\Buttons\\WHITE8X8",
'edgeFile', "Interface\\Tooltips\\UI-Tooltip-Border",
1976,7 → 2032,7
 
local width = GetScreenWidth()
local height = GetScreenHeight()
if registration.movable == false then
if registration and registration.movable == false then
detached:RegisterForDrag()
else
detached:RegisterForDrag("LeftButton")
1989,6 → 2045,8
detached:SetScript("OnDragStop", function(this)
detached:StopMovingOrSizing()
detached.moving = nil
detached:SetClampedToScreen(1)
detached:SetClampedToScreen(nil)
local anchor
local offsetx
local offsety
2076,7 → 2134,11
return
end
if detached.menu then
detached.menu(level, value)
if type(detached.menu) == "function" then
detached.menu(level, value)
else
Dewdrop:FeedAceOptionsTable(detached.menu)
end
if level == 1 then
Dewdrop:AddLine()
end
2238,7 → 2300,9
function detached:Lock()
self:EnableMouse(self.locked)
self.locked = not self.locked
self.detachedData.locked = self.locked or nil
if self.detachedData then
self.detachedData.locked = self.locked or nil
end
self:children()
end
 
2285,17 → 2349,35
local detachedData = info.detachedData
if detachedData and detachedData.detached then
ReleaseDetachedFrame(self, data, detachedData)
elseif tooltip.data == data then
elseif tooltip and tooltip.data == data then
tooltip:Hide()
if tooltip.registration then
tooltip.registration.tooltip = nil
tooltip.registration = nil
end
end
tooltip.enteredFrame = false
if tooltip then tooltip.enteredFrame = false end
end
Tablet.Close = wrap(Tablet.Close, "Tablet:Close")
 
local function frame_children(self)
if not self.preventRefresh and self:GetParent() and self:GetParent():IsShown() then
Tablet.currentFrame = self
Tablet.currentTabletData = TabletData:new(self)
Tablet.currentTabletData.minWidth = self.minWidth
self:ClearLines()
if self.runChildren then
self.runChildren()
end
Tablet.currentTabletData:Display(Tablet.currentFrame)
self:Show(Tablet.currentTabletData)
Tablet.currentTabletData:del()
Tablet.currentTabletData = nil
Tablet.currentFrame = nil
end
end
frame_children = wrap(frame_children, "frame_children")
 
function Tablet:Open(fakeParent, parent)
self:argCheck(fakeParent, 2, "table", "string")
self:argCheck(parent, 3, "nil", "table", "string")
2326,22 → 2408,7
frame.minWidth = info.minWidth
if not frame.children or not frame.childrenVer or frame.childrenVer < MINOR_VERSION then
frame.childrenVer = MINOR_VERSION
function frame:children()
if not self.preventRefresh and self:GetParent():IsShown() then
Tablet.currentFrame = self
Tablet.currentTabletData = TabletData:new(self)
Tablet.currentTabletData.minWidth = self.minWidth
self:ClearLines()
if self.runChildren then
self.runChildren()
end
Tablet.currentTabletData:Display(Tablet.currentFrame)
self:Show(Tablet.currentTabletData)
Tablet.currentTabletData:del()
Tablet.currentTabletData = nil
Tablet.currentFrame = nil
end
end
frame.children = frame_children
end
frame:SetOwner(fakeParent)
frame:children()
2369,6 → 2436,8
end
local offsetx = 0
local offsety = 0
frame:SetClampedToScreen(1)
frame:SetClampedToScreen(nil)
if frame:GetBottom() and frame:GetLeft() then
if frame:GetRight() > GetScreenWidth() then
offsetx = frame:GetRight() - GetScreenWidth()
2461,7 → 2530,7
info = new(...)
end
self.registry[parent] = info
info.data = info.data or info.detachedData or {}
info.data = info.data or info.detachedData or new()
info.detachedData = info.detachedData or info.data
local data = info.data
local detachedData = info.detachedData
2536,6 → 2605,7
end
_id = 0
end
CleanCategoryPool = wrap(CleanCategoryPool, "CleanCategoryPool")
 
function Tablet:AddCategory(...)
if not self.currentFrame then
2578,18 → 2648,22
function Tablet:GetNormalFontSize()
return normalSize
end
Tablet.GetNormalFontSize = wrap(Tablet.GetNormalFontSize, "Tablet:GetNormalFontSize")
 
function Tablet:GetHeaderFontSize()
return headerSize
end
Tablet.GetHeaderFontSize = wrap(Tablet.GetHeaderFontSize, "Tablet:GetHeaderFontSize")
 
function Tablet:GetNormalFontObject()
return GameTooltipText
end
Tablet.GetNormalFontObject = wrap(Tablet.GetNormalFontObject, "Tablet:GetNormalFontObject")
 
function Tablet:GetHeaderFontObject()
return GameTooltipHeaderText
end
Tablet.GetHeaderFontObject = wrap(Tablet.GetHeaderFontObject, "Tablet:GetHeaderFontObject")
 
function Tablet:SetFontSizePercent(parent, percent)
self:argCheck(parent, 2, "table", "string")
2732,7 → 2806,7
if not info.detachedData then
self:error("You cannot detach tablet without a data field.")
end
if info.tooltip and info.tooltip == tooltip then
if info.tooltip and info.tooltip == tooltip and tooltip.registration then
tooltip:Detach()
else
info.detachedData.detached = true
2743,22 → 2817,7
detached.minWidth = info.minWidth
if not detached.children or not detached.childrenVer or detached.childrenVer < MINOR_VERSION then
detached.childrenVer = MINOR_VERSION
function detached:children()
if not self.preventRefresh then
Tablet.currentFrame = self
Tablet.currentTabletData = TabletData:new(self)
Tablet.currentTabletData.minWidth = self.minWidth
self:ClearLines()
if self.runChildren then
self.runChildren()
end
Tablet.currentTabletData:Display(Tablet.currentFrame)
self:Show(Tablet.currentTabletData)
Tablet.currentTabletData:del()
Tablet.currentTabletData = nil
Tablet.currentFrame = nil
end
end
detached.children = frame_children
end
detached:SetOwner(parent)
detached:children()
2883,7 → 2942,7
SLASH_TABLET1 = "/tablet"
SLASH_TABLET2 = "/tabletlib"
SlashCmdList["TABLET"] = function(msg)
TabletLib:GetInstance(MAJOR_VERSION):ListProfileInfo()
AceLibrary(MAJOR_VERSION):ListProfileInfo()
end
end