Skip to content

Commit

Permalink
Close #216: Add row border configurations (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mctalian authored Dec 18, 2024
1 parent 293d842 commit 2d6337c
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 65 deletions.
95 changes: 54 additions & 41 deletions LootDisplay/LootDisplayFrame/LootDisplayRow/LootDisplayRow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ local function rowText(row, icon)
if icon then
if row.unit then
row.SecondaryText:SetPoint(anchor, row.UnitPortrait, iconAnchor, xOffset, 0)
local classColor
if GetExpansionLevel() >= G_RLF.Expansion.BFA then
classColor = C_ClassColor.GetClassColor(select(2, UnitClass(row.unit)))
else
classColor = RAID_CLASS_COLORS[select(2, UnitClass(row.unit))]
end
row.SecondaryText:SetTextColor(classColor.r, classColor.g, classColor.b, 1)
else
row.SecondaryText:SetPoint(anchor, row.Icon, iconAnchor, xOffset, 0)
end
Expand All @@ -173,46 +180,6 @@ local function rowText(row, icon)
end
end

local function updateBorderPositions(row)
if row.borderCachedWidth ~= row:GetWidth() or row.borderCachedHeight ~= row:GetHeight() then
row.borderCachedWidth = row:GetWidth()
row.borderCachedHeight = row:GetHeight()
else
return
end
-- Adjust the Top border
row.TopBorder:ClearAllPoints()
row.TopBorder:SetWidth(row:GetWidth())
row.TopBorder:SetHeight(4)
row.TopBorder:SetTexCoord(0, 1, 1, 0)
row.TopBorder:SetPoint("TOPLEFT", row, "TOPLEFT", 0, 2)
row.TopBorder:SetPoint("TOPRIGHT", row, "TOPRIGHT", 0, 2)

-- Adjust the Left border
row.LeftBorder:ClearAllPoints()
row.LeftBorder:SetHeight(row:GetHeight())
row.LeftBorder:SetWidth(4)
row.LeftBorder:SetTexCoord(1, 0, 0, 1)
row.LeftBorder:SetPoint("TOPLEFT", row, "TOPLEFT", -2, 0)
row.LeftBorder:SetPoint("BOTTOMLEFT", row, "BOTTOMLEFT", -2, 0)

-- Adjust the Bottom border
row.BottomBorder:ClearAllPoints()
row.BottomBorder:SetWidth(row:GetWidth())
row.BottomBorder:SetHeight(4)
row.BottomBorder:SetTexCoord(0, 1, 0, 1)
row.BottomBorder:SetPoint("BOTTOMLEFT", row, "BOTTOMLEFT", 0, -2)
row.BottomBorder:SetPoint("BOTTOMRIGHT", row, "BOTTOMRIGHT", 0, -2)

-- Adjust the Right border
row.RightBorder:ClearAllPoints()
row.RightBorder:SetHeight(row:GetHeight())
row.RightBorder:SetWidth(4)
row.RightBorder:SetTexCoord(0, 1, 0, 1)
row.RightBorder:SetPoint("TOPRIGHT", row, "TOPRIGHT", 2, 0)
row.RightBorder:SetPoint("BOTTOMRIGHT", row, "BOTTOMRIGHT", 2, 0)
end

local function rowHighlightBorder(row)
if not row.HighlightAnimation then
local borders = {
Expand Down Expand Up @@ -253,7 +220,6 @@ local function rowHighlightBorder(row)
end

function row.HighlightAnimation:Play()
updateBorderPositions(row)
row.TopBorder.HighlightAnimation:Play()
row.RightBorder.HighlightAnimation:Play()
row.BottomBorder.HighlightAnimation:Play()
Expand Down Expand Up @@ -340,6 +306,7 @@ local function rowStyles(row)
rowUnitPortrait(row)
rowText(row, row.icon)
rowHighlightBorder(row)
row:SetRowBorders()
rowFadeOutAnimation(row)
end

Expand Down Expand Up @@ -441,6 +408,52 @@ function LootDisplayRowMixin:UpdateStyles()
end
end

function LootDisplayRowMixin:SetRowBorders()
if not G_RLF.db.global.enableRowBorder then
self.StaticTopBorder:Hide()
self.StaticRightBorder:Hide()
self.StaticBottomBorder:Hide()
self.StaticLeftBorder:Hide()
end

if self.cachedBorderSize ~= G_RLF.db.global.rowBorderSize then
self.cachedBorderSize = G_RLF.db.global.rowBorderSize
self.StaticTopBorder:SetSize(0, G_RLF.db.global.rowBorderSize)
self.StaticRightBorder:SetSize(G_RLF.db.global.rowBorderSize, 0)
self.StaticBottomBorder:SetSize(0, G_RLF.db.global.rowBorderSize)
self.StaticLeftBorder:SetSize(G_RLF.db.global.rowBorderSize, 0)
end

if self.cacheBorderColor ~= G_RLF.db.global.rowBorderColor or G_RLF.db.global.rowBorderClassColors then
self.cacheBorderColor = G_RLF.db.global.rowBorderColor
if G_RLF.db.global.rowBorderClassColors then
local classColor
if GetExpansionLevel() >= G_RLF.Expansion.BFA then
classColor = C_ClassColor.GetClassColor(select(2, UnitClass(self.unit or "player")))
else
classColor = RAID_CLASS_COLORS[select(2, UnitClass(self.unit or "player"))]
end
self.StaticTopBorder:SetColorTexture(classColor.r, classColor.g, classColor.b, 1)
self.StaticRightBorder:SetColorTexture(classColor.r, classColor.g, classColor.b, 1)
self.StaticBottomBorder:SetColorTexture(classColor.r, classColor.g, classColor.b, 1)
self.StaticLeftBorder:SetColorTexture(classColor.r, classColor.g, classColor.b, 1)
else
local r, g, b, a = unpack(G_RLF.db.global.rowBorderColor)
self.StaticTopBorder:SetColorTexture(r, g, b, a)
self.StaticRightBorder:SetColorTexture(r, g, b, a)
self.StaticBottomBorder:SetColorTexture(r, g, b, a)
self.StaticLeftBorder:SetColorTexture(r, g, b, a)
end
end

if G_RLF.db.global.enableRowBorder then
self.StaticTopBorder:Show()
self.StaticRightBorder:Show()
self.StaticBottomBorder:Show()
self.StaticLeftBorder:Show()
end
end

function LootDisplayRowMixin:UpdateFadeoutDelay()
rowFadeOutAnimation(self)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,62 @@

<!-- Highlight BG Layer -->
<Layer level="BORDER">
<Texture parentKey="HighlightBGOverlay" file="Interface/Buttons/WHITE8x8" alpha="0">
<Texture parentKey="HighlightBGOverlay" file="Interface/Buttons/WHITE8x8" alpha="0" >
<Anchors>
<Anchor point="TOPLEFT" />
<Anchor point="BOTTOMRIGHT" />
</Anchors>
<Color r="1" g="1" b="1" a="0.5" /> <!-- Light white with 50% opacity -->
</Texture>

<!-- Static Row Borders -->
<!-- Top Border -->
<Texture name="$parentStaticTopBorder" parentKey="StaticTopBorder" hidden="true">
<Color r="0" g="0" b="0" a="1" />
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPLEFT" />
<Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" />
</Anchors>
<Size>
<AbsDimension x="0" y="1" />
</Size>
</Texture>

<!-- Bottom Border -->
<Texture name="$parentStaticBottomBorder" parentKey="StaticBottomBorder" hidden="true">
<Color r="0" g="0" b="0" a="1" />
<Anchors>
<Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" />
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" />
</Anchors>
<Size>
<AbsDimension x="0" y="1" />
</Size>
</Texture>

<!-- Left Border -->
<Texture name="$parentStaticLeftBorder" parentKey="StaticLeftBorder" hidden="true">
<Color r="0" g="0" b="0" a="1" />
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOPLEFT" />
<Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" />
</Anchors>
<Size>
<AbsDimension x="1" y="0" />
</Size>
</Texture>

<!-- Right Border -->
<Texture name="$parentStaticRightBorder" parentKey="StaticRightBorder" hidden="true">
<Color r="0" g="0" b="0" a="1" />
<Anchors>
<Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" />
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" />
</Anchors>
<Size>
<AbsDimension x="1" y="0" />
</Size>
</Texture>
</Layer>

<!-- Amount Text Layer -->
Expand All @@ -34,36 +83,48 @@

<!-- Highlight Border Layer -->
<Layer level="OVERLAY">
<Texture name="$parentTopBorder" file="Interface/COMMON/ThinBorder2-Top"
parentKey="TopBorder" horizTile="true" alpha="0">
<Texture name="$parentTopBorder" parentKey="TopBorder" alpha="0">
<Color r="1" g="1" b="1" a="1" />
<Anchors>
<Anchor point="TOPLEFT" />
<Anchor point="TOPRIGHT" />
<Anchor point="TOPLEFT" relativePoint="TOPLEFT" />
<Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" />
</Anchors>
<Size>
<AbsDimension x="0" y="1" />
</Size>
</Texture>

<Texture name="$parentLeftBorder" file="Interface/COMMON/ThinBorder2-Left"
parentKey="LeftBorder" vertTile="true" alpha="0">
<Texture name="$parentLeftBorder" parentKey="LeftBorder" alpha="0">
<Color r="1" g="1" b="1" a="1" />
<Anchors>
<Anchor point="TOPLEFT" />
<Anchor point="BOTTOMLEFT" />
<Anchor point="TOPLEFT" relativePoint="TOPLEFT" />
<Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" />
</Anchors>
<Size>
<AbsDimension x="1" y="0" />
</Size>
</Texture>

<Texture name="$parentBottomBorder" file="Interface/COMMON/ThinBorder2-Top"
parentKey="BottomBorder" horizTile="true" alpha="0">
<Texture name="$parentBottomBorder" parentKey="BottomBorder" alpha="0">
<Color r="1" g="1" b="1" a="1" />
<Anchors>
<Anchor point="BOTTOMLEFT" />
<Anchor point="BOTTOMRIGHT" />
<Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" />
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" />
</Anchors>
<Size>
<AbsDimension x="0" y="1" />
</Size>
</Texture>

<Texture name="$parentRightBorder" file="Interface/COMMON/ThinBorder2-Left"
parentKey="RightBorder" vertTile="true" alpha="0">
<Texture name="$parentRightBorder" parentKey="RightBorder" alpha="0">
<Color r="1" g="1" b="1" a="1" />
<Anchors>
<Anchor point="TOPRIGHT" />
<Anchor point="BOTTOMRIGHT" />
<Anchor point="TOPRIGHT" relativePoint="TOPRIGHT" />
<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" />
</Anchors>
<Size>
<AbsDimension x="1" y="0" />
</Size>
</Texture>
</Layer>
</Layers>
Expand Down
112 changes: 105 additions & 7 deletions config/Styling.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ G_RLF.defaults.global.growUp = true
G_RLF.defaults.global.rowBackgroundGradientStart = { 0.1, 0.1, 0.1, 0.8 } -- Default to dark grey with 80% opacity
G_RLF.defaults.global.rowBackgroundGradientEnd = { 0.1, 0.1, 0.1, 0 } -- Default to dark grey with 0% opacity
G_RLF.defaults.global.disableRowHighlight = false
G_RLF.defaults.global.enableRowBorder = false
G_RLF.defaults.global.rowBorderSize = 1
G_RLF.defaults.global.rowBorderColor = { 0, 0, 0, 1 }
G_RLF.defaults.global.rowBorderClassColors = false
G_RLF.defaults.global.useFontObjects = true
G_RLF.defaults.global.font = "GameFontNormalSmall"
G_RLF.defaults.global.fontFace = "Friz Quadrata TT"
Expand Down Expand Up @@ -60,14 +64,63 @@ G_RLF.options.args.styles = {
set = "SetGradientEndColor",
order = 4,
},
rowHighlight = {
type = "toggle",
name = G_RLF.L["Disable Row Highlight"],
desc = G_RLF.L["DisableRowHighlightDesc"],
width = "double",
get = "GetRowHighlight",
set = "SetRowHighlight",
rowBorders = {
type = "group",
name = G_RLF.L["Row Borders"],
desc = G_RLF.L["RowBordersDesc"],
inline = true,
order = 5,
args = {
rowHighlight = {
type = "toggle",
name = G_RLF.L["Disable Row Highlight"],
desc = G_RLF.L["DisableRowHighlightDesc"],
width = "double",
get = "GetRowHighlight",
set = "SetRowHighlight",
order = 1,
},
rowBordersEnabled = {
type = "toggle",
name = G_RLF.L["Enable Row Borders"],
desc = G_RLF.L["EnableRowBordersDesc"],
width = "double",
get = "GetRowBorders",
set = "SetRowBorders",
order = 2,
},
rowBorderThickness = {
type = "range",
name = G_RLF.L["Row Border Thickness"],
desc = G_RLF.L["RowBorderThicknessDesc"],
min = 1,
max = 10,
step = 1,
disabled = "DisableRowBorders",
get = "GetRowBorderThickness",
set = "SetRowBorderThickness",
order = 3,
},
rowBorderColor = {
type = "color",
name = G_RLF.L["Row Border Color"],
desc = G_RLF.L["RowBorderColorDesc"],
hasAlpha = true,
disabled = "DisableRowColor",
get = "GetRowBorderColor",
set = "SetRowBorderColor",
order = 4,
},
rowBorderClassColors = {
type = "toggle",
name = G_RLF.L["Use Class Colors for Borders"],
desc = G_RLF.L["UseClassColorsForBordersDesc"],
set = "SetRowBorderClassColors",
get = "GetRowBorderClassColors",
disabled = "DisableRowBorders",
order = 5,
},
},
},
enableSecondaryRowText = {
type = "toggle",
Expand Down Expand Up @@ -278,3 +331,48 @@ end
function Styling:GetRowFont(info, value)
return G_RLF.db.global.font
end

function Styling:GetRowBorders(info, value)
return G_RLF.db.global.enableRowBorder
end

function Styling:SetRowBorders(info, value)
G_RLF.db.global.enableRowBorder = value
G_RLF.LootDisplay:UpdateRowStyles()
end

function Styling:GetRowBorderThickness(info, value)
return G_RLF.db.global.rowBorderSize
end

function Styling:SetRowBorderThickness(info, value)
G_RLF.db.global.rowBorderSize = value
G_RLF.LootDisplay:UpdateRowStyles()
end

function Styling:GetRowBorderColor(info, value)
local r, g, b, a = unpack(G_RLF.db.global.rowBorderColor)
return r, g, b, a
end

function Styling:SetRowBorderColor(info, r, g, b, a)
G_RLF.db.global.rowBorderColor = { r, g, b, a }
G_RLF.LootDisplay:UpdateRowStyles()
end

function Styling:DisableRowBorders(info, value)
return G_RLF.db.global.enableRowBorder == false
end

function Styling:DisableRowColor(info, value)
return G_RLF.db.global.enableRowBorder == false or G_RLF.db.global.rowBorderClassColors
end

function Styling:GetRowBorderClassColors(info, value)
return G_RLF.db.global.rowBorderClassColors
end

function Styling:SetRowBorderClassColors(info, value)
G_RLF.db.global.rowBorderClassColors = value
G_RLF.LootDisplay:UpdateRowStyles()
end
Loading

0 comments on commit 2d6337c

Please sign in to comment.