Merge pull request #160 from houqp/new_ui_code

more changes in new_ui_code
pull/2/merge
Dobrica Pavlinušić 12 years ago
commit 5e7b0bfeb9

@ -265,17 +265,37 @@ ItemShortCutIcon = WidgetContainer:new{
height = 22,
key = nil,
bordersize = 2,
radius = 0,
style = "square"
}
function ItemShortCutIcon:init()
if not self.key then
return
end
local radius = 0
local background = 0
if self.style == "rounded_corner" then
radius = math.floor(self.width/2)
elseif self.style == "grey_square" then
background = 3
end
--@TODO calculate font size by icon size 01.05 2012 (houqp)
if self.key:len() > 1 then
sc_face = Font:getFace("ffont", 14)
else
sc_face = Font:getFace("scfont", 22)
end
self[1] = HorizontalGroup:new{
HorizontalSpan:new{ width = 5 },
FrameContainer:new{
padding = 0,
bordersize = self.bordersize,
radius = radius,
background = background,
dimen = {
w = self.width,
h = self.height,
@ -287,7 +307,7 @@ function ItemShortCutIcon:init()
},
TextWidget:new{
text = self.key,
face = Font:getFace("scfont", 22)
face = sc_face,
},
},
},
@ -307,6 +327,7 @@ MenuItem = WidgetContainer:new{
width = nil,
height = nil,
shortcut = nil,
shortcut_style = "square",
}
function MenuItem:init()
@ -331,6 +352,8 @@ function MenuItem:init()
width = shortcut_icon_w,
height = shortcut_icon_h,
key = self.shortcut,
radius = shortcut_icon_r,
style = self.shortcut_style,
},
HorizontalSpan:new{ width = 5 },
UnderlineContainer:new{
@ -453,7 +476,14 @@ function Menu:_updateItems()
local i = (self.page - 1) * self.perpage + c
if i <= self.items then
local item_shortcut = nil
local shortcut_style = "square"
if self.is_enable_shortcut then
-- give different shortcut_style to keys in different
-- lines of keyboard
if c >= 11 and c <= 20 then
--shortcut_style = "rounded_corner"
shortcut_style = "grey_square"
end
item_shortcut = self.item_shortcuts[c]
if item_shortcut == "Enter" then
item_shortcut = "Ent"
@ -464,7 +494,8 @@ function Menu:_updateItems()
face = self.cface,
width = self.width - 14,
height = self.item_height,
shortcut = item_shortcut
shortcut = item_shortcut,
shortcut_style = shortcut_style,
}
table.insert(item_group, item_tmp)
table.insert(self.layout, {item_tmp})

@ -10,6 +10,8 @@ Draw a border
@r: radius of for border's corner (nil or 0 means right corner border)
--]]
function blitbuffer.paintBorder(bb, x, y, w, h, bw, c, r)
x, y = math.ceil(x), math.ceil(y)
h, w = math.ceil(h), math.ceil(w)
if not r or r == 0 then
bb:paintRect(x, y, w, bw, c)
bb:paintRect(x, y+h-bw, w, bw, c)
@ -38,6 +40,8 @@ Fill a rounded corner rectangular area
@r: radius of for four corners
--]]
function blitbuffer.paintRoundedRect(bb, x, y, w, h, c, r)
x, y = math.ceil(x), math.ceil(y)
h, w = math.ceil(h), math.ceil(w)
if not r or r == 0 then
bb:paintRect(x, y, w, h, c)
else
@ -49,7 +53,6 @@ function blitbuffer.paintRoundedRect(bb, x, y, w, h, c, r)
end
--[[
Draw a progress bar according to following args:

@ -164,27 +164,36 @@ TextWidget = Widget:new{
color = 15,
_bb = nil,
_length = 0,
_height = 0,
_maxlength = 1200,
}
function TextWidget:_render()
local h = self.face.size * 1.3
self._bb = Blitbuffer.new(self._maxlength, h)
self._length = renderUtf8Text(self._bb, 0, h*0.8, self.face, self.text, self.color)
end
--function TextWidget:_render()
--local h = self.face.size * 1.3
--self._bb = Blitbuffer.new(self._maxlength, h)
--self._length = renderUtf8Text(self._bb, 0, h*0.8, self.face, self.text, self.color)
--end
function TextWidget:getSize()
if not self._bb then
self:_render()
end
return { w = self._length, h = self._bb:getHeight() }
--if not self._bb then
--self:_render()
--end
--return { w = self._length, h = self._bb:getHeight() }
self._length = sizeUtf8Text(0, G_width, self.face, self.text, true).x
self._height = self.face.size * 1.3
return {
w = self._length,
h = self._height,
}
end
function TextWidget:paintTo(bb, x, y)
if not self._bb then
self:_render()
end
bb:blitFrom(self._bb, x, y, 0, 0, self._length, self._bb:getHeight())
--if not self._bb then
--self:_render()
--end
--bb:blitFrom(self._bb, x, y, 0, 0, self._length, self._bb:getHeight())
renderUtf8Text(bb, x, y+self._height*0.8, self.face, self.text, true)
end
function TextWidget:free()

Loading…
Cancel
Save