From d5cc370e9d6c45a1e4b15f0564389d282193ed41 Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 18 Apr 2020 12:46:14 +0200 Subject: [PATCH] api: move AlignToPosition into global api --- api/api.lua | 28 ++++++++++++++++++++++++++++ modules/xpbar.lua | 22 ---------------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/api/api.lua b/api/api.lua index 6f2a59f5..ded7aae2 100644 --- a/api/api.lua +++ b/api/api.lua @@ -625,6 +625,34 @@ function pfUI.api.RemoveMovable(frame) pfUI.movables[name] = nil end +-- [ AlignToPosition ] +-- Sets a movable frame to the selected anchor +-- 'frame' [frame] the frame that should be aligned +-- 'anchor' [frame] the frame where it should be aligned to +-- 'position' [string] where it should appear, takes the following: +-- "TOP", "RIGHT", "BOTTOM", "LEFT" +function pfUI.api.AlignToPosition(frame, anchor, position) + local pixel = GetPerfectPixel() + frame:ClearAllPoints() + if position == "TOP" and anchor then + frame:SetPoint("BOTTOMLEFT", anchor, "TOPLEFT", 0, default_border*3) + frame:SetPoint("BOTTOMRIGHT", anchor, "TOPRIGHT", 0, default_border*3) + elseif position == "RIGHT" and anchor then + frame:SetPoint("TOPLEFT", anchor, "TOPRIGHT", default_border*3, 0) + frame:SetPoint("BOTTOMLEFT", anchor, "BOTTOMRIGHT", default_border*3, 0) + elseif position == "BOTTOM" and anchor then + frame:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, -default_border*3) + frame:SetPoint("TOPRIGHT", anchor, "BOTTOMRIGHT", 0, -default_border*3) + elseif position == "LEFT" and anchor then + frame:SetPoint("TOPRIGHT", anchor, "TOPLEFT", -default_border*3, 0) + frame:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMLEFT", -default_border*3, 0) + else + frame:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0) + frame:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0) + end + UpdateMovable(frame, true) +end + -- [ SetAutoPoint ] -- Automatically places the frame according to screen position of the parent. -- 'frame' [frame] the frame that should be moved. diff --git a/modules/xpbar.lua b/modules/xpbar.lua index 0aa78445..1498ce5a 100644 --- a/modules/xpbar.lua +++ b/modules/xpbar.lua @@ -2,28 +2,6 @@ pfUI:RegisterModule("xpbar", "vanilla:tbc", function () local rawborder, default_border = GetBorderSize() local parse_faction = SanitizePattern(FACTION_STANDING_INCREASED) - local function AlignToPosition(frame, anchor, position) - local pixel = GetPerfectPixel() - frame:ClearAllPoints() - if position == "TOP" and anchor then - frame:SetPoint("BOTTOMLEFT", anchor, "TOPLEFT", 0, default_border*3) - frame:SetPoint("BOTTOMRIGHT", anchor, "TOPRIGHT", 0, default_border*3) - elseif position == "RIGHT" and anchor then - frame:SetPoint("TOPLEFT", anchor, "TOPRIGHT", default_border*3, 0) - frame:SetPoint("BOTTOMLEFT", anchor, "BOTTOMRIGHT", default_border*3, 0) - elseif position == "BOTTOM" and anchor then - frame:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, -default_border*3) - frame:SetPoint("TOPRIGHT", anchor, "BOTTOMRIGHT", 0, -default_border*3) - elseif position == "LEFT" and anchor then - frame:SetPoint("TOPRIGHT", anchor, "TOPLEFT", -default_border*3, 0) - frame:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMLEFT", -default_border*3, 0) - else - frame:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0) - frame:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0) - end - UpdateMovable(frame, true) - end - local function CreateBar(t) local xp_timeout = tonumber(C.panel.xp.xp_timeout) local xp_width = C.panel.xp.xp_width