From 54c8257f79492bfa1f790eb717973caf8e721dce Mon Sep 17 00:00:00 2001 From: Martin Konstantin Herrmann Date: Wed, 11 Nov 2026 15:14:50 +0100 Subject: [PATCH] Mouseover highlight on every unit frame Hover wash moves from ClickGrid's status indicators and pet overlay into UnitFrame as a frame-wide hover group, driven by shared Units.HookMouse. Pets keep their cyan default via hoverDefaults; old indicator and pet hover settings migrate on read and import. --- USER_GUIDE.md | 9 +++ UnitFrames/Components/Backdrop.lua | 2 +- UnitFrames/Components/UnitFrame.lua | 37 ++++++++- UnitFrames/Units/Definitions.lua | 17 ++++- UnitFrames/Units/Style.lua | 20 ++++- UnitFrames_ClickGrid/Core/Config.lua | 23 +++++- UnitFrames_ClickGrid/Groups/Definitions.lua | 6 +- UnitFrames_ClickGrid/Groups/Pets.lua | 27 ++----- UnitFrames_ClickGrid/Groups/Refresh.lua | 7 +- UnitFrames_ClickGrid/Groups/Style.lua | 5 +- UnitFrames_ClickGrid/Indicators/Status.lua | 15 ---- UnitFrames_ClickGrid/Integration/Profiles.lua | 2 + UnitFrames_ClickGrid/README.md | 6 +- UnitFrames_Workbench/Pages.lua | 7 +- tests/fixtures/schema_snapshot.txt | 76 ++++++++++++++++--- .../clickgrid/clickgrid_indicators_spec.lua | 17 ++--- tests/spec/clickgrid/clickgrid_pets_spec.lua | 19 +++-- tests/spec/clickgrid/clickgrid_spec.lua | 24 ++++++ tests/spec/units/hover_spec.lua | 67 ++++++++++++++++ 19 files changed, 297 insertions(+), 89 deletions(-) create mode 100644 tests/spec/units/hover_spec.lua diff --git a/USER_GUIDE.md b/USER_GUIDE.md index f50f99f..8863ad8 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -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 diff --git a/UnitFrames/Components/Backdrop.lua b/UnitFrames/Components/Backdrop.lua index 5da94d5..63bf996 100644 --- a/UnitFrames/Components/Backdrop.lua +++ b/UnitFrames/Components/Backdrop.lua @@ -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" } diff --git a/UnitFrames/Components/UnitFrame.lua b/UnitFrames/Components/UnitFrame.lua index 93576e4..e3145da 100644 --- a/UnitFrames/Components/UnitFrame.lua +++ b/UnitFrames/Components/UnitFrame.lua @@ -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 @@ -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") @@ -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 @@ -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" }, @@ -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 = { @@ -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 @@ -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 @@ -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 @@ -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() diff --git a/UnitFrames/Units/Definitions.lua b/UnitFrames/Units/Definitions.lua index 6098373..c4583ca 100644 --- a/UnitFrames/Units/Definitions.lua +++ b/UnitFrames/Units/Definitions.lua @@ -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 @@ -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 diff --git a/UnitFrames/Units/Style.lua b/UnitFrames/Units/Style.lua index 45b10c4..5288106 100644 --- a/UnitFrames/Units/Style.lua +++ b/UnitFrames/Units/Style.lua @@ -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) diff --git a/UnitFrames_ClickGrid/Core/Config.lua b/UnitFrames_ClickGrid/Core/Config.lua index 2f3020e..031518c 100644 --- a/UnitFrames_ClickGrid/Core/Config.lua +++ b/UnitFrames_ClickGrid/Core/Config.lua @@ -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 @@ -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, @@ -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, diff --git a/UnitFrames_ClickGrid/Groups/Definitions.lua b/UnitFrames_ClickGrid/Groups/Definitions.lua index 1bd4fe9..31b2444 100644 --- a/UnitFrames_ClickGrid/Groups/Definitions.lua +++ b/UnitFrames_ClickGrid/Groups/Definitions.lua @@ -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 }, @@ -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 }, diff --git a/UnitFrames_ClickGrid/Groups/Pets.lua b/UnitFrames_ClickGrid/Groups/Pets.lua index 65c61f7..9ecd87f 100644 --- a/UnitFrames_ClickGrid/Groups/Pets.lua +++ b/UnitFrames_ClickGrid/Groups/Pets.lua @@ -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) @@ -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) @@ -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 @@ -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 diff --git a/UnitFrames_ClickGrid/Groups/Refresh.lua b/UnitFrames_ClickGrid/Groups/Refresh.lua index c706c74..41b7cbe 100644 --- a/UnitFrames_ClickGrid/Groups/Refresh.lua +++ b/UnitFrames_ClickGrid/Groups/Refresh.lua @@ -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 } @@ -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) diff --git a/UnitFrames_ClickGrid/Groups/Style.lua b/UnitFrames_ClickGrid/Groups/Style.lua index 700b415..174e8da 100644 --- a/UnitFrames_ClickGrid/Groups/Style.lua +++ b/UnitFrames_ClickGrid/Groups/Style.lua @@ -85,8 +85,7 @@ 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 @@ -94,7 +93,7 @@ function CG:StyleFrame(frame, kind) 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) diff --git a/UnitFrames_ClickGrid/Indicators/Status.lua b/UnitFrames_ClickGrid/Indicators/Status.lua index d86cc59..752544e 100644 --- a/UnitFrames_ClickGrid/Indicators/Status.lua +++ b/UnitFrames_ClickGrid/Indicators/Status.lua @@ -209,14 +209,7 @@ function Status:OnCreate(button, spec) threat.Override = Threat threat:Hide() self.ThreatIndicator = threat - -- Mouseover wash above the bars. Hooks cannot be removed: they check state. - self.hover = overlay:CreateTexture(nil, "ARTWORK") - self.hover:SetAllPoints(button) - self.hover:Hide() - self.hovered = false if self.live then - button:HookScript("OnEnter", function() self:SetHovered(true) end) - button:HookScript("OnLeave", function() self:SetHovered(false) end) -- Native slots are prepared outside combat, like the fixed buff slots. self.dispelContainer = CreateFrame("AuraContainer", nil, overlay, "CustomAuraContainerTemplate") self.dispelContainer:SetPoint("CENTER", overlay, "CENTER") @@ -245,11 +238,6 @@ function Status:OnCreate(button, spec) self.PrivateAuras = private end -function Status:SetHovered(hovered) - self.hovered = hovered - self.hover:SetShown(hovered and not self.released and self.resolved ~= nil and self.resolved.hover) -end - -- Everything the locked slot button needs is set up once, here. function Status:InitDispelSlot(slot) slot:EnableMouse(false) @@ -361,8 +349,6 @@ local function Apply(self, cfg) self:RestyleDispel() end Bind("UFCG_DispelGlow", cfg.dispel and self.dispelContainer and self or nil) - self.hover:SetColorTexture(UF.Util.UnpackColor(cfg.hoverColor)) - self:SetHovered(self.hovered) if self.dispelSample then UF.Glow.Apply(self.dispelSample, cfg.dispelGlow) if not cfg.dispel then self.dispelSample:Hide() end @@ -393,7 +379,6 @@ end function Status:OnRelease() self:SetResurrection(false) - self.hover:Hide() -- AuraContainer:SetUnit(nil) asserts: disable instead. if self.dispelContainer then self.dispelContainer:SetEnabled(false) diff --git a/UnitFrames_ClickGrid/Integration/Profiles.lua b/UnitFrames_ClickGrid/Integration/Profiles.lua index 913aa09..0bbb0f9 100644 --- a/UnitFrames_ClickGrid/Integration/Profiles.lua +++ b/UnitFrames_ClickGrid/Integration/Profiles.lua @@ -18,6 +18,8 @@ end -- Sanitized and fully validated replacements for every store, or nil and a reason. local function Prepare(stores, data, parts) if type(data) ~= "table" then return nil, "The ClickGrid data is damaged." end + data = UF.Util.Copy(data) + CG.Config.MigrateHover(data) local clean, dropped = {}, {} for _, part in ipairs(parts) do local store = stores[part] diff --git a/UnitFrames_ClickGrid/README.md b/UnitFrames_ClickGrid/README.md index 2b82163..a765276 100644 --- a/UnitFrames_ClickGrid/README.md +++ b/UnitFrames_ClickGrid/README.md @@ -127,8 +127,10 @@ client after adding it. For local builds and incremental updates, see the **Dispellable debuff glow** lights the whole cell in the debuff type's colour while the member has a debuff you (or anyone in the group) can dispel, gated by a hidden native aura slot so it works in combat. - **Mouseover highlight** (on by default, colour configurable) lightens the - cell under the mouse, so you can see which member you are about to cast on. Private auras sit inside the right edge by default + **Mouseover highlight** (on by default, colour configurable) is the unit + frames' own frame-wide highlight, set per bar style (member, target, pet): + it lightens the cell under the mouse, so you can see which member you are + about to cast on. Pets default to a distinct cyan. Private auras sit inside the right edge by default (**Private aura position**), leaving the centre to crowd control. - Ready check bar tints on member bars (**Indicators & states > Ready check tints & icon — Member style**): grey while waiting, then green or red, holding and fading after the check with diff --git a/UnitFrames_Workbench/Pages.lua b/UnitFrames_Workbench/Pages.lua index 521193b..f1c07df 100644 --- a/UnitFrames_Workbench/Pages.lua +++ b/UnitFrames_Workbench/Pages.lua @@ -10,9 +10,9 @@ local FEATURES = { } local AURAS = { auras = "External icons", auraBar = "Embedded row", categoryAuras = "Priority icons", slots = "Tracked friendly buffs", privateAuras = "Private auras", blizzardAuras = "Blizzard buffs & debuffs" } -local STATES = { range = true, dead = true, offline = true, resting = true, restingIcon = true, readyCheck = true, readyCheckIcon = true, +local STATES = { range = true, hover = true, dead = true, offline = true, resting = true, restingIcon = true, readyCheck = true, readyCheckIcon = true, raidTarget = true, pvp = true, classification = true, indicators = true } -local LABELS = { spark = "Fill-edge highlight", range = "Fade out-of-range frames", segments = "Shields and healing overlays", +local LABELS = { spark = "Fill-edge highlight", range = "Fade out-of-range frames", hover = "Mouseover highlight", segments = "Shields and healing overlays", castbar = "Cast bar", copyPlayerSettings = "Copy player style" } function Pages.Walk(schema, visit, prefix, ancestors) @@ -69,7 +69,7 @@ local function Location(entry, path) local events = { { "ready", "readyCheck", "Ready check icon" }, { "role", "role", "Group role" }, { "leader", "leader", "Leader & assistant" }, { "death", "death", "Dead & ghost" }, { "resurrection", "resurrection", "Incoming resurrection" }, { "summon", "summon", "Summon" }, - { "threat", "threat", "Threat" }, { "dispel", "dispel", "Dispellable debuffs" }, { "hover", "hover", "Mouseover" } } + { "threat", "threat", "Threat" }, { "dispel", "dispel", "Dispellable debuffs" } } for _, event in ipairs(events) do if key:sub(1, #event[1]) == event[1] then return "states", "Indicators & states", event[2], event[3] end end @@ -122,6 +122,7 @@ function Pages.Build(entry, targets) if opt.key == "format" then label = labels[1] .. " text content — " .. (labels[#labels - 1] or "Text") end if path == "castbar.enabled" then label = "Show cast bar" end if path == "range.enabled" then label = "Fade out-of-range frames" end + if path == "hover.enabled" then label = "Mouseover highlight" end if path == "auras.enabled" then label = "Show external aura icons" end if path == "auraBar.enabled" then label = "Show embedded icon row" end if path == "categoryAuras.enabled" then label = "Show priority icons" end diff --git a/tests/fixtures/schema_snapshot.txt b/tests/fixtures/schema_snapshot.txt index 176689f..a428e14 100644 --- a/tests/fixtures/schema_snapshot.txt +++ b/tests/fixtures/schema_snapshot.txt @@ -2563,6 +2563,9 @@ option range.enabled type="toggle" label="Enabled" default=false option range.outsideAlpha type="range" label="Out-of-range opacity" default=0.55 min=0 max=1 step=0.05 tooltip=#31bd172e option range.mode type="select" label="Range check" default="group" values=#b1e9e395 tooltip=#2c964cf0 option range.spell type="text" label="Spell ID or name" default="" tooltip=#a735d466 hidden +option hover type="group" label="Mouseover highlight" +option hover.enabled type="toggle" label="Enabled" default=true tooltip=#dbbae48b +option hover.color type="color" label="Mouseover colour" default={1,1,1,0.12} hidden option resting type="group" label="Resting border" option resting.enabled type="toggle" label="Enabled" default=true option resting.color type="color" label="Resting colour" default={1,0.753,0.157,1} @@ -4508,6 +4511,8 @@ default health.right.vertical = "auto" default health.right.whileCasting = "keep" default health.right.whileStatus = "status" default health.textLayout = "centred" +default hover.color = {1,1,1,0.12} +default hover.enabled = true default offline.bars = true default offline.border = true default offline.color = {0.62,0.62,0.62,1} @@ -5589,6 +5594,8 @@ resolved health.right.vertical = "auto" resolved health.right.whileCasting = "keep" resolved health.right.whileStatus = "status" resolved health.textLayout = "centred" +resolved hover.color = {1,1,1,0.12} +resolved hover.enabled = true resolved offline.bars = true resolved offline.border = true resolved offline.color = {0.62,0.62,0.62,1} @@ -5957,6 +5964,9 @@ option range.enabled type="toggle" label="Enabled" default=false option range.outsideAlpha type="range" label="Out-of-range opacity" default=0.55 min=0 max=1 step=0.05 tooltip=#31bd172e option range.mode type="select" label="Range check" default="group" values=#b1e9e395 tooltip=#2c964cf0 option range.spell type="text" label="Spell ID or name" default="" tooltip=#a735d466 hidden +option hover type="group" label="Mouseover highlight" +option hover.enabled type="toggle" label="Enabled" default=true tooltip=#dbbae48b +option hover.color type="color" label="Mouseover colour" default={1,1,1,0.12} hidden option readyCheck type="group" label="Ready check" option readyCheck.enabled type="toggle" label="Tint bars" default=true tooltip=#f63d91dc option readyCheck.waitingColor type="color" label="Waiting colour" default={0.5,0.5,0.5,1} @@ -7340,6 +7350,8 @@ default health.right.vertical = "auto" default health.right.whileCasting = "keep" default health.right.whileStatus = "status" default health.textLayout = "edges" +default hover.color = {1,1,1,0.12} +default hover.enabled = true default offline.bars = true default offline.border = true default offline.color = {0.62,0.62,0.62,1} @@ -8143,6 +8155,8 @@ resolved health.right.vertical = "auto" resolved health.right.whileCasting = "keep" resolved health.right.whileStatus = "status" resolved health.textLayout = "edges" +resolved hover.color = {1,1,1,0.12} +resolved hover.enabled = true resolved offline.bars = true resolved offline.border = true resolved offline.color = {0.62,0.62,0.62,1} @@ -8513,6 +8527,9 @@ option range.enabled type="toggle" label="Enabled" default=false option range.outsideAlpha type="range" label="Out-of-range opacity" default=0.55 min=0 max=1 step=0.05 tooltip=#31bd172e option range.mode type="select" label="Range check" default="group" values=#b1e9e395 tooltip=#2c964cf0 option range.spell type="text" label="Spell ID or name" default="" tooltip=#a735d466 hidden +option hover type="group" label="Mouseover highlight" +option hover.enabled type="toggle" label="Enabled" default=true tooltip=#dbbae48b +option hover.color type="color" label="Mouseover colour" default={1,1,1,0.12} hidden option threat type="group" label="Threat glow" defaults={} option threat.enabled type="toggle" label="Enabled" default=true tooltip=#21221959 option threat.colorBy type="select" label="Colour by" default="percent" values=#fbabf46f tooltip=#5ec8e2f3 @@ -9956,6 +9973,8 @@ default health.right.vertical = "auto" default health.right.whileCasting = "keep" default health.right.whileStatus = "status" default health.textLayout = "centred" +default hover.color = {1,1,1,0.12} +default hover.enabled = true default offline.bars = true default offline.border = true default offline.color = {0.62,0.62,0.62,1} @@ -10794,6 +10813,8 @@ resolved health.right.vertical = "auto" resolved health.right.whileCasting = "keep" resolved health.right.whileStatus = "status" resolved health.textLayout = "centred" +resolved hover.color = {1,1,1,0.12} +resolved hover.enabled = true resolved offline.bars = true resolved offline.border = true resolved offline.color = {0.62,0.62,0.62,1} @@ -11171,6 +11192,9 @@ option range.enabled type="toggle" label="Enabled" default=false option range.outsideAlpha type="range" label="Out-of-range opacity" default=0.55 min=0 max=1 step=0.05 tooltip=#31bd172e option range.mode type="select" label="Range check" default="group" values=#b1e9e395 tooltip=#2c964cf0 option range.spell type="text" label="Spell ID or name" default="" tooltip=#a735d466 hidden +option hover type="group" label="Mouseover highlight" +option hover.enabled type="toggle" label="Enabled" default=true tooltip=#dbbae48b +option hover.color type="color" label="Mouseover colour" default={1,1,1,0.12} hidden option threat type="group" label="Threat glow" defaults={enabled=false} option threat.enabled type="toggle" label="Enabled" default=true tooltip=#21221959 option threat.colorBy type="select" label="Colour by" default="percent" values=#fbabf46f tooltip=#5ec8e2f3 @@ -12561,6 +12585,8 @@ default health.right.vertical = "auto" default health.right.whileCasting = "keep" default health.right.whileStatus = "status" default health.textLayout = "edges" +default hover.color = {1,1,1,0.12} +default hover.enabled = true default offline.bars = true default offline.border = true default offline.color = {0.62,0.62,0.62,1} @@ -13370,6 +13396,8 @@ resolved health.right.vertical = "auto" resolved health.right.whileCasting = "keep" resolved health.right.whileStatus = "status" resolved health.textLayout = "edges" +resolved hover.color = {1,1,1,0.12} +resolved hover.enabled = true resolved offline.bars = true resolved offline.border = true resolved offline.color = {0.62,0.62,0.62,1} @@ -13737,6 +13765,9 @@ option range.enabled type="toggle" label="Enabled" default=false option range.outsideAlpha type="range" label="Out-of-range opacity" default=0.55 min=0 max=1 step=0.05 tooltip=#31bd172e option range.mode type="select" label="Range check" default="group" values=#b1e9e395 tooltip=#2c964cf0 option range.spell type="text" label="Spell ID or name" default="" tooltip=#a735d466 hidden +option hover type="group" label="Mouseover highlight" +option hover.enabled type="toggle" label="Enabled" default=true tooltip=#dbbae48b +option hover.color type="color" label="Mouseover colour" default={1,1,1,0.12} hidden option threat type="group" label="Threat glow" defaults={} option threat.enabled type="toggle" label="Enabled" default=true tooltip=#21221959 option threat.colorBy type="select" label="Colour by" default="percent" values=#fbabf46f tooltip=#5ec8e2f3 @@ -15126,6 +15157,8 @@ default health.right.vertical = "auto" default health.right.whileCasting = "keep" default health.right.whileStatus = "status" default health.textLayout = "centred" +default hover.color = {1,1,1,0.12} +default hover.enabled = true default offline.bars = true default offline.border = true default offline.color = {0.62,0.62,0.62,1} @@ -15936,6 +15969,8 @@ resolved health.right.vertical = "auto" resolved health.right.whileCasting = "keep" resolved health.right.whileStatus = "status" resolved health.textLayout = "centred" +resolved hover.color = {1,1,1,0.12} +resolved hover.enabled = true resolved offline.bars = true resolved offline.border = true resolved offline.color = {0.62,0.62,0.62,1} @@ -16304,6 +16339,9 @@ option range.enabled type="toggle" label="Enabled" default=false option range.outsideAlpha type="range" label="Out-of-range opacity" default=0.55 min=0 max=1 step=0.05 tooltip=#31bd172e option range.mode type="select" label="Range check" default="group" values=#b1e9e395 tooltip=#2c964cf0 option range.spell type="text" label="Spell ID or name" default="" tooltip=#a735d466 hidden +option hover type="group" label="Mouseover highlight" +option hover.enabled type="toggle" label="Enabled" default=true tooltip=#dbbae48b +option hover.color type="color" label="Mouseover colour" default={1,1,1,0.12} hidden option threat type="group" label="Threat glow" defaults={enabled=false} option threat.enabled type="toggle" label="Enabled" default=true tooltip=#21221959 option threat.colorBy type="select" label="Colour by" default="percent" values=#fbabf46f tooltip=#5ec8e2f3 @@ -17694,6 +17732,8 @@ default health.right.vertical = "auto" default health.right.whileCasting = "keep" default health.right.whileStatus = "status" default health.textLayout = "edges" +default hover.color = {1,1,1,0.12} +default hover.enabled = true default offline.bars = true default offline.border = true default offline.color = {0.62,0.62,0.62,1} @@ -18503,6 +18543,8 @@ resolved health.right.vertical = "auto" resolved health.right.whileCasting = "keep" resolved health.right.whileStatus = "status" resolved health.textLayout = "edges" +resolved hover.color = {1,1,1,0.12} +resolved hover.enabled = true resolved offline.bars = true resolved offline.border = true resolved offline.color = {0.62,0.62,0.62,1} @@ -21045,6 +21087,9 @@ option range.enabled type="toggle" label="Enabled" default=false option range.outsideAlpha type="range" label="Out-of-range opacity" default=0.55 min=0 max=1 step=0.05 tooltip=#31bd172e option range.mode type="select" label="Range check" default="group" values=#b1e9e395 tooltip=#2c964cf0 option range.spell type="text" label="Spell ID or name" default="" tooltip=#a735d466 hidden +option hover type="group" label="Mouseover highlight" +option hover.enabled type="toggle" label="Enabled" default=true tooltip=#dbbae48b +option hover.color type="color" label="Mouseover colour" default={1,1,1,0.12} hidden option readyCheck type="group" label="Ready check" option readyCheck.enabled type="toggle" label="Tint bars" default=true tooltip=#f63d91dc option readyCheck.waitingColor type="color" label="Waiting colour" default={0.5,0.5,0.5,1} @@ -22396,6 +22441,8 @@ default health.right.vertical = "auto" default health.right.whileCasting = "keep" default health.right.whileStatus = "status" default health.textLayout = "edges" +default hover.color = {1,1,1,0.12} +default hover.enabled = true default offline.bars = true default offline.border = true default offline.color = {0.62,0.62,0.62,1} @@ -23177,6 +23224,8 @@ resolved health.right.vertical = "auto" resolved health.right.whileCasting = "keep" resolved health.right.whileStatus = "status" resolved health.textLayout = "edges" +resolved hover.color = {1,1,1,0.12} +resolved hover.enabled = true resolved offline.bars = true resolved offline.border = true resolved offline.color = {0.62,0.62,0.62,1} @@ -23544,6 +23593,9 @@ option range.enabled type="toggle" label="Enabled" default=false option range.outsideAlpha type="range" label="Out-of-range opacity" default=0.55 min=0 max=1 step=0.05 tooltip=#31bd172e option range.mode type="select" label="Range check" default="group" values=#b1e9e395 tooltip=#2c964cf0 option range.spell type="text" label="Spell ID or name" default="" tooltip=#a735d466 hidden +option hover type="group" label="Mouseover highlight" +option hover.enabled type="toggle" label="Enabled" default=true tooltip=#dbbae48b +option hover.color type="color" label="Mouseover colour" default={1,1,1,0.12} hidden option dead type="group" label="Dead & ghost" option dead.enabled type="toggle" label="Enabled" default=true tooltip=#02954430 option dead.color type="color" label="Ghost colour" default={0.48,0.65,0.7,1} hidden @@ -24916,6 +24968,8 @@ default health.right.vertical = "auto" default health.right.whileCasting = "keep" default health.right.whileStatus = "status" default health.textLayout = "edges" +default hover.color = {1,1,1,0.12} +default hover.enabled = true default offline.bars = true default offline.border = true default offline.color = {0.62,0.62,0.62,1} @@ -25707,6 +25761,8 @@ resolved health.right.vertical = "auto" resolved health.right.whileCasting = "keep" resolved health.right.whileStatus = "status" resolved health.textLayout = "edges" +resolved hover.color = {1,1,1,0.12} +resolved hover.enabled = true resolved offline.bars = true resolved offline.border = true resolved offline.color = {0.62,0.62,0.62,1} @@ -26025,8 +26081,6 @@ option interactive type="toggle" label="Allow pet interaction" default=true tool option side type="select" label="Pet side" default="RIGHT" values=#11c04b33 hidden option gap type="range" label="Gap to member" default=1 min=0 max=30 step=1 hidden option includeInWidth type="toggle" label="Width includes pet" default=true tooltip=#75cdc399 hidden -option hover type="toggle" label="Pet mouseover highlight" default=true -option hoverColor type="color" label="Pet mouseover colour" default={0.2,0.8,1,0.35} option barLayout type="select" label="Arrange bars" default="columns" values=#3f6311d9 tooltip=#99609fd4 option width type="range" label="Width" default=85 min=60 max=600 step=1 hidden option spacing type="range" label="Bar spacing" default=1 min=0 max=20 step=1 @@ -26054,6 +26108,9 @@ option range.enabled type="toggle" label="Enabled" default=false option range.outsideAlpha type="range" label="Out-of-range opacity" default=0.55 min=0 max=1 step=0.05 tooltip=#31bd172e option range.mode type="select" label="Range check" default="group" values=#b1e9e395 tooltip=#2c964cf0 option range.spell type="text" label="Spell ID or name" default="" tooltip=#a735d466 hidden +option hover type="group" label="Mouseover highlight" defaults={color={0.2,0.8,1,0.35}} +option hover.enabled type="toggle" label="Enabled" default=true tooltip=#dbbae48b +option hover.color type="color" label="Mouseover colour" default={1,1,1,0.12} hidden option dead type="group" label="Dead & ghost" option dead.enabled type="toggle" label="Enabled" default=true tooltip=#02954430 option dead.color type="color" label="Ghost colour" default={0.48,0.65,0.7,1} hidden @@ -27400,8 +27457,8 @@ default health.right.vertical = "auto" default health.right.whileCasting = "keep" default health.right.whileStatus = "status" default health.textLayout = "edges" -default hover = true -default hoverColor = {0.2,0.8,1,0.35} +default hover.color = {0.2,0.8,1,0.35} +default hover.enabled = true default includeInWidth = true default interactive = true default offline.bars = true @@ -28182,8 +28239,8 @@ resolved health.right.vertical = "auto" resolved health.right.whileCasting = "keep" resolved health.right.whileStatus = "status" resolved health.textLayout = "edges" -resolved hover = true -resolved hoverColor = {0.2,0.8,1,0.35} +resolved hover.color = {0.2,0.8,1,0.35} +resolved hover.enabled = true resolved includeInWidth = true resolved interactive = true resolved offline.bars = true @@ -28485,6 +28542,7 @@ definition categoryAuras.noMouse = true definition defaultPosition.point = "CENTER" definition defaultPosition.x = -90 definition defaultPosition.y = -235 +definition hoverDefaults.color = {0.2,0.8,1,0.35} definition label = "Group pet" definition portrait.defaults.enabled = false definition portrait.lazyBackends = true @@ -28625,8 +28683,6 @@ option indicators.dispelGlow type="group" label="Dispellable glow" hidden option indicators.dispelGlow.size type="range" label="Glow size" default=12 min=4 max=32 step=1 tooltip=#885cb368 option indicators.dispelGlow.opacity type="range" label="Glow opacity" default=1 min=0.1 max=1 step=0.05 option indicators.dispelGlow.corners type="select" label="Glow corners" default="sharp" values=#588056eb tooltip=#2e13768c -option indicators.hover type="toggle" label="Mouseover highlight" default=true tooltip=#a498db58 -option indicators.hoverColor type="color" label="Mouseover colour" default={1,1,1,0.12} hidden option indicators.phase type="toggle" label="Different phase" default=true option indicators.size type="range" label="Other status icon size" default=14 min=8 max=32 step=1 option indicators.private type="toggle" label="Private encounter auras" default=true @@ -28685,8 +28741,6 @@ default indicators.dispelFilter = "HARMFUL|RAID" default indicators.dispelGlow.corners = "sharp" default indicators.dispelGlow.opacity = 1 default indicators.dispelGlow.size = 12 -default indicators.hover = true -default indicators.hoverColor = {1,1,1,0.12} default indicators.leader = true default indicators.leaderGap = 2 default indicators.leaderOffsetX = 0 @@ -28822,8 +28876,6 @@ resolved indicators.dispelFilter = "HARMFUL|RAID" resolved indicators.dispelGlow.corners = "sharp" resolved indicators.dispelGlow.opacity = 1 resolved indicators.dispelGlow.size = 12 -resolved indicators.hover = true -resolved indicators.hoverColor = {1,1,1,0.12} resolved indicators.leader = true resolved indicators.leaderGap = 2 resolved indicators.leaderOffsetX = 0 diff --git a/tests/spec/clickgrid/clickgrid_indicators_spec.lua b/tests/spec/clickgrid/clickgrid_indicators_spec.lua index ddee525..51925fb 100644 --- a/tests/spec/clickgrid/clickgrid_indicators_spec.lua +++ b/tests/spec/clickgrid/clickgrid_indicators_spec.lua @@ -264,25 +264,24 @@ describe("ClickGrid status indicators", function() assert.is_false(threat:IsShown()) end) - it("highlights the hovered cell above its bars", function() + it("highlights the hovered cell above its bars with the member style's frame highlight", function() local member = CG.headers.party:GetAttribute("child1").Member - local status = CG:GetGridButton(member).status - local hover = status.hover - -- Unitless: the tooltip hook that runs first returns early. + local hover = member.uf.hover + assert.is_nil(CG:GetGridButton(member).status.hover) + -- Unitless: the tooltip skips, the highlight does not. member.__unit = nil assert.is_false(hover:IsShown()) member:RunScript("OnEnter") assert.is_true(hover:IsShown()) assert.same({ 1, 1, 1, 0.12 }, hover.__state.colorTexture) - assert.equals(status.frame, hover:GetParent()) - assert.is_true(status.frame:GetFrameLevel() > member:GetFrameLevel()) + assert.is_true(hover:GetParent():GetFrameLevel() > member:GetFrameLevel()) - CG.Config:Set("indicators.hoverColor", { 0.2, 0.6, 1, 0.3 }) + CG.Config:SetStyle("member", "hover.color", { 0.2, 0.6, 1, 0.3 }) assert.is_true(hover:IsShown(), "restyles keep the hovered state") assert.same({ 0.2, 0.6, 1, 0.3 }, hover.__state.colorTexture) - CG.Config:Set("indicators.hover", false) + CG.Config:SetStyle("member", "hover.enabled", false) assert.is_false(hover:IsShown()) - CG.Config:Set("indicators.hover", true) + CG.Config:SetStyle("member", "hover.enabled", true) assert.is_true(hover:IsShown()) Mock.inCombat = true member:RunScript("OnLeave") diff --git a/tests/spec/clickgrid/clickgrid_pets_spec.lua b/tests/spec/clickgrid/clickgrid_pets_spec.lua index 9a5df71..3723007 100644 --- a/tests/spec/clickgrid/clickgrid_pets_spec.lua +++ b/tests/spec/clickgrid/clickgrid_pets_spec.lua @@ -227,14 +227,18 @@ describe("ClickGrid pets", function() assert.is_true(pet.__state.mouseClickEnabled) assert.is_true(pet.__state.mouseMotionEnabled) assert.equals("target", pet:GetAttribute("type-heal1")) - local status = CG:GetGridButton(Cell().Member).status - status:SetHovered(true) + local member = Cell().Member + member.uf:SetHovered(true) pet.__unit = nil pet:RunScript("OnEnter") - assert.is_true(CG:GetGridButton(pet).hover:IsShown()) - assert.is_false(status.hover:IsShown()) + assert.is_true(pet.uf.hover:IsShown()) + assert.same({ 0.2, 0.8, 1, 0.35 }, pet.uf.hover.__state.colorTexture) + assert.is_false(member.uf.hover:IsShown()) pet:RunScript("OnLeave") - assert.is_false(CG:GetGridButton(pet).hover:IsShown()) + assert.is_false(pet.uf.hover:IsShown()) + pet:RunScript("OnEnter") + CG.Config:SetStyle("pet", "interactive", false) + assert.is_false(pet.uf.hover:IsShown(), "pets without interaction drop the highlight") end) it("uses a pet-only native header and preserves independent styling", function() @@ -313,15 +317,14 @@ describe("ClickGrid pets", function() it("does not recreate components or compile bindings for pet colour edits", function() CG.Config:SetStyle("pet", "display", "inline") UF.Perf.counters = {} - CG.Config:SetStyle("pet", "hoverColor", { 1, 0, 1, 0.3 }) + CG.Config:SetStyle("pet", "hover.color", { 1, 0, 1, 0.3 }) local counters = UF.Perf.counters UF.Perf.counters = nil assert.is_nil(counters.componentCreate) assert.is_nil(counters.headerCreate) assert.is_nil(counters.clickgridBindingsCompile) - assert.is_nil(counters.rootApply) - assert.is_nil(counters.unitBind) assert.is_nil(counters.clickgridPanelLayout) + assert.same({ 1, 0, 1, 0.3 }, Cell().Pet.uf.hover.__state.colorTexture) end) it("keeps parked raid subgroups beyond the pet header's full secure capacity", function() diff --git a/tests/spec/clickgrid/clickgrid_spec.lua b/tests/spec/clickgrid/clickgrid_spec.lua index 23426a5..1b5c155 100644 --- a/tests/spec/clickgrid/clickgrid_spec.lua +++ b/tests/spec/clickgrid/clickgrid_spec.lua @@ -78,6 +78,30 @@ describe("ClickGrid companion", function() assert.is_true(CG:TargetsShown(), "an existing style choice wins") end) + it("moves the old indicator mouseover highlight to the member bar style once", function() + local db = CG.Config.db.profile + db.settings.indicators = { hover = false, hoverColor = { 0, 1, 0, 0.4 } } + local hover = CG.Config.styles.member:Resolved().hover + assert.is_false(hover.enabled) + assert.same({ 0, 1, 0, 0.4 }, hover.color) + assert.is_nil(db.settings.indicators.hover) + assert.is_nil(db.settings.indicators.hoverColor) + db.settings.indicators = { hover = true } + assert.is_false(CG.Config.styles.member:Resolved().hover.enabled, "an existing style choice wins") + end) + + it("migrates the old pet highlight and indicator highlight in imported profiles", function() + local data = { settings = { indicators = { hoverColor = { 0, 1, 0, 0.4 } } }, member = {}, target = {}, + pet = { hover = false, hoverColor = { 1, 0, 1, 0.3 } } } + local apply = UF.Profiles.sections.clickgrid.prepare(data) + assert.equals("function", type(apply)) + apply() + assert.same({ 0, 1, 0, 0.4 }, CG.Config.styles.member:Resolved().hover.color) + assert.same({ enabled = false, color = { 1, 0, 1, 0.3 } }, CG.Config:GetStyle("pet").hover) + assert.is_nil(CG.Config:Get().indicators and CG.Config:Get().indicators.hoverColor) + assert.is_not_nil(data.settings.indicators.hoverColor, "the import data itself is left alone") + end) + it("offers independent aura rows and stops their native feeds on hidden targets", function() CG.Config:SetStyle("member", "auraBar.enabled", true) CG.Config:SetStyle("target", "auraBar.enabled", true) diff --git a/tests/spec/units/hover_spec.lua b/tests/spec/units/hover_spec.lua new file mode 100644 index 0000000..ad49db4 --- /dev/null +++ b/tests/spec/units/hover_spec.lua @@ -0,0 +1,67 @@ +local Helpers = require("helpers") +local Mock = Helpers.Mock + +describe("Mouseover highlight", function() + local ns + before_each(function() + ns = Helpers.LoadAddon(true, true) + Mock.InstallUI() + -- Unitless: the tooltip skips, the highlight does not. + for _, frame in pairs(ns.Units.frames) do frame.__unit = nil end + end) + + it("is offered on every unit frame and lightens it while the mouse is over it", function() + for _, unit in ipairs(ns.Units.order) do + local frame = ns.Units.frames[unit] + local hover = frame.uf.hover + assert.is_not_nil(ns.Schema.Find(frame.uf:GetSchema(), "hover.color"), unit) + assert.is_true(frame.uf.resolved.hover.enabled, unit) + assert.is_false(hover:IsShown(), unit) + frame:RunScript("OnEnter") + assert.is_true(hover:IsShown(), unit) + assert.same({ 1, 1, 1, 0.12 }, hover.__state.colorTexture) + frame:RunScript("OnLeave") + assert.is_false(hover:IsShown(), unit) + end + end) + + it("draws above the bars and below the frame border", function() + local frame = ns.Units.frames.target + local level = frame.uf.hoverHost:GetFrameLevel() + assert.equals(frame.uf.hoverHost, frame.uf.hover:GetParent()) + assert.is_true(level > frame.uf:GetRow("health"):GetFrame():GetFrameLevel()) + assert.is_true(level < frame:GetFrameLevel() + ns.Components.Backdrop.LEVELS.frame) + end) + + it("keeps the hovered state through restyles and follows the settings, also in combat", function() + local frame = ns.Units.frames.player + local hover = frame.uf.hover + frame:RunScript("OnEnter") + ns.Config:SetUnitValue("player", "hover.color", { 0.2, 0.6, 1, 0.3 }) + assert.is_true(hover:IsShown(), "restyles keep the hovered state") + assert.same({ 0.2, 0.6, 1, 0.3 }, hover.__state.colorTexture) + ns.Config:SetUnitValue("player", "hover.enabled", false) + assert.is_false(hover:IsShown()) + ns.Config:SetUnitValue("player", "hover.enabled", true) + assert.is_true(hover:IsShown()) + Mock.inCombat = true + frame:RunScript("OnLeave") + assert.is_false(hover:IsShown()) + frame:RunScript("OnEnter") + assert.is_true(hover:IsShown()) + Mock.inCombat = false + end) + + it("copies with the player style", function() + ns.Config:SetUnitValue("player", "hover.color", { 1, 0, 0, 0.5 }) + assert.is_true(ns.Units:CopyPlayerSettings("focus")) + assert.same({ 1, 0, 0, 0.5 }, ns.Units.frames.focus.uf.resolved.hover.color) + end) + + it("migrates the old flat hover toggle and colour into the group", function() + assert.same({ hover = { enabled = false, color = { 1, 0, 1, 0.3 } } }, + ns.Units:MigrateConfig({ hover = false, hoverColor = { 1, 0, 1, 0.3 } })) + assert.same({ hover = { color = { 1, 0, 1, 0.3 } } }, ns.Units:MigrateConfig({ hoverColor = { 1, 0, 1, 0.3 } })) + assert.same({ hover = { enabled = false } }, ns.Units:MigrateConfig({ hover = { enabled = false } })) + end) +end)