First work on LibWindow-1.1 usage, plumbing for new bar resizing/button positioning

This commit is contained in:
Hendrik Leppkes
2009-01-20 15:33:02 +01:00
parent 2ed2263968
commit acc67ba2a0
7 changed files with 46 additions and 22 deletions
+1
View File
@@ -13,3 +13,4 @@ externals:
libs/AceConfig-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConfig-3.0
libs/LibKeyBound-1.0: svn://svn.wowace.com/wow/libkeybound-1-0/mainline/trunk/LibKeyBound-1.0
libs/LibDBIcon-1.0: svn://svn.wowace.com/wow/libdbicon-1-0/mainline/trunk/LibDBIcon-1.0
libs/LibWindow-1.1: svn://svn.wowace.com/wow/libwindow-1-1/mainline/trunk/LibWindow-1.1
+35 -18
View File
@@ -11,7 +11,6 @@ local table_concat, table_insert = table.concat, table.insert
===================================================================================]]--
local defaults = {
scale = 1,
alpha = 1,
fadeout = false,
fadeoutalpha = 0.1,
@@ -20,10 +19,14 @@ local defaults = {
possess = true,
stance = {},
},
position = {
scale = 1,
},
clickthrough = false,
}
local Sticky = LibStub("LibSimpleSticky-1.0")
local LibWin = LibStub("LibWindow-1.1")
local snapBars = { WorldFrame, UIParent }
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop, barOnClick, barOnUpdateFunc, barOnAttributeChanged
@@ -170,7 +173,11 @@ function Bar:ApplyConfig(config)
if config then
self.config = config
end
LibWin.RegisterConfig(self, self.config.position)
self:UpgradeConfig()
if self.disabled then return end
if Bartender4.Locked then
self:Lock()
else
@@ -183,6 +190,29 @@ function Bar:ApplyConfig(config)
self:InitVisibilityDriver()
end
function Bar:UpgradeConfig()
local version = self.config.version or 1
if version < 2 then
-- LibWindow migration, move scale into position
if self.config.scale then
self.config.position.scale = self.config.scale
self.config.scale = nil
end
-- LibWindow migration, update position data
do
local pos = self.config.position
self:SetScale(pos.scale)
local x, y, s = pos.x, pos.y, self:GetEffectiveScale()
local point, relPoint = pos.point, pos.relPoint
x, y = x/s, y/s
self:ClearSetPoint(point, UIParent, relPoint, x, y)
LibWin.SavePosition(self)
pos.relPoint = nil
end
end
self.config.version = Bartender4.CONFIG_VERSION
end
function Bar:Unlock()
if self.disabled or self.unlocked then return end
self.unlocked = true
@@ -206,22 +236,11 @@ function Bar:StopDragging()
end
function Bar:LoadPosition()
if not self.config.position then return end
local pos = self.config.position
local x, y, s = pos.x, pos.y, self:GetEffectiveScale()
local point, relPoint = pos.point, pos.relPoint
x, y = x/s, y/s
self:ClearSetPoint(point, UIParent, relPoint, x, y)
LibWin.RestorePosition(self)
end
function Bar:SavePosition()
if not self.config.position then self.config.position = {} end
local pos = self.config.position
local point, parent, relPoint, x, y = self:GetPoint()
local s = self:GetEffectiveScale()
x, y = x*s, y*s
pos.x, pos.y = x, y
pos.point, pos.relPoint = point, relPoint
LibWin.SavePosition(self)
end
function Bar:SetSize(width, height)
@@ -243,15 +262,13 @@ function Bar:SetConfigAlpha(alpha)
end
function Bar:GetConfigScale()
return self.config.scale
return self.config.position.scale
end
function Bar:SetConfigScale(scale)
if scale then
self.config.scale = scale
LibWin.SetScale(self, scale)
end
self:SetScale(self.config.scale)
self:LoadPosition()
end
function Bar:GetClickThrough()
+2
View File
@@ -20,6 +20,8 @@ local defaults = {
}
}
Bartender4.CONFIG_VERSION = 2
function Bartender4:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("Bartender4DB", defaults)
self.db.RegisterCallback(self, "OnProfileChanged", "UpdateModuleConfigs")
+2 -1
View File
@@ -5,7 +5,7 @@
## Author: Nevcairiel
## X-Email: h.leppkes AT gmail DOT com
## SavedVariables: Bartender4DB
## OptionalDeps: Ace3, ButtonFacade, LibKeyBound-1.0, LibDBIcon-1.0
## OptionalDeps: Ace3, ButtonFacade, LibKeyBound-1.0, LibDBIcon-1.0, LibWindow-1.1
## X-Category: Action Bars
## Version: 4.2.6
@@ -29,6 +29,7 @@ libs\AceConfig-3.0\AceConfig-3.0.xml
libs\LibKeyBound-1.0\lib.xml
libs\LibDBIcon-1.0\LibDBIcon-1.0.lua
libs\LibWindow-1.1\LibWindow-1.1.lua
#@end-no-lib-strip@
libs\SimpleSticky.lua
+3 -1
View File
@@ -17,7 +17,9 @@ local defaults = { profile = Bartender4:Merge({
possess = false,
},
padding = -3,
scale = 0.8,
position = {
scale = 0.8,
},
}, Bartender4.ButtonBar.defaults) }
function MicroMenuMod:OnInitialize()
-1
View File
@@ -11,7 +11,6 @@ local PetBar = setmetatable({}, {__index = ButtonBar})
local defaults = { profile = Bartender4:Merge({
enabled = true,
scale = 1.0,
hidehotkey = true,
visibility = {
nopet = true,
+3 -1
View File
@@ -17,7 +17,9 @@ local KeyBound = LibStub("LibKeyBound-1.0")
local defaults = { profile = Bartender4:Merge({
enabled = true,
scale = 1.5,
position = {
scale = 1.5,
},
hidehotkey = true,
}, Bartender4.ButtonBar.defaults) }