From bbdf0b06f8f7529a5438f541f7d25cd4e947d4ff Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Wed, 15 Oct 2008 14:37:01 +0200 Subject: [PATCH] Added small popup in unlock mode that allows you to disable snapping and lock the bars again without opening the config --- Bar.lua | 22 +++++++++--- Bartender4.lua | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 5 deletions(-) diff --git a/Bar.lua b/Bar.lua index 0ec6097..205411c 100644 --- a/Bar.lua +++ b/Bar.lua @@ -37,8 +37,12 @@ do function barOnDragStart(self) local parent = self:GetParent() - local offset = 8 - (parent.config.padding or 0) - Sticky:StartMoving(parent, snapBars, offset, offset, offset, offset) + if Bartender4.db.profile.snapping then + local offset = 8 - (parent.config.padding or 0) + Sticky:StartMoving(parent, snapBars, offset, offset, offset, offset) + else + parent:StartMoving() + end self:SetBackdropBorderColor(0, 0, 0, 0) parent.isMoving = true end @@ -46,8 +50,12 @@ do function barOnDragStop(self) local parent = self:GetParent() if parent.isMoving then - local sticky, stickTo = Sticky:StopMoving(parent) - --Bartender4:Print(sticky, stickTo and stickTo:GetName() or nil) + if Bartender4.db.profile.snapping then + local sticky, stickTo = Sticky:StopMoving(parent) + --Bartender4:Print(sticky, stickTo and stickTo:GetName() or nil) + else + parent:StopMovingOrSizing() + end parent:SavePosition() end end @@ -182,13 +190,17 @@ end function Bar:Lock() if self.disabled or not self.unlocked then return end self.unlocked = nil - barOnDragStop(self.overlay) + self:StopDragging() self:ApplyVisibilityDriver() self.overlay:Hide() end +function Bar:StopDragging() + barOnDragStop(self.overlay) +end + function Bar:LoadPosition() if not self.config.position then return end local pos = self.config.position diff --git a/Bartender4.lua b/Bartender4.lua index 2094967..67fd895 100644 --- a/Bartender4.lua +++ b/Bartender4.lua @@ -11,6 +11,7 @@ local defaults = { colors = { range = { r = 0.8, g = 0.1, b = 0.1 }, mana = { r = 0.5, g = 0.5, b = 1.0 } }, selfcastmodifier = true, selfcastrightclick = false, + snapping = true, } } @@ -71,10 +72,101 @@ function Bartender4:ToggleLock() end end +local getSnap, setSnap +do + function getSnap() + return Bartender4.db.profile.snapping + end + + function setSnap(value) + Bartender4.Bar:ForAll("StopDragging") + Bartender4.db.profile.snapping = value + LibStub("AceConfigRegistry-3.0"):NotifyChange("Bartender4") + end +end + +function Bartender4:ShowUnlockDialog() + if not self.unlock_dialog then + local f = CreateFrame('Frame', 'Bartender4Dialog', UIParent) + f:SetFrameStrata('DIALOG') + f:SetToplevel(true) + f:EnableMouse(true) + f:SetClampedToScreen(true) + f:SetWidth(360) + f:SetHeight(110) + f:SetBackdrop{ + bgFile='Interface\\DialogFrame\\UI-DialogBox-Background' , + edgeFile='Interface\\DialogFrame\\UI-DialogBox-Border', + tile = true, + insets = {left = 11, right = 12, top = 12, bottom = 11}, + tileSize = 32, + edgeSize = 32, + } + f:SetPoint('TOP', 0, -50) + f:Hide() + f:SetScript('OnShow', function() PlaySound('igMainMenuOption') end) + f:SetScript('OnHide', function() PlaySound('gsTitleOptionExit') end) + + local tr = f:CreateTitleRegion() + tr:SetAllPoints(f) + + local header = f:CreateTexture(nil, 'ARTWORK') + header:SetTexture('Interface\\DialogFrame\\UI-DialogBox-Header') + header:SetWidth(256); header:SetHeight(64) + header:SetPoint('TOP', 0, 12) + + local title = f:CreateFontString('ARTWORK') + title:SetFontObject('GameFontNormal') + title:SetPoint('TOP', header, 'TOP', 0, -14) + title:SetText(L["Bartender4"]) + + local desc = f:CreateFontString('ARTWORK') + desc:SetFontObject('GameFontHighlight') + desc:SetJustifyV('TOP') + desc:SetJustifyH('LEFT') + desc:SetPoint('TOPLEFT', 18, -32) + desc:SetPoint('BOTTOMRIGHT', -18, 48) + desc:SetText(L["Bars unlocked. Move them now and click Lock when you are done."]) + + local snapping = CreateFrame('CheckButton', 'Bartender4Snapping', f, 'OptionsCheckButtonTemplate') + _G[snapping:GetName() .. 'Text']:SetText(L["Bar Snapping"]) + + snapping:SetScript('OnShow', function(self) + self:SetChecked(getSnap()) + end) + + snapping:SetScript('OnClick', function(self) + setSnap(snapping:GetChecked()) + end) + + local lockBars = CreateFrame('CheckButton', 'Bartender4DialogLock', f, 'OptionsButtonTemplate') + getglobal(lockBars:GetName() .. 'Text'):SetText(L["Lock"]) + + lockBars:SetScript('OnClick', function(self) + Bartender4:Lock() + LibStub("AceConfigRegistry-3.0"):NotifyChange("Bartender4") + end) + + --position buttons + snapping:SetPoint('BOTTOMLEFT', 14, 10) + lockBars:SetPoint('BOTTOMRIGHT', -14, 14) + + self.unlock_dialog = f + end + self.unlock_dialog:Show() +end + +function Bartender4:HideUnlockDialog() + if self.unlock_dialog then + self.unlock_dialog:Hide() + end +end + function Bartender4:Unlock() if self.Locked then self.Locked = false Bartender4.Bar:ForAll("Unlock") + self:ShowUnlockDialog() end end @@ -82,6 +174,7 @@ function Bartender4:Lock() if not self.Locked then self.Locked = true Bartender4.Bar:ForAll("Lock") + self:HideUnlockDialog() end end