mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-07 14:10:01 +00:00
actionbar: rewrite of the autohide logic
This commit is contained in:
Vendored
+28
@@ -402,3 +402,31 @@ function pfUI.api:BarButtonAnchor(button,basename,buttonindex,barsize,formfactor
|
||||
end
|
||||
return button._anchor
|
||||
end
|
||||
|
||||
-- [ Create Autohide ] --
|
||||
-- 'frame' the frame that should be hidden
|
||||
function pfUI.api:CreateAutohide(frame)
|
||||
if not frame then return end
|
||||
frame.hover = CreateFrame("Frame", frame:GetName() .. "Autohide", frame)
|
||||
frame.hover:SetParent(frame)
|
||||
frame.hover:SetAllPoints(frame)
|
||||
frame.hover.parent = frame
|
||||
|
||||
frame.hover:RegisterEvent("PLAYER_LEAVING_WORLD")
|
||||
frame.hover:SetScript("OnEvent", function()
|
||||
this:Hide()
|
||||
end)
|
||||
|
||||
frame.hover:SetScript("OnUpdate", function()
|
||||
if MouseIsOver(this, 10, -10, -10, 10) then
|
||||
this.activeTo = GetTime() + tonumber(pfUI_config.bars.hide_time)
|
||||
this.parent:SetAlpha(1)
|
||||
elseif this.activeTo then
|
||||
if this.activeTo < GetTime() and this.parent:GetAlpha() > 0 then
|
||||
this.parent:SetAlpha(this.parent:GetAlpha() - 0.1)
|
||||
end
|
||||
else
|
||||
this.activeTo = GetTime() + tonumber(pfUI_config.bars.hide_time)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
+27
-83
@@ -89,7 +89,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
SlidingActionBarTexture1.Show = function () return end
|
||||
|
||||
-- create action bar frame
|
||||
pfUI.bars = CreateFrame("Frame",nil,UIParent)
|
||||
pfUI.bars = CreateFrame("Frame", nil, UIParent)
|
||||
pfUI.bars:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
pfUI.bars:RegisterEvent("CVAR_UPDATE")
|
||||
pfUI.bars:RegisterEvent("PET_BAR_UPDATE")
|
||||
@@ -100,6 +100,32 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
pfUI.bars:RegisterEvent("PET_BAR_SHOWGRID")
|
||||
pfUI.bars:RegisterEvent("PET_BAR_HIDEGRID")
|
||||
|
||||
pfUI.bars.autohide = CreateFrame("Frame", nil, UIParent)
|
||||
pfUI.bars.autohide:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
pfUI.bars.autohide:SetScript("OnEvent", function()
|
||||
if pfUI_config.bars.hide_actionmain == "1" then
|
||||
pfUI.api:CreateAutohide(pfUI.bars.actionmain)
|
||||
end
|
||||
if pfUI_config.bars.hide_bottomleft == "1" then
|
||||
pfUI.api:CreateAutohide(pfUI.bars.bottomleft)
|
||||
end
|
||||
if pfUI_config.bars.hide_bottomright == "1" then
|
||||
pfUI.api:CreateAutohide(pfUI.bars.bottomright)
|
||||
end
|
||||
if pfUI_config.bars.hide_right == "1" then
|
||||
pfUI.api:CreateAutohide(pfUI.bars.right)
|
||||
end
|
||||
if pfUI_config.bars.hide_tworight == "1" then
|
||||
pfUI.api:CreateAutohide(pfUI.bars.tworight)
|
||||
end
|
||||
if pfUI_config.bars.hide_shapeshift == "1" then
|
||||
pfUI.api:CreateAutohide(pfUI.bars.shapeshift)
|
||||
end
|
||||
if pfUI_config.bars.hide_pet == "1" then
|
||||
pfUI.api:CreateAutohide(pfUI.bars.pet)
|
||||
end
|
||||
end)
|
||||
|
||||
pfUI.bars.actionmain = CreateFrame("Frame", "pfBarActionMain", UIParent)
|
||||
pfUI.bars.shapeshift = CreateFrame("Frame", "pfBarShapeshift", UIParent)
|
||||
pfUI.bars.bottomleft = CreateFrame("Frame", "pfBarBottomLeft", UIParent)
|
||||
@@ -451,86 +477,4 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
getglobal(button..i..'Name'):SetJustifyV("BOTTOM")
|
||||
end
|
||||
end
|
||||
|
||||
local function pfEnableAutohide(frame)
|
||||
frame.hover = CreateFrame("Frame", frame:GetName() .. "Autohide", frame)
|
||||
frame.hover:SetParent(frame)
|
||||
frame.hover:SetPoint("TOPLEFT", frame, "TOPLEFT", -5, 5)
|
||||
frame.hover:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 5, -5)
|
||||
frame.hover:SetFrameStrata("BACKGROUND")
|
||||
|
||||
frame.hover:RegisterEvent("CVAR_UPDATE")
|
||||
frame.hover:SetScript("OnEvent", function()
|
||||
this.x = nil
|
||||
end)
|
||||
|
||||
frame.hover:SetScript("OnUpdate", function()
|
||||
-- reset frame positions to UIParent
|
||||
if not this.resetpos then
|
||||
this:SetMovable(1)
|
||||
this:StartMoving()
|
||||
this:StopMovingOrSizing()
|
||||
this:SetMovable(0)
|
||||
this.resetpos = true
|
||||
end
|
||||
|
||||
-- cache frame positions
|
||||
if not this.x then
|
||||
local _, _, _, fx, fy = this:GetPoint()
|
||||
fy = GetScreenHeight() + fy
|
||||
local fxmax = fx+this:GetWidth()
|
||||
local fymax = fy-this:GetHeight()
|
||||
|
||||
this.x = fx
|
||||
this.xmax = floor(fxmax)
|
||||
|
||||
this.y = fy
|
||||
this.ymax = floor(fymax)
|
||||
end
|
||||
|
||||
-- get cursor position
|
||||
local x, y = GetCursorPosition()
|
||||
x = x / UIParent:GetEffectiveScale()
|
||||
y = y / UIParent:GetEffectiveScale()
|
||||
|
||||
if not this.activeTo then this.activeTo = GetTime() + tonumber(pfUI_config.bars.hide_time) end
|
||||
if x > this.x and x < this.xmax and y < this.y and y > this.ymax then
|
||||
this.activeTo = GetTime() + tonumber(pfUI_config.bars.hide_time)
|
||||
this:GetParent():SetAlpha(1)
|
||||
else
|
||||
if this.activeTo < GetTime() and this:GetParent():GetAlpha() > 0 then
|
||||
this:GetParent():SetAlpha(this:GetParent():GetAlpha() - 0.1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- configure autohiding frames
|
||||
if pfUI_config.bars.hide_actionmain == "1" then
|
||||
pfEnableAutohide(pfUI.bars.actionmain)
|
||||
end
|
||||
|
||||
if pfUI_config.bars.hide_bottomleft == "1" then
|
||||
pfEnableAutohide(pfUI.bars.bottomleft)
|
||||
end
|
||||
|
||||
if pfUI_config.bars.hide_bottomright == "1" then
|
||||
pfEnableAutohide(pfUI.bars.bottomright)
|
||||
end
|
||||
|
||||
if pfUI_config.bars.hide_right == "1" then
|
||||
pfEnableAutohide(pfUI.bars.right)
|
||||
end
|
||||
|
||||
if pfUI_config.bars.hide_tworight == "1" then
|
||||
pfEnableAutohide(pfUI.bars.tworight)
|
||||
end
|
||||
|
||||
if pfUI_config.bars.hide_shapeshift == "1" then
|
||||
pfEnableAutohide(pfUI.bars.shapeshift)
|
||||
end
|
||||
|
||||
if pfUI_config.bars.hide_pet == "1" then
|
||||
pfEnableAutohide(pfUI.bars.pet)
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user