tooltip: add option to set a custom position

This commit is contained in:
Road-block
2019-06-02 18:01:09 +02:00
committed by shagu
parent 8a4f080bcd
commit 69aa18304b
2 changed files with 30 additions and 2 deletions
+2 -1
View File
@@ -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"],
+28 -1
View File
@@ -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)