Fixed: report window send button, tooltip showing the player's death

This commit is contained in:
Tercio Jose
2022-10-06 16:24:29 -03:00
parent 1daab21a63
commit ea9caa1f40
12 changed files with 2376 additions and 2903 deletions
+499 -708
View File
File diff suppressed because it is too large Load Diff
+41 -34
View File
@@ -15,7 +15,7 @@ local max = math.max
--api locals
local PixelUtil = PixelUtil or DFPixelUtil
local version = 3
local version = 4
local CONST_MENU_TYPE_MAINMENU = "main"
local CONST_MENU_TYPE_SUBMENU = "sub"
@@ -145,10 +145,30 @@ function DF:CreateCoolTip()
}
gameCooltip.AliasList = {
["VerticalOffset"] = "ButtonsYMod",
["VerticalPadding"] = "YSpacingMod",
--set the height of each line, options 'IgnoreButtonAutoHeight' and 'AlignAsBlizzTooltip' must be false
["LineHeightSizeOffset"] = "ButtonHeightMod",
["LineHeightSizeOffsetSub"] = "ButtonHeightModSub",
["FrameHeightSizeOffset"] = "HeighMod",
["FrameHeightSizeOffsetSub"] = "HeighModSub",
--space between the tooltip's left side and the start of the line
["LeftPadding"] = "LeftBorderSize",
--space between the tooltip's right side and the end of the line
["RightPadding"] = "RightBorderSize",
--space between each line, positive values make the lines be closer
["LinePadding"] = "YSpacingMod",
["VerticalPadding"] = "YSpacingMod",
["LinePaddingSub"] = "YSpacingModSub",
["VerticalPaddingSub"] = "YSpacingModSub",
--move each line in the Y axis (vertical offsett)
["LineYOffset"] = "ButtonsYMod",
["VerticalOffset"] = "ButtonsYMod",
["LineYOffsetSub"] = "ButtonsYModSub",
["VerticalOffsetSub"] = "ButtonsYModSub",
}
gameCooltip.OptionsTable = {}
@@ -1475,8 +1495,8 @@ function DF:CreateCoolTip()
frame1.w = gameCooltip.OptionsTable.FixedWidth or 0
frame1.hHeight = 0
frame2.hHeight = 0
gameCooltip.active = true
for i = 1, gameCooltip.Indexes do
local button = frame1.Lines[i]
if (not button) then
@@ -1485,10 +1505,11 @@ function DF:CreateCoolTip()
button.index = i
--basic stuff
button:Show()
button.background:Hide()
button:SetHeight(gameCooltip.OptionsTable.ButtonHeightMod or gameCooltip.default_height)
--clear registered click buttons
button:RegisterForClicks()
--setup texts and icons
@@ -1510,7 +1531,7 @@ function DF:CreateCoolTip()
--normalize height of all rows
local heightValue = -6 + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0)
for i = 1, gameCooltip.Indexes do
for i = 1, gameCooltip.Indexes do
local menuButton = frame1.Lines[i]
menuButton:ClearAllPoints()
@@ -1528,19 +1549,17 @@ function DF:CreateCoolTip()
local height = max(2, menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight(), gameCooltip.OptionsTable.AlignAsBlizzTooltipForceHeight or 2)
menuButton:SetHeight(height)
menuButton:SetPoint("top", frame1, "top", 0, heightValue)
heightValue = heightValue + ( height * -1)
heightValue = heightValue + (height * -1)
elseif (gameCooltip.OptionsTable.IgnoreButtonAutoHeight) then
local height = max(menuButton.leftText:GetStringHeight(), menuButton.rightText:GetStringHeight(), menuButton.leftIcon:GetHeight(), menuButton.rightIcon:GetHeight())
menuButton:SetHeight(height)
menuButton:SetPoint("top", frame1, "top", 0, heightValue)
heightValue = heightValue + ( height * -1) + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0)
heightValue = heightValue + (height * -1) + spacing + (gameCooltip.OptionsTable.ButtonsYMod or 0)
else
menuButton:SetHeight(frame1.hHeight + (gameCooltip.OptionsTable.ButtonHeightMod or 0))
menuButton:SetPoint("top", frame1, "top", 0, ( ( (i-1) * frame1.hHeight) * -1) - 6 + (gameCooltip.OptionsTable.ButtonsYMod or 0) + spacing)
menuButton:SetPoint("top", frame1, "top", 0, (((i-1) * frame1.hHeight) * -1) - 6 + (gameCooltip.OptionsTable.ButtonsYMod or 0) + spacing)
end
if (gameCooltip.OptionsTable.YSpacingMod and not gameCooltip.OptionsTable.IgnoreButtonAutoHeight) then
@@ -1553,8 +1572,8 @@ function DF:CreateCoolTip()
if (not gameCooltip.OptionsTable.FixedWidth) then
if (gameCooltip.Type == 2) then --with bars
if (gameCooltip.OptionsTable.MinWidth) then
local w = frame1.w + 34
PixelUtil.SetWidth(frame1, math.max(w, gameCooltip.OptionsTable.MinWidth))
local width = frame1.w + 34
PixelUtil.SetWidth(frame1, math.max(width, gameCooltip.OptionsTable.MinWidth))
else
PixelUtil.SetWidth(frame1, frame1.w + 34)
end
@@ -1585,7 +1604,7 @@ function DF:CreateCoolTip()
PixelUtil.SetHeight(frame1, (heightValue + spacing) * -1)
else
PixelUtil.SetHeight(frame1, max( (frame1.hHeight * gameCooltip.Indexes) + 8 + ((gameCooltip.OptionsTable.ButtonsYMod or 0)*-1), 22 ))
PixelUtil.SetHeight(frame1, max((frame1.hHeight * gameCooltip.Indexes) + 8 + ((gameCooltip.OptionsTable.ButtonsYMod or 0) * -1), 22))
end
end
@@ -3136,39 +3155,27 @@ function DF:CreateCoolTip()
self:Reset(true)
end
gameCooltip:SetOption("StatusBarTexture", [[Interface\WorldStateFrame\WORLDSTATEFINALSCORE-HIGHLIGHT]])
self:SetOption("TextFont", DF:GetBestFontForLanguage())
self:SetOption("TextColor", "orange")
self:SetOption("TextSize", 11)
self:SetOption("ButtonsYMod", -4)
self:SetOption("YSpacingMod", -4)
self:SetOption("IgnoreButtonAutoHeight", true)
if (presetId == 1) then
self:SetOption("TextFont", DF:GetBestFontForLanguage())
self:SetOption("TextColor", "orange")
self:SetOption("TextSize", 12)
self:SetOption("ButtonsYMod", -4)
self:SetOption("YSpacingMod", -4)
self:SetOption("IgnoreButtonAutoHeight", true)
self:SetColor(1, 0.5, 0.5, 0.5, 0.5)
elseif (presetId == 2) then --used by most of the widgets
self:SetOption("TextFont", DF:GetBestFontForLanguage())
self:SetOption("TextColor", "orange")
self:SetOption("TextSize", 12)
self:SetOption("FixedWidth", 220)
self:SetOption("ButtonsYMod", -4)
self:SetOption("YSpacingMod", -4)
self:SetOption("IgnoreButtonAutoHeight", true)
self:SetColor(1, defaultBackdropColor)
self:SetColor(2, defaultBackdropColor)
self:SetBackdrop(1, defaultBackdrop, defaultBackdropColor, defaultBackdropBorderColor)
self:SetBackdrop(2, defaultBackdrop, defaultBackdropColor, defaultBackdropBorderColor)
elseif (presetId == 3) then --default used when Cooltip:Reset() is called
self:SetOption("TextFont", DF:GetBestFontForLanguage())
self:SetOption("TextColor", "orange")
self:SetOption("TextSize", 12)
self:SetOption("ButtonsYMod", -4)
self:SetOption("YSpacingMod", -4)
self:SetOption("IgnoreButtonAutoHeight", true)
self:SetColor(1, defaultBackdropColor)
self:SetColor(2, defaultBackdropColor)
self:SetBackdrop(1, defaultBackdrop, defaultBackdropColor, defaultBackdropBorderColor)
self:SetBackdrop(2, defaultBackdrop, defaultBackdropColor, defaultBackdropBorderColor)
end
+11 -67
View File
@@ -37,6 +37,9 @@ end
local DropDownMetaFunctions = _G[DF.GlobalWidgetControlNames["dropdown"]]
DF:Mixin(DropDownMetaFunctions, DF.SetPointMixin)
DF:Mixin(DropDownMetaFunctions, DF.FrameMixin)
------------------------------------------------------------------------------------------------------------
--metatables
@@ -173,30 +176,7 @@ local DropDownMetaFunctions = _G[DF.GlobalWidgetControlNames["dropdown"]]
------------------------------------------------------------------------------------------------------------
function DropDownMetaFunctions:SetBackdrop(...)
return self.dropdown:SetBackdrop(...)
end
function DropDownMetaFunctions:SetBackdropColor(...)
return self.dropdown:SetBackdropColor(...)
end
function DropDownMetaFunctions:SetBackdropBorderColor(...)
return self.dropdown:SetBackdropBorderColor(...)
end
--> methods
function DropDownMetaFunctions:IsShown()
return self.dropdown:IsShown()
end
function DropDownMetaFunctions:Show()
return self.dropdown:Show()
end
function DropDownMetaFunctions:Hide()
return self.dropdown:Hide()
end
--> menu width and height
--menu width and height
function DropDownMetaFunctions:SetMenuSize(width, height)
if (width) then
return rawset(self, "realsizeW", width)
@@ -209,7 +189,7 @@ end
return rawget(self, "realsizeW"), rawget(self, "realsizeH")
end
--> function
--function
function DropDownMetaFunctions:SetFunction(func)
return rawset(self, "func", func)
end
@@ -217,7 +197,7 @@ end
return rawget(self, "func")
end
--> value
--value
function DropDownMetaFunctions:GetValue()
return rawget(self, "myvalue")
end
@@ -225,27 +205,7 @@ end
return rawset(self, "myvalue", value)
end
--> setpoint
function DropDownMetaFunctions:SetPoint(v1, v2, v3, v4, v5)
v1, v2, v3, v4, v5 = DF:CheckPoints(v1, v2, v3, v4, v5, self)
if (not v1) then
print("Invalid parameter for SetPoint")
return
end
return self.widget:SetPoint(v1, v2, v3, v4, v5)
end
--> sizes
function DropDownMetaFunctions:SetSize(width, height)
if (width) then
self.dropdown:SetWidth(width)
end
if (height) then
return self.dropdown:SetHeight(height)
end
end
--> tooltip
--tooltip
function DropDownMetaFunctions:SetTooltip(tooltip)
if (tooltip) then
return rawset(self, "have_tooltip", tooltip)
@@ -257,10 +217,7 @@ end
return rawget(self, "have_tooltip")
end
--> frame levels
function DropDownMetaFunctions:GetFrameLevel()
return self.dropdown:GetFrameLevel()
end
--frame levels
function DropDownMetaFunctions:SetFrameLevel(level, frame)
if (not frame) then
return self.dropdown:SetFrameLevel(level)
@@ -270,25 +227,12 @@ end
end
end
--> frame stratas
function DropDownMetaFunctions:GetFrameStrata()
return self.dropdown:GetFrameStrata()
end
function DropDownMetaFunctions:SetFrameStrata(strata)
if (type(strata) == "table") then
self.dropdown:SetFrameStrata(strata:GetFrameStrata())
else
self.dropdown:SetFrameStrata(strata)
end
end
--> enabled
--enabled
function DropDownMetaFunctions:IsEnabled()
return self.dropdown:IsEnabled()
end
function DropDownMetaFunctions:Enable()
self:SetAlpha(1)
rawset(self, "lockdown", false)
@@ -306,13 +250,13 @@ end
end
end
--> fixed value
--fixed value
function DropDownMetaFunctions:SetFixedParameter(value)
rawset(self, "FixedValue", value)
end
------------------------------------------------------------------------------------------------------------
--> scripts
--scripts
local lastOpened = false
+263 -251
View File
@@ -1,6 +1,6 @@
local dversion = 375
local dversion = 376
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)
@@ -9,6 +9,8 @@ if (not DF) then
return
end
_G["DetailsFramework"] = DF
DetailsFrameworkCanLoad = true
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
@@ -37,6 +39,10 @@ DF.AuthorInfo = {
Discord = "https://discord.gg/AGSzAZX",
}
function DF:Msg(msg, ...)
print("|cFFFFFFAA" .. (self.__name or "FW Msg:") .. "|r ", msg, ...)
end
local PixelUtil = PixelUtil or DFPixelUtil
if (not PixelUtil) then
--check if is in classic, TBC, or WotLK wow, if it is, build a replacement for PixelUtil
@@ -226,23 +232,23 @@ function DF.GetSpecialization()
return nil
end
function DF.GetSpecializationInfoByID (...)
function DF.GetSpecializationInfoByID(...)
if (GetSpecializationInfoByID) then
return GetSpecializationInfoByID (...)
return GetSpecializationInfoByID(...)
end
return nil
end
function DF.GetSpecializationInfo (...)
function DF.GetSpecializationInfo(...)
if (GetSpecializationInfo) then
return GetSpecializationInfo (...)
return GetSpecializationInfo(...)
end
return nil
end
function DF.GetSpecializationRole (...)
function DF.GetSpecializationRole(...)
if (GetSpecializationRole) then
return GetSpecializationRole (...)
return GetSpecializationRole(...)
end
return nil
end
@@ -283,11 +289,9 @@ DF.SplitBarCounter = DF.SplitBarCounter or init_counter
DF.FRAMELEVEL_OVERLAY = 750
DF.FRAMELEVEL_BACKGROUND = 150
--/dump DetailsFramework:PrintVersion()
DF.FrameWorkVersion = tostring(dversion)
function DF:PrintVersion()
print ("Details! Framework Version:", DF.FrameWorkVersion)
print("Details! Framework Version:", DF.FrameWorkVersion)
end
--get the working folder
@@ -303,10 +307,17 @@ end
DF.debug = false
_G["DetailsFramework"] = DF
function DF:GetFrameworkFolder()
return DF.folder
end
function DF:SetFrameworkDebugState(state)
DF.debug = state
end
DF.embeds = DF.embeds or {}
local embed_functions = {
local embedFunctions = {
"RemoveRealName",
"table",
"BuildDropDownFontList",
@@ -331,7 +342,7 @@ local embed_functions = {
"GetPlayerRole",
"GetCharacterTalents",
"GetCharacterPvPTalents",
"CreateDropDown",
"CreateButton",
"CreateColorPickButton",
@@ -382,14 +393,12 @@ local embed_functions = {
"SendScriptComm",
}
DF.table = {}
function DF:GetFrameworkFolder()
return DF.folder
end
function DF:SetFrameworkDebugState(state)
DF.debug = state
function DF:Embed(target)
for k, v in pairs(embedFunctions) do
target[v] = self[v]
end
self.embeds[target] = true
return target
end
function DF:FadeFrame(frame, t)
@@ -411,6 +420,11 @@ function DF:FadeFrame(frame, t)
end
end
------------------------------------------------------------------------------------------------------------
--table
DF.table = {}
function DF.table.find(t, value)
for i = 1, #t do
if (t[i] == value) then
@@ -686,34 +700,27 @@ function DF:IntegerToTimer(value)
return "" .. floor(value/60) .. ":" .. format("%02.f", value%60)
end
function DF:Embed (target)
for k, v in pairs (embed_functions) do
target[v] = self[v]
end
self.embeds [target] = true
return target
function DF:RemoveRealmName(name)
return name:gsub(("%-.*"), "")
end
function DF:RemoveRealmName (name)
return name:gsub (("%-.*"), "")
function DF:RemoveRealName(name)
return name:gsub(("%-.*"), "")
end
function DF:RemoveRealName (name)
return name:gsub (("%-.*"), "")
function DF:SetFontSize(fontString, ...)
local font, _, flags = fontString:GetFont()
fontString:SetFont(font, max(...), flags)
end
function DF:SetFontSize (fontString, ...)
local fonte, _, flags = fontString:GetFont()
fontString:SetFont (fonte, max (...), flags)
end
function DF:SetFontFace (fontString, fontface)
local font = SharedMedia:Fetch ("font", fontface, true)
function DF:SetFontFace(fontString, fontface)
local font = SharedMedia:Fetch("font", fontface, true)
if (font) then
fontface = font
end
local _, size, flags = fontString:GetFont()
fontString:SetFont (fontface, size, flags)
fontString:SetFont(fontface, size, flags)
end
function DF:SetFontColor (fontString, r, g, b, a)
r, g, b, a = DF:ParseColors (r, g, b, a)
@@ -745,39 +752,38 @@ function DF:SetFontRotation(fontString, degrees)
end
end
function DF:AddClassColorToText (text, class)
if (type (class) ~= "string") then
return DF:RemoveRealName (text)
elseif (class == "UNKNOW" or class == "PET") then
return DF:RemoveRealName (text)
function DF:AddClassColorToText(text, className)
if (type(className) ~= "string") then
return DF:RemoveRealName(text)
elseif (className == "UNKNOW" or className == "PET") then
return DF:RemoveRealName(text)
end
local color = RAID_CLASS_COLORS [class]
local color = RAID_CLASS_COLORS[className]
if (color) then
text = "|c" .. color.colorStr .. DF:RemoveRealName (text) .. "|r"
text = "|c" .. color.colorStr .. DF:RemoveRealName(text) .. "|r"
else
return DF:RemoveRealName (text)
return DF:RemoveRealName(text)
end
return text
end
function DF:GetClassTCoordsAndTexture(class)
local l, r, t, b = unpack(CLASS_ICON_TCOORDS[class])
return l, r, t, b, [[Interface\WORLDSTATEFRAME\Icons-Classes]]
--return l, r, t, b, "Interface\\TargetingFrame\\UI-Classes-Circles"
end
function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize)
local size = iconSize or 16
local iconToUse, spec
local spec
if (useSpec) then
if (Details) then
local guid = UnitGUID(playerName)
if (guid) then
local spec = Details.cached_specs[guid]
local GUID = UnitGUID(playerName)
if (GUID) then
spec = Details.cached_specs[GUID]
if (spec) then
spec = spec
end
@@ -787,7 +793,7 @@ function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize)
if (spec) then --if spec is valid, the user has Details! installed
local specString = ""
local L, R, T, B = unpack (Details.class_specs_coords[spec])
local L, R, T, B = unpack(Details.class_specs_coords[spec])
if (L) then
specString = "|TInterface\\AddOns\\Details\\images\\spec_icons_normal:" .. size .. ":" .. size .. ":0:0:512:512:" .. (L * 512) .. ":" .. (R * 512) .. ":" .. (T * 512) .. ":" .. (B * 512) .. "|t"
return specString .. " " .. text
@@ -796,7 +802,7 @@ function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize)
if (class) then
local classString = ""
local L, R, T, B = unpack (Details.class_coords[class])
local L, R, T, B = unpack(Details.class_coords[class])
if (L) then
local imageSize = 128
classString = "|TInterface\\AddOns\\Details\\images\\classes_small:" .. size .. ":" .. size .. ":0:0:" .. imageSize .. ":" .. imageSize .. ":" .. (L * imageSize) .. ":" .. (R * imageSize) .. ":" .. (T * imageSize) .. ":" .. (B * imageSize) .. "|t"
@@ -807,11 +813,11 @@ function DF:AddClassIconToText(text, playerName, class, useSpec, iconSize)
return text
end
function DF:GetFontSize (fontString)
function DF:GetFontSize(fontString)
local _, size = fontString:GetFont()
return size
end
function DF:GetFontFace (fontString)
function DF:GetFontFace(fontString)
local fontface = fontString:GetFont()
return fontface
end
@@ -822,8 +828,9 @@ local ValidOutlines = {
["OUTLINE"] = true,
["THICKOUTLINE"] = true,
}
function DF:SetFontOutline (fontString, outline)
local fonte, size = fontString:GetFont()
function DF:SetFontOutline(fontString, outline)
local font, fontSize = fontString:GetFont()
if (outline) then
if (type(outline) == "string") then
outline = outline:upper()
@@ -831,27 +838,30 @@ function DF:SetFontOutline (fontString, outline)
if (ValidOutlines[outline]) then
outline = outline
elseif (type(outline) == "boolean" and outline) then
outline = "OUTLINE"
elseif (type(outline) == "boolean" and not outline) then
outline = "NONE"
elseif (outline == 1) then
outline = "OUTLINE"
elseif (outline == 2) then
outline = "THICKOUTLINE"
end
end
fontString:SetFont (fonte, size, outline)
fontString:SetFont(font, fontSize, outline)
end
function DF:Trim (s) --hello name conventions!
return DF:trim (s)
function DF:Trim(string)
return DF:trim(string)
end
function DF:trim (s)
local from = s:match"^%s*()"
return from > #s and "" or s:match(".*%S", from)
function DF:trim(string)
local from = string:match"^%s*()"
return from > #string and "" or string:match(".*%S", from)
end
--truncated revoming at a maximum of 10 character from the string
@@ -876,17 +886,17 @@ function DF:TruncateTextSafe(fontString, maxWidth)
fontString:SetText(text)
end
function DF:TruncateText (fontString, maxWidth)
function DF:TruncateText(fontString, maxWidth)
local text = fontString:GetText()
while (fontString:GetStringWidth() > maxWidth) do
text = strsub (text, 1, #text - 1)
fontString:SetText (text)
if (string.len (text) <= 1) then
text = strsub(text, 1, #text - 1)
fontString:SetText(text)
if (string.len(text) <= 1) then
break
end
end
text = DF:CleanTruncateUTF8String(text)
fontString:SetText (text)
end
@@ -896,20 +906,26 @@ function DF:CleanTruncateUTF8String(text)
local b1 = (#text > 0) and strbyte(strsub(text, #text, #text)) or nil
local b2 = (#text > 1) and strbyte(strsub(text, #text-1, #text)) or nil
local b3 = (#text > 2) and strbyte(strsub(text, #text-2, #text)) or nil
if b1 and b1 >= 194 and b1 <= 244 then
text = strsub (text, 1, #text - 1)
elseif b2 and b2 >= 224 and b2 <= 244 then
text = strsub (text, 1, #text - 2)
elseif b3 and b3 >= 240 and b3 <= 244 then
text = strsub (text, 1, #text - 3)
end
end
return text
end
--DF:TruncateNumber(number, fractionDigits): truncate the amount of numbers used to show fraction.
function DF:TruncateNumber(number, fractionDigits)
fractionDigits = fractionDigits or 2
local truncatedNumber = number
--local truncatedNumber = format("%." .. fractionDigits .. "f", number) --4x slower than:
--http://lua-users.org/wiki/SimpleRound
local mult = 10 ^ fractionDigits
@@ -922,34 +938,30 @@ function DF:TruncateNumber(number, fractionDigits)
return truncatedNumber
end
function DF:Msg (msg, ...)
print ("|cFFFFFFAA" .. (self.__name or "FW Msg:") .. "|r ", msg, ...)
end
function DF:GetNpcIdFromGuid (guid)
local NpcId = select ( 6, strsplit ( "-", guid ) )
if (NpcId) then
return tonumber ( NpcId )
function DF:GetNpcIdFromGuid(GUID)
local npcId = select(6, strsplit("-", GUID ))
if (npcId) then
return tonumber(npcId)
end
return 0
end
function DF.SortOrder1 (t1, t2)
function DF.SortOrder1(t1, t2)
return t1[1] > t2[1]
end
function DF.SortOrder2 (t1, t2)
function DF.SortOrder2(t1, t2)
return t1[2] > t2[2]
end
function DF.SortOrder3 (t1, t2)
function DF.SortOrder3(t1, t2)
return t1[3] > t2[3]
end
function DF.SortOrder1R (t1, t2)
function DF.SortOrder1R(t1, t2)
return t1[1] < t2[1]
end
function DF.SortOrder2R (t1, t2)
function DF.SortOrder2R(t1, t2)
return t1[2] < t2[2]
end
function DF.SortOrder3R (t1, t2)
function DF.SortOrder3R(t1, t2)
return t1[3] < t2[3]
end
@@ -996,232 +1008,226 @@ function DF:GetSpellBookSpells()
return spellNamesInSpellBook, spellIdsInSpellBook
end
------------------------------
------------------------------------------------------------------------------------------------------------------------
--flash animation
local onFinish = function (self)
local onFinishFlashAnimation = function(self)
if (self.showWhenDone) then
self.frame:SetAlpha (1)
self.frame:SetAlpha(1)
else
self.frame:SetAlpha (0)
self.frame:SetAlpha(0)
self.frame:Hide()
end
if (self.onFinishFunc) then
self:onFinishFunc (self.frame)
self:onFinishFunc(self.frame)
end
end
local stop = function (self)
local stopAnimation_Method = function(self)
local FlashAnimation = self.FlashAnimation
FlashAnimation:Stop()
end
local flash = function (self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType)
local FlashAnimation = self.FlashAnimation
local fadeIn = FlashAnimation.fadeIn
local fadeOut = FlashAnimation.fadeOut
local startFlash_Method = function(self, fadeInTime, fadeOutTime, flashDuration, showWhenDone, flashInHoldTime, flashOutHoldTime, loopType)
local flashAnimation = self.FlashAnimation
local fadeIn = flashAnimation.fadeIn
local fadeOut = flashAnimation.fadeOut
fadeIn:Stop()
fadeOut:Stop()
fadeIn:SetDuration (fadeInTime or 1)
fadeIn:SetEndDelay (flashInHoldTime or 0)
fadeOut:SetDuration (fadeOutTime or 1)
fadeOut:SetEndDelay (flashOutHoldTime or 0)
fadeIn:SetDuration(fadeInTime or 1)
fadeIn:SetEndDelay(flashInHoldTime or 0)
fadeOut:SetDuration(fadeOutTime or 1)
fadeOut:SetEndDelay(flashOutHoldTime or 0)
flashAnimation.duration = flashDuration
flashAnimation.loopTime = flashAnimation:GetDuration()
flashAnimation.finishAt = GetTime() + flashDuration
flashAnimation.showWhenDone = showWhenDone
flashAnimation:SetLooping(loopType or "REPEAT")
FlashAnimation.duration = flashDuration
FlashAnimation.loopTime = FlashAnimation:GetDuration()
FlashAnimation.finishAt = GetTime() + flashDuration
FlashAnimation.showWhenDone = showWhenDone
FlashAnimation:SetLooping (loopType or "REPEAT")
self:Show()
self:SetAlpha (0)
FlashAnimation:Play()
self:SetAlpha(0)
flashAnimation:Play()
end
function DF:CreateFlashAnimation (frame, onFinishFunc, onLoopFunc)
local FlashAnimation = frame:CreateAnimationGroup()
FlashAnimation.fadeOut = FlashAnimation:CreateAnimation ("Alpha") --> fade out anime
FlashAnimation.fadeOut:SetOrder (1)
FlashAnimation.fadeOut:SetFromAlpha (0)
FlashAnimation.fadeOut:SetToAlpha (1)
FlashAnimation.fadeIn = FlashAnimation:CreateAnimation ("Alpha") --> fade in anime
FlashAnimation.fadeIn:SetOrder (2)
FlashAnimation.fadeIn:SetFromAlpha (1)
FlashAnimation.fadeIn:SetToAlpha (0)
frame.FlashAnimation = FlashAnimation
FlashAnimation.frame = frame
FlashAnimation.onFinishFunc = onFinishFunc
FlashAnimation:SetScript ("OnLoop", onLoopFunc)
FlashAnimation:SetScript ("OnFinished", onFinish)
frame.Flash = flash
frame.Stop = stop
function DF:CreateFlashAnimation(frame, onFinishFunc, onLoopFunc)
local flashAnimation = frame:CreateAnimationGroup()
flashAnimation.fadeOut = flashAnimation:CreateAnimation("Alpha")
flashAnimation.fadeOut:SetOrder(1)
flashAnimation.fadeOut:SetFromAlpha(0)
flashAnimation.fadeOut:SetToAlpha(1)
flashAnimation.fadeIn = flashAnimation:CreateAnimation("Alpha")
flashAnimation.fadeIn:SetOrder(2)
flashAnimation.fadeIn:SetFromAlpha(1)
flashAnimation.fadeIn:SetToAlpha(0)
frame.FlashAnimation = flashAnimation
flashAnimation.frame = frame
flashAnimation.onFinishFunc = onFinishFunc
flashAnimation:SetScript("OnLoop", onLoopFunc)
flashAnimation:SetScript("OnFinished", onFinishFlashAnimation)
frame.Flash = startFlash_Method
frame.Stop = stopAnimation_Method
return flashAnimation
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> points
--anchoring
function DF:CheckPoints(v1, v2, v3, v4, v5, object)
if (not v1 and not v2) then
function DF:CheckPoints(point1, point2, point3, point4, point5, object)
if (not point1 and not point2) then
return "topleft", object.widget:GetParent(), "topleft", 0, 0
end
if (type(v1) == "string") then
local frameGlobal = _G[v1]
if (type(point1) == "string") then
local frameGlobal = _G[point1]
if (frameGlobal and type(frameGlobal) == "table" and frameGlobal.GetObjectType) then
return DF:CheckPoints(frameGlobal, v2, v3, v4, v5, object)
return DF:CheckPoints(frameGlobal, point2, point3, point4, point5, object)
end
elseif (type(v2) == "string") then
local frameGlobal = _G[v2]
elseif (type(point2) == "string") then
local frameGlobal = _G[point2]
if (frameGlobal and type(frameGlobal) == "table" and frameGlobal.GetObjectType) then
return DF:CheckPoints(v1, frameGlobal, v3, v4, v5, object)
return DF:CheckPoints(point1, frameGlobal, point3, point4, point5, object)
end
end
if (type(v1) == "string" and type(v2) == "table") then --setpoint("left", frame, _, _, _)
if (not v3 or type(v3) == "number") then --setpoint("left", frame, 10, 10)
v1, v2, v3, v4, v5 = v1, v2, v1, v3, v4
if (type(point1) == "string" and type(point2) == "table") then --setpoint("left", frame, _, _, _)
if (not point3 or type(point3) == "number") then --setpoint("left", frame, 10, 10)
point1, point2, point3, point4, point5 = point1, point2, point1, point3, point4
end
elseif (type(v1) == "string" and type(v2) == "number") then --setpoint("topleft", x, y)
v1, v2, v3, v4, v5 = v1, object.widget:GetParent(), v1, v2, v3
elseif (type(point1) == "string" and type(point2) == "number") then --setpoint("topleft", x, y)
point1, point2, point3, point4, point5 = point1, object.widget:GetParent(), point1, point2, point3
elseif (type(v1) == "number") then --setpoint(x, y)
v1, v2, v3, v4, v5 = "topleft", object.widget:GetParent(), "topleft", v1, v2
elseif (type(point1) == "number") then --setpoint(x, y)
point1, point2, point3, point4, point5 = "topleft", object.widget:GetParent(), "topleft", point1, point2
elseif (type(v1) == "table") then --setpoint(frame, x, y)
v1, v2, v3, v4, v5 = "topleft", v1, "topleft", v2, v3
elseif (type(point1) == "table") then --setpoint(frame, x, y)
point1, point2, point3, point4, point5 = "topleft", point1, "topleft", point2, point3
end
if (not v2) then
v2 = object.widget:GetParent()
elseif (v2.dframework) then
v2 = v2.widget
if (not point2) then
point2 = object.widget:GetParent()
elseif (point2.dframework) then
point2 = point2.widget
end
return v1 or "topleft", v2, v3 or "topleft", v4 or 0, v5 or 0
return point1 or "topleft", point2, point3 or "topleft", point4 or 0, point5 or 0
end
local anchoring_functions = {
function (frame, anchorTo, offSetX, offSetY) --> 1 TOP LEFT
local anchoringFunctions = {
function(frame, anchorTo, offSetX, offSetY) --1 TOP LEFT
frame:ClearAllPoints()
frame:SetPoint ("bottomleft", anchorTo, "topleft", offSetX, offSetY)
frame:SetPoint("bottomleft", anchorTo, "topleft", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 2 LEFT
function(frame, anchorTo, offSetX, offSetY) --2 LEFT
frame:ClearAllPoints()
frame:SetPoint ("right", anchorTo, "left", offSetX, offSetY)
frame:SetPoint("right", anchorTo, "left", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 3 BOTTOM LEFT
function(frame, anchorTo, offSetX, offSetY) --3 BOTTOM LEFT
frame:ClearAllPoints()
frame:SetPoint ("topleft", anchorTo, "bottomleft", offSetX, offSetY)
frame:SetPoint("topleft", anchorTo, "bottomleft", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 4 BOTTOM
function(frame, anchorTo, offSetX, offSetY) --4 BOTTOM
frame:ClearAllPoints()
frame:SetPoint ("top", anchorTo, "bottom", offSetX, offSetY)
frame:SetPoint("top", anchorTo, "bottom", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 5 BOTTOM RIGHT
function(frame, anchorTo, offSetX, offSetY) --5 BOTTOM RIGHT
frame:ClearAllPoints()
frame:SetPoint ("topright", anchorTo, "bottomright", offSetX, offSetY)
frame:SetPoint("topright", anchorTo, "bottomright", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 6 RIGHT
function(frame, anchorTo, offSetX, offSetY) --6 RIGHT
frame:ClearAllPoints()
frame:SetPoint ("left", anchorTo, "right", offSetX, offSetY)
frame:SetPoint("left", anchorTo, "right", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 7 TOP RIGHT
function(frame, anchorTo, offSetX, offSetY) --7 TOP RIGHT
frame:ClearAllPoints()
frame:SetPoint ("bottomright", anchorTo, "topright", offSetX, offSetY)
frame:SetPoint("bottomright", anchorTo, "topright", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 8 TOP
function(frame, anchorTo, offSetX, offSetY) --8 TOP
frame:ClearAllPoints()
frame:SetPoint ("bottom", anchorTo, "top", offSetX, offSetY)
frame:SetPoint("bottom", anchorTo, "top", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 9 CENTER
function(frame, anchorTo, offSetX, offSetY) --9 CENTER
frame:ClearAllPoints()
frame:SetPoint ("center", anchorTo, "center", offSetX, offSetY)
frame:SetPoint("center", anchorTo, "center", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 10
function(frame, anchorTo, offSetX, offSetY) --10
frame:ClearAllPoints()
frame:SetPoint ("left", anchorTo, "left", offSetX, offSetY)
frame:SetPoint("left", anchorTo, "left", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 11
function(frame, anchorTo, offSetX, offSetY) --11
frame:ClearAllPoints()
frame:SetPoint ("right", anchorTo, "right", offSetX, offSetY)
frame:SetPoint("right", anchorTo, "right", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 12
function(frame, anchorTo, offSetX, offSetY) --12
frame:ClearAllPoints()
frame:SetPoint ("top", anchorTo, "top", offSetX, offSetY)
frame:SetPoint("top", anchorTo, "top", offSetX, offSetY)
end,
function (frame, anchorTo, offSetX, offSetY) --> 13
function(frame, anchorTo, offSetX, offSetY) --13
frame:ClearAllPoints()
frame:SetPoint ("bottom", anchorTo, "bottom", offSetX, offSetY)
frame:SetPoint("bottom", anchorTo, "bottom", offSetX, offSetY)
end
}
function DF:SetAnchor (widget, config, anchorTo)
function DF:SetAnchor(widget, config, anchorTo)
anchorTo = anchorTo or widget:GetParent()
anchoring_functions [config.side] (widget, anchorTo, config.x, config.y)
end
anchoringFunctions[config.side](widget, anchorTo, config.x, config.y)
end
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> colors
--colors
function DF:NewColor (_colorname, _colortable, _green, _blue, _alpha)
assert (type (_colorname) == "string", "NewColor: colorname must be a string.")
assert (not DF.alias_text_colors [_colorname], "NewColor: colorname already exists.")
--add a new color name, the color can be query using DetailsFramework:ParseColors(colorName)
function DF:NewColor(colorName, red, green, blue, alpha)
assert(type(colorName) == "string", "DetailsFramework:NewColor(): colorName must be a string.")
assert(not DF.alias_text_colors[colorName], "DetailsFramework:NewColor(): colorName already exists.")
if (type (_colortable) == "table") then
if (_colortable[1] and _colortable[2] and _colortable[3]) then
_colortable[4] = _colortable[4] or 1
DF.alias_text_colors [_colorname] = _colortable
else
error ("invalid color table.")
end
elseif (_colortable and _green and _blue) then
_alpha = _alpha or 1
DF.alias_text_colors [_colorname] = {_colortable, _green, _blue, _alpha}
else
error ("invalid parameter.")
end
return true
red, green, blue, alpha = DetailsFramework:ParseColors(red, green, blue, alpha)
local colorTable = DetailsFramework:FormatColor("table", red, green, blue, alpha)
DF.alias_text_colors[colorName] = colorTable
return colorTable
end
local colorTableMixin = {
GetColor = function (self)
GetColor = function(self)
return self.r, self.g, self.b, self.a
end,
SetColor = function (self, r, g, b, a)
r, g, b, a = DF:ParseColors (r, g, b, a)
SetColor = function(self, r, g, b, a)
r, g, b, a = DF:ParseColors(r, g, b, a)
self.r = r or self.r
self.g = g or self.g
self.b = b or self.b
self.a = a or self.a
end,
IsColorTable = true,
}
@@ -1255,22 +1261,22 @@ end
end
end
function DF:CreateColorTable (r, g, b, a)
function DF:CreateColorTable(r, g, b, a)
local t = {
r = r or 1,
g = g or 1,
b = b or 1,
r = r or 1,
g = g or 1,
b = b or 1,
a = a or 1,
}
DF:Mixin (t, colorTableMixin)
DF:Mixin(t, colorTableMixin)
return t
end
function DF:IsHtmlColor (color)
return DF.alias_text_colors [color]
function DF:IsHtmlColor(color)
return DF.alias_text_colors[color]
end
function DF:ParseColors (red, green, blue, alpha)
function DF:ParseColors(red, green, blue, alpha)
local firstParameter = red
--the first value passed is a table?
@@ -1569,6 +1575,7 @@ end
--dropdowns
elseif (widgetTable.type == "select" or widgetTable.type == "dropdown") then
assert(widgetTable.get, "DetailsFramework:BuildMenu(): .get not found in the widget table for 'select'")
local dropdown = getMenuWidgetVolative(parent, "dropdown", widgetIndexes)
widgetCreated = dropdown
@@ -1577,7 +1584,7 @@ end
dropdown:Select(widgetTable.get())
dropdown:SetTemplate(dropdownTemplate)
dropdown.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)
dropdown:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId))
dropdown._get = widgetTable.get
dropdown.widget_type = "select"
@@ -1619,7 +1626,7 @@ end
switch:SetTemplate(switchTemplate)
switch:SetAsCheckBox() --it's always a checkbox on volatile menu
switch.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)
switch:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId))
switch._get = widgetTable.get
switch.widget_type = "toggle"
switch.OnSwitch = widgetTable.set
@@ -1683,7 +1690,7 @@ end
slider:SetTemplate(sliderTemplate)
slider.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)
slider:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId))
slider._get = widgetTable.get
slider.widget_type = "range"
slider:SetHook("OnValueChange", widgetTable.set)
@@ -1729,7 +1736,7 @@ end
colorpick:SetTemplate(buttonTemplate)
colorpick:SetSize(18, 18)
colorpick.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)
colorpick:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId))
colorpick._get = widgetTable.get
colorpick.widget_type = "color"
@@ -1800,7 +1807,7 @@ end
button:SetPoint(currentXOffset, currentYOffset)
end
button.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)
button:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId))
button.widget_type = "execute"
--hook list
@@ -1835,7 +1842,7 @@ end
textentry:SetTemplate(widgetTable.template or widgetTable.button_template or buttonTemplate)
textentry:SetSize(widgetTable.width or 120, widgetTable.height or 18)
textentry.tooltip = (languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId)
textentry:SetTooltip((languageTable and languageTable[widgetTable.namePhraseId]) or (widgetTable.desc) or (widgetTable.namePhraseId))
textentry.text = widgetTable.get()
textentry._get = widgetTable.get
textentry.widget_type = "textentry"
@@ -1962,7 +1969,7 @@ end
if (widgetTable.namePhraseId) then
DetailsFramework.Language.RegisterFontString(languageAddonId, label.widget, widgetTable.namePhraseId)
else
local textToSet = widgetTable.get() or widgetTable.text or ""
local textToSet = (widgetTable.get and widgetTable.get()) or widgetTable.text or ""
label:SetText(textToSet)
end
@@ -1977,14 +1984,17 @@ end
end
elseif (widgetTable.type == "select") then
assert(widgetTable.get, "DetailsFramework:BuildMenu(): .get not found in the widget table for 'select'")
local dropdown = DF:NewDropDown(parent, nil, "$parentWidget" .. index, nil, 140, 18, widgetTable.values, widgetTable.get(), dropdownTemplate)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, dropdown, "tooltip", widgetTable.descPhraseId, widgetTable.desc)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, dropdown, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc)
dropdown._get = widgetTable.get
dropdown.widget_type = "select"
local label = DF:NewLabel(parent, nil, "$parentLabel" .. index, nil, widgetTable.name .. (useColon and ": " or ""), "GameFontNormal", widgetTable.text_template or textTemplate or 12)
local label = DF:NewLabel(parent, nil, "$parentLabel" .. index, nil, "", "GameFontNormal", widgetTable.text_template or textTemplate or 12)
DetailsFramework.Language.RegisterObjectWithDefault(languageAddonId, label.widget, widgetTable.namePhraseId, formatOptionNameWithColon(widgetTable.name, useColon))
dropdown:SetPoint("left", label, "right", 2)
label:SetPoint(currentXOffset, currentYOffset)
dropdown.hasLabel = label
@@ -2020,7 +2030,7 @@ end
elseif (widgetTable.type == "toggle") then
local switch = DF:NewSwitch(parent, nil, "$parentWidget" .. index, nil, 60, 20, nil, nil, widgetTable.get(), nil, nil, nil, nil, switchTemplate)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, switch, "tooltip", widgetTable.descPhraseId, widgetTable.desc)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, switch, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc)
switch._get = widgetTable.get
switch.widget_type = "toggle"
@@ -2084,10 +2094,11 @@ end
amountLineWidgetCreated = amountLineWidgetCreated + 1
elseif (widgetTable.type == "range") then
assert(widgetTable.get, "DetailsFramework:BuildMenu(): .get not found in the widget table for 'range'")
local isDecimanls = widgetTable.usedecimals
local slider = DF:NewSlider(parent, nil, "$parentWidget" .. index, nil, 140, 20, widgetTable.min, widgetTable.max, widgetTable.step, widgetTable.get(), isDecimanls, nil, nil, sliderTemplate)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, slider, "tooltip", widgetTable.descPhraseId, widgetTable.desc)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, slider, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc)
slider._get = widgetTable.get
slider.widget_type = "range"
@@ -2134,9 +2145,10 @@ end
amountLineWidgetCreated = amountLineWidgetCreated + 1
elseif (widgetTable.type == "color") then
assert(widgetTable.get, "DetailsFramework:BuildMenu(): .get not found in the widget table for 'color'")
local colorpick = DF:NewColorPickButton(parent, "$parentWidget" .. index, nil, widgetTable.set, nil, buttonTemplate)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, colorpick, "tooltip", widgetTable.descPhraseId, widgetTable.desc)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, colorpick, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc)
colorpick._get = widgetTable.get
colorpick.widget_type = "color"
@@ -2206,7 +2218,7 @@ end
button:SetPoint(currentXOffset, currentYOffset)
end
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, button, "tooltip", widgetTable.descPhraseId, widgetTable.desc)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, button, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc)
button.widget_type = "execute"
@@ -2248,7 +2260,7 @@ end
elseif (widgetTable.type == "textentry") then
local textentry = DF:CreateTextEntry(parent, widgetTable.func or widgetTable.set, 120, 18, nil, "$parentWidget" .. index, nil, buttonTemplate)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, textentry, "tooltip", widgetTable.descPhraseId, widgetTable.desc)
DetailsFramework.Language.RegisterTableKeyWithDefault(languageAddonId, textentry, "have_tooltip", widgetTable.descPhraseId, widgetTable.desc)
textentry.text = widgetTable.get()
textentry._get = widgetTable.get
+63 -64
View File
@@ -12,7 +12,6 @@ do
WidgetType = "label",
SetHook = detailsFramework.SetHook,
RunHooksForWidget = detailsFramework.RunHooksForWidget,
dversion = detailsFramework.dversion,
}
@@ -215,21 +214,22 @@ detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.SetPointMixin)
end
------------------------------------------------------------------------------------------------------------
--> methods
--methods
--text text
--text text
function LabelMetaFunctions:SetTextTruncated(text, maxWidth)
self.widget:SetText(text)
detailsFramework:TruncateText(self.widget, maxWidth)
end
--textcolor
--textcolor
function LabelMetaFunctions:SetTextColor(r, g, b, a)
r, g, b, a = detailsFramework:ParseColors(r, g, b, a)
return self.label:SetTextColor(r, g, b, a)
end
------------------------------------------------------------------------------------------------------------
--template
function LabelMetaFunctions:SetTemplate(template)
if (template.size) then
@@ -247,84 +247,83 @@ detailsFramework:Mixin(LabelMetaFunctions, detailsFramework.SetPointMixin)
end
------------------------------------------------------------------------------------------------------------
--> object constructor
function detailsFramework:CreateLabel(parent, text, size, color, font, member, name, layer)
return detailsFramework:NewLabel(parent, nil, name, member, text, font, size, color, layer)
end
--object constructor
function detailsFramework:NewLabel(parent, container, name, member, text, font, size, color, layer)
if (not parent) then
return error("Details! Framework: parent not found.", 2)
end
if (not container) then
container = parent
function detailsFramework:CreateLabel(parent, text, size, color, font, member, name, layer)
return detailsFramework:NewLabel(parent, nil, name, member, text, font, size, color, layer)
end
if (not name) then
name = "DetailsFrameworkLabelNumber" .. detailsFramework.LabelNameCounter
detailsFramework.LabelNameCounter = detailsFramework.LabelNameCounter + 1
end
function detailsFramework:NewLabel(parent, container, name, member, text, font, size, color, layer)
if (not parent) then
return error("Details! Framework: parent not found.", 2)
end
if (not container) then
container = parent
end
if (name:find("$parent")) then
local parentName = detailsFramework.GetParentName(parent)
name = name:gsub("$parent", parentName)
end
if (not name) then
name = "DetailsFrameworkLabelNumber" .. detailsFramework.LabelNameCounter
detailsFramework.LabelNameCounter = detailsFramework.LabelNameCounter + 1
end
local LabelObject = {type = "label", dframework = true}
if (name:find("$parent")) then
local parentName = detailsFramework.GetParentName(parent)
name = name:gsub("$parent", parentName)
end
if (member) then
parent[member] = LabelObject
end
local labelObject = {type = "label", dframework = true}
if (parent.dframework) then
parent = parent.widget
end
if (member) then
parent[member] = labelObject
end
if (container.dframework) then
container = container.widget
end
if (parent.dframework) then
parent = parent.widget
end
font = font == "" and "GameFontHighlightSmall" or font or "GameFontHighlightSmall"
if (container.dframework) then
container = container.widget
end
LabelObject.label = parent:CreateFontString(name, layer or "OVERLAY", font)
LabelObject.widget = LabelObject.label
LabelObject.label.MyObject = LabelObject
font = font == "" and "GameFontHighlightSmall" or font or "GameFontHighlightSmall"
if (not loadedAPILabelFunctions) then
loadedAPILabelFunctions = true
local idx = getmetatable(LabelObject.label).__index
for funcName, funcAddress in pairs(idx) do
if (not LabelMetaFunctions[funcName]) then
LabelMetaFunctions[funcName] = function (object, ...)
local x = loadstring( "return _G['"..object.label:GetName().."']:"..funcName.."(...)")
return x(...)
labelObject.label = parent:CreateFontString(name, layer or "OVERLAY", font)
labelObject.widget = labelObject.label
labelObject.label.MyObject = labelObject
if (not loadedAPILabelFunctions) then
loadedAPILabelFunctions = true
local idx = getmetatable(labelObject.label).__index
for funcName, funcAddress in pairs(idx) do
if (not LabelMetaFunctions[funcName]) then
LabelMetaFunctions[funcName] = function (object, ...)
local x = loadstring( "return _G['"..object.label:GetName().."']:"..funcName.."(...)")
return x(...)
end
end
end
end
end
LabelObject.label:SetText(text)
labelObject.label:SetText(text)
labelObject.label:SetJustifyH("left")
if (color) then
local r, g, b, a = detailsFramework:ParseColors(color)
LabelObject.label:SetTextColor(r, g, b, a)
end
if (color) then
local r, g, b, a = detailsFramework:ParseColors(color)
labelObject.label:SetTextColor(r, g, b, a)
end
if (size and type(size) == "number") then
detailsFramework:SetFontSize(LabelObject.label, size)
end
if (size and type(size) == "number") then
detailsFramework:SetFontSize(labelObject.label, size)
end
LabelObject.HookList = {
}
labelObject.HookList = {}
LabelObject.label:SetJustifyH("LEFT")
setmetatable(labelObject, LabelMetaFunctions)
setmetatable(LabelObject, LabelMetaFunctions)
--if template has been passed as the third parameter
if (size and type(size) == "table") then
labelObject:SetTemplate(size)
end
--if template has been passed as the third parameter
if (size and type(size) == "table") then
LabelObject:SetTemplate(size)
end
return LabelObject
end
return labelObject
end
+41
View File
@@ -89,6 +89,47 @@ local doublePoint = {
["left-right"] = true,
}
detailsFramework.FrameMixin = {
SetFrameStrata = function(self, strata)
if (type(strata) == "table" and strata.GetObjectType) then
local UIObject = strata
self.widget:SetFrameStrata(UIObject:GetFrameStrata())
else
self.widget:SetFrameStrata(strata)
end
end,
SetFrameLevel = function(self, level, UIObject)
if (not UIObject) then
return self.widget:SetFrameLevel(level)
else
local framelevel = UIObject:GetFrameLevel(UIObject) + level
return self.widget:SetFrameLevel(framelevel)
end
end,
SetBackdrop = function(self, ...)
return self.widget:SetBackdrop(...)
end,
SetBackdropColor = function(self, ...)
return self.widget:SetBackdropColor(...)
end,
SetBackdropBorderColor = function(self, ...)
return self.widget:SetBackdropBorderColor(...)
end,
SetSize = function(self, width, height)
if (width) then
self.widget:SetWidth(width)
end
if (height) then
return self.widget:SetHeight(height)
end
end
}
detailsFramework.SetPointMixin = {
SetPoint = function(object, anchorName1, anchorObject, anchorName2, xOffset, yOffset)
if (doublePoint[anchorName1]) then
+11 -13
View File
@@ -5,7 +5,6 @@ if (not detailsFramework or not DetailsFrameworkCanLoad) then
end
local _
local loadstring = loadstring
local APIImageFunctions = false
do
@@ -13,7 +12,6 @@ do
WidgetType = "image",
SetHook = detailsFramework.SetHook,
RunHooksForWidget = detailsFramework.RunHooksForWidget,
dversion = detailsFramework.dversion,
}
@@ -116,12 +114,12 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin)
--texture
local smember_texture = function(object, value)
if (type(value) == "table") then
local r, g, b, a = detailsFramework:ParseColors(value)
object.image:SetTexture(r, g, b, a or 1)
local red, green, blue, alpha = detailsFramework:ParseColors(value)
object.image:SetTexture(red, green, blue, alpha)
else
if (detailsFramework:IsHtmlColor(value)) then
local r, g, b, a = detailsFramework:ParseColors(value)
object.image:SetTexture(r, g, b, a or 1)
local red, green, blue, alpha = detailsFramework:ParseColors(value)
object.image:SetTexture(red, green, blue, alpha)
else
object.image:SetTexture(value)
end
@@ -145,14 +143,14 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin)
--color
local smember_color = function(object, value)
local r, g, b, a = detailsFramework:ParseColors(value)
object.image:SetColorTexture(r, g, b, a or 1)
local red, green, blue, alpha = detailsFramework:ParseColors(value)
object.image:SetColorTexture(red, green, blue, alpha)
end
--vertex color
local smember_vertexcolor = function(object, value)
local r, g, b, a = detailsFramework:ParseColors(value)
object.image:SetVertexColor(r, g, b, a or 1)
local red, green, blue, alpha = detailsFramework:ParseColors(value)
object.image:SetVertexColor(red, green, blue, alpha)
end
--desaturated
@@ -248,7 +246,7 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin)
function detailsFramework:NewImage(parent, texture, width, height, layer, texCoord, member, name)
if (not parent) then
return error("Details! FrameWork: parent not found.", 2)
return error("DetailsFrameWork: NewImage() parent not found.", 2)
end
if (not name) then
@@ -273,7 +271,7 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin)
texture = texture or ""
ImageObject.image = parent:CreateTexture(name, layer or "OVERLAY")
ImageObject.image = parent:CreateTexture(name, layer or "overlay")
ImageObject.widget = ImageObject.image
detailsFramework:Mixin(ImageObject.image, detailsFramework.WidgetFunctions)
@@ -346,4 +344,4 @@ detailsFramework:Mixin(ImageMetaFunctions, detailsFramework.SetPointMixin)
setmetatable(ImageObject, ImageMetaFunctions)
return ImageObject
end
end
+157 -159
View File
@@ -1,235 +1,233 @@
local DF = _G ["DetailsFramework"]
--note: this scroll bar is using legacy code and shouldn't be used on creating new stuff
local DF = _G["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
return
return
end
function DF:CreateScrollBar (master, slave, x, y)
return DF:NewScrollBar (master, slave, x, y)
function DF:CreateScrollBar(master, scrollContainer, x, y)
return DF:NewScrollBar(master, scrollContainer, x, y)
end
function DF:NewScrollBar (master, slave, x, y)
function DF:NewScrollBar(parent, scrollContainer, x, y)
local newSlider = CreateFrame("Slider", nil, parent, "BackdropTemplate")
newSlider.scrollMax = 560
local new_slider = CreateFrame ("Slider", nil, master,"BackdropTemplate")
new_slider.scrollMax = 560 --default - tamanho da janela de fundo
newSlider:SetPoint("TOPLEFT", parent, "TOPRIGHT", x, y)
newSlider.ativo = true
-- ///// SLIDER /////
new_slider:SetPoint ("TOPLEFT", master, "TOPRIGHT", x, y)
new_slider.ativo = true
new_slider.bg = new_slider:CreateTexture (nil, "BACKGROUND")
new_slider.bg:SetAllPoints (true)
new_slider.bg:SetTexture (0, 0, 0, 0)
--coisinha do meio
new_slider.thumb = new_slider:CreateTexture (nil, "OVERLAY")
new_slider.thumb:SetTexture ("Interface\\Buttons\\UI-ScrollBar-Knob")
new_slider.thumb:SetSize (29, 30)
new_slider:SetThumbTexture (new_slider.thumb)
new_slider:SetOrientation ("VERTICAL")
new_slider:SetSize(16, 100)
new_slider:SetMinMaxValues(0, new_slider.scrollMax)
new_slider:SetValue(0)
new_slider.ultimo = 0
newSlider.bg = newSlider:CreateTexture(nil, "BACKGROUND")
newSlider.bg:SetAllPoints(true)
newSlider.bg:SetTexture(0, 0, 0, 0)
local botao_cima = CreateFrame ("Button", nil, master,"BackdropTemplate")
botao_cima:SetPoint ("BOTTOM", new_slider, "TOP", 0, -12)
botao_cima.x = 0
botao_cima.y = -12
botao_cima:SetWidth (29)
botao_cima:SetHeight (32)
botao_cima:SetNormalTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Up")
botao_cima:SetPushedTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Down")
botao_cima:SetDisabledTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Disabled")
botao_cima:Show()
botao_cima:Disable()
local botao_baixo = CreateFrame ("Button", nil, master,"BackdropTemplate")
botao_baixo:SetPoint ("TOP", new_slider, "BOTTOM", 0, 12)
botao_baixo.x = 0
botao_baixo.y = 12
botao_baixo:SetWidth (29)
botao_baixo:SetHeight (32)
botao_baixo:SetNormalTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Up")
botao_baixo:SetPushedTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Down")
botao_baixo:SetDisabledTexture ("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Disabled")
botao_baixo:Show()
botao_baixo:Disable()
newSlider.thumb = newSlider:CreateTexture(nil, "OVERLAY")
newSlider.thumb:SetTexture("Interface\\Buttons\\UI-ScrollBar-Knob")
newSlider.thumb:SetSize(29, 30)
newSlider:SetThumbTexture(newSlider.thumb)
newSlider:SetOrientation("VERTICAL")
newSlider:SetSize(16, 100)
newSlider:SetMinMaxValues(0, newSlider.scrollMax)
newSlider:SetValue(0)
newSlider.ultimo = 0
master.baixo = botao_baixo
master.cima = botao_cima
master.slider = new_slider
botao_baixo:SetScript ("OnMouseDown", function(self)
if (not new_slider:IsEnabled()) then
local upButton = CreateFrame("Button", nil, parent,"BackdropTemplate")
upButton:SetPoint("BOTTOM", newSlider, "TOP", 0, -12)
upButton.x = 0
upButton.y = -12
upButton:SetWidth(29)
upButton:SetHeight(32)
upButton:SetNormalTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Up")
upButton:SetPushedTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Down")
upButton:SetDisabledTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollUpButton-Disabled")
upButton:Show()
upButton:Disable()
local downDutton = CreateFrame("Button", nil, parent,"BackdropTemplate")
downDutton:SetPoint("TOP", newSlider, "BOTTOM", 0, 12)
downDutton.x = 0
downDutton.y = 12
downDutton:SetWidth(29)
downDutton:SetHeight(32)
downDutton:SetNormalTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Up")
downDutton:SetPushedTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Down")
downDutton:SetDisabledTexture("Interface\\BUTTONS\\UI-ScrollBar-ScrollDownButton-Disabled")
downDutton:Show()
downDutton:Disable()
parent.baixo = downDutton
parent.cima = upButton
parent.slider = newSlider
downDutton:SetScript("OnMouseDown", function(self)
if (not newSlider:IsEnabled()) then
return
end
local current = new_slider:GetValue()
local minValue, maxValue = new_slider:GetMinMaxValues()
if (current+5 < maxValue) then
new_slider:SetValue (current+5)
local current = newSlider:GetValue()
local minValue, maxValue = newSlider:GetMinMaxValues()
if (current + 5 < maxValue) then
newSlider:SetValue(current + 5)
else
new_slider:SetValue (maxValue)
newSlider:SetValue(maxValue)
end
self.precionado = true
self.last_up = -0.3
self:SetScript ("OnUpdate", function(self, elapsed)
self:SetScript("OnUpdate", function(self, elapsed)
self.last_up = self.last_up + elapsed
if (self.last_up > 0.03) then
self.last_up = 0
local current = new_slider:GetValue()
local minValue, maxValue = new_slider:GetMinMaxValues()
if (current+2 < maxValue) then
new_slider:SetValue (current+2)
local current = newSlider:GetValue()
local minValue, maxValue = newSlider:GetMinMaxValues()
if (current + 2 < maxValue) then
newSlider:SetValue(current + 2)
else
new_slider:SetValue (maxValue)
newSlider:SetValue(maxValue)
end
end
end)
end)
botao_baixo:SetScript ("OnMouseUp", function(self)
downDutton:SetScript("OnMouseUp", function(self)
self.precionado = false
self:SetScript ("OnUpdate", nil)
end)
botao_cima:SetScript ("OnMouseDown", function(self)
if (not new_slider:IsEnabled()) then
self:SetScript("OnUpdate", nil)
end)
upButton:SetScript("OnMouseDown", function(self)
if (not newSlider:IsEnabled()) then
return
end
local current = new_slider:GetValue()
if (current-5 > 0) then
new_slider:SetValue (current-5)
local current = newSlider:GetValue()
if (current - 5 > 0) then
newSlider:SetValue(current - 5)
else
new_slider:SetValue (0)
end
newSlider:SetValue(0)
end
self.precionado = true
self.last_up = -0.3
self:SetScript ("OnUpdate", function(self, elapsed)
self:SetScript("OnUpdate", function(self, elapsed)
self.last_up = self.last_up + elapsed
if (self.last_up > 0.03) then
self.last_up = 0
local current = new_slider:GetValue()
if (current-2 > 0) then
new_slider:SetValue (current-2)
local current = newSlider:GetValue()
if (current - 2 > 0) then
newSlider:SetValue(current - 2)
else
new_slider:SetValue (0)
newSlider:SetValue(0)
end
end
end)
end)
botao_cima:SetScript ("OnMouseUp", function(self)
upButton:SetScript("OnMouseUp", function(self)
self.precionado = false
self:SetScript ("OnUpdate", nil)
self:SetScript("OnUpdate", nil)
end)
--> isso aqui pra quando o slider ativar, o scroll fica na posio zero
botao_cima:SetScript ("OnEnable", function (self)
local current = new_slider:GetValue()
upButton:SetScript("OnEnable", function(self)
local current = newSlider:GetValue()
if (current == 0) then
botao_cima:Disable()
upButton:Disable()
end
end)
new_slider:SetScript ("OnValueChanged", function (self)
newSlider:SetScript("OnValueChanged", function(self)
local current = self:GetValue()
master:SetVerticalScroll (current)
local minValue, maxValue = new_slider:GetMinMaxValues()
parent:SetVerticalScroll(current)
local minValue, maxValue = newSlider:GetMinMaxValues()
if (current == minValue) then
botao_cima:Disable()
elseif (not botao_cima:IsEnabled()) then
botao_cima:Enable()
upButton:Disable()
elseif (not upButton:IsEnabled()) then
upButton:Enable()
end
if (current == maxValue) then
botao_baixo:Disable()
elseif (not botao_baixo:IsEnabled()) then
botao_baixo:Enable()
downDutton:Disable()
elseif (not downDutton:IsEnabled()) then
downDutton:Enable()
end
end)
new_slider:SetScript ("OnShow", function (self)
botao_cima:Show()
botao_baixo:Show()
newSlider:SetScript("OnShow", function(self)
upButton:Show()
downDutton:Show()
end)
new_slider:SetScript ("OnDisable", function (self)
botao_cima:Disable()
botao_baixo:Disable()
newSlider:SetScript("OnDisable", function(self)
upButton:Disable()
downDutton:Disable()
end)
new_slider:SetScript ("OnEnable", function (self)
botao_cima:Enable()
botao_baixo:Enable()
newSlider:SetScript("OnEnable", function(self)
upButton:Enable()
downDutton:Enable()
end)
master:SetScript ("OnMouseWheel", function (self, delta)
if (not new_slider:IsEnabled()) then
parent:SetScript("OnMouseWheel", function(self, delta)
if (not newSlider:IsEnabled()) then
return
end
local current = new_slider:GetValue()
if (delta < 0) then
--baixo
local minValue, maxValue = new_slider:GetMinMaxValues()
if (current + (master.wheel_jump or 20) < maxValue) then
new_slider:SetValue (current + (master.wheel_jump or 20))
local current = newSlider:GetValue()
if (delta < 0) then
local minValue, maxValue = newSlider:GetMinMaxValues()
if (current + (parent.wheel_jump or 20) < maxValue) then
newSlider:SetValue(current + (parent.wheel_jump or 20))
else
new_slider:SetValue (maxValue)
newSlider:SetValue(maxValue)
end
elseif (delta > 0) then
--cima
if (current + (master.wheel_jump or 20) > 0) then
new_slider:SetValue (current - (master.wheel_jump or 20))
if (current + (parent.wheel_jump or 20) > 0) then
newSlider:SetValue(current - (parent.wheel_jump or 20))
else
new_slider:SetValue (0)
newSlider:SetValue(0)
end
end
end)
function new_slider:Altura (h)
self:SetHeight (h)
function newSlider:Altura(height)
self:SetHeight(height)
end
function new_slider:Update (desativar)
function newSlider:Update(desativar)
if (desativar) then
new_slider:Disable()
new_slider:SetValue(0)
new_slider.ativo = false
master:EnableMouseWheel (false)
newSlider:Disable()
newSlider:SetValue(0)
newSlider.ativo = false
parent:EnableMouseWheel(false)
return
end
self.scrollMax = slave:GetHeight()-master:GetHeight()
self.scrollMax = scrollContainer:GetHeight() - parent:GetHeight()
if (self.scrollMax > 0) then
new_slider:SetMinMaxValues (0, self.scrollMax)
if (not new_slider.ativo) then
new_slider:Enable()
new_slider.ativo = true
master:EnableMouseWheel (true)
newSlider:SetMinMaxValues(0, self.scrollMax)
if (not newSlider.ativo) then
newSlider:Enable()
newSlider.ativo = true
parent:EnableMouseWheel(true)
end
else
new_slider:Disable()
new_slider:SetValue(0)
new_slider.ativo = false
master:EnableMouseWheel (false)
newSlider:Disable()
newSlider:SetValue(0)
newSlider.ativo = false
parent:EnableMouseWheel(false)
end
end
function new_slider:cimaPoint (x, y)
botao_cima:SetPoint ("BOTTOM", new_slider, "TOP", x, (y)-12)
function newSlider:cimaPoint(x, y)
upButton:SetPoint("BOTTOM", newSlider, "TOP", x, y - 12)
end
function new_slider:baixoPoint (x, y)
botao_baixo:SetPoint ("TOP", new_slider, "BOTTOM", x, (y)+12)
function newSlider:baixoPoint(x, y)
downDutton:SetPoint("TOP", newSlider, "BOTTOM", x, y + 12)
end
return new_slider
return newSlider
end
+183 -248
View File
@@ -1,21 +1,10 @@
local DF = _G ["DetailsFramework"]
local DF = _G["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
return
return
end
local _
local _rawset = rawset --> lua local
local _rawget = rawget --> lua local
local _setmetatable = setmetatable --> lua local
local _unpack = unpack --> lua local
local _type = type --> lua local
local _math_floor = math.floor --> lua local
local loadstring = loadstring --> lua local
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
local cleanfunction = function() end
local APISliderFunctions = false
do
@@ -25,14 +14,13 @@ do
HasHook = DF.HasHook,
ClearHooks = DF.ClearHooks,
RunHooksForWidget = DF.RunHooksForWidget,
dversion = DF.dversion
}
--check if there's a metaPrototype already existing
if (_G[DF.GlobalWidgetControlNames["slider"]]) then
--get the already existing metaPrototype
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames ["slider"]]
local oldMetaPrototype = _G[DF.GlobalWidgetControlNames["slider"]]
--check if is older
if ( (not oldMetaPrototype.dversion) or (oldMetaPrototype.dversion < DF.dversion) ) then
--the version is older them the currently loading one
@@ -43,281 +31,229 @@ do
end
else
--first time loading the framework
_G[DF.GlobalWidgetControlNames ["slider"]] = metaPrototype
_G[DF.GlobalWidgetControlNames["slider"]] = metaPrototype
end
end
local DFSliderMetaFunctions = _G[DF.GlobalWidgetControlNames ["slider"]]
local DFSliderMetaFunctions = _G[DF.GlobalWidgetControlNames["slider"]]
DF:Mixin(DFSliderMetaFunctions, DF.SetPointMixin)
DF:Mixin(DFSliderMetaFunctions, DF.FrameMixin)
------------------------------------------------------------------------------------------------------------
--> metatables
--metatables
DFSliderMetaFunctions.__call = function (_table, value)
DFSliderMetaFunctions.__call = function(object, value)
if (not value) then
if (_table.isSwitch) then
if (type (value) == "boolean") then --> false
return _table.slider:SetValue (1)
if (object.isSwitch) then
if (type(value) == "boolean") then
object.slider:SetValue(1)
return
end
if (_table.slider:GetValue() == 1) then
if (object.slider:GetValue() == 1) then
return false
else
return true
end
end
return _table.slider:GetValue()
return object.slider:GetValue()
else
if (_table.isSwitch) then
if (type (value) == "boolean") then
if (object.isSwitch) then
if (type(value) == "boolean") then
if (value) then
_table.slider:SetValue (2)
object.slider:SetValue(2)
else
_table.slider:SetValue (1)
object.slider:SetValue(1)
end
else
_table.slider:SetValue (value)
object.slider:SetValue(value)
end
return
end
return _table.slider:SetValue (value)
return object.slider:SetValue(value)
end
end
------------------------------------------------------------------------------------------------------------
--> members
--members
--> tooltip
local gmember_tooltip = function (_object)
return _object:GetTooltip()
--tooltip
local gmember_tooltip = function(object)
return object:GetTooltip()
end
--> shown
local gmember_shown = function (_object)
return _object:IsShown()
--shown
local gmember_shown = function(object)
return object:IsShown()
end
--> frame width
local gmember_width = function (_object)
return _object.slider:GetWidth()
--frame width
local gmember_width = function(object)
return object.slider:GetWidth()
end
--> frame height
local gmember_height = function (_object)
return _object.slider:GetHeight()
--frame height
local gmember_height = function(object)
return object.slider:GetHeight()
end
--> locked
local gmember_locked = function (_object)
return _rawget (_object, "lockdown")
--locked
local gmember_locked = function(object)
return rawget(object, "lockdown")
end
--fractional
local gmember_fractional = function(object)
return rawget(object, "useDecimals")
end
--value
local gmember_value = function(object)
return object()
end
--> fractional
local gmember_fractional = function (_object)
return _rawget (_object, "useDecimals")
end
--> value
local gmember_value = function (_object)
return _object()
end
DFSliderMetaFunctions.GetMembers = DFSliderMetaFunctions.GetMembers or {}
DFSliderMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip
DFSliderMetaFunctions.GetMembers ["shown"] = gmember_shown
DFSliderMetaFunctions.GetMembers ["width"] = gmember_width
DFSliderMetaFunctions.GetMembers ["height"] = gmember_height
DFSliderMetaFunctions.GetMembers ["locked"] = gmember_locked
DFSliderMetaFunctions.GetMembers ["fractional"] = gmember_fractional
DFSliderMetaFunctions.GetMembers ["value"] = gmember_value
DFSliderMetaFunctions.GetMembers["tooltip"] = gmember_tooltip
DFSliderMetaFunctions.GetMembers["shown"] = gmember_shown
DFSliderMetaFunctions.GetMembers["width"] = gmember_width
DFSliderMetaFunctions.GetMembers["height"] = gmember_height
DFSliderMetaFunctions.GetMembers["locked"] = gmember_locked
DFSliderMetaFunctions.GetMembers["fractional"] = gmember_fractional
DFSliderMetaFunctions.GetMembers["value"] = gmember_value
DFSliderMetaFunctions.__index = function (_table, _member_requested)
local func = DFSliderMetaFunctions.GetMembers [_member_requested]
DFSliderMetaFunctions.__index = function(object, key)
local func = DFSliderMetaFunctions.GetMembers[key]
if (func) then
return func (_table, _member_requested)
return func(object, key)
end
local fromMe = _rawget (_table, _member_requested)
local fromMe = rawget(object, key)
if (fromMe) then
return fromMe
end
return DFSliderMetaFunctions [_member_requested]
return DFSliderMetaFunctions[key]
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> tooltip
local smember_tooltip = function (_object, _value)
return _object:SetTooltip (_value)
--tooltip
local smember_tooltip = function(object, value)
return object:SetTooltip(value)
end
--> show
local smember_show = function (_object, _value)
if (_value) then
return _object:Show()
--show
local smember_show = function(object, value)
if (value) then
return object:Show()
else
return _object:Hide()
return object:Hide()
end
end
--> hide
local smember_hide = function (_object, _value)
if (not _value) then
return _object:Show()
--hide
local smember_hide = function(object, value)
if (not value) then
return object:Show()
else
return _object:Hide()
return object:Hide()
end
end
--> frame width
local smember_width = function (_object, _value)
return _object.slider:SetWidth (_value)
--frame width
local smember_width = function(object, value)
return object.slider:SetWidth(value)
end
--> frame height
local smember_height = function (_object, _value)
return _object.slider:SetHeight (_value)
--frame height
local smember_height = function(object, value)
return object.slider:SetHeight(value)
end
--> locked
local smember_locked = function (_object, _value)
if (_value) then
return self:Disable()
--locked
local smember_locked = function(object, value)
if (value) then
return object:Disable()
else
return self:Enable()
return object:Enable()
end
end
--> backdrop
local smember_backdrop = function (_object, _value)
return _object.slider:SetBackdrop (_value)
end
--> fractional
local smember_fractional = function (_object, _value)
return _rawset (_object, "useDecimals", _value)
--backdrop
local smember_backdrop = function(object, value)
return object.slider:SetBackdrop(value)
end
--> value
local smember_value = function (_object, _value)
_object (_value)
--fractional
local smember_fractional = function(object, value)
return rawset(object, "useDecimals", value)
end
--value
local smember_value = function(object, value)
object(value)
end
DFSliderMetaFunctions.SetMembers = DFSliderMetaFunctions.SetMembers or {}
DFSliderMetaFunctions.SetMembers ["tooltip"] = smember_tooltip
DFSliderMetaFunctions.SetMembers ["show"] = smember_show
DFSliderMetaFunctions.SetMembers ["hide"] = smember_hide
DFSliderMetaFunctions.SetMembers ["backdrop"] = smember_backdrop
DFSliderMetaFunctions.SetMembers ["width"] = smember_width
DFSliderMetaFunctions.SetMembers ["height"] = smember_height
DFSliderMetaFunctions.SetMembers ["locked"] = smember_locked
DFSliderMetaFunctions.SetMembers ["fractional"] = smember_fractional
DFSliderMetaFunctions.SetMembers ["value"] = smember_value
DFSliderMetaFunctions.__newindex = function (_table, _key, _value)
local func = DFSliderMetaFunctions.SetMembers [_key]
DFSliderMetaFunctions.SetMembers["tooltip"] = smember_tooltip
DFSliderMetaFunctions.SetMembers["show"] = smember_show
DFSliderMetaFunctions.SetMembers["hide"] = smember_hide
DFSliderMetaFunctions.SetMembers["backdrop"] = smember_backdrop
DFSliderMetaFunctions.SetMembers["width"] = smember_width
DFSliderMetaFunctions.SetMembers["height"] = smember_height
DFSliderMetaFunctions.SetMembers["locked"] = smember_locked
DFSliderMetaFunctions.SetMembers["fractional"] = smember_fractional
DFSliderMetaFunctions.SetMembers["value"] = smember_value
DFSliderMetaFunctions.__newindex = function (object, key, value)
local func = DFSliderMetaFunctions.SetMembers[key]
if (func) then
return func (_table, _value)
return func(object, value)
else
return _rawset (_table, _key, _value)
return rawset(object, key, value)
end
end
end
------------------------------------------------------------------------------------------------------------
--> methods
--methods
--> show & hide
function DFSliderMetaFunctions:IsShown()
return self.slider:IsShown()
end
function DFSliderMetaFunctions:Show()
return self.slider:Show()
end
function DFSliderMetaFunctions:Hide()
return self.slider:Hide()
end
--> fixed value
function DFSliderMetaFunctions:SetFixedParameter (value)
_rawset (self, "FixedValue", value)
end
--> set value
function DFSliderMetaFunctions:SetValue (value)
return self (value)
end
-- thumb size
function DFSliderMetaFunctions:SetThumbSize (w, h)
if (not w) then
w = self.thumb:GetWidth()
end
if (not h) then
h = self.thumb:GetHeight()
end
return self.thumb:SetSize (w, h)
end
function DFSliderMetaFunctions:SetBackdrop(...)
return self.slider:SetBackdrop(...)
--fixed value
function DFSliderMetaFunctions:SetFixedParameter(value)
rawset(self, "FixedValue", value)
end
function DFSliderMetaFunctions:SetBackdropColor(...)
return self.slider:SetBackdropColor(...)
--set value
function DFSliderMetaFunctions:SetValue(value)
return self(value)
end
function DFSliderMetaFunctions:SetBackdropBorderColor(...)
return self.slider:SetBackdropBorderColor(...)
-- thumb size
function DFSliderMetaFunctions:SetThumbSize(width, height)
if (not width) then
width = self.thumb:GetWidth()
end
if (not height) then
height = self.thumb:GetHeight()
end
return self.thumb:SetSize(width, height)
end
-- setpoint
function DFSliderMetaFunctions:SetPoint (v1, v2, v3, v4, v5)
v1, v2, v3, v4, v5 = DF:CheckPoints (v1, v2, v3, v4, v5, self)
if (not v1) then
print ("Invalid parameter for SetPoint")
return
end
return self.widget:SetPoint (v1, v2, v3, v4, v5)
end
-- sizes
function DFSliderMetaFunctions:SetSize (w, h)
if (w) then
self.slider:SetWidth (w)
end
if (h) then
return self.slider:SetHeight (h)
end
end
-- tooltip
function DFSliderMetaFunctions:SetTooltip (tooltip)
--tooltip
function DFSliderMetaFunctions:SetTooltip(tooltip)
if (tooltip) then
return _rawset (self, "have_tooltip", tooltip)
return rawset(self, "have_tooltip", tooltip)
else
return _rawset (self, "have_tooltip", nil)
return rawset(self, "have_tooltip", nil)
end
end
function DFSliderMetaFunctions:GetTooltip()
return _rawget (self, "have_tooltip")
end
-- frame levels
function DFSliderMetaFunctions:GetFrameLevel()
return self.slider:GetFrameLevel()
end
function DFSliderMetaFunctions:SetFrameLevel (level, frame)
if (not frame) then
return self.slider:SetFrameLevel (level)
else
local framelevel = frame:GetFrameLevel (frame) + level
return self.slider:SetFrameLevel (framelevel)
end
return rawget(self, "have_tooltip")
end
-- frame stratas
function DFSliderMetaFunctions:SetFrameStrata()
return self.slider:GetFrameStrata()
end
function DFSliderMetaFunctions:SetFrameStrata (strata)
if (_type (strata) == "table") then
self.slider:SetFrameStrata (strata:GetFrameStrata())
else
self.slider:SetFrameStrata (strata)
end
end
-- clear focus
--clear focus
function DFSliderMetaFunctions:ClearFocus()
local editbox = DFSliderMetaFunctions.editbox_typevalue
if editbox and self.typing_value then
@@ -327,33 +263,32 @@ local DFSliderMetaFunctions = _G[DF.GlobalWidgetControlNames ["slider"]]
editbox:GetParent().MyObject.value = self.typing_value_started
end
end
-- enabled
--enabled
function DFSliderMetaFunctions:IsEnabled()
return not _rawget (self, "lockdown")
return not rawget(self, "lockdown")
end
function DFSliderMetaFunctions:Enable()
self.slider:Enable()
if (not self.is_checkbox) then
if (not self.lock_texture) then
DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
self.lock_texture:SetDesaturated (true)
self.lock_texture:SetPoint ("center", self.amt, "center")
DF:NewImage(self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
self.lock_texture:SetDesaturated(true)
self.lock_texture:SetPoint("center", self.amt, "center")
end
self.lock_texture:Hide()
end
self.slider.amt:Show()
self:SetAlpha (1)
self:SetAlpha(1)
if (self.is_checkbox) then
self.checked_texture:Show()
end
return _rawset (self, "lockdown", false)
return rawset(self, "lockdown", false)
end
function DFSliderMetaFunctions:Disable()
self:ClearFocus()
self.slider:Disable()
self.slider.amt:Hide()
@@ -362,26 +297,24 @@ local DFSliderMetaFunctions = _G[DF.GlobalWidgetControlNames ["slider"]]
if (not self.is_checkbox) then
if (not self.lock_texture) then
DF:NewImage (self, [[Interface\PetBattles\PetBattle-LockIcon]], 12, 12, "overlay", {0.0546875, 0.9453125, 0.0703125, 0.9453125}, "lock_texture", "$parentLockTexture")
self.lock_texture:SetDesaturated (true)
self.lock_texture:SetPoint ("center", self.amt, "center")
self.lock_texture:SetDesaturated(true)
self.lock_texture:SetPoint("center", self.amt, "center")
end
self.lock_texture:Show()
end
if (self.is_checkbox) then
self.checked_texture:Show()
end
--print ("result 2:", self.checked_texture:IsShown(), self.checked_texture:GetAlpha(), self.checked_texture:GetSize())
return _rawset (self, "lockdown", true)
return rawset(self, "lockdown", true)
end
------------------------------------------------------------------------------------------------------------
--> scripts
local OnEnter = function (slider)
if (_rawget (slider.MyObject, "lockdown")) then
if (rawget (slider.MyObject, "lockdown")) then
return
end
@@ -413,7 +346,7 @@ local DFSliderMetaFunctions = _G[DF.GlobalWidgetControlNames ["slider"]]
local OnLeave = function (slider)
if (_rawget (slider.MyObject, "lockdown")) then
if (rawget (slider.MyObject, "lockdown")) then
return
end
@@ -814,16 +747,16 @@ local SwitchOnClick = function (self, button, forced_value, value)
local slider = self.MyObject
if (_rawget (slider, "lockdown")) then
if (rawget (slider, "lockdown")) then
return
end
if (forced_value) then
_rawset (slider, "value", not value)
rawset (slider, "value", not value)
end
if (_rawget (slider, "value")) then --actived
_rawset (slider, "value", false)
if (rawget (slider, "value")) then --actived
rawset (slider, "value", false)
if (slider.backdrop_disabledcolor) then
slider:SetBackdropColor (unpack (slider.backdrop_disabledcolor))
@@ -839,7 +772,7 @@ local SwitchOnClick = function (self, button, forced_value, value)
slider._thumb:SetPoint ("left", slider.widget, "left")
end
else
_rawset (slider, "value", true)
rawset (slider, "value", true)
if (slider.backdrop_enabledcolor) then
slider:SetBackdropColor (unpack (slider.backdrop_enabledcolor))
else
@@ -855,7 +788,7 @@ local SwitchOnClick = function (self, button, forced_value, value)
end
if (slider.OnSwitch and not forced_value) then
local value = _rawget (slider, "value")
local value = rawget (slider, "value")
if (slider.return_func) then
value = slider:return_func (value)
end
@@ -892,7 +825,7 @@ local switch_set_value = function (self, value)
end
local switch_set_fixparameter = function (self, value)
_rawset (self, "FixedValue", value)
rawset (self, "FixedValue", value)
end
local switch_disable = function (self)
@@ -910,11 +843,11 @@ local switch_disable = function (self)
end
self:SetAlpha (.4)
_rawset (self, "lockdown", true)
rawset (self, "lockdown", true)
end
local switch_enable = function (self)
if (self.is_checkbox) then
if (_rawget (self, "value")) then
if (rawget (self, "value")) then
self.checked_texture:Show()
else
self.checked_texture:Hide()
@@ -930,7 +863,7 @@ local switch_enable = function (self)
end
self:SetAlpha (1)
return _rawset (self, "lockdown", false)
return rawset (self, "lockdown", false)
end
local set_switch_func = function (self, newFunction)
@@ -951,7 +884,7 @@ local set_as_checkbok = function (self)
self.is_checkbox = true
if (_rawget (self, "value")) then
if (rawget (self, "value")) then
self.checked_texture:Show()
if (self.backdrop_enabledcolor) then
self:SetBackdropColor (unpack (self.backdrop_enabledcolor))
@@ -1265,7 +1198,7 @@ function DF:NewSlider (parent, container, name, member, w, h, min, max, step, de
SliderObject.slider:SetScript ("OnMouseDown", OnMouseDown)
SliderObject.slider:SetScript ("OnMouseUp", OnMouseUp)
_setmetatable (SliderObject, DFSliderMetaFunctions)
setmetatable (SliderObject, DFSliderMetaFunctions)
if (with_label) then
local label = DF:CreateLabel (SliderObject.slider, with_label, nil, nil, nil, "label", nil, "overlay")
@@ -1440,6 +1373,8 @@ local createAdjustmentSliderFrames = function(parent, options, name)
DF:Mixin(adjustmentSlider, DF.OptionsFunctions)
DF:Mixin(adjustmentSlider, DF.AdjustmentSliderFunctions)
DF:Mixin(adjustmentSlider, DF.PayloadMixin)
DF:Mixin(adjustmentSlider, DF.SetPointMixin)
DF:Mixin(adjustmentSlider, DF.FrameMixin)
adjustmentSlider:BuildOptionsTable(DF.AdjustmentSliderOptions, options)
adjustmentSlider:SetSize(adjustmentSlider.options.width, adjustmentSlider.options.height)
+39 -111
View File
@@ -37,12 +37,17 @@ do
end
local TextEntryMetaFunctions = _G[DF.GlobalWidgetControlNames["textentry"]]
DF:Mixin(TextEntryMetaFunctions, DF.SetPointMixin)
DF:Mixin(TextEntryMetaFunctions, DF.FrameMixin)
DF.TextEntryCounter = DF.TextEntryCounter or 1
------------------------------------------------------------------------------------------------------------
--metatables
TextEntryMetaFunctions.__call = function(object, value)
TextEntryMetaFunctions.__call = function(object, value)
end
------------------------------------------------------------------------------------------------------------
@@ -173,94 +178,32 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
------------------------------------------------------------------------------------------------------------
--methods
local cleanfunction = function()end
function TextEntryMetaFunctions:SetEnterFunction(func, param1, param2)
if (func) then
rawset (self, "func", func)
rawset(self, "func", func)
else
rawset (self, "func", cleanfunction)
rawset(self, "func", cleanfunction)
end
if (param1 ~= nil) then
rawset (self, "param1", param1)
rawset(self, "param1", param1)
end
if (param2 ~= nil) then
rawset (self, "param2", param2)
rawset(self, "param2", param2)
end
end
--set point
function TextEntryMetaFunctions:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y, Width)
if (type (MyAnchor) == "boolean" and MyAnchor and self.space) then
local textWidth = self.label:GetStringWidth()+2
self.editbox:SetWidth (self.space - textWidth - 15)
return
elseif (type (MyAnchor) == "boolean" and MyAnchor and not self.space) then
self.space = self.label:GetStringWidth()+2 + self.editbox:GetWidth()
end
if (Width) then
self.space = Width
end
MyAnchor, SnapTo, HisAnchor, x, y = DF:CheckPoints (MyAnchor, SnapTo, HisAnchor, x, y, self)
if (not MyAnchor) then
print ("Invalid parameter for SetPoint")
return
end
if (self.space) then
self.label:ClearAllPoints()
self.editbox:ClearAllPoints()
self.label:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y)
self.editbox:SetPoint ("left", self.label, "right", 2, 0)
local textWidth = self.label:GetStringWidth()+2
self.editbox:SetWidth (self.space - textWidth - 15)
else
self.label:ClearAllPoints()
self.editbox:ClearAllPoints()
self.editbox:SetPoint (MyAnchor, SnapTo, HisAnchor, x, y)
end
function TextEntryMetaFunctions:SetText(text)
self.editbox:SetText(text)
end
function TextEntryMetaFunctions:SetText (text)
self.editbox:SetText (text)
end
function TextEntryMetaFunctions:GetText()
return self.editbox:GetText()
end
--frame levels
function TextEntryMetaFunctions:GetFrameLevel()
return self.editbox:GetFrameLevel()
end
function TextEntryMetaFunctions:SetFrameLevel (level, frame)
if (not frame) then
return self.editbox:SetFrameLevel (level)
else
local framelevel = frame:GetFrameLevel (frame) + level
return self.editbox:SetFrameLevel (framelevel)
end
end
function TextEntryMetaFunctions:SetBackdrop(...)
return self.editbox:SetBackdrop(...)
end
function TextEntryMetaFunctions:SetBackdropColor(...)
return self.editbox:SetBackdropColor(...)
end
function TextEntryMetaFunctions:SetBackdropBorderColor(...)
return self.editbox:SetBackdropBorderColor(...)
end
--select all text
--select all text
function TextEntryMetaFunctions:SelectAll()
self.editbox:HighlightText()
end
@@ -268,51 +211,36 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
function TextEntryMetaFunctions:SetAutoSelectTextOnFocus(value)
self.autoSelectAllText = value
end
--set labal description
function TextEntryMetaFunctions:SetLabelText (text)
if (text) then
self.label:SetText (text)
else
self.label:SetText ("")
end
self:SetPoint (true) --> refresh
--set label description
function TextEntryMetaFunctions:SetLabelText(text)
self.label:SetText(text)
end
--> set tab order
function TextEntryMetaFunctions:SetNext (nextbox)
--set tab order
function TextEntryMetaFunctions:SetNext(nextbox)
self.next = nextbox
end
--> blink
--blink
function TextEntryMetaFunctions:Blink()
self.label:SetTextColor (1, .2, .2, 1)
end
--> show & hide
function TextEntryMetaFunctions:IsShown()
return self.editbox:IsShown()
self.label:SetTextColor(1, .2, .2, 1)
end
function TextEntryMetaFunctions:Show()
return self.editbox:Show()
end
function TextEntryMetaFunctions:Hide()
return self.editbox:Hide()
end
-- tooltip
function TextEntryMetaFunctions:SetTooltip (tooltip)
--tooltip
function TextEntryMetaFunctions:SetTooltip(tooltip)
if (tooltip) then
return rawset (self, "have_tooltip", tooltip)
return rawset(self, "have_tooltip", tooltip)
else
return rawset (self, "have_tooltip", nil)
return rawset(self, "have_tooltip", nil)
end
end
function TextEntryMetaFunctions:GetTooltip()
return rawget (self, "have_tooltip")
return rawget(self, "have_tooltip")
end
--> hooks
--hooks
function TextEntryMetaFunctions:Enable()
if (not self.editbox:IsEnabled()) then
self.editbox:Enable()
@@ -325,7 +253,7 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
end
end
end
function TextEntryMetaFunctions:Disable()
if (self.editbox:IsEnabled()) then
self.enabled_border_color = {self.editbox:GetBackdropBorderColor()}
@@ -334,12 +262,12 @@ DF.TextEntryCounter = DF.TextEntryCounter or 1
self.editbox:Disable()
self.editbox:SetBackdropBorderColor (.5, .5, .5, .5)
self.editbox:SetBackdropColor (.5, .5, .5, .5)
self.editbox:SetTextColor (.5, .5, .5, .5)
self.editbox:SetBackdropBorderColor(.5, .5, .5, .5)
self.editbox:SetBackdropColor(.5, .5, .5, .5)
self.editbox:SetTextColor(.5, .5, .5, .5)
if (self.editbox.borderframe) then
self.editbox.borderframe:SetBackdropColor (.5, .5, .5, .5)
self.editbox.borderframe:SetBackdropColor(.5, .5, .5, .5)
end
end
end