From cec4b5fb7d35a1ad6e7554a139eceeb667faf91d Mon Sep 17 00:00:00 2001 From: Vollmer Date: Tue, 10 Sep 2024 10:45:04 +0200 Subject: [PATCH] [Feature] Un-anchor frames when dragging them --- UnitFrames/EditMode.lua | 10 ++++++++++ Util/Utils.lua | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/UnitFrames/EditMode.lua b/UnitFrames/EditMode.lua index f551c6d..cd9defa 100644 --- a/UnitFrames/EditMode.lua +++ b/UnitFrames/EditMode.lua @@ -303,6 +303,16 @@ local function CreateOverlayBox(button, unit) CUF:Fire("UpdateLayout", nil, "position", const.UNIT.TARGET) end + if Util:ButtonIsAnchoredToParent(unit) then + CUF.DB.CurrentLayoutTable()[unit].anchorToParent = false + CUF:Fire("UpdateLayout", nil, "position", unit) + end + + if Util:ButtonIsMirrored(unit) then + CUF.DB.CurrentLayoutTable()[unit].mirrorPlayer = false + CUF:Fire("UpdateLayout", nil, "position", unit) + end + UpdatePositioningPopup() end) diff --git a/Util/Utils.lua b/Util/Utils.lua index b5cee9e..6914dfc 100644 --- a/Util/Utils.lua +++ b/Util/Utils.lua @@ -319,6 +319,16 @@ function Util:IsPropSameType(a, b) return type(a) == type(b) end +---@param unit Unit +function Util:ButtonIsAnchoredToParent(unit) + return DB.CurrentLayoutTable()[unit].anchorToParent +end + +---@param unit Unit +function Util:ButtonIsMirrored(unit) + return DB.CurrentLayoutTable()[unit].mirrorPlayer +end + ------------------------------------------------- -- MARK: Frames -------------------------------------------------