diff --git a/Definitions.lua b/Definitions.lua
index 7f154563..9858759a 100644
--- a/Definitions.lua
+++ b/Definitions.lua
@@ -133,7 +133,8 @@
---@field CreateFontString fun(self: frame, name: string|nil, layer: "background"|"border"|"artwork"|"overlay"|"highlight", inherits: string|nil, subLayer: number|nil) : fontstring
---@field EnableMouse fun(self: frame, enable: boolean)
---@field SetResizable fun(self: frame, enable: boolean)
----@field SetResizeBounds fun(minWidth: number, minHeight: number, maxWidth: number, maxHeight: number)
+---@field EnableMouseWheel fun(self: frame, enable: boolean)
+---@field SetResizeBounds fun(self: frame, minWidth: number, minHeight: number, maxWidth: number, maxHeight: number)
---@class button : frame
---@field SetNormalTexture fun(self: button, texture: texture)
diff --git a/Libs/DF/containers.lua b/Libs/DF/containers.lua
new file mode 100644
index 00000000..60a653cb
--- /dev/null
+++ b/Libs/DF/containers.lua
@@ -0,0 +1,221 @@
+
+local detailsFramework = _G ["DetailsFramework"]
+if (not detailsFramework or not DetailsFrameworkCanLoad) then
+ return
+end
+
+local _
+local DF = detailsFramework
+
+local CreateFrame = CreateFrame
+
+---@class framecontainer : frame
+---@field bIsSizing boolean
+---@field options table
+---@field leftResizer button
+---@field rightResizer button
+---@field OnSizeChanged fun(frameContainer: framecontainer)
+---@field OnResizerMouseDown fun(resizerButton: button, mouseButton: string)
+---@field OnResizerMouseUp fun(resizerButton: button, mouseButton: string)
+---@field HideResizer fun(frameContainer: framecontainer)
+---@field ShowResizer fun(frameContainer: framecontainer)
+---@field OnInitialize fun(frameContainer: framecontainer)
+---@field SetLocked fun(frameContainer: framecontainer, isLocked: boolean)
+---@field CheckLockedState fun(frameContainer: framecontainer)
+
+detailsFramework.frameContainerMixin = {
+ --methods
+ ---run when the container has its size changed
+ ---@param frameContainer framecontainer
+ OnSizeChanged = function(frameContainer)
+ ---@type frame[]
+ local children = {frameContainer:GetChildren()}
+ ---@type number
+ local childrenAmount = #children
+
+ --get the width of each children and sum the values, do the same thing for height
+ ---@type number
+ local childrenWidth = 0
+ ---@type number
+ local childrenHeight = 0
+
+ for i = 1, childrenAmount do
+ childrenWidth = childrenWidth + children[i]:GetWidth()
+ childrenHeight = childrenHeight + children[i]:GetHeight()
+ end
+
+ print("running...")
+
+ --if the children width is bigger than the container width, then need to resize the width of the children to porportionally fit the container
+ --this resize is done by getting the width of each child and reduce the width of the child by the percentage of the difference between the container width and the children width
+ if childrenWidth > frameContainer:GetWidth() then
+ ---@type number
+ local widthDifference = childrenWidth - frameContainer:GetWidth()
+
+ for i = 1, childrenAmount do
+ children[i]:SetWidth(children[i]:GetWidth() - (children[i]:GetWidth() * (widthDifference / childrenWidth)))
+ end
+ end
+ end,
+
+ ---run when the user click on the resizer
+ ---@param resizerButton button
+ ---@param mouseButton string
+ OnResizerMouseDown = function(resizerButton, mouseButton)
+ if (mouseButton ~= "LeftButton") then
+ return
+ end
+print(1)
+ ---@type framecontainer
+ local frameContainer = resizerButton:GetParent() --Cannot assign `frame` to `framecontainer`. .. but framecontainer is inherited from frame
+
+ if (frameContainer.bIsSizing) then
+ return
+ end
+
+ frameContainer.bIsSizing = true
+ frameContainer:StartSizing("bottomright")
+ end,
+
+ ---run when the user click on the resizer
+ ---@param resizerButton button
+ ---@param mouseButton string
+ OnResizerMouseUp = function(resizerButton, mouseButton)
+ ---@type framecontainer
+ local frameContainer = resizerButton:GetParent() --Cannot assign `frame` to `framecontainer`. .. but framecontainer is inherited from frame
+ print(2)
+ if (not frameContainer.bIsSizing) then
+ print("fuck")
+ return
+ end
+
+ frameContainer:StopMovingOrSizing()
+ frameContainer.bIsSizing = false
+ end,
+
+ ---hide resizer
+ ---@param frameContainer framecontainer
+ HideResizer = function(frameContainer)
+ frameContainer.leftResizer:Hide()
+ frameContainer.rightResizer:Hide()
+ end,
+
+ ---show resizer
+ ---@param frameContainer framecontainer
+ ShowResizer = function(frameContainer)
+ if (frameContainer.options.use_left_resizer) then
+ frameContainer.leftResizer:Show()
+ end
+ if (frameContainer.options.use_right_resizer) then
+ frameContainer.rightResizer:Show()
+ end
+ end,
+
+ ---check the lock state and show or hide the resizer, set the frame as movable or not, resizeable or not
+ ---@param frameContainer framecontainer
+ CheckLockedState = function(frameContainer)
+ if (frameContainer.options.is_locked) then
+ frameContainer:HideResizer()
+ frameContainer:EnableMouse(false)
+ frameContainer:SetResizable(false)
+ else
+ frameContainer:ShowResizer()
+ frameContainer:EnableMouse(true)
+ frameContainer:SetResizable(true)
+ end
+ end,
+
+ ---set the lock state
+ ---@param frameContainer framecontainer
+ ---@param isLocked boolean
+ SetLocked = function(frameContainer, isLocked)
+ frameContainer.options.is_locked = isLocked
+ frameContainer:CheckLockedState()
+ end,
+
+ ---run when the container is created
+ ---@param frameContainer framecontainer
+ OnInitialize = function(frameContainer)
+ frameContainer.leftResizer:SetScript("OnMouseDown", frameContainer.OnResizerMouseDown)
+ frameContainer.leftResizer:SetScript("OnMouseUp", frameContainer.OnResizerMouseUp)
+ frameContainer.rightResizer:SetScript("OnMouseDown", frameContainer.OnResizerMouseDown)
+ frameContainer.rightResizer:SetScript("OnMouseUp", frameContainer.OnResizerMouseUp)
+
+ if (frameContainer.options.is_locked) then
+ frameContainer:HideResizer()
+ else
+ frameContainer:ShowResizer()
+ end
+
+ frameContainer:CheckLockedState()
+
+ frameContainer:SetResizeBounds(50, 50, 1000, 1000)
+ end,
+
+}
+
+local frameContainerOptions = {
+ --default settings
+ width = 300,
+ height = 150,
+ is_locked = false,
+ use_left_resizer = false,
+ use_right_resizer = true,
+}
+
+---create a frame container, which is a frame that envelops another frame, and can be moved, resized, etc.
+---@param parent frame
+---@param options table|nil
+---@param frameName string|nil
+---@return framecontainer
+function DF:CreateFrameContainer(parent, options, frameName)
+ ---@type framecontainer
+ local container = CreateFrame("frame", frameName or ("$parentFrameContainer" .. math.random(10000, 99999)), parent, "BackdropTemplate")
+
+ detailsFramework:Mixin(container, detailsFramework.frameContainerMixin)
+ detailsFramework:Mixin(container, detailsFramework.OptionsFunctions)
+
+ detailsFramework:CreateResizeGrips(container)
+
+ container:BuildOptionsTable(frameContainerOptions, options)
+
+ container:SetScript("OnSizeChanged", container.OnSizeChanged)
+
+ container.bIsSizing = false
+
+ container:OnInitialize()
+
+ return container
+end
+
+function DF:CreateFrameContainerTest(parent, options, frameName)
+
+ local container = DF:CreateFrameContainer(parent, options, frameName)
+ container:SetSize(400, 400)
+ container:SetPoint("center", UIParent, "center", 0, 0)
+
+ detailsFramework:ApplyStandardBackdrop(container)
+
+ for i = 1, 3 do
+ for o = 1, 3 do
+ local frame = CreateFrame("frame", "$parentFrame" .. math.random(10000, 99999), container, "BackdropTemplate")
+ frame:SetBackdrop({bgFile = "Interface\\AddOns\\Details\\images\\background", tile = true, tileSize = 16, edgeFile = "Interface\\AddOns\\Details\\images\\border_2", edgeSize = 16, insets = {left = 4, right = 4, top = 4, bottom = 4}})
+ frame:SetBackdropColor(0, 0, 0, 0.5)
+ frame:SetBackdropBorderColor(1, 1, 1, 0.5)
+ frame:SetSize(100, 100)
+ frame:SetPoint("TOPLEFT", container, "TOPLEFT", 10 + (i - 1) * 110, -10 - (o - 1) * 110)
+ end
+ end
+end
+
+C_Timer.After(2, function()
+ --DetailsFramework:CreateFrameContainerTest(UIParent)
+end)
+
+--[=[
+ /run DetailsFramework:CreateFrameContainerTest(UIParent)
+
+ C_Timer.After(2, function()
+ DetailsFramework:CreateFrameContainerTest(UIParent)
+ end)
+--]=]
\ No newline at end of file
diff --git a/Libs/DF/load.xml b/Libs/DF/load.xml
index 7380d8d5..66e96f2c 100644
--- a/Libs/DF/load.xml
+++ b/Libs/DF/load.xml
@@ -4,6 +4,7 @@
+
diff --git a/Libs/DF/mixins.lua b/Libs/DF/mixins.lua
index 4e34bbf3..123d721d 100644
--- a/Libs/DF/mixins.lua
+++ b/Libs/DF/mixins.lua
@@ -267,7 +267,7 @@ detailsFramework.SetPointMixin = {
end,
}
---mixin for options functions
+---mixin for options
detailsFramework.OptionsFunctions = {
SetOption = function(self, optionName, optionValue)
if (self.options) then
diff --git a/Libs/DF/panel.lua b/Libs/DF/panel.lua
index 46e02659..84935ec7 100644
--- a/Libs/DF/panel.lua
+++ b/Libs/DF/panel.lua
@@ -3907,28 +3907,52 @@ end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- ~resizers
-function detailsFramework:CreateResizeGrips (parent)
+--these options are copied to the object with object:BuildOptionsTable()
+local rezieGripOptions = {
+ width = 32,
+ height = 32,
+ should_mirror_left_texture = true,
+ normal_texture = [[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Up]],
+ highlight_texture = [[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Highlight]],
+ pushed_texture = [[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Down]],
+}
+
+---create the two resize grips for a frame, one in the bottom left and another in the bottom right
+---@param parent frame
+---@return frame, frame
+function detailsFramework:CreateResizeGrips(parent, options, frameName)
if (parent) then
local parentName = parent:GetName()
- local leftResizer = CreateFrame("button", parentName and parentName .. "LeftResizer" or nil, parent, "BackdropTemplate")
- local rightResizer = CreateFrame("button", parentName and parentName .. "RightResizer" or nil, parent, "BackdropTemplate")
+ local leftResizer = CreateFrame("button", frameName or (parentName and "$parentLeftResizer"), parent, "BackdropTemplate")
+ local rightResizer = CreateFrame("button", frameName or (parentName and "$parentRightResizer"), parent, "BackdropTemplate")
- leftResizer:SetPoint("bottomleft", parent, "bottomleft")
- rightResizer:SetPoint("bottomright", parent, "bottomright")
- leftResizer:SetSize(16, 16)
- rightResizer:SetSize(16, 16)
+ parent.leftResizer = leftResizer
+ parent.rightResizer = rightResizer
- rightResizer:SetNormalTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Up]])
- rightResizer:SetHighlightTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Highlight]])
- rightResizer:SetPushedTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Down]])
- leftResizer:SetNormalTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Up]])
- leftResizer:SetHighlightTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Highlight]])
- leftResizer:SetPushedTexture([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Down]])
+ detailsFramework:Mixin(leftResizer, detailsFramework.OptionsFunctions)
+ detailsFramework:Mixin(rightResizer, detailsFramework.OptionsFunctions)
+ leftResizer:BuildOptionsTable(rezieGripOptions, options)
+ rightResizer:BuildOptionsTable(rezieGripOptions, options)
- leftResizer:GetNormalTexture():SetTexCoord(1, 0, 0, 1)
- leftResizer:GetHighlightTexture():SetTexCoord(1, 0, 0, 1)
- leftResizer:GetPushedTexture():SetTexCoord(1, 0, 0, 1)
+ leftResizer:SetPoint("bottomleft", parent, "bottomleft", 0, 0)
+ rightResizer:SetPoint("bottomright", parent, "bottomright", 0, 0)
+ leftResizer:SetSize(leftResizer.options.width, leftResizer.options.height)
+ rightResizer:SetSize(leftResizer.options.width, leftResizer.options.height)
+
+ rightResizer:SetNormalTexture(rightResizer.options.normal_texture)
+ rightResizer:SetHighlightTexture(rightResizer.options.highlight_texture)
+ rightResizer:SetPushedTexture(rightResizer.options.pushed_texture)
+
+ leftResizer:SetNormalTexture(leftResizer.options.normal_texture)
+ leftResizer:SetHighlightTexture(leftResizer.options.highlight_texture)
+ leftResizer:SetPushedTexture(leftResizer.options.pushed_texture)
+
+ if (leftResizer.options.should_mirror_left_texture) then
+ leftResizer:GetNormalTexture():SetTexCoord(1, 0, 0, 1)
+ leftResizer:GetHighlightTexture():SetTexCoord(1, 0, 0, 1)
+ leftResizer:GetPushedTexture():SetTexCoord(1, 0, 0, 1)
+ end
return leftResizer, rightResizer
end
diff --git a/frames/window_playerbreakdown_spells.lua b/frames/window_playerbreakdown_spells.lua
index 1b13ba5d..1d297b33 100644
--- a/frames/window_playerbreakdown_spells.lua
+++ b/frames/window_playerbreakdown_spells.lua
@@ -331,9 +331,6 @@ function spellsTab.OnCreateTabCallback(tabButton, tabFrame)
--create the targets container
spellsTab.CreateTargetContainer(tabFrame)
- --craete special backgrounds (still needed?)
- spellsTab.CreateSpecialBackgrounds(tabFrame)
-
--create the report buttons for each container
spellsTab.CreateReportButtons(tabFrame)
@@ -357,152 +354,6 @@ function spellsTab.OnCreateTabCallback(tabButton, tabFrame)
--]=]
end
-function spellsTab.TrocaBackgroundInfo(tabFrame) --> spells tab | to be refactored | called fom OpenJanelaInfo function
- tabFrame.bg3_sec_texture:Hide()
- tabFrame.bg2_sec_texture:Hide()
- tabFrame.report_direita:Hide()
-
- if (breakdownWindow.atributo == 1) then --damage
- if (breakdownWindow.sub_atributo == 1 or breakdownWindow.sub_atributo == 2) then --damage done / dps
- tabFrame.bg1_sec_texture:SetTexture("")
- tabFrame.tipo = 1
-
- if (breakdownWindow.sub_atributo == 2) then
- tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. " " .. Loc ["STRING_ATTRIBUTE_DAMAGE_DPS"] .. ":")
- tabFrame.target_persecond = true
- else
- tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":")
- end
-
- elseif (breakdownWindow.sub_atributo == 3) then --damage taken
- tabFrame.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4)
- tabFrame.bg3_sec_texture:Show()
- tabFrame.bg2_sec_texture:Show()
- tabFrame.tipo = 2
-
- for i = 1, spellBlockContainerSettings.amount do
- tabFrame["right_background" .. i]:Hide()
- end
-
- tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":")
- tabFrame.no_targets:Show()
- tabFrame.no_targets.text:Show()
- tabFrame.report_direita:Show()
-
- elseif (breakdownWindow.sub_atributo == 4) then --friendly fire
- tabFrame.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4)
- tabFrame.bg3_sec_texture:Show()
- tabFrame.bg2_sec_texture:Show()
- tabFrame.tipo = 3
-
- for i = 1, spellBlockContainerSettings.amount do
- tabFrame["right_background" .. i]:Hide()
- end
-
- tabFrame.targets:SetText(Loc ["STRING_SPELLS"] .. ":")
- tabFrame.report_direita:Show()
-
- elseif (breakdownWindow.sub_atributo == 6) then --enemies
- tabFrame.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4)
- tabFrame.bg3_sec_texture:Show()
- tabFrame.bg2_sec_texture:Show()
- tabFrame.tipo = 3
-
- for i = 1, spellBlockContainerSettings.amount do
- tabFrame["right_background" .. i]:Hide()
- end
-
- tabFrame.targets:SetText(Loc ["STRING_DAMAGE_TAKEN_FROM"])
- end
-
- elseif (breakdownWindow.atributo == 2) then --healing
- if (breakdownWindow.sub_atributo == 1 or breakdownWindow.sub_atributo == 2 or breakdownWindow.sub_atributo == 3) then --damage done / dps
- tabFrame.bg1_sec_texture:SetTexture("")
- tabFrame.tipo = 1
-
- if (breakdownWindow.sub_atributo == 3) then
- tabFrame.targets:SetText(Loc ["STRING_OVERHEALED"] .. ":")
- tabFrame.target_member = "overheal"
- tabFrame.target_text = Loc ["STRING_OVERHEALED"] .. ":"
-
- elseif (breakdownWindow.sub_atributo == 2) then
- tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. " " .. Loc ["STRING_ATTRIBUTE_HEAL_HPS"] .. ":")
- tabFrame.target_persecond = true
-
- else
- tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":")
- end
-
- elseif (breakdownWindow.sub_atributo == 4) then --Healing taken
- tabFrame.bg1_sec_texture:SetColorTexture(.05, .05, .05, .4)
- tabFrame.bg3_sec_texture:Show()
- tabFrame.bg2_sec_texture:Show()
- tabFrame.tipo = 2
-
- for i = 1, spellBlockContainerSettings.amount do
- tabFrame ["right_background" .. i]:Hide()
- end
-
- tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":")
- tabFrame.no_targets:Show()
- tabFrame.no_targets.text:Show()
- tabFrame.report_direita:Show()
- end
-
- elseif (breakdownWindow.atributo == 3) then --energy
- tabFrame.bg1_sec_texture:SetTexture("")
- tabFrame.tipo = 2
- tabFrame.targets:SetText("Vindo de:")
-
- elseif (breakdownWindow.atributo == 4) then --utility
- tabFrame.bg1_sec_texture:SetTexture("")
- tabFrame.tipo = 2
-
- tabFrame.targets:SetText(Loc ["STRING_TARGETS"] .. ":")
- end
-end
-
-do --hide bars functions - to be refactored
- --hide all the bars of the skills in the window info
- function spellsTab.HidaAllBarrasInfo()
- local allBars = _detalhes.playerDetailWindow.barras1
- for index = 1, #allBars, 1 do
- allBars[index]:Hide()
- allBars[index].textura:SetStatusBarColor(1, 1, 1, 1)
- end
- end
-
- --hide the 5 bars on the right side of the window
- function spellsTab.HidaAllDetalheInfo() --there's a call from the breakdown file yet
- for i = 1, spellBlockContainerSettings.amount do
- spellsTab.HidaDetalheInfo(i)
- end
-
- --breakdownWindow.barras3 will not exists anymore soon
- --for _, thisBar in ipairs(breakdownWindow.barras3) do
- -- thisBar:Hide()
- --end
- --_detalhes.playerDetailWindow.spell_icone:SetTexture("")
- end
-
- function spellsTab.ResetBars()
- spellsTab.HidaAllBarrasInfo()
- spellsTab.HidaAllBarrasAlvo()
- spellsTab.HidaAllDetalheInfo()
- end
-
- function spellsTab.HidaDetalheInfo(index) --> spells tab this is getting called from class damage and heal
- local info = _detalhes.playerDetailWindow.grupos_detalhes[index]
- info.nome:SetText("")
- info.nome2:SetText("")
- info.dano:SetText("")
- info.dano_porcento:SetText("")
- info.dano_media:SetText("")
- info.dano_dps:SetText("")
- info.bg:Hide()
- end
-end
-
function spellsTab.CreateReportButtons(tabFrame)
--spell list report button
tabFrame.report_esquerda = Details.gump:NewDetailsButton(tabFrame, tabFrame, nil, _detalhes.Reportar, tabFrame, 1, 16, 16, "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", "Interface\\COMMON\\VOICECHAT-ON", nil, "DetailsJanelaInfoReport2")
@@ -1488,22 +1339,6 @@ function spellsTab.CreateSpellScrollContainer(tabFrame)
return scrollFrame
end
---special backgrounds -- fundos especiais de friendly fire e outros
-function spellsTab.CreateSpecialBackgrounds(tabFrame)
- tabFrame.no_targets = tabFrame:CreateTexture("DetailsBreakdownWindow_no_targets", "overlay")
- tabFrame.no_targets:SetPoint("bottomleft", tabFrame, "bottomleft", 20, 6)
- tabFrame.no_targets:SetSize(301, 100)
- tabFrame.no_targets:SetTexture([[Interface\QUESTFRAME\UI-QUESTLOG-EMPTY-TOPLEFT]])
- tabFrame.no_targets:SetTexCoord(0.015625, 1, 0.01171875, 0.390625)
- tabFrame.no_targets:SetDesaturated(true)
- tabFrame.no_targets:SetAlpha(.7)
- tabFrame.no_targets.text = tabFrame:CreateFontString(nil, "overlay", "GameFontNormal")
- tabFrame.no_targets.text:SetPoint("center", tabFrame.no_targets, "center")
- tabFrame.no_targets.text:SetText(Loc ["STRING_NO_TARGET_BOX"])
- tabFrame.no_targets.text:SetTextColor(1, 1, 1, .4)
- tabFrame.no_targets:Hide()
-end
-
---on enter function for the spell target frame
---@param targetFrame breakdowntargetframe
local onEnterSpellTarget = function(targetFrame)