Add WorldFrame and UIParent to the list of frames to snap to and tweak sticky code
This commit is contained in:
@@ -25,12 +25,7 @@ local defaults = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local Sticky = LibStub("LibSimpleSticky-1.0")
|
local Sticky = LibStub("LibSimpleSticky-1.0")
|
||||||
|
local snapBars = { WorldFrame, UIParent }
|
||||||
local barregistry = {}
|
|
||||||
Bartender4.Bar = {}
|
|
||||||
Bartender4.Bar.defaults = defaults
|
|
||||||
Bartender4.Bar.prototype = Bar
|
|
||||||
Bartender4.Bar.barregistry = barregistry
|
|
||||||
|
|
||||||
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop, barOnClick, barOnUpdateFunc
|
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop, barOnClick, barOnUpdateFunc
|
||||||
do
|
do
|
||||||
@@ -45,7 +40,7 @@ do
|
|||||||
function barOnDragStart(self)
|
function barOnDragStart(self)
|
||||||
local parent = self:GetParent()
|
local parent = self:GetParent()
|
||||||
local offset = 8 - (parent.config.padding or 0)
|
local offset = 8 - (parent.config.padding or 0)
|
||||||
Sticky:StartMoving(parent, barregistry, offset, offset, offset, offset)
|
Sticky:StartMoving(parent, snapBars, offset, offset, offset, offset)
|
||||||
self:SetBackdropBorderColor(0, 0, 0, 0)
|
self:SetBackdropBorderColor(0, 0, 0, 0)
|
||||||
parent.isMoving = true
|
parent.isMoving = true
|
||||||
end
|
end
|
||||||
@@ -73,12 +68,19 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local barregistry = {}
|
||||||
|
Bartender4.Bar = {}
|
||||||
|
Bartender4.Bar.defaults = defaults
|
||||||
|
Bartender4.Bar.prototype = Bar
|
||||||
|
Bartender4.Bar.barregistry = barregistry
|
||||||
function Bartender4.Bar:Create(id, config, name)
|
function Bartender4.Bar:Create(id, config, name)
|
||||||
id = tostring(id)
|
id = tostring(id)
|
||||||
assert(not barregistry[id], "duplicated entry in barregistry.")
|
assert(not barregistry[id], "duplicated entry in barregistry.")
|
||||||
|
|
||||||
local bar = setmetatable(CreateFrame("Frame", ("BT4Bar%s"):format(id), UIParent, "SecureHandlerStateTemplate"), Bar_MT)
|
local bar = setmetatable(CreateFrame("Frame", ("BT4Bar%s"):format(id), UIParent, "SecureHandlerStateTemplate"), Bar_MT)
|
||||||
barregistry[id] = bar
|
barregistry[id] = bar
|
||||||
|
table_insert(snapBars, bar)
|
||||||
|
|
||||||
bar.id = id
|
bar.id = id
|
||||||
bar.name = name or id
|
bar.name = name or id
|
||||||
bar:SetMovable(true)
|
bar:SetMovable(true)
|
||||||
|
|||||||
@@ -134,7 +134,8 @@ function StickyFrames:GetUpdateFunc(frame, frameList, xoffset, yoffset, left, to
|
|||||||
frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", x+xoffset, y+yoffset)
|
frame:SetPoint("CENTER", UIParent, "BOTTOMLEFT", x+xoffset, y+yoffset)
|
||||||
|
|
||||||
StickyFrames.sticky[frame] = nil
|
StickyFrames.sticky[frame] = nil
|
||||||
for k,v in pairs(frameList) do
|
for i = 1, #frameList do
|
||||||
|
local v = frameList[i]
|
||||||
if frame ~= v and not IsShiftKeyDown() and v:IsVisible() then
|
if frame ~= v and not IsShiftKeyDown() and v:IsVisible() then
|
||||||
if self:SnapFrame(frame, v, left, top, right, bottom) then
|
if self:SnapFrame(frame, v, left, top, right, bottom) then
|
||||||
StickyFrames.sticky[frame] = v
|
StickyFrames.sticky[frame] = v
|
||||||
|
|||||||
Reference in New Issue
Block a user