2012-01-10 23:13:40 +01:00
|
|
|
UIProgressBar = extends(UIWidget)
|
|
|
|
|
|
|
|
function UIProgressBar.create()
|
|
|
|
local progressbar = UIProgressBar.internalCreate()
|
|
|
|
progressbar:setFocusable(false)
|
|
|
|
progressbar:setPhantom(true)
|
2012-01-15 16:13:22 +01:00
|
|
|
progressbar.m_percent = 0
|
|
|
|
progressbar:updateBackground()
|
2012-01-10 23:13:40 +01:00
|
|
|
return progressbar
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIProgressBar:setPercent(percent)
|
2012-01-15 16:13:22 +01:00
|
|
|
self.m_percent = percent
|
|
|
|
self:updateBackground()
|
2012-01-10 23:13:40 +01:00
|
|
|
end
|
|
|
|
|
2012-01-15 16:13:22 +01:00
|
|
|
|
2012-01-10 23:13:40 +01:00
|
|
|
function UIProgressBar:getPercent()
|
2012-01-15 16:13:22 +01:00
|
|
|
return self.m_percent
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIProgressBar:updateBackground()
|
|
|
|
local width = math.max((self.m_percent * self:getWidth())/100, 1)
|
|
|
|
local height = self:getHeight()
|
|
|
|
self:setBackgroundSize({width=width, height=height})
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function UIProgressBar:onGeometryChange(oldRect, newRect)
|
|
|
|
self:updateBackground()
|
2012-01-10 23:13:40 +01:00
|
|
|
end
|