All pastes #113112 Raw Edit

Something

public text v1 · immutable
·published 2006-08-03 11:23 UTC
rendered paste body
idActionBar:RegisterDB('idActionBarDB')
idActionBar:RegisterDefaults('profile', {
    Position = {
        Mainbar = {
            p1 = 'BOTTOM',
            pr = UIParent,
            p2 = 'BOTTOM',
            x = 0,
            y = 0
        },
    }
})

...

function idBar.prototype:Enable()
    self.Width = 0
    self.Height = 0
    self.x = 0
    self.y = 0
    self.DBName = self.DBName or ''

    self:savePosition(
    idActionBar.db.profile.Position[self.DBName].p1,
    idActionBar.db.profile.Position[self.DBName].pr,
    idActionBar.db.profile.Position[self.DBName].p2,
    idActionBar.db.profile.Position[self.DBName].px,
    idActionBar.db.profile.Position[self.DBName].py)

    self.Background = CreateFrame('Frame')
    self.Background:EnableMouse(true)
    self.Background:SetMovable(true)
    self.Background:RegisterForDrag('LeftButton')
    self.Background:SetScript('OnDragStart', function() if IsAltKeyDown() then self.Background:StartMoving() end end)
    self.Background:SetScript('OnDragStop', function()
        self.Background:StopMovingOrSizing()
        self:savePosition('BOTTOMLEFT', UIParent, 'BOTTOMLEFT', self.Background:GetLeft(), self.Background:GetBottom())
    end)

    self:resetButtons()
    self:resetBackground()

    self:Hook('ActionButton_HideGrid', 'HideGrid')
end

...

function idBar.prototype:savePosition(p1, pr, p2, x, y)
    self.p1 = p1 or self.p1
    self.pr = pr or self.pr
    self.p2 = p2 or self.p2
    self.x = x or self.x
    self.y = y or self.y

    idActionBar.db.profile.Position[self.DBName].p1 = self.p1
    idActionBar.db.profile.Position[self.DBName].pr = self.pr
    idActionBar.db.profile.Position[self.DBName].p2 = self.p2
    idActionBar.db.profile.Position[self.DBName].x = self.x
    idActionBar.db.profile.Position[self.DBName].y = self.y
end

function idBar.prototype:loadPosition()
    self.Background:SetPoint(self.p1, self.pr, self.p2, self.x, self.y)
end