apply more duct tape

This commit is contained in:
Hendrik Leppkes
2007-11-30 14:15:53 +00:00
parent a4526dc438
commit cfa080b1cf
3 changed files with 61 additions and 16 deletions
+27 -11
View File
@@ -4,7 +4,7 @@
--[[ $Id$ ]]
local Bar = CreateFrame("Frame")
local Bar = CreateFrame("Button")
local Bar_MT = {__index = Bar}
local function createOptions(id)
@@ -12,8 +12,9 @@ local function createOptions(id)
end
Bartender4.Bar = {}
function Bartender4.Bar:Create(id, template)
local bar = setmetatable(CreateFrame("Frame", ("BT4Bar%s"):format(id), UIParent, template), Bar_MT)
Bartender4.Bar.prototype = Bar
function Bartender4.Bar:Create(id, template, config)
local bar = setmetatable(CreateFrame("Button", ("BT4Bar%s"):format(id), UIParent, template), Bar_MT)
bar:EnableMouse(false)
bar:SetMovable(true)
@@ -29,19 +30,20 @@ function Bartender4.Bar:Create(id, template)
})
bar:SetBackdropColor(0, 0, 0, 0)
bar:SetBackdropBorderColor(0.5, 0.5, 0, 0)
bar.Text = frame:CreateFontString(nil, "ARTWORK")
bar.Text = bar:CreateFontString(nil, "ARTWORK")
bar.Text:SetFontObject(GameFontNormal)
bar.Text:SetText("Bar "..id)
bar.Text:Hide()
bar.Text:ClearAllPoints()
bar.Text:SetPoint("CENTER", bar, "CENTER")
bar.config = config
bar.options = createOptions(id)
return bar
end
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop
local barOnEnter, barOnLeave, barOnDragStart, barOnDragStop, barOnClick
do
function barOnEnter(self)
self:SetBackdropBorderColor(0.5, 0.5, 0, 1)
@@ -54,11 +56,19 @@ do
function barOnDragStart(self)
self:StartMoving()
self:SetBackdropBorderColor(0, 0, 0, 0)
self.isMoving = true
end
function barOnDragStop(self)
self:StopMovingOrSizing()
self:SavePosition()
if self.isMoving then
self:StopMovingOrSizing()
self:SavePosition()
end
end
function barOnClick(self)
-- TODO: Hide/Show bar on Click
-- TODO: Once dropdown config is stable, show dropdown on rightclick
end
end
@@ -68,7 +78,7 @@ function Bar:Unlock()
self:SetScript("OnLeave", barOnLeave)
self:SetScript("OnDragStart", barOnDragStart)
self:SetScript("OnDragStop", barOnDragStop)
self:SetScript("OnClick", nil)
self:SetScript("OnClick", barOnClick)
self.Text:Show()
self:SetFrameLevel(5)
@@ -80,6 +90,7 @@ function Bar:Unlock()
end
function Bar:Lock()
barOnDragStop(self)
self:EnableMouse(false)
self:SetScript("OnEnter", nil)
self:SetScript("OnLeave", nil)
@@ -93,7 +104,7 @@ function Bar:Lock()
end
function Bar:LoadPosition()
local x, y, s = self.config.PosX, self.config.PosY, self:GetEffectiveScale()
local x, y, s = self.config.x, self.config.y, self:GetEffectiveScale()
x, y = x/s, y/s
self:ClearAllPoints()
self:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", x, y)
@@ -103,6 +114,11 @@ function Bar:SavePosition()
local x, y = self:GetLeft(), self:GetBottom()
local s = self:GetEffectiveScale()
x, y = x*s, y*s
self.config.PosX = x
self.config.PosY = y
self.config.x = x
self.config.y = y
end
function Bar:SetSize(width, height)
self:SetWidth(width)
self:SetHeight(height or width)
end