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
9 changes: 9 additions & 0 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,15 @@ the top-left border corner after the PvP flag. It is placed like the raid
marker and leaves no gap while you are not resting. Preview it with
**Preview only > Resting**.

## Mouseover highlight

Every frame's **Mouseover highlight** section (Indicators & states) lightens
the frame under the mouse with a translucent wash above its bars, so you can
see which unit your clicks and mouseover casts will reach. It is on by
default in a faint white; **Mouseover colour** picks the colour and opacity.
It works in combat and copies with **Copy player style**. ClickGrid member,
target and pet bars use the same setting in their own bar styles.

## Range fading

Each frame's **Out-of-range opacity** section offers an opt-in fade with
Expand Down
2 changes: 1 addition & 1 deletion UnitFrames/Components/Backdrop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local Media, Util = ns.Media, ns.Util
--
-- Other components embed it as a `border` group and call Backdrop.ApplyTo.
local Backdrop = ns.Component:Extend("Backdrop")
Backdrop.LEVELS = { border = 20, frame = 60, panel = 100, decorations = 120 }
Backdrop.LEVELS = { border = 20, hover = 30, frame = 60, panel = 100, decorations = 120 }

local BORDER_PIECES = { "TopLeftCorner", "TopRightCorner", "BottomLeftCorner", "BottomRightCorner",
"TopEdge", "BottomEdge", "LeftEdge", "RightEdge" }
Expand Down
37 changes: 36 additions & 1 deletion UnitFrames/Components/UnitFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ spec:
frame use this frame as the root (the oUF unit button); else one is created
width default width (of the rows area, including the border padding)
borderDefaults frame border option defaults, e.g. { enabled = false }
resting offer the resting border (player)
hoverDefaults mouseover highlight option defaults, e.g. { color = { 0.2, 0.8, 1, 0.35 } }
resting offer the resting border (player)
threat { defaults } to offer the threat glow: the player's threat on the
unit as a soft halo in the threat stage colours (SetThreat)
playerFrame the frame always shows the player: its texts offer player-only
Expand All @@ -62,6 +63,8 @@ GetReadyCheck() returns the ReadyCheck presenter when the spec offers one.
SetUnitState(state) shows the dead/ghost ("dead") or offline look (bars,
portrait, border, texts); nil restores the frame. SetThreat(status, percent)
tints the threat glow (either may be secret; nil off the threat list).
SetHovered(hovered) shows the mouseover highlight; owners call it from the
unit button's mouse scripts (Units.HookMouse).
]]
local UnitFrame = ns.Component:Extend("UnitFrame")

Expand Down Expand Up @@ -237,6 +240,14 @@ function UnitFrame:OnCreate(parent, spec)
self.partsByKey[part.key] = component
end
end
-- Mouseover wash on a raised child: textures on the unit button itself
-- render below its bars.
self.hoverHost = CreateFrame("Frame", nil, self.frame)
self.hoverHost:SetAllPoints(self.frame)
self.hover = self.hoverHost:CreateTexture(nil, "ARTWORK")
self.hover:SetAllPoints()
self.hover:Hide()
self.hovered = false
-- Under the frame, so its background and contents sit on top of the glow.
if spec.threat then self.threatGlow = ns.Glow.Create(self.frame, self.frame) end
if spec.readyCheck then
Expand Down Expand Up @@ -282,6 +293,12 @@ local function UnitStateSchema(tooltip, colorLabel, color)
}
end

UnitFrame.HOVER_SCHEMA = {
{ key = "enabled", type = "toggle", label = "Enabled", default = true,
tooltip = "Lightens the frame under the mouse, so you can see which unit your clicks and mouseover casts will reach." },
{ key = "color", type = "color", label = "Mouseover colour", hasAlpha = true, default = { 1, 1, 1, 0.12 }, hidden = StateOff },
}

UnitFrame.THREAT_COLOR_BY = {
{ "percent", "Threat %" },
{ "status", "Threat status" },
Expand Down Expand Up @@ -340,6 +357,8 @@ function UnitFrame.BuildSchema(spec)
hidden = function(cfg) return cfg.mode ~= "spell" end,
tooltip = "Choose a spell you know that applies to this unit (a heal for allies, an attack for enemies). Unknown spells, invalid targets and spells without a range check do not fade the frame. Names must match your client language." },
} },
{ key = "hover", type = "group", label = "Mouseover highlight", schema = UnitFrame.HOVER_SCHEMA,
defaults = spec.hoverDefaults },
}
if spec.resting then
schema[#schema + 1] = { key = "resting", type = "group", label = "Resting border", schema = {
Expand Down Expand Up @@ -398,6 +417,7 @@ local function Apply(self, cfg)
self:ApplyRangeOpacity()
self:ApplyUnitState()
self:ApplyThreatGlow()
self:ApplyHover()
if self.readyCheck then self.readyCheck:Apply(cfg.readyCheck) end
end

Expand Down Expand Up @@ -547,6 +567,19 @@ function UnitFrame:HasThreatGlow()
return self.threatGlow ~= nil and self.resolved.threat.enabled and ns.Caps.curves
end

-- Hover is plain mouse state, so it may change in combat: only the
-- unprotected wash shows or hides.
function UnitFrame:ApplyHover()
local cfg = self.resolved.hover
self.hover:SetColorTexture(ns.Util.UnpackColor(cfg.color))
self.hover:SetShown(self.hovered and cfg.enabled and not self.released)
end

function UnitFrame:SetHovered(hovered)
self.hovered = hovered and true or false
self:ApplyHover()
end

-- The ReadyCheck presenter (tints and icon), or nil when not offered.
function UnitFrame:GetReadyCheck()
return self.readyCheck
Expand Down Expand Up @@ -640,6 +673,7 @@ function UnitFrame:Layout()
if part.def.stack then part.component:Layout(self.layoutContext) end
end
self.decorations:Reflow()
self.hoverHost:SetFrameLevel(self.frame:GetFrameLevel() + Backdrop.LEVELS.hover)
Backdrop.SetBorderLevel(self.border, self.frame:GetFrameLevel() + Backdrop.LEVELS.frame)
ns.Perf:End("unit layout")
end
Expand Down Expand Up @@ -822,6 +856,7 @@ end

function UnitFrame:OnRelease()
self.border:SetScript("OnUpdate", nil)
self.hover:Hide()
self.onReadyCheckChanged = nil
if self.readyCheck then self.readyCheck:Release() end
self.decorations:Release()
Expand Down
17 changes: 14 additions & 3 deletions UnitFrames/Units/Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,24 @@ function Units:GetDefinition(unit)
return self.definitions[unit]
end

-- Storage/import migration: placement used to double as the enable switch.
-- Storage/import migrations: placement used to double as the enable switch.
-- Only the old Off value needs translating; other placements keep their value.
-- ClickGrid pets kept a flat hover toggle and colour before every frame
-- offered the mouseover highlight group.
function Units:MigrateConfig(config)
local castbar = type(config) == "table" and config.castbar
if type(config) ~= "table" then return config end
local castbar = config.castbar
if type(castbar) == "table" and castbar.placement == "off" then
castbar.placement = nil
if castbar.enabled == nil then castbar.enabled = false end
end
local hover = config.hover
if type(hover) == "boolean" or config.hoverColor ~= nil then
local group = type(hover) == "table" and hover or {}
if type(hover) == "boolean" then group.enabled = hover end
if group.color == nil then group.color = config.hoverColor end
config.hover, config.hoverColor = group, nil
end
return config
end

Expand Down Expand Up @@ -310,7 +320,8 @@ end
function Units:GetSpec(def, frame)
local spec = { frame = frame, rows = def.rows, width = def.width, resting = def.resting, readyCheck = def.readyCheck,
barLayout = def.barLayout,
playerFrame = def.playerFrame, borderDefaults = def.borderDefaults, threat = def.threat, blizzardAuras = def.blizzardAuras }
playerFrame = def.playerFrame, borderDefaults = def.borderDefaults, hoverDefaults = def.hoverDefaults,
threat = def.threat, blizzardAuras = def.blizzardAuras }
for _, part in ipairs(ns.Components.UnitFrame.PARTS) do spec[part.key] = def[part.key] end
-- The class is fixed for the session: other classes' frames leave the row out.
if spec.comboPoints then
Expand Down
20 changes: 18 additions & 2 deletions UnitFrames/Units/Style.lua
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,28 @@ function Units.HideTooltip()
GameTooltip:Hide()
end

local function OnEnter(frame)
frame.uf:SetHovered(true)
Units.ShowTooltip(frame)
end

local function OnLeave(frame)
frame.uf:SetHovered(false)
Units.HideTooltip()
end

-- The unit tooltip and mouseover highlight of an oUF frame with a UnitFrame
-- (frame.uf). Hooks cannot be removed: the highlight checks its own state.
function Units.HookMouse(frame)
frame:HookScript("OnEnter", OnEnter)
frame:HookScript("OnLeave", OnLeave)
end

oUF:RegisterStyle(Units.STYLE, function(frame, unit)
frame.uf = Units:CreateFrame(unit, UIParent, frame)
frame.uf:SetThemeManaged(true)
frame:RegisterForClicks("AnyUp")
frame:HookScript("OnEnter", Units.ShowTooltip)
frame:HookScript("OnLeave", Units.HideTooltip)
Units.HookMouse(frame)
Units:Bind(frame)
end)

Expand Down
23 changes: 21 additions & 2 deletions UnitFrames_ClickGrid/Core/Config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ local function MigrateTargets(profile)
panel.targets = nil
end

-- The mouseover highlight moved from the status indicators to the member
-- bar style (Units' frame-wide hover group). Same once-only carry-over;
-- imports pass their style data through it too.
function Config.MigrateHover(profile)
local indicators = type(profile.settings) == "table" and profile.settings.indicators
if type(indicators) ~= "table" or indicators.hover == nil and indicators.hoverColor == nil then return end
if type(profile.member) ~= "table" then profile.member = {} end
local hover = type(profile.member.hover) == "table" and profile.member.hover or {}
if hover.enabled == nil then hover.enabled = indicators.hover end
if hover.color == nil then hover.color = indicators.hoverColor end
profile.member.hover = hover
indicators.hover, indicators.hoverColor = nil, nil
end

local function MigrateProfile(profile)
MigrateTargets(profile)
Config.MigrateHover(profile)
end

-- Fixed slots also need parseable spell IDs, beyond the schema's types.
local function CheckSlots(candidate)
for _, slot in pairs(UF.Schema.Resolve(CG.SlotSchema, candidate.slots)) do
Expand Down Expand Up @@ -61,7 +80,7 @@ function Config:Initialize()
schema = self.schema, theme = true, validate = true, check = CheckSlots,
changed = function(path) Changed("settings", path) end,
read = function()
MigrateTargets(db.profile)
MigrateProfile(db.profile)
return self:MigrateSettings(db.profile.settings)
end,
write = function(settings) db.profile.settings = settings end,
Expand All @@ -71,7 +90,7 @@ function Config:Initialize()
self.styles[kind] = UF.Store:New({
schema = function() return CG:StyleSchema(kind) end, theme = true, validate = true,
read = function()
MigrateTargets(db.profile)
MigrateProfile(db.profile)
return UF.Units:MigrateConfig(db.profile[kind])
end,
write = function(style) db.profile[kind] = style end,
Expand Down
6 changes: 2 additions & 4 deletions UnitFrames_ClickGrid/Groups/Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ end
CG.definitions.target.readyCheck, CG.definitions.target.threat = nil, nil
CG.definitions.pet.readyCheck, CG.definitions.pet.threat = nil, nil
CG.definitions.pet.barLayout = "columns"
-- Pets stand apart from their member under the mouse.
CG.definitions.pet.hoverDefaults = { color = { 0.2, 0.8, 1, 0.35 } }

CG.LayoutSchema = {
{ key = "enabled", type = "toggle", label = "Show healing panel", default = true },
Expand Down Expand Up @@ -169,10 +171,6 @@ CG.IndicatorSchema = UF.Schema.Concat(
tooltip = "Me: debuffs you can dispel, like Blizzard's raid frames. Anyone in the group can light up debuffs you cannot remove yourself." },
{ key = "dispelGlow", type = "group", label = "Dispellable glow", schema = CELL_GLOW_SCHEMA,
hidden = function(c) return not c.dispel end },
{ key = "hover", type = "toggle", label = "Mouseover highlight", default = true,
tooltip = "Lightens the cell under the mouse, so you can see which member your clicks and mouseover casts will reach." },
{ key = "hoverColor", type = "color", label = "Mouseover colour", hasAlpha = true, default = { 1, 1, 1, 0.12 },
hidden = function(c) return not c.hover end },
{ key = "phase", type = "toggle", label = "Different phase", default = true },
{ key = "size", type = "range", label = "Other status icon size", min = 8, max = 32, step = 1, default = 14 },
{ key = "private", type = "toggle", label = "Private encounter auras", default = true },
Expand Down
27 changes: 6 additions & 21 deletions UnitFrames_ClickGrid/Groups/Pets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ CG.PetSchema = {
{ key = "includeInWidth", type = "toggle", label = "Width includes pet", default = true,
tooltip = "On: members keep their configured width and the pet and gap take their space from it. Off: members grow by the pet's width and gap.",
hidden = function(cfg) return cfg.display ~= "inline" end },
{ key = "hover", type = "toggle", label = "Pet mouseover highlight", default = true },
{ key = "hoverColor", type = "color", label = "Pet mouseover colour", default = { 0.2, 0.8, 1, 0.35 }, hasAlpha = true },
}

function CG.PetUnit(owner)
Expand Down Expand Up @@ -73,23 +71,13 @@ function CG:EnsureInlinePets(panel)
oUF:SetActiveStyle(previous)
end

function CG:CreatePetHover(frame)
local overlay = CreateFrame("Frame", nil, frame)
overlay:SetAllPoints()
overlay:SetFrameLevel(frame:GetFrameLevel() + 30)
local hover = overlay:CreateTexture(nil, "OVERLAY")
hover:SetAllPoints()
hover:Hide()
self:GetGridButton(frame).hover = hover
-- An inline pet sits over its member: entering it leaves the member.
-- Non-interactive pets take no mouse motion, so they never highlight.
function CG:WatchPetHover(frame)
frame:HookScript("OnEnter", function()
local cfg = self:GetGridButton(frame).petConfig
if not cfg then return end
if cfg.interactive and cfg.hover then hover:Show() end
local cell = frame:GetParent()
local owner = cell.Member and self:GetGridButton(cell.Member)
if owner and owner.status then owner.status:SetHovered(false) end
local member = frame:GetParent().Member
if member then member.uf:SetHovered(false) end
end)
frame:HookScript("OnLeave", function() hover:Hide() end)
end

function CG:RefreshPet(frame, changes, layout)
Expand All @@ -98,13 +86,11 @@ function CG:RefreshPet(frame, changes, layout)
local active = separate and self.metrics.pet.mode == "group" or not separate and self.metrics.pet.mode == "inline"
if not active or not self.activeHeaders[cell:GetParent()] then
self:DeactivateFrame(frame)
button.hover:Hide()
if not separate then self:ReserveMember(cell.Member.uf, false, false) end
return false
end
local activated = button.inactive or not button.refreshed
local cfg = self.Config.styles.pet:Resolved()
button.petConfig = cfg
local layoutChanged = activated or not changes or changes.full or changes.layout
local styled = self:ApplyUnitStyle(frame.uf, "pet", changes, layout, activated)
if styled then UF.Units:Bind(frame) end
Expand Down Expand Up @@ -132,8 +118,7 @@ function CG:RefreshPet(frame, changes, layout)
if styled or layoutChanged or changes and changes.petInteraction then
frame:SetMouseClickEnabled(cfg.interactive)
frame:SetMouseMotionEnabled(cfg.interactive)
button.hover:SetColorTexture(UF.Util.UnpackColor(cfg.hoverColor))
button.hover:Hide()
if not cfg.interactive then frame.uf:SetHovered(false) end
end
if styled or activated then UF.Units:UpdateFrame(frame, "UnitFramesClickGridRefresh") end
button.refreshed = true
Expand Down
7 changes: 4 additions & 3 deletions UnitFrames_ClickGrid/Groups/Refresh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ function CG:RefreshChanges(kind, path)
if not path then return { full = true } end
if kind == "member" or kind == "target" or kind == "pet" then
if not UF.Schema.Find(self:StyleSchema(kind), path) then return { full = true } end
if kind == "pet" and (path == "interactive" or path == "hover" or path == "hoverColor") then
return { petInteraction = true }
end
if kind == "pet" and path == "interactive" then return { petInteraction = true } end
-- The mouseover highlight restyles the bars only: nothing moves.
if path == "hover" or path:match("^hover%.") then return { [kind] = true } end
if kind == "pet" and (path == "gap" or path == "side" or path == "includeInWidth") then return { layout = true } end
if kind == "target" and (path == "emptyText" or path:match("^emptyText%.")) then return { emptyText = true } end
local changes = { layout = true, [kind] = true }
Expand Down Expand Up @@ -76,6 +76,7 @@ function CG:DeactivateFrame(frame)
RegisterAttributeDriver(frame, "state-visibility", "hide")
frame:PauseAllElements()
DisableAuras(frame.uf)
frame.uf:SetHovered(false)
if button.slots then button.slots:SetEnabled(false) end
if frame.uf:GetReadyCheck() then frame.uf:GetReadyCheck():Set(nil) end
UF.Units:ClearTags(frame)
Expand Down
5 changes: 2 additions & 3 deletions UnitFrames_ClickGrid/Groups/Style.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,15 @@ function CG:StyleFrame(frame, kind)
frame.uf:SetCombatDeferred(true)
frame.uf:SetThemeManaged(true)
frame:RegisterForClicks("AnyUp")
frame:HookScript("OnEnter", UF.Units.ShowTooltip)
frame:HookScript("OnLeave", UF.Units.HideTooltip)
UF.Units.HookMouse(frame)
UF.Units:Bind(frame)
if target then button.empty = CG.EmptyTarget:New(frame:GetParent(), frame)
elseif kind == "member" then
button.status, button.slots = CG:AddMemberExtras(frame.uf, frame, true)
UF.Units.SetElement(frame, "UFCG_Slots", button.slots)
end
CG.frames[#CG.frames + 1] = frame
if kind == "pet" then self:CreatePetHover(frame) end
if kind == "pet" then self:WatchPetHover(frame) end
end

oUF:RegisterStyle(CG.STYLE, function(frame) CG:StyleFrame(frame) end)
Expand Down
Loading
Loading