mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
update Microbar
This commit is contained in:
@@ -4,10 +4,11 @@ local AB = E:GetModule("ActionBars");
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local _G = _G
|
||||
local getn = table.getn
|
||||
local mod = math.mod
|
||||
local gsub, match = string.gsub, string.match
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
local UIFrameFadeIn = UIFrameFadeIn
|
||||
local UIFrameFadeOut = UIFrameFadeOut
|
||||
|
||||
local microBar = CreateFrame("Frame", "ElvUI_MicroBar", E.UIParent)
|
||||
microBar:SetFrameStrata("BACKGROUND")
|
||||
@@ -23,15 +24,15 @@ local MICRO_BUTTONS = {
|
||||
"HelpMicroButton"
|
||||
}
|
||||
|
||||
local function Button_OnEnter()
|
||||
local function onEnter()
|
||||
if AB.db.microbar.mouseover then
|
||||
UIFrameFadeIn(microBar, .2, microBar:GetAlpha(), AB.db.microbar.alpha)
|
||||
UIFrameFadeIn(ElvUI_MicroBar, 0.2, ElvUI_MicroBar:GetAlpha(), AB.db.microbar.alpha)
|
||||
end
|
||||
end
|
||||
|
||||
local function Button_OnLeave()
|
||||
local function onLeave()
|
||||
if AB.db.microbar.mouseover then
|
||||
UIFrameFadeOut(microBar, .2, microBar:GetAlpha(), 0)
|
||||
UIFrameFadeOut(ElvUI_MicroBar, 0.2, ElvUI_MicroBar:GetAlpha(), 0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,21 +41,19 @@ function AB:HandleMicroButton(button)
|
||||
local normal = button:GetNormalTexture()
|
||||
local disabled = button:GetDisabledTexture()
|
||||
|
||||
button:SetParent(microBar)
|
||||
button:Show()
|
||||
button:SetAlpha(self.db.microbar.alpha)
|
||||
|
||||
E:Kill(button:GetHighlightTexture())
|
||||
HookScript(button, "OnEnter", Button_OnEnter)
|
||||
HookScript(button, "OnLeave", Button_OnLeave)
|
||||
|
||||
local f = CreateFrame("Frame", nil, button)
|
||||
f:SetFrameLevel(1)
|
||||
E:Point(f, "BOTTOMLEFT", button, "BOTTOMLEFT", 2, 0)
|
||||
E:Point(f, "TOPRIGHT", button, "TOPRIGHT", -2, -28)
|
||||
f:SetFrameLevel(button:GetFrameLevel() - 2)
|
||||
E:SetTemplate(f, "Default", true)
|
||||
E:SetOutside(f, button)
|
||||
button.backdrop = f
|
||||
|
||||
button:SetParent(ElvUI_MicroBar)
|
||||
E:Kill(button:GetHighlightTexture())
|
||||
HookScript(button, "OnEnter", onEnter)
|
||||
HookScript(button, "OnLeave", onLeave)
|
||||
button:SetHitRectInsets(0, 0, 0, 0)
|
||||
button:Show()
|
||||
|
||||
pushed:SetTexCoord(0.17, 0.87, 0.5, 0.908)
|
||||
E:SetInside(pushed, f)
|
||||
|
||||
@@ -68,50 +67,65 @@ function AB:HandleMicroButton(button)
|
||||
end
|
||||
|
||||
function AB:UpdateMicroPositionDimensions()
|
||||
if not microBar then return end
|
||||
if not ElvUI_MicroBar then return end
|
||||
|
||||
local numRows = 1
|
||||
local button, prevButton, lastColumnButton
|
||||
for i = 1, getn(MICRO_BUTTONS) do
|
||||
button = _G[MICRO_BUTTONS[i]]
|
||||
prevButton = _G[MICRO_BUTTONS[i-1]] or microBar
|
||||
lastColumnButton = _G[MICRO_BUTTONS[i-self.db.microbar.buttonsPerRow]]
|
||||
local prevButton = ElvUI_MicroBar
|
||||
local offset = E:Scale(E.PixelMode and 1 or 3)
|
||||
local spacing = E:Scale(offset + self.db.microbar.buttonSpacing)
|
||||
|
||||
for i = 1, getn(MICRO_BUTTONS) do
|
||||
local button = _G[MICRO_BUTTONS[i]]
|
||||
local lastColumnButton = i - self.db.microbar.buttonsPerRow
|
||||
lastColumnButton = _G[MICRO_BUTTONS[lastColumnButton]]
|
||||
|
||||
E:Size(button, self.db.microbar.buttonSize, self.db.microbar.buttonSize * 1.4)
|
||||
button:ClearAllPoints()
|
||||
|
||||
if prevButton == microBar then
|
||||
E:Point(button, "TOPLEFT", prevButton, "TOPLEFT", -2 + E.Border, 28 - E.Border)
|
||||
if prevButton == ElvUI_MicroBar then
|
||||
E:Point(button, "TOPLEFT", prevButton, "TOPLEFT", offset, -offset)
|
||||
elseif mod((i - 1), self.db.microbar.buttonsPerRow) == 0 then
|
||||
E:Point(button, "TOP", lastColumnButton, "BOTTOM", 0, 28 - self.db.microbar.yOffset)
|
||||
E:Point(button, "TOP", lastColumnButton, "BOTTOM", 0, -spacing)
|
||||
numRows = numRows + 1
|
||||
else
|
||||
E:Point(button, "LEFT", prevButton, "RIGHT", - 4 + self.db.microbar.xOffset, 0)
|
||||
end
|
||||
E:Point(button, "LEFT", prevButton, "RIGHT", spacing, 0)
|
||||
end
|
||||
|
||||
if self.db.microbar.mouseover then
|
||||
microBar:SetAlpha(0)
|
||||
prevButton = button
|
||||
end
|
||||
|
||||
if AB.db.microbar.mouseover and not MouseIsOver(ElvUI_MicroBar) then
|
||||
ElvUI_MicroBar:SetAlpha(0)
|
||||
else
|
||||
microBar:SetAlpha(self.db.microbar.alpha)
|
||||
ElvUI_MicroBar:SetAlpha(self.db.microbar.alpha)
|
||||
end
|
||||
|
||||
E:Size(microBar, ((CharacterMicroButton:GetWidth() - 4) * self.db.microbar.buttonsPerRow) + (self.db.microbar.xOffset * (self.db.microbar.buttonsPerRow - 1)) + E.Border * 2, ((CharacterMicroButton:GetHeight() - 28) * numRows) + (self.db.microbar.yOffset * (numRows - 1)) + E.Border * 2)
|
||||
AB.MicroWidth = (((_G["CharacterMicroButton"]:GetWidth() + spacing) * self.db.microbar.buttonsPerRow) - spacing) + (offset * 2)
|
||||
AB.MicroHeight = (((_G["CharacterMicroButton"]:GetHeight() + spacing) * numRows) - spacing) + (offset * 2)
|
||||
E:Size(ElvUI_MicroBar, AB.MicroWidth, AB.MicroHeight)
|
||||
|
||||
-- local visibility = self.db.microbar.visibility
|
||||
-- if visibility and match(visibility, "[\n\r]") then
|
||||
-- visibility = gsub(visibility, "[\n\r]", "")
|
||||
-- end
|
||||
|
||||
|
||||
if ElvUI_MicroBar.mover then
|
||||
if self.db.microbar.enabled then
|
||||
microBar:Show()
|
||||
if microBar.mover then
|
||||
E:EnableMover(microBar.mover:GetName())
|
||||
end
|
||||
ElvUI_MicroBar:Show()
|
||||
E:EnableMover(ElvUI_MicroBar.mover:GetName())
|
||||
else
|
||||
microBar:Hide()
|
||||
if microBar.mover then
|
||||
E:DisableMover(microBar.mover:GetName())
|
||||
ElvUI_MicroBar:Hide()
|
||||
E:DisableMover(ElvUI_MicroBar.mover:GetName())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AB:SetupMicroBar()
|
||||
E:Point(microBar, "TOPLEFT", 4, -48)
|
||||
E:Point(ElvUI_MicroBar, "TOPLEFT", E.UIParent, "TOPLEFT", 4, -48)
|
||||
ElvUI_MicroBar:EnableMouse(true)
|
||||
ElvUI_MicroBar:SetScript("OnEnter", onEnter)
|
||||
ElvUI_MicroBar:SetScript("OnLeave", onLeave)
|
||||
|
||||
for i = 1, getn(MICRO_BUTTONS) do
|
||||
self:HandleMicroButton(_G[MICRO_BUTTONS[i]])
|
||||
@@ -121,5 +135,7 @@ function AB:SetupMicroBar()
|
||||
|
||||
self:UpdateMicroPositionDimensions()
|
||||
|
||||
E:CreateMover(microBar, "MicrobarMover", L["Micro Bar"], nil, nil, nil, "ALL,ACTIONBARS")
|
||||
E:Kill(MainMenuBarPerformanceBarFrame)
|
||||
|
||||
E:CreateMover(ElvUI_MicroBar, 'MicrobarMover', L["Micro Bar"], nil, nil, nil, "ALL,ACTIONBARS", nil, "actionbar,microbar")
|
||||
end
|
||||
Reference in New Issue
Block a user