From 19e25ae39ab7e7916e3d441bcc9af06809a41b22 Mon Sep 17 00:00:00 2001 From: urnati Date: Sun, 29 Mar 2026 08:23:46 -0400 Subject: [PATCH] - Titan : Fix for scaling plugins - Titan : new .tooltipTemplateFunction for plugins --- Titan/TitanTemplate.lua | 28 +++++++++++++++-- TitanBag/TitanBag.lua | 76 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 83 insertions(+), 21 deletions(-) diff --git a/Titan/TitanTemplate.lua b/Titan/TitanTemplate.lua index dad81ea..1a485dc 100644 --- a/Titan/TitanTemplate.lua +++ b/Titan/TitanTemplate.lua @@ -279,6 +279,7 @@ local function TitanPanelButton_SetTooltip(self) local ok = false local frame = TitanPanelTooltip --GameTooltip local id = self.registry.id +--local frame = CreateFrame("GameTooltip","myTooltipFrame",UIParent,"GameTooltipTemplate") frame.registry_id = id -- for use in other routines frame.plugin_frame = self @@ -302,14 +303,36 @@ local function TitanPanelButton_SetTooltip(self) self.plugin_frame = TitanUtils_ButtonName(id) if (plugin and plugin.ldb) then -- assume the TitanLDB processing will handle the tooltip. + elseif (plugin and plugin.tooltipTemplateFunction) then + -- 2026 Mar Added to pass a tooltip frame to a plugin as an explicit agreement. + -- This acts as Blizz GameTooltip so plugin can 'add line' etc. + + -- Hide the Titan Tooltip in case it is open. + frame:Hide() + frame:ClearLines() -- Hand off a blank tooltip + TitanTooltip_SetPanelTooltip(self, id, frame) + + -- The plugin is in full control of contents. + self.tooltipTemplateFunction = plugin.tooltipTemplateFunction; + dbg_msg = dbg_msg .. " | custom" + call_success, -- for pcall + tmp_txt = pcall(self.tooltipTemplateFunction, self, frame) + if call_success then + -- all is good + dbg_msg = dbg_msg .. " | ok" + else + dbg_msg = dbg_msg .. " | Err: " .. tmp_txt + end + frame:Show(); -- now show it elseif (plugin and plugin.tooltipCustomFunction) then -- Hide the Titan Tooltip in case it is open. frame:Hide() -- 2026 Jan Switching to a Titan controlled frame made us realize -- changing GameTooltip for custom tooltips creates a hybrid mess... - -- The plugin Dev should take full ownership of the tooltip :). - -- For now, use the Game tooltip for custom until we can converse with other devs... + -- This should be treated as deprecated as of 2026 Mar. + -- It is left so older plugins will work - but they error as of Midnight (12.0.0) + -- Use tooltipTemplateFunction instead! local custom_f = GameTooltip TitanTooltip_SetPanelTooltip(self, id, custom_f); @@ -789,6 +812,7 @@ local function TitanPanelButton_SetButtonText(id) local text = false if button then buttonText = _G[button:GetName() .. TITAN_PANEL_TEXT]; + button:SetScale(TitanPanelGetVar("Scale")) local newfont = media:Fetch("font", TitanPanelGetVar("FontName")) if newfont then diff --git a/TitanBag/TitanBag.lua b/TitanBag/TitanBag.lua index a63e746..8606855 100644 --- a/TitanBag/TitanBag.lua +++ b/TitanBag/TitanBag.lua @@ -971,6 +971,7 @@ Attributes: .buttonTextFunction : See .registry Routines below. .tooltipTitle : Used as the title for the tool tip .tooltipTextFunction : See .registry Routines below. +.tooltipCustomFunction : See .registry Routines below. .icon : Path to the icon to be used. It is recommended to store the icon in the plugin folder, even if exists within WoW. .iconWidth : Best left at 16... @@ -1024,37 +1025,74 @@ NOTE: Titan routines have used 1 as true since inception so be careful on 'true --]] ---[[ .registry Routines +--[[ .registry Routines Overview -Titan looks for specified routines in the .registry : +Titan looks for specified routines in the .registry allowing the plugin to present its data and actions. + +NOTES: +- Each .registry routine is called using pcall to protect Titan. +- Unless specified, these routines have NO parameters. +- Each routine can be specified : +--- As a string, it MUST be in the global namespace. Strings were the only method for a long time until Feb 2024. +--- As a global function +--- As a local function which is preferred + +--]] + +--[[ .registry Routines for plugin text + +Titan looks for : - .buttonTextFunction : Routine that updates the plugin button text. -- .tooltipTextFunction : Routine that generates the tool tip text. -- .menuContextFunction : NOTE: Creating menu below -- .menuTextFunction : NOTE: Creating menu below -.buttonTextFunction : This is called whenever the button is to be updated. - This is called from within the plugin and from Titan via TitanPanelButton_UpdateButton(TITAN_PLUGIN) . +The specified function is called whenever the button is to be updated. + The function is called from within the plugin and from Titan via TitanPanelButton_UpdateButton(Id) . Titan will usually return "" if the routine dies. If you need to see the error, search for this attribute in the Titan folder and uncomment the print of the error message. This may generate a LOT of messages! -.tooltipTextFunction : This is called when the mouse enters the plugin frame - OnEnter. - The Titan templates set the OnEnter script for the plugin frame. - On a tooltip error, Titan will usually show part of the error in the tool tip. - If you need to see the full error, search for this attribute in the Titan folder and uncomment the print of the error message. +--]] -NOTE: Each .registry routine is called using pcall to protect Titan. -These routines are expected to have NO parameters. Handling parameters was not implemented in any version of Titan. +--[[ .registry Routines for Menu creation -NOTE: Creating menu -Routine that creates the options for the menu (right click). Titan will use only one, if found, in order : +Titan looks for a function to create a menu, in order: 1) registry.menuContextFunction : NEW Jan 2026 2) registry.menuTextFunction : Feb 2024 3) "TitanPanelRightClickMenu_Prepare" .. id .. "Menu" : Old as Titan :) +4) Nothing found, no menu + +Titan will use only the first, if found, on right click of the plugin frame. + +1) Uses the new Titan_Menu which wraps Blizzard_Menu to help protect plugins from Blizzard changes. +2) and 3) Use the deprecated UIDropdownMenu scheme. Blizzard will remove this from game code at some future time. + +Titan_Menu expects an object approach. The older scheme uses a table driven which is code intensive. +--]] + +--[[ .registry Routines for Tooltip creation +If Titan finds a tooltip function, Titan will assume it needs to position, show, and hide the tooltip. + +Titan looks for a function to create a tooltip, in order: +1) .tooltipTemplateFunction : New 2026 Mar +A game tooltip template is passed to plugin as an explicit agreement + pcall(self.tooltipTemplateFunction, self, frame) + +2) .tooltipCustomFunction : Deprecated Midnight (12.0.0) / 2026 Mar : +Assumes GameTooltip as implicit agreement + tmp_txt = pcall(self.tooltipCustomFunction, self) + +3) .tooltipTextFunction : Titan adds plugin name as Title; expects text in return to fill the tooltip. + +The tooltip function is called when the mouse enters the plugin frame - OnEnter. +Titan templates set the OnEnter script for the plugin frame. +On a tooltip error, Titan will usually show part of the error in the tool tip. +If you need to see the full error, search for this attribute in the Titan folder; +and uncomment the print of the error message. -NOTE: Each routine can be specified : -- As a string, it MUST be in the global namespace. Strings were the only method for a long time until Feb 2024. -- As a function, it may be in the global namespace but could be local. -This example uses a local routine which is preferred. +Due to changes in Midnight (12.0.0) Titan tooltips have undergone major changes to avoid 'secret' errors. +Titan had to move to a custom tooltip rather than use Blizzard's GameTooltip. +This causes conflict in the 'custom' scheme which assumes GameTooltip in Titan and the Titan plugin. +To resolve this .tooltipTemplateFunction was added (2026 Mar). +The new attribute allows plugins to update as needed to Midnight. +It also allows older, possibly abandoned, plugins to run as long as practical. Until a breaking API change. --]] -- 1.7.9.5