move modules with mouse

This commit is contained in:
Sumsebrum 2021-09-24 15:51:24 +02:00
parent 1010d59bd3
commit 3f28947b05
7 changed files with 82 additions and 0 deletions

View File

@ -6,6 +6,7 @@ local pairs = pairs
local tinsert = table.insert local tinsert = table.insert
local tsort = table.sort local tsort = table.sort
local str_lower = string.lower local str_lower = string.lower
local math_abs = math.abs
local GetTime = GetTime local GetTime = GetTime
local CreateFrame = CreateFrame local CreateFrame = CreateFrame
local DEFAULT_CHAT_FRAME = DEFAULT_CHAT_FRAME local DEFAULT_CHAT_FRAME = DEFAULT_CHAT_FRAME
@ -172,6 +173,56 @@ function Gladdy:NewModule(name, priority, defaults)
return module return module
end end
function Gladdy:CreateMover(frame, x, y, name, points)
if not frame.mover then
frame.mover = CreateFrame("Frame", nil, frame, BackdropTemplateMixin and "BackdropTemplate")
frame.mover:SetFrameStrata("TOOLTIP")
frame.mover:SetPoint(points[1], frame, points[2], 0, 0)
local backdrop = {
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "",
tile = true, tileSize = 16, edgeSize = 10,
insets = {left = 0, right = 0, top = 0, bottom = 0}
}
frame.mover:SetBackdrop(backdrop)
frame.mover:SetBackdropColor(0,0,0,0.8)
frame.mover:SetHeight(15)
frame.mover:SetWidth(60)
frame.mover.text = frame.mover:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
frame.mover.text:SetText(name)
frame.mover.text:SetPoint("CENTER")
frame.mover:SetMovable(true)
frame.mover:EnableMouse(true)
frame.mover:SetScript("OnMouseDown", function(self)
self.point = { frame:GetPoint() }
self.start = { frame:GetCenter() }
frame:StartMoving()
self:StartMoving()
end)
frame.mover:SetScript("OnMouseUp", function(self)
frame:StopMovingOrSizing()
self:StopMovingOrSizing()
self.stop = { frame:GetCenter() }
local diffX = math_abs(self.start[1] - self.stop[1])
diffX = self.start[1] > self.stop[1] and -diffX or diffX
local diffY = math_abs(self.start[2] - self.stop[2])
diffY = self.start[2] > self.stop[2] and -diffY or diffY
frame:ClearAllPoints()
frame:SetPoint(self.point[1], self.point[2], self.point[3], self.point[4] + diffX, self.point[5] + diffY)
Gladdy.db[x] = self.point[4] + diffX
Gladdy.db[y] = self.point[5] + diffY
Gladdy:UpdateFrame()
end)
else
frame.mover:ClearAllPoints()
frame.mover:SetPoint(points[1], frame, points[2], 0, 0)
end
end
--------------------------- ---------------------------
-- INIT -- INIT

View File

@ -235,11 +235,13 @@ end
function BuffsDebuffs:CreateFrame(unit) function BuffsDebuffs:CreateFrame(unit)
local verticalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding local verticalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
local debuffFrame = CreateFrame("Frame", "GladdyDebuffs" .. unit, Gladdy.buttons[unit]) local debuffFrame = CreateFrame("Frame", "GladdyDebuffs" .. unit, Gladdy.buttons[unit])
debuffFrame:SetMovable(true)
debuffFrame:SetHeight(Gladdy.db.buffsIconSize) debuffFrame:SetHeight(Gladdy.db.buffsIconSize)
debuffFrame:SetWidth(1) debuffFrame:SetWidth(1)
debuffFrame:SetPoint("BOTTOMLEFT", Gladdy.buttons[unit].healthBar, "TOPLEFT", 0, verticalMargin) debuffFrame:SetPoint("BOTTOMLEFT", Gladdy.buttons[unit].healthBar, "TOPLEFT", 0, verticalMargin)
debuffFrame.unit = unit debuffFrame.unit = unit
local buffFrame = CreateFrame("Frame", "GladdyBuffs" .. unit, Gladdy.buttons[unit]) local buffFrame = CreateFrame("Frame", "GladdyBuffs" .. unit, Gladdy.buttons[unit])
buffFrame:SetMovable(true)
buffFrame:SetHeight(Gladdy.db.buffsIconSize) buffFrame:SetHeight(Gladdy.db.buffsIconSize)
buffFrame:SetWidth(1) buffFrame:SetWidth(1)
buffFrame:SetPoint("BOTTOMLEFT", Gladdy.buttons[unit].healthBar, "TOPLEFT", 0, verticalMargin) buffFrame:SetPoint("BOTTOMLEFT", Gladdy.buttons[unit].healthBar, "TOPLEFT", 0, verticalMargin)
@ -328,6 +330,9 @@ function BuffsDebuffs:UpdateFrame(unit)
self.frames[unit].debuffFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset) self.frames[unit].debuffFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset)
end end
end end
if (unit == "arena1") then
Gladdy:CreateMover(self.frames[unit].debuffFrame, "buffsXOffset", "buffsYOffset", L["Debuffs"], {"BOTTOMLEFT", "TOPLEFT"})
end
--BUFFS --BUFFS
self.frames[unit].buffFrame:SetHeight(Gladdy.db.buffsBuffsIconSize) self.frames[unit].buffFrame:SetHeight(Gladdy.db.buffsBuffsIconSize)
@ -422,6 +427,10 @@ function BuffsDebuffs:UpdateFrame(unit)
self.frames[unit].buffFrame:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset) self.frames[unit].buffFrame:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset)
end end
end end
if (unit == "arena1") then
Gladdy:CreateMover(self.frames[unit].buffFrame, "buffsBuffsXOffset", "buffsBuffsYOffset", L["Buffs"], {"BOTTOMLEFT", "TOPLEFT"})
end
for i=1, #self.frames[unit].auras[AURA_TYPE_BUFF] do for i=1, #self.frames[unit].auras[AURA_TYPE_BUFF] do
styleIcon(self.frames[unit].auras[AURA_TYPE_BUFF][i], AURA_TYPE_BUFF) styleIcon(self.frames[unit].auras[AURA_TYPE_BUFF][i], AURA_TYPE_BUFF)
end end

View File

@ -59,6 +59,7 @@ end
function Castbar:CreateFrame(unit) function Castbar:CreateFrame(unit)
local castBar = CreateFrame("Frame", nil, Gladdy.buttons[unit], BackdropTemplateMixin and "BackdropTemplate") local castBar = CreateFrame("Frame", nil, Gladdy.buttons[unit], BackdropTemplateMixin and "BackdropTemplate")
castBar:EnableMouse(false) castBar:EnableMouse(false)
castBar:SetMovable(true)
castBar.unit = unit castBar.unit = unit
castBar:SetBackdrop({ edgeFile = Gladdy:SMFetch("border", "castBarBorderStyle"), castBar:SetBackdrop({ edgeFile = Gladdy:SMFetch("border", "castBarBorderStyle"),
@ -191,6 +192,10 @@ function Castbar:UpdateFrame(unit)
castBar.icon.texture.overlay:SetTexture(Gladdy.db.castBarIconStyle) castBar.icon.texture.overlay:SetTexture(Gladdy.db.castBarIconStyle)
castBar.icon.texture.overlay:SetVertexColor(Gladdy.db.castBarIconColor.r, Gladdy.db.castBarIconColor.g, Gladdy.db.castBarIconColor.b, Gladdy.db.castBarIconColor.a) castBar.icon.texture.overlay:SetVertexColor(Gladdy.db.castBarIconColor.r, Gladdy.db.castBarIconColor.g, Gladdy.db.castBarIconColor.b, Gladdy.db.castBarIconColor.a)
if (unit == "arena1") then
Gladdy:CreateMover(castBar, "castBarXOffset", "castBarYOffset", L["Cast Bar"], {"BOTTOMLEFT", "TOPLEFT"})
end
end end
--------------------------- ---------------------------

View File

@ -38,6 +38,7 @@ function CombatIndicator:CreateFrame(unit)
end end
local ciFrame = CreateFrame("Frame", "GladdyCombatindicator" .. unit, button) local ciFrame = CreateFrame("Frame", "GladdyCombatindicator" .. unit, button)
ciFrame:EnableMouse(false) ciFrame:EnableMouse(false)
ciFrame:SetMovable(true)
ciFrame:SetFrameStrata("HIGH") ciFrame:SetFrameStrata("HIGH")
ciFrame:SetHeight(Gladdy.db.ciSize) ciFrame:SetHeight(Gladdy.db.ciSize)
ciFrame:SetWidth(Gladdy.db.ciSize * Gladdy.db.ciWidthFactor) ciFrame:SetWidth(Gladdy.db.ciSize * Gladdy.db.ciWidthFactor)
@ -77,6 +78,9 @@ function CombatIndicator:UpdateFrame(unit)
else else
ciFrame:Show() ciFrame:Show()
end end
if (unit == "arena1") then
Gladdy:CreateMover(ciFrame, "ciXOffset", "ciYOffset", L["Combat Indicator"], {"BOTTOMLEFT", "TOPLEFT"})
end
end end
function CombatIndicator:Test() function CombatIndicator:Test()

View File

@ -94,6 +94,7 @@ function Cooldowns:CreateFrame(unit)
-- Cooldown frame -- Cooldown frame
local spellCooldownFrame = CreateFrame("Frame", nil, button) local spellCooldownFrame = CreateFrame("Frame", nil, button)
spellCooldownFrame:EnableMouse(false) spellCooldownFrame:EnableMouse(false)
spellCooldownFrame:SetMovable(true)
for x = 1, 14 do for x = 1, 14 do
local icon = CreateFrame("Frame", nil, spellCooldownFrame) local icon = CreateFrame("Frame", nil, spellCooldownFrame)
icon:EnableMouse(false) icon:EnableMouse(false)
@ -166,6 +167,9 @@ function Cooldowns:UpdateFrame(unit)
button.spellCooldownFrame:SetHeight(Gladdy.db.cooldownSize) button.spellCooldownFrame:SetHeight(Gladdy.db.cooldownSize)
button.spellCooldownFrame:SetWidth(1) button.spellCooldownFrame:SetWidth(1)
button.spellCooldownFrame:Show() button.spellCooldownFrame:Show()
if (unit == "arena1") then
Gladdy:CreateMover(button.spellCooldownFrame, "cooldownXOffset", "cooldownYOffset", L["Cooldown"], {"BOTTOMLEFT", "TOPLEFT"})
end
-- Update each cooldown icon -- Update each cooldown icon
local o = 1 local o = 1
for j = 1, 14 do for j = 1, 14 do

View File

@ -67,6 +67,7 @@ end
function Diminishings:CreateFrame(unit) function Diminishings:CreateFrame(unit)
local drFrame = CreateFrame("Frame", nil, Gladdy.buttons[unit]) local drFrame = CreateFrame("Frame", nil, Gladdy.buttons[unit])
drFrame:EnableMouse(false) drFrame:EnableMouse(false)
drFrame:SetMovable(true)
for i = 1, 16 do for i = 1, 16 do
local icon = CreateFrame("Frame", "GladdyDr" .. unit .. "Icon" .. i, drFrame) local icon = CreateFrame("Frame", "GladdyDr" .. unit .. "Icon" .. i, drFrame)
@ -177,6 +178,10 @@ function Diminishings:UpdateFrame(unit)
drFrame:SetWidth(Gladdy.db.drIconSize * 16) drFrame:SetWidth(Gladdy.db.drIconSize * 16)
drFrame:SetHeight(Gladdy.db.drIconSize) drFrame:SetHeight(Gladdy.db.drIconSize)
if (unit == "arena1") then
Gladdy:CreateMover(drFrame, "drXOffset", "drYOffset", L["Diminishings"],
Gladdy.db.drCooldownPos == "RIGHT" and {"BOTTOMLEFT", "TOPLEFT"} or {"BOTTOMRIGHT", "TOPRIGHT"})
end
for i = 1, 16 do for i = 1, 16 do
local icon = drFrame["icon" .. i] local icon = drFrame["icon" .. i]

View File

@ -134,6 +134,7 @@ function Pets:CreateFrame(unitId)
return return
end end
local button = CreateFrame("Frame", "GladdyButtonFramePet" .. unit, Gladdy.frame) local button = CreateFrame("Frame", "GladdyButtonFramePet" .. unit, Gladdy.frame)
button:SetMovable(true)
--button:SetAlpha(0) --button:SetAlpha(0)
button:SetPoint("LEFT", Gladdy.buttons[unitId].healthBar, "RIGHT", Gladdy.db.petXOffset, Gladdy.db.petYOffset) button:SetPoint("LEFT", Gladdy.buttons[unitId].healthBar, "RIGHT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
@ -289,6 +290,9 @@ function Pets:UpdateFrame(unitId)
end end
healthBar.nameText:SetTextColor(Gladdy.db.petHealthBarFontColor.r, Gladdy.db.petHealthBarFontColor.g, Gladdy.db.petHealthBarFontColor.b, Gladdy.db.petHealthBarFontColor.a) healthBar.nameText:SetTextColor(Gladdy.db.petHealthBarFontColor.r, Gladdy.db.petHealthBarFontColor.g, Gladdy.db.petHealthBarFontColor.b, Gladdy.db.petHealthBarFontColor.a)
healthBar.healthText:SetTextColor(Gladdy.db.petHealthBarFontColor.r, Gladdy.db.petHealthBarFontColor.g, Gladdy.db.petHealthBarFontColor.b, Gladdy.db.petHealthBarFontColor.a) healthBar.healthText:SetTextColor(Gladdy.db.petHealthBarFontColor.r, Gladdy.db.petHealthBarFontColor.g, Gladdy.db.petHealthBarFontColor.b, Gladdy.db.petHealthBarFontColor.a)
if (unit == "arenapet1") then
Gladdy:CreateMover(self.frames[unit], "petXOffset", "petYOffset", L["Pets"], {"BOTTOMLEFT", "TOPLEFT"})
end
end end
function Pets:SetHealthText(healthBar, health, healthMax) function Pets:SetHealthText(healthBar, health, healthMax)