From aad91256a2f2dcf47345e38102211fbf175b00b0 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Tue, 25 Apr 2023 20:47:01 -0300 Subject: [PATCH] Fixed the spell container size not saving properly, fixed spellbars not being allowed to click --- Libs/DF/containers.lua | 42 +++++++++++++----------- frames/window_playerbreakdown_spells.lua | 24 +++++++------- functions/profiles.lua | 3 +- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Libs/DF/containers.lua b/Libs/DF/containers.lua index 0b15b41f..c8fa90fd 100644 --- a/Libs/DF/containers.lua +++ b/Libs/DF/containers.lua @@ -140,26 +140,26 @@ detailsFramework.FrameContainerMixin = { ---check the lock state and show or hide the resizer, set the frame as movable or not, resizeable or not ---@param frameContainer df_framecontainer CheckResizeLockedState = function(frameContainer) - if (frameContainer.options.can_resize) then - frameContainer:ShowResizer() - frameContainer:SetResizable(true) - else + if (frameContainer.options.is_locked) then frameContainer:HideResizer() frameContainer:SetResizable(false) + else + frameContainer:ShowResizer() + frameContainer:SetResizable(true) end end, ---check if the framecontainer can be moved and show or hide the mover ---@param frameContainer df_framecontainer CheckMovableLockedState = function(frameContainer) - if (frameContainer.options.can_move) then - frameContainer:SetMovable(true) - frameContainer:EnableMouse(true) - frameContainer.moverFrame:Show() - else + if (frameContainer.options.is_movement_locked) then frameContainer:SetMovable(false) frameContainer:EnableMouse(false) frameContainer.moverFrame:Hide() + else + frameContainer:SetMovable(true) + frameContainer:EnableMouse(true) + frameContainer.moverFrame:Show() end end, @@ -167,7 +167,8 @@ detailsFramework.FrameContainerMixin = { ---@param frameContainer df_framecontainer ---@param isLocked boolean SetResizeLocked = function(frameContainer, isLocked) - frameContainer.options.can_resize = not isLocked + frameContainer.options.is_locked = isLocked + frameContainer:SendSettingChangedCallback("is_locked", isLocked) frameContainer:CheckResizeLockedState() end, @@ -175,7 +176,8 @@ detailsFramework.FrameContainerMixin = { ---@param frameContainer df_framecontainer ---@param isLocked boolean SetMovableLocked = function(frameContainer, isLocked) - frameContainer.options.can_move = not isLocked + frameContainer.options.is_movement_locked = isLocked + frameContainer:SendSettingChangedCallback("is_movement_locked", isLocked) frameContainer:CheckMovableLockedState() end, @@ -185,15 +187,16 @@ detailsFramework.FrameContainerMixin = { local mover = CreateFrame("button", nil, frameContainer) frameContainer.moverFrame = mover mover:SetAllPoints(frameContainer) + mover:EnableMouse(false) mover:SetMovable(true) mover:SetScript("OnMouseDown", function(self, mouseButton) - if (mouseButton ~= "LeftButton" or not frameContainer.options.can_move) then + if (mouseButton ~= "LeftButton" or frameContainer.options.is_movement_locked) then return end frameContainer:StartMoving() end) mover:SetScript("OnMouseUp", function(self, mouseButton) - if (mouseButton ~= "LeftButton" or not frameContainer.options.can_move) then + if (mouseButton ~= "LeftButton" or frameContainer.options.is_movement_locked) then return end frameContainer:StopMovingOrSizing() @@ -311,10 +314,10 @@ detailsFramework.FrameContainerMixin = { frameContainer.rightResizer:SetPoint("topright", frameContainer, "topright", 2, 0) frameContainer.rightResizer:SetPoint("bottomright", frameContainer, "bottomright", 2, 0) - if (frameContainer.options.can_resize) then - frameContainer:ShowResizer() - else + if (frameContainer.options.is_locked) then frameContainer:HideResizer() + else + frameContainer:ShowResizer() end frameContainer:CheckResizeLockedState() @@ -424,7 +427,7 @@ detailsFramework.FrameContainerMixin = { frameContainer.movableChildren[child] = true frameContainer:RefreshChildrenState() child:SetFrameStrata(frameContainer:GetFrameStrata()) - child:SetFrameLevel(frameContainer:GetFrameLevel() - 3) + child:SetFrameLevel(frameContainer:GetFrameLevel() + 1) end, ---@param frameContainer df_framecontainer @@ -457,8 +460,8 @@ local frameContainerOptions = { --default settings width = 300, height = 150, - can_resize = false, --can or not be resized - can_move = false, --can or not be moved + is_locked = true, --can or not be resized + is_movement_locked = true, --can or not be moved can_move_children = true, use_topleft_resizer = false, use_topright_resizer = false, @@ -480,6 +483,7 @@ function DF:CreateFrameContainer(parent, options, frameName) local frameContainer = CreateFrame("frame", frameName or ("$parentFrameContainer" .. math.random(10000, 99999)), parent, "BackdropTemplate") frameContainer.components = {} frameContainer.movableChildren = {} + frameContainer:EnableMouse(false) detailsFramework:Mixin(frameContainer, detailsFramework.FrameContainerMixin) detailsFramework:Mixin(frameContainer, detailsFramework.OptionsFunctions) diff --git a/frames/window_playerbreakdown_spells.lua b/frames/window_playerbreakdown_spells.lua index ac86c9b7..cf8285ce 100644 --- a/frames/window_playerbreakdown_spells.lua +++ b/frames/window_playerbreakdown_spells.lua @@ -242,9 +242,6 @@ function spellsTab.BuildHeaderTable(containerType) end if (bCanAdd) then - --print("key added:", columnData.key) - --key = "casts", key = "percent", - ---@type headercolumndata local headerColumnData = { width = columnSettings.width, @@ -355,7 +352,7 @@ function spellsTab.OnCreateTabCallback(tabButton, tabFrame) spellsTab.CreateTargetContainer(tabFrame) --create the report buttons for each container - spellsTab.CreateReportButtons(tabFrame) + --spellsTab.CreateReportButtons(tabFrame) --these bars table are kinda deprecated now: --store the spell bars for the spell container @@ -1281,7 +1278,7 @@ function spellsTab.CreateSpellScrollContainer(tabFrame) --~scroll ~create local options = { width = Details.breakdown_spell_tab.spellcontainer_width, height = Details.breakdown_spell_tab.spellcontainer_height, - can_resize = Details.breakdown_spell_tab.spellcontainer_locked, + is_locked = Details.breakdown_spell_tab.spellcontainer_islocked, can_move = false, can_move_children = false, use_bottom_resizer = true, @@ -1293,18 +1290,21 @@ function spellsTab.CreateSpellScrollContainer(tabFrame) --~scroll ~create local container = DF:CreateFrameContainer(tabFrame, options, tabFrame:GetName() .. "SpellScrollContainer") container:SetPoint("topleft", tabFrame, "topleft", 5, -5) container:SetFrameLevel(tabFrame:GetFrameLevel() + 10) + spellsTab.SpellContainerFrame = container - local settingChangedCallbackFunction = function(frameContainer, settingName, settingValue) --doiing here the callback for thge settings changed in the container + local settingChangedCallbackFunction = function(frameContainer, settingName, settingValue) --doing here the callback for thge settings changed in the container if (frameContainer:IsShown()) then if (settingName == "height") then ---@type height local currentHeight = spellsTab.SpellScrollFrame:GetHeight() Details.breakdown_spell_tab.spellcontainer_height = settingValue spellsTab.SpellScrollFrame:SetNumFramesShown(math.floor(currentHeight / CONST_SPELLSCROLL_LINEHEIGHT) - 1) + elseif (settingName == "width") then Details.breakdown_spell_tab.spellcontainer_width = settingValue - elseif (settingName == "can_resize") then - Details.breakdown_spell_tab.spellcontainer_locked = settingValue + + elseif (settingName == "is_locked") then + Details.breakdown_spell_tab.spellcontainer_islocked = settingValue end end end @@ -1312,13 +1312,11 @@ function spellsTab.CreateSpellScrollContainer(tabFrame) --~scroll ~create local defaultAmountOfLines = 50 container:SetSettingChangedCallback(settingChangedCallbackFunction) - container:SetResizeLocked(false) --debug --replace this with a framework scrollframe local scrollFrame = DF:CreateScrollBox(container, "$parentSpellScroll", refreshFunc, {}, width, height, defaultAmountOfLines, CONST_SPELLSCROLL_LINEHEIGHT) DF:ReskinSlider(scrollFrame) scrollFrame:SetBackdrop(nil) - scrollFrame:SetPoint("topleft", container, "topleft", 0, 0) --need to set the points scrollFrame:SetPoint("bottomright", container, "bottomright", 0, 0) --need to set the points @@ -1601,7 +1599,7 @@ end ---@return breakdownspellbar function spellsTab.CreateSpellBar(self, index) --~spellbar ~spellline ~spell ~create ~createline ---@type breakdownspellbar - local spellBar = CreateFrame("button", self:GetName() .. "SpellBar" .. index, self, "BackdropTemplate") + local spellBar = CreateFrame("button", self:GetName() .. "SpellBarButton" .. index, self, "BackdropTemplate") spellBar.index = index --size and positioning @@ -1859,7 +1857,7 @@ function spellsTab.monta_relatorio(botao) --deprecated? elseif (botao == 3) then --targets if (mainSection == 1 and subSection == 3) then - print(Loc ["STRING_ACTORFRAME_NOTHING"]) + Details:Msg(Loc ["STRING_ACTORFRAME_NOTHING"]) return end @@ -1878,7 +1876,7 @@ function spellsTab.monta_relatorio(botao) --deprecated? --dano --damage done --dps --heal if ((mainSection == 1 and (subSection == 1 or subSection == 2)) or (mainSection == 2)) then if (not player.detalhes) then - print(Loc ["STRING_ACTORFRAME_NOTHING"]) + Details:Msg(Loc ["STRING_ACTORFRAME_NOTHING"]) return end diff --git a/functions/profiles.lua b/functions/profiles.lua index a3960d95..0788c1e2 100644 --- a/functions/profiles.lua +++ b/functions/profiles.lua @@ -1419,10 +1419,9 @@ local default_global_data = { spellcontainer_width = 535, spellcontainer_height = 311, - spellcontainer_locked = true, + spellcontainer_islocked = true, --spellline_height = 20, - spellcontainer_headers = {}, --store information about active headers and their sizes spellcontainer_header_height = 20, spellcontainer_header_fontsize = 10,