From 5815b9e81e1567d7bcb768338876764d30ed5bee Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Wed, 2 Sep 2026 11:40:20 -0500 Subject: [PATCH] chat: let pfUI's chat colors own their alpha and apply live Two problems with routing the native transparency slider into the pfUI panel. RefreshBackgroundAlpha overwrote the alpha of C.chat.global.background on every refresh, so anyone with custom colors enabled saw their configured opacity revert on reload, tab switch and dock change. That value carries its own alpha, is set by the shipped profiles and is shared with the meter skins, so the slider must not own it. Skip the alpha mirror entirely when custom colors are on; the slider still drives the panel on the default theme, which is what issue #48 was actually about. The colors were also only applied at module load, so the pickers needed a /reload to show anything. Extract that into ApplyPanelColors and expose it as pfUI.chat:UpdateConfig, which the gui resolves as U["chat"], so the three chat color settings take effect on the spot. CreateBackdrop is re-run first to restore the appearance theme, which is what lets toggling custom colors back off return the panel to the global theme without a reload. --- modules/chat.lua | 53 +++++++++++++++++++++++++++++++----------------- modules/gui.lua | 6 +++--- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/modules/chat.lua b/modules/chat.lua index 4e28daf0..79c96799 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -63,6 +63,23 @@ pfUI:RegisterModule("chat", function () return pfUI_cache["chathistory"][realm][player][id] end + -- [ Chat Panel Colors ] + -- The panels normally inherit pfUI's global appearance theme; custom colors let chat + -- deviate from it. CreateBackdrop is re-run first to restore the theme, so toggling + -- custom colors back off doesn't leave the previous override behind. + local function ApplyPanelColors(panel) + if not panel then return end + + CreateBackdrop(panel, default_border, nil, .8) + if C.chat.global.custombg ~= "1" then return end + + local r, g, b, a = GetStringColor(C.chat.global.background) + panel.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) + + local r, g, b, a = GetStringColor(C.chat.global.border) + panel.backdrop:SetBackdropBorderColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) + end + pfUI.chat = CreateFrame("Frame",nil,UIParent) pfUI.chat.left = CreateFrame("Frame", "pfChatLeft", UIParent) @@ -76,19 +93,11 @@ pfUI:RegisterModule("chat", function () pfUI.chat.left:SetPoint("BOTTOMLEFT", 2*default_border,2*default_border) pfUI.chat.left:SetScript("OnShow", function() pfUI.chat:RefreshChat() end) UpdateMovable(pfUI.chat.left) - CreateBackdrop(pfUI.chat.left, default_border, nil, .8) + ApplyPanelColors(pfUI.chat.left) if C.chat.global.frameshadow == "1" then CreateBackdropShadow(pfUI.chat.left) end - if C.chat.global.custombg == "1" then - local r, g, b, a = GetStringColor(C.chat.global.background) - pfUI.chat.left.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - - local r, g, b, a = GetStringColor(C.chat.global.border) - pfUI.chat.left.backdrop:SetBackdropBorderColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - end - pfUI.chat.left.panelTop = CreateFrame("Frame", "leftChatPanelTop", pfUI.chat.left) pfUI.chat.left.panelTop:ClearAllPoints() pfUI.chat.left.panelTop:SetHeight(C.global.font_size+default_border*2) @@ -251,19 +260,11 @@ pfUI:RegisterModule("chat", function () pfUI.chat.right:SetPoint("BOTTOMRIGHT", -2*default_border,2*default_border) pfUI.chat.right:SetScript("OnShow", function() pfUI.chat:RefreshChat() end) UpdateMovable(pfUI.chat.right) - CreateBackdrop(pfUI.chat.right, default_border, nil, .8) + ApplyPanelColors(pfUI.chat.right) if C.chat.global.frameshadow == "1" then CreateBackdropShadow(pfUI.chat.right) end - if C.chat.global.custombg == "1" then - local r, g, b, a = GetStringColor(C.chat.global.background) - pfUI.chat.right.backdrop:SetBackdropColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - - local r, g, b, a = GetStringColor(C.chat.global.border) - pfUI.chat.right.backdrop:SetBackdropBorderColor(tonumber(r), tonumber(g), tonumber(b), tonumber(a)) - end - pfUI.chat.right.panelTop = CreateFrame("Frame", "rightChatPanelTop", pfUI.chat.right) pfUI.chat.right.panelTop:ClearAllPoints() pfUI.chat.right.panelTop:SetHeight(C.global.font_size+default_border*2) @@ -300,7 +301,7 @@ pfUI:RegisterModule("chat", function () -- Blizzard's per-window transparency slider drives FCF_SetWindowAlpha, which only -- touches the ChatFrame*Background textures that pfUI hides on docked frames. Mirror -- the window's stored alpha onto the visible pfUI backdrop so the native slider - -- controls it directly. The slider is authoritative for the panel's alpha. + -- controls it directly. local function ApplyChatBackgroundAlpha(panel, frame) if not (panel and panel.backdrop and frame) then return end local _, _, _, _, _, alpha = GetChatWindowInfo(frame:GetID()) @@ -311,6 +312,12 @@ pfUI:RegisterModule("chat", function () end function pfUI.chat:RefreshBackgroundAlpha() + -- Custom colors own the alpha. C.chat.global.background carries its own alpha, is + -- set by profiles and is shared with the meter skins, so the native slider must not + -- overwrite it -- doing so reverted the configured opacity on every refresh. The + -- slider only drives the panel when the user hasn't opted into pfUI's chat colors. + if C.chat.global.custombg == "1" then return end + -- left panel follows the currently selected docked tab local selected = SELECTED_CHAT_FRAME if not (selected and selected:GetParent() == pfUI.chat.left) then @@ -323,6 +330,14 @@ pfUI:RegisterModule("chat", function () end end + -- live config apply, resolved by the gui as U["chat"]. Lets the color pickers + -- take effect on the spot instead of waiting for a /reload. + function pfUI.chat:UpdateConfig() + ApplyPanelColors(pfUI.chat.left) + ApplyPanelColors(pfUI.chat.right) + pfUI.chat:RefreshBackgroundAlpha() + end + function pfUI.chat:MigrateBackgroundAlpha() -- Runs once per character. The previous SetupPositions default stored a hard 0 window -- alpha, which now renders the pfUI backdrop fully transparent. Restore the historical diff --git a/modules/gui.lua b/modules/gui.lua index 9d873b1e..6ccdb426 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -2880,9 +2880,9 @@ pfUI:RegisterModule("gui", function () CreateConfig(nil, T["Only Show Chat Dock On Mouseover"], C.chat.global, "tabmouse", "checkbox") CreateConfig(nil, T["Enable Chat Tab Flashing"], C.chat.global, "chatflash", "checkbox") CreateConfig(nil, T["Enable Frame Shadow"], C.chat.global, "frameshadow", "checkbox") - CreateConfig(nil, T["Enable Custom Colors"], C.chat.global, "custombg", "checkbox") - CreateConfig(nil, T["Chat Background Color"], C.chat.global, "background", "color") - CreateConfig(nil, T["Chat Border Color"], C.chat.global, "border", "color") + CreateConfig(U["chat"], T["Enable Custom Colors"], C.chat.global, "custombg", "checkbox") + CreateConfig(U["chat"], T["Chat Background Color"], C.chat.global, "background", "color") + CreateConfig(U["chat"], T["Chat Border Color"], C.chat.global, "border", "color") CreateConfig(nil, T["Enable Custom Incoming Whispers Layout"], C.chat.global, "whispermod", "checkbox") CreateConfig(nil, T["Incoming Whispers Color"], C.chat.global, "whisper", "color") CreateConfig(nil, T["Enable Sticky Chat"], C.chat.global, "sticky", "checkbox")