From 69aa18304bf33b8e01b5f1200053dac818a3741b Mon Sep 17 00:00:00 2001 From: Road-block Date: Fri, 31 May 2019 07:09:45 +0300 Subject: [PATCH] tooltip: add option to set a custom position --- modules/gui.lua | 3 ++- modules/tooltip.lua | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/modules/gui.lua b/modules/gui.lua index db07dec2..5123cb40 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1008,7 +1008,8 @@ pfUI:RegisterModule("gui", 20400, function () ["tooltip_position"] = { "bottom:" .. T["Bottom"], "chat:" .. T["Dodge"], - "cursor:" .. T["Cursor"] + "cursor:" .. T["Cursor"], + "free:" .. T["Custom"] }, ["tooltip_align"] = { "native:" .. T["Native"], diff --git a/modules/tooltip.lua b/modules/tooltip.lua index 641922c4..6cf55384 100644 --- a/modules/tooltip.lua +++ b/modules/tooltip.lua @@ -1,4 +1,27 @@ pfUI:RegisterModule("tooltip", 20400, function () + + pfUI.tooltip = CreateFrame('Frame', "pfTooltip", GameTooltip) + pfUI.tooltip.anchorframe = CreateFrame('Frame', "pfTooltipAnchor", UIParent) + pfUI.tooltip.anchorframe:SetWidth(128) + pfUI.tooltip.anchorframe:SetHeight(72) + pfUI.tooltip.anchorframe:SetPoint("TOP", UIParent, "TOP", 0, -50) + pfUI.tooltip.anchorframe:Hide() + UpdateMovable(pfUI.tooltip.anchorframe) + + function pfUI.tooltip:GetAnchorPoint() + local prefix = "TOP" + local suffix = "RIGHT" + local px, py = UIParent:GetCenter() + local tx, ty = this.anchorframe:GetCenter() + if (tx < px) then + suffix = "LEFT" + end + if (ty < py) then + prefix = "BOTTOM" + end + return prefix..suffix + end + if C.tooltip.position == "cursor" then function _G.GameTooltip_SetDefaultAnchor(tooltip, parent) tooltip:SetOwner(parent, "ANCHOR_CURSOR") @@ -30,7 +53,6 @@ pfUI:RegisterModule("tooltip", 20400, function () end local units = { "mouseover", "player", "pet", "target", "party", "partypet", "raid", "raidpet" } - pfUI.tooltip = CreateFrame('Frame', "pfTooltip", GameTooltip) function pfUI.tooltip:GetUnit() pfUI.tooltip.unit = "none" @@ -90,6 +112,11 @@ pfUI:RegisterModule("tooltip", 20400, function () else GameTooltip:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -5, 5) end + elseif C.tooltip.position == "free" then + local point = this:GetAnchorPoint() + if point then + GameTooltip:SetPoint(point, this.anchorframe, point, 0, 0) + end end end end)