minor fixes, add TouchMenu example to wtest.lua

pull/2/merge
Qingping Hou 11 years ago
parent 1fcb5281a0
commit 3c97c65f5c

@ -40,7 +40,7 @@ function ConfirmBox:init()
}
self.layout = { { ok_button, cancel_button } }
self.selected.x = 2 -- Cancel is default
self.selected.x = 2 -- Cancel is default
self[1] = CenterContainer:new{
dimen = Screen:getSize(),

@ -33,7 +33,9 @@ function HorizontalGroup:paintTo(bb, x, y)
for i, widget in ipairs(self) do
if self.align == "center" then
widget:paintTo(bb, x + self._offsets[i].x, y + (size.h - self._offsets[i].y) / 2)
widget:paintTo(bb,
x + self._offsets[i].x,
y + (size.h - self._offsets[i].y) / 2)
elseif self.align == "top" then
widget:paintTo(bb, x + self._offsets[i].x, y)
elseif self.align == "bottom" then
@ -88,7 +90,7 @@ end
function VerticalGroup:paintTo(bb, x, y)
local size = self:getSize()
for i, widget in ipairs(self) do
if self.align == "center" then
widget:paintTo(bb, x + (size.w - self._offsets[i].x) / 2, y + self._offsets[i].y)
@ -150,7 +152,7 @@ end
function OverlapGroup:paintTo(bb, x, y)
local size = self:getSize()
for i, wget in ipairs(self) do
local wget_size = wget:getSize()
if wget.align == "right" then

@ -0,0 +1,31 @@
require "ui/widget/base"
LineWidget = Widget:new{
style = "solid",
background = 15,
dimen = nil,
--@TODO replay dirty hack here 13.03 2013 (houqp)
empty_segments = nil,
}
function LineWidget:paintTo(bb, x, y)
if self.style == "dashed" then
for i = 0, self.dimen.w - 20, 20 do
bb:paintRect(x + i, y,
16, self.dimen.h, self.background)
end
else
if self.empty_segments then
bb:paintRect(x, y,
self.empty_segments[1].s,
self.dimen.h,
self.background)
bb:paintRect(x + self.empty_segments[1].e, y,
self.dimen.w - x - self.empty_segments[1].e,
self.dimen.h,
self.background)
else
bb:paintRect(x, y, self.dimen.w, self.dimen.h, self.background)
end
end
end

@ -8,7 +8,7 @@ require "ui/font"
--[[
Widget that displays a shortcut icon for menu item
]]
--]]
ItemShortCutIcon = WidgetContainer:new{
dimen = Geom:new{ w = 22, h = 22 },
key = nil,

@ -176,24 +176,70 @@ reader = ReaderUI:new{
readerwindow[1][1] = reader
main_menu = TouchMenu:new{
touch_menu = TouchMenu:new{
title = "Document menu",
item_table = {
{
text = "item1",
callback = function()
end,
icon = "resources/icons/appbar.pokeball.png",
{
text = "item1",
callback = function()
end,
},
{
text = "item2",
callback = function()
end,
},
{
text = "item3",
callback = function()
end,
},
{
text = "item4",
callback = function()
end,
},
{
text = "item5",
callback = function()
end,
},
{
text = "item6",
callback = function()
end,
},
{
text = "item7",
callback = function()
end,
},
{
text = "item8",
callback = function()
end,
},
{
text = "item9",
callback = function()
end,
},
},
{
text = "item2",
callback = function()
end,
},
{
text = "item3",
callback = function()
end,
},
icon = "resources/icons/appbar.page.corner.bookmark.png",
{
text = "item10",
callback = function()
end,
},
{
text = "item11",
callback = function()
end,
},
}
},
}
@ -204,11 +250,11 @@ main_menu = TouchMenu:new{
-----------------------------------------------------------------------
UIManager:show(Background:new())
UIManager:show(TestGrid)
UIManager:show(Clock:new())
--UIManager:show(Clock:new())
--UIManager:show(M)
--UIManager:show(Quiz)
--UIManager:show(readerwindow)
UIManager:show(TouchMenu:new())
UIManager:show(touch_menu)
UIManager:run()

Loading…
Cancel
Save