mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 23:26:51 +01:00
Reimplement text edit scrolling in C++
* And update some corelib APIs
This commit is contained in:
@@ -6,6 +6,10 @@ function UIProgressBar.create()
|
||||
progressbar:setFocusable(false)
|
||||
progressbar:setPhantom(true)
|
||||
progressbar.percent = 0
|
||||
progressbar.bgBorderLeft = 0
|
||||
progressbar.bgBorderRight = 0
|
||||
progressbar.bgBorderTop = 0
|
||||
progressbar.bgBorderBottom = 0
|
||||
progressbar:updateBackground()
|
||||
return progressbar
|
||||
end
|
||||
@@ -25,11 +29,30 @@ function UIProgressBar:getPercentPixels()
|
||||
end
|
||||
|
||||
function UIProgressBar:updateBackground()
|
||||
local width = math.round(math.max((self.percent * self:getWidth())/100, 1))
|
||||
local height = self:getHeight()
|
||||
self:setBackgroundSize({width=width, height=height})
|
||||
local width = math.round(math.max((self.percent * (self:getWidth() - self.bgBorderLeft - self.bgBorderRight))/100, 1))
|
||||
local height = self:getHeight() - self.bgBorderTop - self.bgBorderBottom
|
||||
local rect = { x = self.bgBorderLeft, y = self.bgBorderTop, width = width, height = height }
|
||||
self:setBackgroundRect(rect)
|
||||
end
|
||||
|
||||
function UIProgressBar:onStyleApply(name, node)
|
||||
for name,value in pairs(node) do
|
||||
if name == 'background-border-left' then
|
||||
self.bgBorderLeft = tonumber(value)
|
||||
elseif name == 'background-border-right' then
|
||||
self.bgBorderRight = tonumber(value)
|
||||
elseif name == 'background-border-top' then
|
||||
self.bgBorderTop = tonumber(value)
|
||||
elseif name == 'background-border-bottom' then
|
||||
self.bgBorderBottom = tonumber(value)
|
||||
elseif name == 'background-border' then
|
||||
self.bgBorderLeft = tonumber(value)
|
||||
self.bgBorderRight = tonumber(value)
|
||||
self.bgBorderTop = tonumber(value)
|
||||
self.bgBorderBottom = tonumber(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function UIProgressBar:onGeometryChange(oldRect, newRect)
|
||||
self:updateBackground()
|
||||
|
||||
Reference in New Issue
Block a user