Skip to content

Commit

Permalink
Version Bump and Framework Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed May 20, 2023
1 parent 7f4d966 commit 64a7053
Show file tree
Hide file tree
Showing 11 changed files with 506 additions and 263 deletions.
1 change: 1 addition & 0 deletions Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@
---@field grupo boolean
---@field fight_component boolean
---@field boss_fight_component boolean
---@field pvp_component boolean
---@field boss boolean
---@field last_event unixtime
---@field total_without_pet number
Expand Down
2 changes: 1 addition & 1 deletion Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


local dversion = 429
local dversion = 430
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)

Expand Down
48 changes: 40 additions & 8 deletions Libs/DF/header.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@ local geterrorhandler = geterrorhandler
local wipe = wipe

--definitions

---@class df_headercolumndata : {key: string, name: string, icon: string, texcoord: table, text: string, canSort: boolean, selected: boolean, width: number, height: number, align: string, offset: number}

---@class df_headerchild : uiobject
---@field FramesToAlign table

---@class df_headerframe : frame, df_headermixin, df_optionsmixin
---@field columnHeadersCreated df_headercolumnframe[]
---@field options table
---@field HeaderTable table
---@field HeaderTable df_headercolumndata[]
---@field columnSelected number

---@class df_headermixin : table
---@field NextHeader number
---@field HeaderWidth number
---@field HeaderHeight number
---@field OnColumnSettingChangeCallback function
---@field GetColumnWidth fun(self: df_headerframe, columnId: number)
---@field SetHeaderTable fun(self: df_headerframe, newTable)
---@field GetColumnWidth fun(self: df_headerframe, columnId: number) : number
---@field SetHeaderTable fun(self: df_headerframe, table)
---@field GetSelectedColumn fun(self: df_headerframe) : number, string, string, string
---@field Refresh fun(self: df_headerframe)
---@field UpdateSortArrow fun(self: df_headerframe, columnHeader: df_headercolumnframe, defaultShown: boolean|nil, defaultOrder: string|nil)
Expand Down Expand Up @@ -127,8 +130,8 @@ detailsFramework.HeaderFunctions = {
---@param buttonClicked string
OnClick = function(columnHeader, buttonClicked)
--get the header main frame
---@type df_headerframe
local headerFrame = columnHeader:GetParent()
---@cast headerFrame df_headerframe

--if this header does not have a clickable header, just ignore
if (not headerFrame.columnSelected) then
Expand Down Expand Up @@ -352,7 +355,6 @@ detailsFramework.HeaderMixin = {
UpdateColumnHeader = function(self, columnHeader, headerIndex)
--this is the data to update the columnHeader
local columnData = self.HeaderTable[headerIndex]

columnHeader.key = columnData.key or "total"

if (columnData.icon) then
Expand Down Expand Up @@ -417,7 +419,7 @@ detailsFramework.HeaderMixin = {

columnHeader.XPosition = self.HeaderWidth -- + self.options.padding
columnHeader.YPosition = self.HeaderHeight -- + self.options.padding

columnHeader.columnAlign = columnData.align or "left"
columnHeader.columnOffset = columnData.offset or 0

Expand Down Expand Up @@ -589,6 +591,7 @@ detailsFramework.HeaderMixin = {
HeaderHeight = 0,
}

--default options
local default_header_options = {
backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
backdrop_color = {0, 0, 0, 0.2},
Expand Down Expand Up @@ -629,13 +632,17 @@ local default_header_options = {
line_separator_gap_align = false,
}

---create a header frame
---create a df_headerframe, alias 'header'.
---a header is a frame that can hold multiple columns which are also frames, each column is a df_headercolumnframe, these columns are arranged in horizontal form.
---a header is used to organize columns giving them a name/title, a way to sort and align them.
---each column is placed on the right side of the previous column.
---@param parent frame
---@param headerTable table
---@param options table|nil
---@param frameName string|nil
---@return df_headerframe
function detailsFramework:CreateHeader(parent, headerTable, options, frameName)
---create the header frame which is returned by this function
---@type df_headerframe
local newHeader = CreateFrame("frame", frameName or "$parentHeaderLine", parent, "BackdropTemplate")

Expand All @@ -644,11 +651,36 @@ function detailsFramework:CreateHeader(parent, headerTable, options, frameName)

newHeader:BuildOptionsTable(default_header_options, options)

--set the backdrop and backdrop color following the values in the options table
newHeader:SetBackdrop(newHeader.options.backdrop)
newHeader:SetBackdropColor(unpack(newHeader.options.backdrop_color))
newHeader:SetBackdropBorderColor(unpack(newHeader.options.backdrop_border_color))

newHeader:SetHeaderTable(headerTable)

return newHeader
end
end


--[=[example:
C_Timer.After(1, function()
local parent = UIParent
--declare the columns the headerFrame will have
---@type df_headercolumndata[]
local headerTable = {
{name = "playername", text = "Player Name", width = 120, align = "left", canSort = true},
{name = "damage", text = "Damage Done", width = 80, align = "right", canSort = true},
{name = "points", text = "Total Points", width = 80, align = "right", canSort = false},
}
local frameName = "MyAddOnOptionsFrame"
local options = {}
local headerFrame = DetailsFramework:CreateHeader(parent, headerTable, options, frameName)
headerFrame:SetPoint("center", parent, "center", 10, -10)
end)
--]=]
1 change: 1 addition & 0 deletions Libs/DF/load.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@

<Script file="pictureedit.lua"/>
<Script file="auras.lua"/>
<Script file="tabcontainer.lua"/>
</Ui>
Loading

0 comments on commit 64a7053

Please sign in to comment.