Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UnitFrames/Components/AuraBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ for _, kind in ipairs(KINDS) do
local source = ns.Schema.Find(Auras.schema, kind)
local group = ns.Schema.Without(ns.Util.Copy(source.schema), {
position = true, alignment = true, growth = true, gap = true, offsetX = true, offsetY = true, lineSize = true,
separateHeight = true, height = true,
})
group = ns.Schema.Override(group, "size", { label = "Icon width", default = 32,
tooltip = "Artwork stays square and centred vertically. Icons wider than their section show none." })
Expand Down
64 changes: 44 additions & 20 deletions UnitFrames/Components/AuraIcon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,12 @@ function AuraIcon.Create(button, kind, preview, opts)
button.ufHarmful = opts.harmful == true
button.ufPreview = preview and true or false
-- The button includes the below-icon timer in its layout bounds. The
-- artwork stays square, even when the container flows upwards.
-- artwork keeps its configured size, even when the container flows upwards.
local iconFrame = CreateFrame("Frame", nil, button, "BackdropTemplate")
iconFrame:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0)
button.ufIconFrame = iconFrame

local icon = iconFrame:CreateTexture(nil, "ARTWORK")
icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
button.ufIcon = icon
if not preview then button:SetIcon(icon) end

Expand All @@ -121,7 +120,7 @@ function AuraIcon.Create(button, kind, preview, opts)

local cover = CreateFrame("Frame", nil, iconFrame)
cover:SetAllPoints(iconFrame)
cover:SetFrameLevel(cooldown:GetFrameLevel() + 1)
button.ufCover = cover

-- The engine fills registered texts immediately, before OnApply.
button.ufCountHolder = CreateFrame("Frame", nil, cover)
Expand Down Expand Up @@ -170,16 +169,40 @@ end

-- The icon artwork's inset inside its frame border. Keep a drawable centre
-- even at the smallest icon size.
local function ArtPadding(cfg, size)
return cfg.border.enabled and math.min(cfg.border.padding, (size - 2) / 2) or 0
local function ArtPadding(cfg, width, height)
return cfg.border.enabled and math.min(cfg.border.padding, (math.min(width, height) - 2) / 2) or 0
end

function AuraIcon.Apply(button, cfg, size, dispelColors, swipe, showSwipeEdge)
-- Trims Blizzard's baked icon edge, then crops the longer side so the
-- artwork fills a non-square icon without stretching.
local ICON_TRIM = 0.08
function AuraIcon.TexCoords(width, height)
local cropX, cropY = ICON_TRIM, ICON_TRIM
if width > height then
cropY = 0.5 - (0.5 - ICON_TRIM) * height / width
elseif height > width then
cropX = 0.5 - (0.5 - ICON_TRIM) * width / height
end
return cropX, 1 - cropX, cropY, 1 - cropY
end

-- Stacked above the artwork and swipe: the frame's border edges, then the
-- texts. Levels are set on every apply, since owners may relevel the button.
local function ApplyLayers(button, backdrop)
local level = button.ufCooldown:GetFrameLevel()
if backdrop and (backdrop.edgeFile or backdrop.raidBorder) then
Backdrop.SetBorderLevel(button.ufIconFrame, level + 1)
end
button.ufCover:SetFrameLevel(level + 2)
end

function AuraIcon.Apply(button, cfg, width, height, dispelColors, swipe, showSwipeEdge)
AuraIcon.ApplySwipe(button, swipe, showSwipeEdge)
button:SetSize(size, size + AuraIcon.TextRoom(cfg))
button.ufIconFrame:SetSize(size, size)
Backdrop.ApplyToFixedSize(button.ufIconFrame, cfg.border, size, size, false)
local pad = ArtPadding(cfg, size)
button:SetSize(width, height + AuraIcon.TextRoom(cfg))
button.ufIconFrame:SetSize(width, height)
ApplyLayers(button, Backdrop.ApplyToFixedSize(button.ufIconFrame, cfg.border, width, height, false))
local pad = ArtPadding(cfg, width, height)
button.ufIcon:SetTexCoord(AuraIcon.TexCoords(width - 2 * pad, height - 2 * pad))
for _, region in ipairs({ button.ufIcon, button.ufCooldown }) do
region:ClearAllPoints()
region:SetPoint("TOPLEFT", button.ufIconFrame, "TOPLEFT", pad, -pad)
Expand All @@ -197,14 +220,14 @@ function AuraIcon.Apply(button, cfg, size, dispelColors, swipe, showSwipeEdge)
end
button.ufCountHolder:SetShown(cfg.showCount)
button.ufTime:SetShown(cfg.showDuration)
AuraIcon.ApplyDispelBorder(button, cfg, size, dispelColors)
AuraIcon.ApplyDispelGlow(button, cfg, size, dispelColors)
AuraIcon.ApplyDispelBorder(button, cfg, width, height, dispelColors)
AuraIcon.ApplyDispelGlow(button, cfg, width, height, dispelColors)
end

-- Per button: the reused border settings (the icon border without a
-- background) and what the dispel textures were last registered with.
local dispelBorders = setmetatable({}, { __mode = "k" })
function AuraIcon.ApplyDispelBorder(button, cfg, size, dispelColors)
function AuraIcon.ApplyDispelBorder(button, cfg, width, height, dispelColors)
local enabled = cfg.border.enabled and cfg.dispelBorder and button.ufHarmful or false
local state = dispelBorders[button]
if not state then
Expand All @@ -219,12 +242,13 @@ function AuraIcon.ApplyDispelBorder(button, cfg, size, dispelColors)
-- button redrawn per texture). Unchanged artwork, size and colours keep
-- the engine's tint; only the icon frame's border, which applying the
-- icon backdrop recoloured, is hidden again.
if state.applied and state.enabled == enabled and state.info == info and state.size == size
and state.colors == dispelColors then
if state.applied and state.enabled == enabled and state.info == info and state.width == width
and state.height == height and state.colors == dispelColors then
if state.registered then Backdrop.SetBorderColor(button.ufIconFrame, 0, 0, 0, 0) end
return
end
state.applied, state.enabled, state.info, state.size, state.colors = true, enabled, info, size, dispelColors
state.applied, state.enabled, state.info, state.colors = true, enabled, info, dispelColors
state.width, state.height = width, height
state.registered = false
-- Re-register after applying the backdrop: its setters reset vertex
-- colours, and inbound options are copied by the engine, not shared.
Expand All @@ -237,7 +261,7 @@ function AuraIcon.ApplyDispelBorder(button, cfg, size, dispelColors)
Backdrop.ApplyTo(button.ufBorder, { enabled = false })
return
end
local backdrop = Backdrop.ApplyToFixedSize(button.ufBorder, border, size, size, false)
local backdrop = Backdrop.ApplyToFixedSize(button.ufBorder, border, width, height, false)
if backdrop and (backdrop.edgeFile or backdrop.raidBorder) then
state.registered = true
Backdrop.SetBorderColor(button.ufIconFrame, 0, 0, 0, 0)
Expand Down Expand Up @@ -286,18 +310,18 @@ function AuraIcon.GetGlow(button)
return state and state.active
end

function AuraIcon.ApplyDispelGlow(button, cfg, size, dispelColors)
function AuraIcon.ApplyDispelGlow(button, cfg, width, height, dispelColors)
local glow = cfg.dispelGlow
local enabled = glow and glow.enabled and button.ufHarmful or false
local style = enabled and (glow.style == "proc" and "proc" or "halo") or nil
local active = style and GlowHolder(button, style) or nil
for _, holder in pairs(glowHolders[button] or {}) do holder:SetShown(holder == active) end
if style == "proc" then
Glow.ApplyProc(active, glow, size)
Glow.ApplyProc(active, glow, width, height)
elseif active then
-- From the artwork's edge: border art draws its line anywhere within
-- the edge, so the halo starts under the border to leave no gap.
local pad = ArtPadding(cfg, size)
local pad = ArtPadding(cfg, width, height)
active:ClearAllPoints()
active:SetPoint("TOPLEFT", button.ufIconFrame, "TOPLEFT", pad, -pad)
active:SetPoint("BOTTOMRIGHT", button.ufIconFrame, "BOTTOMRIGHT", -pad, pad)
Expand Down
32 changes: 24 additions & 8 deletions UnitFrames/Components/Auras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@ local function GroupSchema(label, filters, size, position)
} },
{ key = "showSwipeEdge", type = "toggle", label = "Show swipe edge", default = true,
tooltip = "Show the spinning line along the cooldown swipe. Hidden when Cooldown swipe is None." },
{ key = "size", type = "range", label = "Icon size", min = 10, max = 64, step = 1, default = size },
{ key = "size", type = "range", label = "Icon size", min = 10, max = 64, step = 1, default = size,
tooltip = "With a separate icon height, this sets the icon width." },
{ key = "separateHeight", type = "toggle", label = "Separate icon height", default = false,
tooltip = "Enable to set the icon height on its own. The artwork fills the icon and is cropped to its shape.",
onSet = function(config, value, before)
if value and not before.separateHeight and config.height == nil then config.height = before.size end
end },
{ key = "height", type = "range", label = "Icon height", min = 6, max = 64, step = 1, default = size,
hidden = function(cfg) return not cfg.separateHeight end },
{ key = "position", type = "select", label = "Side", values = Auras.POSITIONS, default = position },
{ key = "alignment", type = "select", label = "Alignment", values = Auras.ALIGNMENTS, default = "start",
tooltip = "Align the whole aura block along the selected side. Centre aligns the block, including wrapped rows." },
Expand Down Expand Up @@ -226,10 +234,16 @@ function Auras:UpdateStyleToken()
self.styleToken = StyleToken(self, self.styleToken)
end

-- A group's configured icon width and height; square without a separate height.
function Auras.IconSize(group)
return group.size, group.separateHeight and group.height or group.size
end

function Auras:StyleButton(button)
ns.Perf:Count("auraButtonStyle")
local group = self.resolved[button.ufKind]
AuraIcon.Apply(button, self:GetArtworkConfig(), group.size, self.dispelColors, group.swipe, group.showSwipeEdge)
local width, height = Auras.IconSize(group)
AuraIcon.Apply(button, self:GetArtworkConfig(), width, height, self.dispelColors, group.swipe, group.showSwipeEdge)
end

-- A group's native candidate filters (nil = none).
Expand Down Expand Up @@ -318,7 +332,8 @@ end
function Auras:LineLength(group)
local vertical = VerticalSide(group)
local length = group.lineSize > 0 and group.lineSize or vertical and self.hostHeight or self.hostWidth
return math.max(length, group.size + (vertical and AuraIcon.TextRoom(self:GetArtworkConfig()) or 0))
local width, height = Auras.IconSize(group)
return math.max(length, vertical and height + AuraIcon.TextRoom(self:GetArtworkConfig()) or width)
end

local function OtherKind(kind)
Expand Down Expand Up @@ -359,8 +374,9 @@ function Auras:StackDepth(group)
local vertical = VerticalSide(group)
local textRoom = AuraIcon.TextRoom(self:GetArtworkConfig())
local spacing = self.resolved.spacing
local along = group.size + (vertical and textRoom or 0)
local across = group.size + (vertical and 0 or textRoom)
local width, height = Auras.IconSize(group)
local along = vertical and height + textRoom or width
local across = vertical and width or height + textRoom
local perLine = math.max(1, math.floor((self:LineLength(group) + spacing) / (along + spacing)))
local lines = math.ceil(group.max / perLine)
local side = group.position
Expand All @@ -378,9 +394,9 @@ function Auras:Layout(width, height)
local firstKind = self:CombinedFirstKind()
for _, containerKind in ipairs(self.containers.buffs and KINDS or {}) do
for _, kind in ipairs(self:ContainerGroups(containerKind)) do
local size = self.resolved[kind].size
Auras.ApplyGroupLayout(self.containers[containerKind], kind, size,
size + AuraIcon.TextRoom(self:GetArtworkConfig()), self.resolved.spacing, self.resolved.spacing,
local width, height = Auras.IconSize(self.resolved[kind])
Auras.ApplyGroupLayout(self.containers[containerKind], kind, width,
height + AuraIcon.TextRoom(self:GetArtworkConfig()), self.resolved.spacing, self.resolved.spacing,
firstKind and kind ~= firstKind and 2 or 1)
end
end
Expand Down
4 changes: 2 additions & 2 deletions UnitFrames/Components/CategoryAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ end
function CategoryAuras:StyleButton(button)
ns.Perf:Count("categoryButtonStyle")
local cfg = self.resolved
AuraIcon.Apply(button, self.art[button.ufKind], self.size, nil, cfg.swipe, cfg.showSwipeEdge)
button:SetFrameLevel(self.level + 1 + (#CategoryAuras.CATEGORIES - PRIORITY[button.ufKind]) * LEVEL_BAND)
AuraIcon.Apply(button, self.art[button.ufKind], self.size, self.size, nil, cfg.swipe, cfg.showSwipeEdge)
button:ClearAllPoints()
button:SetPoint("CENTER", self.anchor, "CENTER", 0, 0)
button:SetFrameLevel(self.level + 1 + (#CategoryAuras.CATEGORIES - PRIORITY[button.ufKind]) * LEVEL_BAND)
end

-- Access to native slot buttons may be denied while aura data is secret:
Expand Down
8 changes: 4 additions & 4 deletions UnitFrames/Components/Glow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ function Glow.CreateProc(parent)
return holder
end

-- size: the owner's known configured square size.
function Glow.ApplyProc(holder, cfg, size)
holder:SetSize(size * PROC_SCALE, size * PROC_SCALE)
holder.Start:SetSize(size * PROC_START_SCALE, size * PROC_START_SCALE)
-- width, height: the owner's known configured size.
function Glow.ApplyProc(holder, cfg, width, height)
holder:SetSize(width * PROC_SCALE, height * PROC_SCALE)
holder.Start:SetSize(width * PROC_START_SCALE, height * PROC_START_SCALE)
holder:SetAlpha(cfg.opacity)
end

Expand Down
3 changes: 2 additions & 1 deletion UnitFrames_ClickGrid/Auras/Slots.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ function Slots:InitButton(button, key, preview)
end

function Slots:StyleButton(button)
AuraIcon.Apply(button, self.resolved, self.resolved[button.ufKind].size)
local size = self.resolved[button.ufKind].size
AuraIcon.Apply(button, self.resolved, size, size)
end

function Slots:OnApply(cfg)
Expand Down
Loading
Loading