framework update

This commit is contained in:
Tercio Jose
2022-10-03 22:30:55 -03:00
parent 3ca0936474
commit 12c046fded
4 changed files with 193 additions and 196 deletions
+96 -22
View File
@@ -1,21 +1,75 @@
local DF = _G ["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
local detailsFramework = _G["DetailsFramework"]
if (not detailsFramework or not DetailsFrameworkCanLoad) then
return
end
local _
DF.DefaultMetaFunctionsGet = {
parent = function(object)
return object:GetParent()
detailsFramework.WidgetFunctions = {
GetCapsule = function(self)
return self.MyObject
end,
GetObject = function(self)
return self.MyObject
end,
}
DF.DefaultMetaFunctionsSet = {
detailsFramework.DefaultMetaFunctionsGet = {
parent = function(object)
return object:GetParent()
end,
shown = function(object)
return object:IsShown()
end,
}
detailsFramework.DefaultMetaFunctionsSet = {
parent = function(object, value)
return object:SetParent(value)
end,
show = function(object, value)
if (value) then
return object:Show()
else
return object:Hide()
end
end,
hide = function(object, value)
if (value) then
return object:Hide()
else
return object:Show()
end
end,
}
detailsFramework.DefaultMetaFunctionsSet.shown = detailsFramework.DefaultMetaFunctionsSet.show
detailsFramework.LayeredRegionMetaFunctionsSet = {
drawlayer = function(object, value)
object.image:SetDrawLayer(value)
end,
sublevel = function(object, value)
local drawLayer = object:GetDrawLayer()
object:SetDrawLayer(drawLayer, value)
end,
}
detailsFramework.LayeredRegionMetaFunctionsGet = {
drawlayer = function(object)
return object.image:GetDrawLayer()
end,
sublevel = function(object)
local _, subLevel = object.image:GetDrawLayer()
return subLevel
end,
}
local doublePoint = {
@@ -23,12 +77,19 @@ local doublePoint = {
["rights"] = true,
["tops"] = true,
["bottoms"] = true,
["left-left"] = true,
["right-right"] = true,
["top-top"] = true,
["bottom-bottom"] = true,
["bottom-top"] = true,
["top-bottom"] = true,
["right-left"] = true,
["left-right"] = true,
}
DF.SetPointMixin = {
detailsFramework.SetPointMixin = {
SetPoint = function(object, anchorName1, anchorObject, anchorName2, xOffset, yOffset)
if (doublePoint[anchorName1]) then
object:ClearAllPoints()
@@ -58,6 +119,18 @@ DF.SetPointMixin = {
object:SetPoint("bottomleft", anchorTo, "bottomleft", xOffset, yOffset)
object:SetPoint("bottomright", anchorTo, "bottomright", -xOffset, yOffset)
elseif (anchorName1 == "left-left") then
object:SetPoint("left", anchorTo, "left", xOffset, yOffset)
elseif (anchorName1 == "right-right") then
object:SetPoint("right", anchorTo, "right", xOffset, yOffset)
elseif (anchorName1 == "top-top") then
object:SetPoint("top", anchorTo, "top", xOffset, yOffset)
elseif (anchorName1 == "bottom-bottom") then
object:SetPoint("bottom", anchorTo, "bottom", xOffset, yOffset)
elseif (anchorName1 == "bottom-top") then
object:SetPoint("bottomleft", anchorTo, "topleft", xOffset, yOffset)
object:SetPoint("bottomright", anchorTo, "topright", -xOffset, yOffset)
@@ -68,7 +141,11 @@ DF.SetPointMixin = {
elseif (anchorName1 == "right-left") then
object:SetPoint("topright", anchorTo, "topleft", xOffset, -yOffset)
object:SetPoint("bottomright", anchorTo, "bottomright", xOffset, yOffset)
object:SetPoint("bottomright", anchorTo, "bottomleft", xOffset, yOffset)
elseif (anchorName1 == "left-right") then
object:SetPoint("topleft", anchorTo, "topright", xOffset, -yOffset)
object:SetPoint("bottomleft", anchorTo, "bottomright", xOffset, yOffset)
end
return
@@ -77,7 +154,7 @@ DF.SetPointMixin = {
xOffset = xOffset or 0
yOffset = yOffset or 0
anchorName1, anchorObject, anchorName2, xOffset, yOffset = DF:CheckPoints(anchorName1, anchorObject, anchorName2, xOffset, yOffset, object)
anchorName1, anchorObject, anchorName2, xOffset, yOffset = detailsFramework:CheckPoints(anchorName1, anchorObject, anchorName2, xOffset, yOffset, object)
if (not anchorName1) then
error("SetPoint: Invalid parameter.")
return
@@ -87,7 +164,7 @@ DF.SetPointMixin = {
}
--mixin for options functions
DF.OptionsFunctions = {
detailsFramework.OptionsFunctions = {
SetOption = function (self, optionName, optionValue)
if (self.options) then
self.options [optionName] = optionValue
@@ -97,7 +174,7 @@ DF.OptionsFunctions = {
end
if (self.OnOptionChanged) then
DF:Dispatch (self.OnOptionChanged, self, optionName, optionValue)
detailsFramework:Dispatch (self.OnOptionChanged, self, optionName, optionValue)
end
end,
@@ -119,13 +196,13 @@ DF.OptionsFunctions = {
BuildOptionsTable = function (self, defaultOptions, userOptions)
self.options = self.options or {}
DF.table.deploy (self.options, userOptions or {})
DF.table.deploy (self.options, defaultOptions or {})
detailsFramework.table.deploy (self.options, userOptions or {})
detailsFramework.table.deploy (self.options, defaultOptions or {})
end
}
--payload mixin
DF.PayloadMixin = {
detailsFramework.PayloadMixin = {
ClearPayload = function(self)
self.payload = {}
end,
@@ -157,12 +234,12 @@ DF.PayloadMixin = {
--does not copy wow objects, just pass them to the new table, tables strings and numbers are copied entirely
DuplicatePayload = function(self)
local duplicatedPayload = DF.table.duplicate({}, self.payload)
local duplicatedPayload = detailsFramework.table.duplicate({}, self.payload)
return duplicatedPayload
end,
}
DF.ScrollBoxFunctions = {
detailsFramework.ScrollBoxFunctions = {
Refresh = function(self)
--hide all frames and tag as not in use
for index, frame in ipairs(self.Frames) do
@@ -176,7 +253,7 @@ DF.ScrollBoxFunctions = {
offset = self:GetOffsetFaux()
end
DF:CoreDispatch((self:GetName() or "ScrollBox") .. ":Refresh()", self.refresh_func, self, self.data, offset, self.LineAmount)
detailsFramework:CoreDispatch((self:GetName() or "ScrollBox") .. ":Refresh()", self.refresh_func, self, self.data, offset, self.LineAmount)
for index, frame in ipairs(self.Frames) do
if (not frame._InUse) then
@@ -411,7 +488,7 @@ local SortByMemberReverse = function (t1, t2)
return t1[SortMember] < t2[SortMember]
end
DF.SortFunctions = {
detailsFramework.SortFunctions = {
Sort = function(self, thisTable, memberName, isReverse)
SortMember = memberName
if (not isReverse) then
@@ -420,7 +497,4 @@ DF.SortFunctions = {
table.sort(thisTable, SortByMemberReverse)
end
end
}
}