framework update

This commit is contained in:
Tercio Jose
2022-09-30 15:38:16 -03:00
parent 04967f63b4
commit 5ba7f229c0
6 changed files with 399 additions and 1607 deletions
+67 -53
View File
@@ -1,6 +1,6 @@
local dversion = 368
local dversion = 369
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
@@ -2546,10 +2546,9 @@ end
--> ~templates
--fonts
DF.font_templates = DF.font_templates or {}
--> detect which language is the client and select the font accordingly
--detect which language is the client and select the font accordingly
local clientLanguage = GetLocale()
if (clientLanguage == "enGB") then
clientLanguage = "enUS"
@@ -2557,7 +2556,7 @@ end
DF.ClientLanguage = clientLanguage
--> returns which region the language the client is running, return "western", "russia" or "asia"
--returns which region the language the client is running, return "western", "russia" or "asia"
function DF:GetClientRegion()
if (clientLanguage == "zhCN" or clientLanguage == "koKR" or clientLanguage == "zhTW") then
return "asia"
@@ -2568,7 +2567,7 @@ function DF:GetClientRegion()
end
end
--> return the best font to use for the client language
--return the best font to use for the client language
function DF:GetBestFontForLanguage (language, western, cyrillic, china, korean, taiwan)
if (not language) then
language = DF.ClientLanguage
@@ -2576,31 +2575,29 @@ function DF:GetBestFontForLanguage (language, western, cyrillic, china, korean,
if (language == "enUS" or language == "deDE" or language == "esES" or language == "esMX" or language == "frFR" or language == "itIT" or language == "ptBR") then
return western or "Friz Quadrata TT"
elseif (language == "ruRU") then
return cyrillic or "Arial Narrow"
elseif (language == "zhCN") then
return china or "AR CrystalzcuheiGBK Demibold"
elseif (language == "koKR") then
return korean or "2002"
elseif (language == "zhTW") then
return taiwan or "AR CrystalzcuheiGBK Demibold"
end
end
--DF.font_templates ["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 11, font = "Accidental Presidency"}
--DF.font_templates ["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 12, font = "Accidental Presidency"}
DF.font_templates ["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 10, font = DF:GetBestFontForLanguage()}
DF.font_templates ["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 9.6, font = DF:GetBestFontForLanguage()}
-- dropdowns
DF.font_templates["ORANGE_FONT_TEMPLATE"] = {color = "orange", size = 10, font = DF:GetBestFontForLanguage()}
DF.font_templates["OPTIONS_FONT_TEMPLATE"] = {color = "yellow", size = 9.6, font = DF:GetBestFontForLanguage()}
--dropdowns
DF.dropdown_templates = DF.dropdown_templates or {}
DF.dropdown_templates ["OPTIONS_DROPDOWN_TEMPLATE"] = {
DF.dropdown_templates["OPTIONS_DROPDOWN_TEMPLATE"] = {
backdrop = {
edgeFile = [[Interface\Buttons\WHITE8X8]],
edgeSize = 1,
@@ -2619,10 +2616,28 @@ DF.dropdown_templates ["OPTIONS_DROPDOWN_TEMPLATE"] = {
dropiconpoints = {-2, -3},
}
-- switches
DF.dropdown_templates["OPTIONS_DROPDOWNDARK_TEMPLATE"] = {
backdrop = {
edgeFile = [[Interface\Buttons\WHITE8X8]],
edgeSize = 1,
bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
tileSize = 64,
tile = true
},
backdropcolor = {0.1215, 0.1176, 0.1294, 0.8000},
backdropbordercolor = {.2, .2, .2, 1},
onentercolor = {.5, .5, .5, .9},
onenterbordercolor = {.4, .4, .4, 1},
dropicon = "Interface\\BUTTONS\\arrow-Down-Down",
dropiconsize = {16, 16},
dropiconpoints = {-2, -3},
}
--switches
DF.switch_templates = DF.switch_templates or {}
DF.switch_templates ["OPTIONS_CHECKBOX_TEMPLATE"] = {
DF.switch_templates["OPTIONS_CHECKBOX_TEMPLATE"] = {
backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
backdropcolor = {1, 1, 1, .5},
backdropbordercolor = {0, 0, 0, 1},
@@ -2632,7 +2647,7 @@ DF.switch_templates ["OPTIONS_CHECKBOX_TEMPLATE"] = {
disabled_backdropcolor = {1, 1, 1, .2},
onenterbordercolor = {1, 1, 1, 1},
}
DF.switch_templates ["OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"] = {
DF.switch_templates["OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"] = {
backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
backdropcolor = {1, 1, 1, .5},
backdropbordercolor = {0, 0, 0, 1},
@@ -2643,19 +2658,17 @@ DF.switch_templates ["OPTIONS_CHECKBOX_BRIGHT_TEMPLATE"] = {
onenterbordercolor = {1, 1, 1, 1},
}
-- buttons
--buttons
DF.button_templates = DF.button_templates or {}
DF.button_templates ["OPTIONS_BUTTON_TEMPLATE"] = {
DF.button_templates["OPTIONS_BUTTON_TEMPLATE"] = {
backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
backdropcolor = {1, 1, 1, .5},
backdropbordercolor = {0, 0, 0, 1},
}
-- sliders
--sliders
DF.slider_templates = DF.slider_templates or {}
DF.slider_templates ["OPTIONS_SLIDER_TEMPLATE"] = {
DF.slider_templates["OPTIONS_SLIDER_TEMPLATE"] = {
backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true},
backdropcolor = {1, 1, 1, .5},
backdropbordercolor = {0, 0, 0, 1},
@@ -2667,46 +2680,47 @@ DF.slider_templates ["OPTIONS_SLIDER_TEMPLATE"] = {
thumbcolor = {0, 0, 0, 0.5},
}
function DF:InstallTemplate (widget_type, template_name, template, parent_name)
function DF:InstallTemplate (widgetType, templateName, template, parentName)
local newTemplate = {}
--if has a parent, just copy the parent to the new template
if (parent_name and type (parent_name) == "string") then
local parentTemplate = DF:GetTemplate (widget_type, parent_name)
if (parentName and type(parentName) == "string") then
local parentTemplate = DF:GetTemplate(widgetType, parentName)
if (parentTemplate) then
DF.table.copy (newTemplate, parentTemplate)
DF.table.copy(newTemplate, parentTemplate)
end
end
--copy the template passed into the new template
DF.table.copy (newTemplate, template)
widget_type = string.lower (widget_type)
local template_table
if (widget_type == "font") then
template_table = DF.font_templates
--copy the template passed into the new template
DF.table.copy(newTemplate, template)
widgetType = string.lower(widgetType)
local templateTable
if (widgetType == "font") then
templateTable = DF.font_templates
local font = template.font
if (font) then
--> fonts passed into the template has default to western
--> the framework will get the game client language and change the font if needed
font = DF:GetBestFontForLanguage (nil, font)
--fonts passed into the template has default to western
--the framework will get the game client language and change the font if needed
font = DF:GetBestFontForLanguage(nil, font)
end
elseif (widget_type == "dropdown") then
template_table = DF.dropdown_templates
elseif (widget_type == "button") then
template_table = DF.button_templates
elseif (widget_type == "switch") then
template_table = DF.switch_templates
elseif (widget_type == "slider") then
template_table = DF.slider_templates
elseif (widgetType == "dropdown") then
templateTable = DF.dropdown_templates
elseif (widgetType == "button") then
templateTable = DF.button_templates
elseif (widgetType == "switch") then
templateTable = DF.switch_templates
elseif (widgetType == "slider") then
templateTable = DF.slider_templates
end
template_table [template_name] = newTemplate
templateTable[templateName] = newTemplate
return newTemplate
end
+1
View File
@@ -3,6 +3,7 @@
<Script file ="DFPixelUtil.lua"/>
<Script file="fw.lua"/>
<Script file="mixins.lua"/>
<Script file="util.lua"/>
<Script file="addon.lua"/>
<Script file="colors.lua"/>
<Script file="help.lua"/>
+10 -1
View File
@@ -211,11 +211,20 @@ DF.ScrollBoxFunctions = {
end
local okay, newLine = pcall(func, self, #self.Frames+1)
if (okay) then
if (not newLine) then
error("ScrollFrame:CreateLine() function did not returned a line, use: 'return line'")
end
tinsert(self.Frames, newLine)
newLine.Index = #self.Frames
return newLine
else
error("Details! FrameWork: CreateLine(): " .. newLine)
error("ScrollFrame:CreateLine() error on creating a line: " .. newLine)
end
end,
CreateLines = function(self, callback, lineAmount)
for i = 1, lineAmount do
self:CreateLine(callback)
end
end,
+124 -125
View File
@@ -5430,38 +5430,38 @@ end
--mixed functions
DF.HeaderFunctions = {
AddFrameToHeaderAlignment = function (self, frame)
AddFrameToHeaderAlignment = function(self, frame)
self.FramesToAlign = self.FramesToAlign or {}
tinsert (self.FramesToAlign, frame)
tinsert(self.FramesToAlign, frame)
end,
--@self: an object like a line
--@headerFrame: the main header frame
--@anchor: which side the columnHeaders are attach
AlignWithHeader = function (self, headerFrame, anchor)
AlignWithHeader = function(self, headerFrame, anchor)
local columnHeaderFrames = headerFrame.columnHeadersCreated
anchor = anchor or "topleft"
for i = 1, #self.FramesToAlign do
local frame = self.FramesToAlign [i]
local frame = self.FramesToAlign[i]
frame:ClearAllPoints()
local columnHeader = columnHeaderFrames [i]
local columnHeader = columnHeaderFrames[i]
local offset = 0
if (columnHeader.columnAlign == "right") then
offset = columnHeader:GetWidth()
if (frame:GetObjectType() == "FontString") then
frame:SetJustifyH ("right")
frame:SetJustifyH("right")
end
end
frame:SetPoint (columnHeader.columnAlign, self, anchor, columnHeader.XPosition + columnHeader.columnOffset + offset, 0)
frame:SetPoint(columnHeader.columnAlign, self, anchor, columnHeader.XPosition + columnHeader.columnOffset + offset, 0)
end
end,
--@self: column header button
OnClick = function (self, buttonClicked)
OnClick = function(self, buttonClicked)
--get the header main frame
local headerFrame = self:GetParent()
@@ -5472,10 +5472,10 @@ DF.HeaderFunctions = {
end
--get the latest column header selected
local previousColumnHeader = headerFrame.columnHeadersCreated [headerFrame.columnSelected]
local previousColumnHeader = headerFrame.columnHeadersCreated[headerFrame.columnSelected]
previousColumnHeader.Arrow:Hide()
headerFrame:ResetColumnHeaderBackdrop (previousColumnHeader)
headerFrame:SetBackdropColorForSelectedColumnHeader (self)
headerFrame:ResetColumnHeaderBackdrop(previousColumnHeader)
headerFrame:SetBackdropColorForSelectedColumnHeader(self)
if (headerFrame.columnSelected == self.columnIndex) then
self.order = self.order ~= "ASC" and "ASC" or "DESC"
@@ -5485,20 +5485,24 @@ DF.HeaderFunctions = {
--set the new column header selected
headerFrame.columnSelected = self.columnIndex
headerFrame:UpdateSortArrow (self)
headerFrame:UpdateSortArrow(self)
if (headerFrame.options.header_click_callback) then
--callback with the main header frame, column header, column index and column order as payload
local okay, errortext = pcall (headerFrame.options.header_click_callback, headerFrame, self, self.columnIndex, self.order)
local okay, errortext = pcall(headerFrame.options.header_click_callback, headerFrame, self, self.columnIndex, self.order)
if (not okay) then
print ("DF: Header onClick callback error:", errortext)
print("DF: Header onClick callback error:", errortext)
end
end
end,
}
DF.HeaderCoreFunctions = {
SetHeaderTable = function (self, newTable)
GetColumnWidth = function(self, columnId)
return self.HeaderTable[columnId].width
end,
SetHeaderTable = function(self, newTable)
self.columnHeadersCreated = self.columnHeadersCreated or {}
self.HeaderTable = newTable
self.NextHeader = 1
@@ -5508,72 +5512,70 @@ DF.HeaderCoreFunctions = {
end,
--return which header is current selected and the the order ASC DESC
GetSelectedColumn = function (self)
return self.columnSelected, self.columnHeadersCreated [self.columnSelected or 1].order
GetSelectedColumn = function(self)
return self.columnSelected, self.columnHeadersCreated[self.columnSelected or 1].order
end,
--clean up and rebuild the header following the header options
--@self: main header frame
Refresh = function (self)
--> refresh background frame
self:SetBackdrop (self.options.backdrop)
self:SetBackdropColor (unpack (self.options.backdrop_color))
self:SetBackdropBorderColor (unpack (self.options.backdrop_border_color))
Refresh = function(self)
--refresh background frame
self:SetBackdrop(self.options.backdrop)
self:SetBackdropColor(unpack (self.options.backdrop_color))
self:SetBackdropBorderColor(unpack (self.options.backdrop_border_color))
--> reset all header frames
--reset all header frames
for i = 1, #self.columnHeadersCreated do
local columnHeader = self.columnHeadersCreated [i]
local columnHeader = self.columnHeadersCreated[i]
columnHeader.InUse = false
columnHeader:Hide()
end
local previousColumnHeader
local growDirection = string.lower (self.options.grow_direction)
local growDirection = string.lower(self.options.grow_direction)
--> update header frames
--update header frames
local headerSize = #self.HeaderTable
for i = 1, headerSize do
--> get the header button, a new one is created if it doesn't exists yet
--get the header button, a new one is created if it doesn't exists yet
local columnHeader = self:GetNextHeader()
self:UpdateColumnHeader (columnHeader, i)
self:UpdateColumnHeader(columnHeader, i)
--> grow direction
--grow direction
if (not previousColumnHeader) then
columnHeader:SetPoint ("topleft", self, "topleft", 0, 0)
columnHeader:SetPoint("topleft", self, "topleft", 0, 0)
if (growDirection == "right") then
if (self.options.use_line_separators) then
columnHeader.Separator:Show()
columnHeader.Separator:SetWidth (self.options.line_separator_width)
columnHeader.Separator:SetColorTexture (unpack (self.options.line_separator_color))
columnHeader.Separator:SetWidth(self.options.line_separator_width)
columnHeader.Separator:SetColorTexture(unpack(self.options.line_separator_color))
columnHeader.Separator:ClearAllPoints()
if (self.options.line_separator_gap_align) then
columnHeader.Separator:SetPoint ("topleft", columnHeader, "topright", 0, 0)
columnHeader.Separator:SetPoint("topleft", columnHeader, "topright", 0, 0)
else
columnHeader.Separator:SetPoint ("topright", columnHeader, "topright", 0, 0)
columnHeader.Separator:SetPoint("topright", columnHeader, "topright", 0, 0)
end
columnHeader.Separator:SetHeight (self.options.line_separator_height)
columnHeader.Separator:SetHeight(self.options.line_separator_height)
end
end
else
if (growDirection == "right") then
columnHeader:SetPoint ("topleft", previousColumnHeader, "topright", self.options.padding, 0)
columnHeader:SetPoint("topleft", previousColumnHeader, "topright", self.options.padding, 0)
if (self.options.use_line_separators) then
columnHeader.Separator:Show()
columnHeader.Separator:SetWidth (self.options.line_separator_width)
columnHeader.Separator:SetColorTexture (unpack (self.options.line_separator_color))
columnHeader.Separator:SetWidth(self.options.line_separator_width)
columnHeader.Separator:SetColorTexture(unpack (self.options.line_separator_color))
columnHeader.Separator:ClearAllPoints()
if (self.options.line_separator_gap_align) then
columnHeader.Separator:SetPoint ("topleft", columnHeader, "topright", 0, 0)
columnHeader.Separator:SetPoint("topleft", columnHeader, "topright", 0, 0)
else
columnHeader.Separator:SetPoint ("topleft", columnHeader, "topright", 0, 0)
columnHeader.Separator:SetPoint("topleft", columnHeader, "topright", 0, 0)
end
columnHeader.Separator:SetHeight (self.options.line_separator_height)
columnHeader.Separator:SetHeight(self.options.line_separator_height)
if (headerSize == i) then
columnHeader.Separator:Hide()
@@ -5581,84 +5583,81 @@ DF.HeaderCoreFunctions = {
end
elseif (growDirection == "left") then
columnHeader:SetPoint ("topright", previousColumnHeader, "topleft", -self.options.padding, 0)
columnHeader:SetPoint("topright", previousColumnHeader, "topleft", -self.options.padding, 0)
elseif (growDirection == "bottom") then
columnHeader:SetPoint ("topleft", previousColumnHeader, "bottomleft", 0, -self.options.padding)
columnHeader:SetPoint("topleft", previousColumnHeader, "bottomleft", 0, -self.options.padding)
elseif (growDirection == "top") then
columnHeader:SetPoint ("bottomleft", previousColumnHeader, "topleft", 0, self.options.padding)
columnHeader:SetPoint("bottomleft", previousColumnHeader, "topleft", 0, self.options.padding)
end
end
previousColumnHeader = columnHeader
end
self:SetSize (self.HeaderWidth, self.HeaderHeight)
self:SetSize(self.HeaderWidth, self.HeaderHeight)
end,
--@self: main header frame
UpdateSortArrow = function (self, columnHeader, defaultShown, defaultOrder)
UpdateSortArrow = function(self, columnHeader, defaultShown, defaultOrder)
local options = self.options
local order = defaultOrder or columnHeader.order
local arrowIcon = columnHeader.Arrow
if (type (defaultShown) ~= "boolean") then
if (type(defaultShown) ~= "boolean") then
arrowIcon:Show()
else
arrowIcon:SetShown (defaultShown)
arrowIcon:SetShown(defaultShown)
if (defaultShown) then
self:SetBackdropColorForSelectedColumnHeader (columnHeader)
self:SetBackdropColorForSelectedColumnHeader(columnHeader)
end
end
arrowIcon:SetAlpha (options.arrow_alpha)
arrowIcon:SetAlpha(options.arrow_alpha)
if (order == "ASC") then
arrowIcon:SetTexture (options.arrow_up_texture)
arrowIcon:SetTexCoord (unpack (options.arrow_up_texture_coords))
arrowIcon:SetSize (unpack (options.arrow_up_size))
arrowIcon:SetTexture(options.arrow_up_texture)
arrowIcon:SetTexCoord(unpack(options.arrow_up_texture_coords))
arrowIcon:SetSize(unpack(options.arrow_up_size))
elseif (order == "DESC") then
arrowIcon:SetTexture (options.arrow_down_texture)
arrowIcon:SetTexCoord (unpack (options.arrow_down_texture_coords))
arrowIcon:SetSize (unpack (options.arrow_down_size))
arrowIcon:SetTexture(options.arrow_down_texture)
arrowIcon:SetTexCoord(unpack(options.arrow_down_texture_coords))
arrowIcon:SetSize(unpack(options.arrow_down_size))
end
end,
--@self: main header frame
UpdateColumnHeader = function (self, columnHeader, headerIndex)
local headerData = self.HeaderTable [headerIndex]
UpdateColumnHeader = function(self, columnHeader, headerIndex)
local headerData = self.HeaderTable[headerIndex]
if (headerData.icon) then
columnHeader.Icon:SetTexture (headerData.icon)
columnHeader.Icon:SetTexture(headerData.icon)
if (headerData.texcoord) then
columnHeader.Icon:SetTexCoord (unpack (headerData.texcoord))
columnHeader.Icon:SetTexCoord(unpack(headerData.texcoord))
else
columnHeader.Icon:SetTexCoord (0, 1, 0, 1)
columnHeader.Icon:SetTexCoord(0, 1, 0, 1)
end
columnHeader.Icon:SetPoint ("left", columnHeader, "left", self.options.padding, 0)
columnHeader.Icon:SetPoint("left", columnHeader, "left", self.options.padding, 0)
columnHeader.Icon:Show()
end
if (headerData.text) then
columnHeader.Text:SetText (headerData.text)
columnHeader.Text:SetText(headerData.text)
--> text options
DF:SetFontColor (columnHeader.Text, self.options.text_color)
DF:SetFontSize (columnHeader.Text, self.options.text_size)
DF:SetFontOutline (columnHeader.Text, self.options.text_shadow)
--text options
DF:SetFontColor(columnHeader.Text, self.options.text_color)
DF:SetFontSize(columnHeader.Text, self.options.text_size)
DF:SetFontOutline(columnHeader.Text, self.options.text_shadow)
--> point
--point
if (not headerData.icon) then
columnHeader.Text:SetPoint ("left", columnHeader, "left", self.options.padding, 0)
columnHeader.Text:SetPoint("left", columnHeader, "left", self.options.padding, 0)
else
columnHeader.Text:SetPoint ("left", columnHeader.Icon, "right", self.options.padding, 0)
columnHeader.Text:SetPoint("left", columnHeader.Icon, "right", self.options.padding, 0)
end
columnHeader.Text:Show()
@@ -5669,43 +5668,43 @@ DF.HeaderCoreFunctions = {
if (headerData.canSort) then
columnHeader.order = "DESC"
columnHeader.Arrow:SetTexture (self.options.arrow_up_texture)
columnHeader.Arrow:SetTexture(self.options.arrow_up_texture)
else
columnHeader.Arrow:Hide()
end
if (headerData.selected) then
columnHeader.Arrow:Show()
columnHeader.Arrow:SetAlpha (.843)
self:UpdateSortArrow (columnHeader, true, columnHeader.order)
columnHeader.Arrow:SetAlpha(.843)
self:UpdateSortArrow(columnHeader, true, columnHeader.order)
self.columnSelected = headerIndex
else
if (headerData.canSort) then
self:UpdateSortArrow (columnHeader, false, columnHeader.order)
self:UpdateSortArrow(columnHeader, false, columnHeader.order)
end
end
--> size
--size
if (headerData.width) then
columnHeader:SetWidth (headerData.width)
columnHeader:SetWidth(headerData.width)
end
if (headerData.height) then
columnHeader:SetHeight (headerData.height)
columnHeader:SetHeight(headerData.height)
end
columnHeader.XPosition = self.HeaderWidth-- + self.options.padding
columnHeader.YPosition = self.HeaderHeight-- + self.options.padding
columnHeader.XPosition = self.HeaderWidth -- + self.options.padding
columnHeader.YPosition = self.HeaderHeight -- + self.options.padding
columnHeader.columnAlign = headerData.align or "left"
columnHeader.columnOffset = headerData.offset or 0
--> add the header piece size to the total header size
local growDirection = string.lower (self.options.grow_direction)
--add the header piece size to the total header size
local growDirection = string.lower(self.options.grow_direction)
if (growDirection == "right" or growDirection == "left") then
self.HeaderWidth = self.HeaderWidth + columnHeader:GetWidth() + self.options.padding
self.HeaderHeight = math.max (self.HeaderHeight, columnHeader:GetHeight())
elseif (growDirection == "top" or growDirection == "bottom") then
self.HeaderWidth = math.max (self.HeaderWidth, columnHeader:GetWidth())
self.HeaderHeight = self.HeaderHeight + columnHeader:GetHeight() + self.options.padding
@@ -5717,63 +5716,63 @@ DF.HeaderCoreFunctions = {
--reset column header backdrop
--@self: main header frame
ResetColumnHeaderBackdrop = function (self, columnHeader)
columnHeader:SetBackdrop (self.options.header_backdrop)
columnHeader:SetBackdropColor (unpack (self.options.header_backdrop_color))
columnHeader:SetBackdropBorderColor (unpack (self.options.header_backdrop_border_color))
ResetColumnHeaderBackdrop = function(self, columnHeader)
columnHeader:SetBackdrop(self.options.header_backdrop)
columnHeader:SetBackdropColor(unpack(self.options.header_backdrop_color))
columnHeader:SetBackdropBorderColor(unpack(self.options.header_backdrop_border_color))
end,
--@self: main header frame
SetBackdropColorForSelectedColumnHeader = function (self, columnHeader)
columnHeader:SetBackdropColor (unpack (self.options.header_backdrop_color_selected))
SetBackdropColorForSelectedColumnHeader = function(self, columnHeader)
columnHeader:SetBackdropColor(unpack(self.options.header_backdrop_color_selected))
end,
--clear the column header
--@self: main header frame
ClearColumnHeader = function (self, columnHeader)
columnHeader:SetSize (self.options.header_width, self.options.header_height)
self:ResetColumnHeaderBackdrop (columnHeader)
ClearColumnHeader = function(self, columnHeader)
columnHeader:SetSize(self.options.header_width, self.options.header_height)
self:ResetColumnHeaderBackdrop(columnHeader)
columnHeader:ClearAllPoints()
columnHeader.Icon:SetTexture ("")
columnHeader.Icon:SetTexture("")
columnHeader.Icon:Hide()
columnHeader.Text:SetText ("")
columnHeader.Text:SetText("")
columnHeader.Text:Hide()
end,
--get the next column header, create one if doesn't exists
--@self: main header frame
GetNextHeader = function (self)
GetNextHeader = function(self)
local nextHeader = self.NextHeader
local columnHeader = self.columnHeadersCreated [nextHeader]
local columnHeader = self.columnHeadersCreated[nextHeader]
if (not columnHeader) then
--create a new column header
local newHeader = CreateFrame ("button", "$parentHeaderIndex" .. nextHeader, self,"BackdropTemplate")
newHeader:SetScript ("OnClick", DF.HeaderFunctions.OnClick)
local newHeader = CreateFrame("button", "$parentHeaderIndex" .. nextHeader, self, "BackdropTemplate")
newHeader:SetScript("OnClick", DF.HeaderFunctions.OnClick)
--header icon
DF:CreateImage (newHeader, "", self.options.header_height, self.options.header_height, "ARTWORK", nil, "Icon", "$parentIcon")
DF:CreateImage(newHeader, "", self.options.header_height, self.options.header_height, "ARTWORK", nil, "Icon", "$parentIcon")
--header separator
DF:CreateImage (newHeader, "", 1, 1, "ARTWORK", nil, "Separator", "$parentSeparator")
DF:CreateImage(newHeader, "", 1, 1, "ARTWORK", nil, "Separator", "$parentSeparator")
--header name text
DF:CreateLabel (newHeader, "", self.options.text_size, self.options.text_color, "GameFontNormal", "Text", "$parentText", "ARTWORK")
DF:CreateLabel(newHeader, "", self.options.text_size, self.options.text_color, "GameFontNormal", "Text", "$parentText", "ARTWORK")
--header selected and order icon
DF:CreateImage (newHeader, self.options.arrow_up_texture, 12, 12, "ARTWORK", nil, "Arrow", "$parentArrow")
DF:CreateImage(newHeader, self.options.arrow_up_texture, 12, 12, "ARTWORK", nil, "Arrow", "$parentArrow")
newHeader.Arrow:SetPoint ("right", newHeader, "right", -1, 0)
newHeader.Arrow:SetPoint("right", newHeader, "right", -1, 0)
newHeader.Separator:Hide()
newHeader.Arrow:Hide()
self:UpdateSortArrow (newHeader, false, "DESC")
self:UpdateSortArrow(newHeader, false, "DESC")
tinsert (self.columnHeadersCreated, newHeader)
tinsert(self.columnHeadersCreated, newHeader)
columnHeader = newHeader
end
self:ClearColumnHeader (columnHeader)
self:ClearColumnHeader(columnHeader)
self.NextHeader = self.NextHeader + 1
return columnHeader
end,
@@ -5817,21 +5816,21 @@ local default_header_options = {
line_separator_gap_align = false,
}
function DF:CreateHeader (parent, headerTable, options, frameName)
local f = CreateFrame ("frame", frameName or "$parentHeaderLine", parent,"BackdropTemplate")
function DF:CreateHeader(parent, headerTable, options, frameName)
local newHeader = CreateFrame("frame", frameName or "$parentHeaderLine", parent, "BackdropTemplate")
DF:Mixin (f, DF.OptionsFunctions)
DF:Mixin (f, DF.HeaderCoreFunctions)
DF:Mixin(newHeader, DF.OptionsFunctions)
DF:Mixin(newHeader, DF.HeaderCoreFunctions)
f:BuildOptionsTable (default_header_options, options)
newHeader:BuildOptionsTable(default_header_options, options)
f:SetBackdrop (f.options.backdrop)
f:SetBackdropColor (unpack (f.options.backdrop_color))
f:SetBackdropBorderColor (unpack (f.options.backdrop_border_color))
newHeader:SetBackdrop(newHeader.options.backdrop)
newHeader:SetBackdropColor(unpack(newHeader.options.backdrop_color))
newHeader:SetBackdropBorderColor(unpack(newHeader.options.backdrop_border_color))
f:SetHeaderTable (headerTable)
newHeader:SetHeaderTable(headerTable)
return f
return newHeader
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+173 -1428
View File
File diff suppressed because it is too large Load Diff
+24
View File
@@ -0,0 +1,24 @@
local DetailsFramework = _G["DetailsFramework"]
if (not DetailsFramework or not DetailsFrameworkCanLoad) then
return
end
local _
local DF = DetailsFramework
--backdrop namespace
DF.BackdropUtil = {}
function DF.BackdropUtil:SetColorStripe(frame, index, backdrop, color1, color2)
if (backdrop == nil or type(backdrop) == "table") then
frame:SetBackdrop(backdrop and {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
end
if (index % 2 == 0) then
local r, g, b, a = DF:ParseColors(color1 or {.2, .2, .2, 0.5})
frame:SetBackdropColor(r, g, b, a)
else
local r, g, b, a = DF:ParseColors(color2 or {.3, .3, .3, 0.5})
frame:SetBackdropColor(r, g, b, a)
end
end