Merge pull request #155 from houqp/new_ui_code

add paintRoundedRect & use it in FrameContainer
pull/2/merge
Dobrica Pavlinušić 12 years ago
commit c486f5f8b3

@ -16,8 +16,8 @@ function blitbuffer.paintBorder(bb, x, y, w, h, bw, c, r)
bb:paintRect(x, y+bw, bw, h - 2*bw, c)
bb:paintRect(x+w-bw, y+bw, bw, h - 2*bw, c)
else
if h < 2*r then h = 2 * r end
if w < 2*r then w = 2 * r end
if h < 2*r then r = math.floor(h/2) end
if w < 2*r then r = math.floor(w/2) end
bb:paintRoundedCorner(x, y, w, h, bw, r, c)
bb:paintRect(r+x, y, w-2*r, bw, c)
bb:paintRect(r+x, y+h-bw, w-2*r, bw, c)
@ -27,6 +27,28 @@ function blitbuffer.paintBorder(bb, x, y, w, h, bw, c, r)
end
--[[
Fill a rounded corner rectangular area
@x: start position in x axis
@y: start position in y axis
@w: width of the area
@h: height of the area
@c: color used to fill the area
@r: radius of for four corners
--]]
function blitbuffer.paintRoundedRect(bb, x, y, w, h, c, r)
if not r or r == 0 then
bb:paintRect(x, y, w, h, c)
else
if h < 2*r then r = math.floor(h/2) end
if w < 2*r then r = math.floor(w/2) end
bb:paintBorder(x, y, w, h, r, c, r)
bb:paintRect(x+r, y+r, w-2*r, h-2*r, c)
end
end
--[[
Draw a progress bar according to following args:

@ -141,7 +141,7 @@ function FrameContainer:paintTo(bb, x, y)
local my_size = self:getSize()
if self.background then
bb:paintRect(x, y, my_size.w, my_size.h, self.background)
bb:paintRoundedRect(x, y, my_size.w, my_size.h, self.background, self.radius)
end
if self.bordersize > 0 then
bb:paintBorder(x + self.margin, y + self.margin,

Loading…
Cancel
Save