diff --git a/Definitions.lua b/Definitions.lua index 4da8714f..8a86362d 100644 --- a/Definitions.lua +++ b/Definitions.lua @@ -31,9 +31,9 @@ ---@class color : table, string @table(r: red|number, g: green|number, b: blue|number, a: alpha|number) @string(color name) @hex (000000-ffffff) value representing a color, the value must be a table with the following fields: r, g, b, a. r, g, b are numbers between 0 and 1, a is a number between 0 and 1. To retrieve a color from a string or table use: local red, green, blue, alpha = DetailsFramework:ParseColors(color) ---@class scale : number @number(0.65-2.40) value representing the scale factor of the UIObject, the value must be between 0.65 and 2.40, the width and height of the UIObject will be multiplied by this value. ---@class texture : string, number is an object that represents a graphical image. Textures are used to display visual elements such as icons, backgrounds, borders, and more. ----@class frame : uiobject represents a container for other UI elements, such as textures, buttons, text, and more. +---@class frame : uiobject represents a container for other UI elements, such as textures, buttons, text, and more. Gotten from the first result of GetWidth() or from the first result of GetSize(). It is expected a GetWidth() or GetSize() when the type 'width' is used. ---@class width : number property that represents the horizontal size of a UI element, such as a frame or a texture. ----@class height : number property that represents the vertical size of a UI element, such as a frame or a texture. +---@class height : number property that represents the vertical size of a UI element, such as a frame or a texture. Gotten from the first result of GetHeight() or from the second result of GetSize(). It is expected a GetHeight() or GetSize() when the type 'height' is used. ---@class script : string, function is a piece of code that is executed in response to a specific event, such as a button click or a frame update. Scripts can be used to implement behavior and logic for UI elements. ---@class event : string is a notification that is sent to a frame when something happens, such as a button click or a frame update. Events can be used to trigger scripts. ---@class framestrata : string @string(BACKGROUND, LOW, MEDIUM, HIGH, DIALOG, FULLSCREEN, FULLSCREEN_DIALOG, TOOLTIP) property that determines the stacking order of frames. Higher strata values indicate frames that should be displayed on top of frames with lower strata values. @@ -85,7 +85,7 @@ ---@field SetDuration fun(self: animationgroup, duration: number) ---@field SetEndDelay fun(self: animationgroup, delay: number) ---@field SetLooping fun(self: animationgroup, loop: boolean) ----@field SetScript fun(self: animationgroup, event: string, handler: function) "OnEvent"|"OnShow" +---@field SetScript fun(self: animationgroup, event: string, handler: function|nil) "OnEvent"|"OnShow" ---@field SetSmoothProgress fun(self: animationgroup, smooth: boolean) ---@field Stop fun(self: animationgroup) @@ -104,13 +104,13 @@ ---@field SetDuration fun(self: animation, duration: number) ---@field SetEndDelay fun(self: animation, delay: number) ---@field SetOrder fun(self: animation, order: number) ----@field SetScript fun(self: animation, event: string, handler: function) +---@field SetScript fun(self: animation, event: string, handler: function|nil) ---@field SetSmoothing fun(self: animation, smoothing: string) ---@field Stop fun(self: animation) ---@class frame : uiobject ---@field SetAttribute fun(self: frame, name: string, value: any) ----@field SetScript fun(self: frame, event: string, handler: function) +---@field SetScript fun(self: frame, event: string, handler: function|nil) ---@field GetScript fun(self: frame, event: string) : function ---@field SetFrameStrata fun(self: frame, strata: framestrata|"background"|"low"|"medium"|"high"|"dialog"|"fullscreen"|"fullscreen_dialog"|"tooltip") ---@field SetFrameLevel fun(self: frame, level: number) diff --git a/Libs/DF/containers.lua b/Libs/DF/containers.lua index 336e0b88..0b15b41f 100644 --- a/Libs/DF/containers.lua +++ b/Libs/DF/containers.lua @@ -11,7 +11,7 @@ local CreateFrame = CreateFrame local wipe = wipe local unpack = unpack ----@class dfframecontainer : frame, dfframecontainermixin, df_optionsmixin +---@class df_framecontainer : frame, dfframecontainermixin, df_optionsmixin ---@field bIsSizing boolean ---@field options table ---@field currentWidth number @@ -28,24 +28,27 @@ local unpack = unpack ---@field sideResizers framecontainerresizer[] ---@field components table ---@field moverFrame frame ----@field movableChildren frame[] ----@field OnSizeChanged fun(frameContainer: dfframecontainer) +---@field movableChildren table +---@field settingChangedCallback fun(frameContainer: df_framecontainer, settingName: string, settingValue: any) +---@field OnSizeChanged fun(frameContainer: df_framecontainer) ---@field OnResizerMouseDown fun(resizerButton: button, mouseButton: string) ---@field OnResizerMouseUp fun(resizerButton: button, mouseButton: string) ----@field HideResizer fun(frameContainer: dfframecontainer) ----@field ShowResizer fun(frameContainer: dfframecontainer) ----@field OnInitialize fun(frameContainer: dfframecontainer) ----@field SetResizeLocked fun(frameContainer: dfframecontainer, isLocked: boolean) ----@field SetMovableLocked fun(frameContainer: dfframecontainer, isLocked: boolean) ----@field CheckResizeLockedState fun(frameContainer: dfframecontainer) ----@field CheckMovableLockedState fun(frameContainer: dfframecontainer) ----@field CreateMover fun(frameContainer: dfframecontainer) ----@field CreateResizers fun(frameContainer: dfframecontainer) ----@field RegisterChildForDrag fun(frameContainer: dfframecontainer, child: frame) ----@field UnregisterChildForDrag fun(frameContainer: dfframecontainer, child: frame) ----@field RefreshChildrenState fun(frameContainer: dfframecontainer) ----@field OnChildDragStart fun(frameContainer: dfframecontainer, child: frame) ----@field OnChildDragStop fun(frameContainer: dfframecontainer, child: frame) +---@field HideResizer fun(frameContainer: df_framecontainer) +---@field ShowResizer fun(frameContainer: df_framecontainer) +---@field OnInitialize fun(frameContainer: df_framecontainer) +---@field SetResizeLocked fun(frameContainer: df_framecontainer, isLocked: boolean) +---@field SetMovableLocked fun(frameContainer: df_framecontainer, isLocked: boolean) +---@field CheckResizeLockedState fun(frameContainer: df_framecontainer) +---@field CheckMovableLockedState fun(frameContainer: df_framecontainer) +---@field CreateMover fun(frameContainer: df_framecontainer) +---@field CreateResizers fun(frameContainer: df_framecontainer) +---@field RegisterChildForDrag fun(frameContainer: df_framecontainer, child: frame) +---@field UnregisterChildForDrag fun(frameContainer: df_framecontainer, child: frame) +---@field RefreshChildrenState fun(frameContainer: df_framecontainer) +---@field OnChildDragStart fun(frameContainer: df_framecontainer, child: frame) +---@field OnChildDragStop fun(frameContainer: df_framecontainer, child: frame) +---@field SetSettingChangedCallback fun(frameContainer: df_framecontainer, callback: fun(frameContainer: df_framecontainer, settingName: string, settingValue: any)) +---@field SendSettingChangedCallback fun(frameContainer: df_framecontainer, settingName: string, settingValue: any) @@ -64,8 +67,8 @@ detailsFramework.FrameContainerMixin = { return end - ---@type dfframecontainer - local frameContainer = resizerButton:GetParent() --Cannot assign `frame` to `dfframecontainer`. .. but dfframecontainer is inherited from frame + ---@type df_framecontainer + local frameContainer = resizerButton:GetParent() --Cannot assign `frame` to `df_framecontainer`. .. but df_framecontainer is inherited from frame if (frameContainer.bIsSizing) then return @@ -79,8 +82,8 @@ detailsFramework.FrameContainerMixin = { ---@param resizerButton framecontainerresizer ---@param mouseButton string OnResizerMouseUp = function(resizerButton, mouseButton) - ---@type dfframecontainer - local frameContainer = resizerButton:GetParent() --Cannot assign `frame` to `dfframecontainer`. .. but dfframecontainer is inherited from frame + ---@type df_framecontainer + local frameContainer = resizerButton:GetParent() --Cannot assign `frame` to `df_framecontainer`. .. but df_framecontainer is inherited from frame if (not frameContainer.bIsSizing) then return @@ -91,7 +94,7 @@ detailsFramework.FrameContainerMixin = { end, ---hide resizer - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer HideResizer = function(frameContainer) for i = 1, #frameContainer.cornerResizers do frameContainer.cornerResizers[i]:Hide() @@ -103,7 +106,7 @@ detailsFramework.FrameContainerMixin = { end, ---show resizer - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer ShowResizer = function(frameContainer) --corner resizers if (frameContainer.options.use_bottomleft_resizer) then @@ -135,7 +138,7 @@ detailsFramework.FrameContainerMixin = { end, ---check the lock state and show or hide the resizer, set the frame as movable or not, resizeable or not - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer CheckResizeLockedState = function(frameContainer) if (frameContainer.options.can_resize) then frameContainer:ShowResizer() @@ -147,7 +150,7 @@ detailsFramework.FrameContainerMixin = { end, ---check if the framecontainer can be moved and show or hide the mover - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer CheckMovableLockedState = function(frameContainer) if (frameContainer.options.can_move) then frameContainer:SetMovable(true) @@ -161,7 +164,7 @@ detailsFramework.FrameContainerMixin = { end, ---set the lock state - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer ---@param isLocked boolean SetResizeLocked = function(frameContainer, isLocked) frameContainer.options.can_resize = not isLocked @@ -169,7 +172,7 @@ detailsFramework.FrameContainerMixin = { end, ---set the state of the mover frame - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer ---@param isLocked boolean SetMovableLocked = function(frameContainer, isLocked) frameContainer.options.can_move = not isLocked @@ -177,7 +180,7 @@ detailsFramework.FrameContainerMixin = { end, ---create a mover to move the frame - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer CreateMover = function(frameContainer) local mover = CreateFrame("button", nil, frameContainer) frameContainer.moverFrame = mover @@ -198,7 +201,7 @@ detailsFramework.FrameContainerMixin = { end, ---create four corner resizer and four side resizer - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer CreateResizers = function(frameContainer) local parent = frameContainer:GetParent() --create resizers for the container corners @@ -214,7 +217,7 @@ detailsFramework.FrameContainerMixin = { frameContainer.topResizer = topResizer frameContainer.bottomResizer = bottomResizer - local leftResizer, rightResizer = detailsFramework:CreateResizeGrips(frameContainer, nil, parent:GetName() .. "LeftResizer", parent:GetName() .. "TopResizer") + local leftResizer, rightResizer = detailsFramework:CreateResizeGrips(frameContainer, nil, parent:GetName() .. "LeftResizer", parent:GetName() .. "RightResizer") frameContainer.leftResizer = leftResizer frameContainer.rightResizer = rightResizer @@ -235,16 +238,17 @@ detailsFramework.FrameContainerMixin = { --add all resizers to the frameContainer.components table for i = 1, #frameContainer.cornerResizers do frameContainer.components[frameContainer.cornerResizers[i]] = true - frameContainer.cornerResizers[i]:SetFrameStrata("TOOLTIP") end for i = 1, #frameContainer.sideResizers do frameContainer.components[frameContainer.sideResizers[i]] = true - frameContainer.sideResizers[i]:SetFrameStrata("TOOLTIP") end + + --hide all resizers + frameContainer:HideResizer() end, ---run when the container is created - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer OnInitialize = function(frameContainer) --õninit ~init ~oninit --set the default members frameContainer.bIsSizing = false @@ -256,7 +260,7 @@ detailsFramework.FrameContainerMixin = { frameContainer.cornerResizers[i]:SetScript("OnMouseUp", frameContainer.OnResizerMouseUp) end - local sideResizeThickness = 3 + local sideResizeThickness = 2 --iterate among the side resizers and set the mouse down and up scripts; set the texture color; clear all points; set the thickness for i = 1, #frameContainer.sideResizers do @@ -298,14 +302,14 @@ detailsFramework.FrameContainerMixin = { frameContainer.rightResizer.sizingFrom = "right" --set the side resizer points - frameContainer.topResizer:SetPoint("topleft", frameContainer, "topleft", 0, 0) - frameContainer.topResizer:SetPoint("topright", frameContainer, "topright", 0, 0) - frameContainer.bottomResizer:SetPoint("bottomleft", frameContainer, "bottomleft", 0, 0) - frameContainer.bottomResizer:SetPoint("bottomright", frameContainer, "bottomright", 0, 0) - frameContainer.leftResizer:SetPoint("topleft", frameContainer, "topleft", 0, 0) - frameContainer.leftResizer:SetPoint("bottomleft", frameContainer, "bottomleft", 0, 0) - frameContainer.rightResizer:SetPoint("topright", frameContainer, "topright", 0, 0) - frameContainer.rightResizer:SetPoint("bottomright", frameContainer, "bottomright", 0, 0) + frameContainer.topResizer:SetPoint("topleft", frameContainer, "topleft", 0, 2) + frameContainer.topResizer:SetPoint("topright", frameContainer, "topright", 0, 2) + frameContainer.bottomResizer:SetPoint("bottomleft", frameContainer, "bottomleft", 0, -2) + frameContainer.bottomResizer:SetPoint("bottomright", frameContainer, "bottomright", 0, -2) + frameContainer.leftResizer:SetPoint("topleft", frameContainer, "topleft", -2, 0) + frameContainer.leftResizer:SetPoint("bottomleft", frameContainer, "bottomleft", -2, 0) + frameContainer.rightResizer:SetPoint("topright", frameContainer, "topright", 2, 0) + frameContainer.rightResizer:SetPoint("bottomright", frameContainer, "bottomright", 2, 0) if (frameContainer.options.can_resize) then frameContainer:ShowResizer() @@ -319,7 +323,7 @@ detailsFramework.FrameContainerMixin = { end, ---run when the container has its size changed - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer OnSizeChanged = function(frameContainer) ---@type frame[] local children = {frameContainer:GetChildren()} @@ -346,6 +350,9 @@ detailsFramework.FrameContainerMixin = { --update the current size of the container frameContainer.currentWidth = frameContainer:GetWidth() frameContainer.currentHeight = frameContainer:GetHeight() + + frameContainer:SendSettingChangedCallback("width", frameContainer.currentWidth) + frameContainer:SendSettingChangedCallback("height", frameContainer.currentHeight) end, OnChildDragStop = function(child) @@ -353,8 +360,9 @@ detailsFramework.FrameContainerMixin = { child:SetScript("OnUpdate", nil) end, + ---@param child frame OnChildDragStart = function(child) - ---@type dfframecontainer + ---@type df_framecontainer local frameContainer = child:GetParent() ---get the coordinates for the frame container, which is called 'boundingBox' for convenience @@ -388,7 +396,7 @@ detailsFramework.FrameContainerMixin = { end, ---check if the children can be moved and set the properties on thisFrame - ---@param frameContainer dfframecontainer + ---@param frameContainer df_framecontainer RefreshChildrenState = function(frameContainer) frameContainer:EnableMouse(true) if (frameContainer.options.can_move_children) then @@ -410,18 +418,40 @@ detailsFramework.FrameContainerMixin = { end end, + ---@param frameContainer df_framecontainer + ---@param child frame RegisterChildForDrag = function(frameContainer, child) frameContainer.movableChildren[child] = true frameContainer:RefreshChildrenState() + child:SetFrameStrata(frameContainer:GetFrameStrata()) + child:SetFrameLevel(frameContainer:GetFrameLevel() - 3) end, + ---@param frameContainer df_framecontainer + ---@param child frame UnregisterChildForDrag = function(frameContainer, child) frameContainer.movableChildren[child] = nil frameContainer:RefreshChildrenState() end, + + ---@param frameContainer df_framecontainer + ---@param callback function + SetSettingChangedCallback = function(frameContainer, callback) + frameContainer.settingChangedCallback = callback + end, + + ---send a callback to the setting changed callback + ---@param frameContainer df_framecontainer + ---@param key string + ---@param value any + SendSettingChangedCallback = function(frameContainer, key, value) + if (type(frameContainer.settingChangedCallback) == "function") then + detailsFramework:Dispatch(frameContainer.settingChangedCallback, frameContainer, key, value) + end + end, } ----these are the default settings for the frame container; these keys can be accessed by dfframecontainer.options[key] +---these are the default settings for the frame container; these keys can be accessed by df_framecontainer.options[key] ---@type table local frameContainerOptions = { --default settings @@ -433,7 +463,7 @@ local frameContainerOptions = { use_topleft_resizer = false, use_topright_resizer = false, use_bottomleft_resizer = false, - use_bottomright_resizer = true, + use_bottomright_resizer = false, use_top_resizer = false, use_bottom_resizer = false, use_left_resizer = false, @@ -444,9 +474,9 @@ local frameContainerOptions = { ---@param parent frame ---@param options table|nil ---@param frameName string|nil ----@return dfframecontainer +---@return df_framecontainer function DF:CreateFrameContainer(parent, options, frameName) - ---@type dfframecontainer + ---@type df_framecontainer local frameContainer = CreateFrame("frame", frameName or ("$parentFrameContainer" .. math.random(10000, 99999)), parent, "BackdropTemplate") frameContainer.components = {} frameContainer.movableChildren = {} diff --git a/frames/window_playerbreakdown_spells.lua b/frames/window_playerbreakdown_spells.lua index cbc677ed..ac86c9b7 100644 --- a/frames/window_playerbreakdown_spells.lua +++ b/frames/window_playerbreakdown_spells.lua @@ -149,7 +149,6 @@ local onColumnHeaderClickCallback = function(headerFrame, columnHeader) end end ----update details profile ---copy settings from the ColumnInfo table which doesn't exists in the details profile ---this is called when the profile changes or when the tab is opened with a different actor than before ---@param containerType "spells"|"targets" @@ -366,7 +365,7 @@ function spellsTab.OnCreateTabCallback(tabButton, tabFrame) spellsTab.TabFrame = tabFrame - --open the breakdown window at startup + --open the breakdown window at startup for testing --[= C_Timer.After(1, function() Details:OpenPlayerDetails(1) @@ -1272,29 +1271,59 @@ end ---creates a scrollframe which show breakdownspellbar to show the spells used by an actor ---@param tabFrame tabframe ---@return breakdownspellscrollframe -function spellsTab.CreateSpellScrollContainer(tabFrame) +function spellsTab.CreateSpellScrollContainer(tabFrame) --~scroll ~create + ---@type width + local width = Details.breakdown_spell_tab.spellcontainer_width + ---@type height + local height = Details.breakdown_spell_tab.spellcontainer_height + --create a container for the scrollframe local options = { - width = CONST_SPELLSCROLL_WIDTH, - height = CONST_SPELLSCROLL_HEIGHT, - can_resize = false, + width = Details.breakdown_spell_tab.spellcontainer_width, + height = Details.breakdown_spell_tab.spellcontainer_height, + can_resize = Details.breakdown_spell_tab.spellcontainer_locked, can_move = false, can_move_children = false, use_bottom_resizer = true, use_right_resizer = true, + } - ---@type dfframecontainer + + ---@type df_framecontainer local container = DF:CreateFrameContainer(tabFrame, options, tabFrame:GetName() .. "SpellScrollContainer") container:SetPoint("topleft", tabFrame, "topleft", 5, -5) + container:SetFrameLevel(tabFrame:GetFrameLevel() + 10) + + local settingChangedCallbackFunction = function(frameContainer, settingName, settingValue) --doiing 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 + end + end + end + + local defaultAmountOfLines = 50 + + container:SetSettingChangedCallback(settingChangedCallbackFunction) + container:SetResizeLocked(false) --debug --replace this with a framework scrollframe - local scrollFrame = DF:CreateScrollBox(container, "$parentSpellScroll", refreshFunc, {}, CONST_SPELLSCROLL_WIDTH, CONST_SPELLSCROLL_HEIGHT, CONST_SPELLSCROLL_AMTLINES, CONST_SPELLSCROLL_LINEHEIGHT) + local scrollFrame = DF:CreateScrollBox(container, "$parentSpellScroll", refreshFunc, {}, width, height, defaultAmountOfLines, CONST_SPELLSCROLL_LINEHEIGHT) DF:ReskinSlider(scrollFrame) - DF:ApplyStandardBackdrop(scrollFrame) - container:RegisterChildForDrag(scrollFrame) + scrollFrame:SetBackdrop(nil) + scrollFrame:SetPoint("topleft", container, "topleft", 0, 0) --need to set the points - --scrollFrame:EnableMouse(true) - --scrollFrame:SetMovable(true) + scrollFrame:SetPoint("bottomright", container, "bottomright", 0, 0) --need to set the points + + container:RegisterChildForDrag(scrollFrame) + scrollFrame.DontHideChildrenOnPreRefresh = true tabFrame.SpellScrollFrame = scrollFrame spellsTab.SpellScrollFrame = scrollFrame @@ -1315,7 +1344,7 @@ function spellsTab.CreateSpellScrollContainer(tabFrame) local headerTable = {} ---@type df_headerframe - local header = DetailsFramework:CreateHeader(tabFrame, headerTable, headerOptions) + local header = DetailsFramework:CreateHeader(container, headerTable, headerOptions) scrollFrame.Header = header scrollFrame.Header:SetPoint("topleft", scrollFrame, "topleft", 0, 1) scrollFrame.Header:SetColumnSettingChangedCallback(onHeaderColumnOptionChanged) @@ -1324,7 +1353,7 @@ function spellsTab.CreateSpellScrollContainer(tabFrame) headerContainerType[scrollFrame.Header] = "spells" --create the scroll lines - for i = 1, CONST_SPELLSCROLL_AMTLINES do + for i = 1, defaultAmountOfLines do scrollFrame:CreateLine(spellsTab.CreateSpellBar) end diff --git a/functions/profiles.lua b/functions/profiles.lua index 507aead0..a3960d95 100644 --- a/functions/profiles.lua +++ b/functions/profiles.lua @@ -1417,6 +1417,12 @@ local default_global_data = { blockspell_spark_show = true, blockspell_spark_color = {1, 1, 1, 0.7}, + spellcontainer_width = 535, + spellcontainer_height = 311, + spellcontainer_locked = true, + --spellline_height = 20, + + spellcontainer_headers = {}, --store information about active headers and their sizes spellcontainer_header_height = 20, spellcontainer_header_fontsize = 10,