Merge pull request #803 from houqp/new_ui_houqp

some minor adjustments & finished up touchmenu
pull/2/merge
Huang Xin 11 years ago
commit 1f01537751

2
.gitignore vendored

@ -14,6 +14,7 @@ git-rev
kpdfview
slider_watcher
*.o
tags
kindlepdfviewer-*.zip
@ -46,3 +47,4 @@ popen-noshell/popen_noshell_examples.c
popen-noshell/popen_noshell_tests.c
popen-noshell/popen_noshell_tests.cpp
kpvcrlib/libcrengine.so

@ -44,7 +44,7 @@ function Font:getFace(font, size)
font = self.cfont
end
local size = math.floor(size*Screen:getDPI()/167)
local size = math.floor(scaleByDPI(size))
local face = self.faces[font..size]
-- build face if not found

@ -7,7 +7,7 @@ PageCropDialog = VerticalGroup:new{
cancel_text = "Cancel",
ok_callback = function() end,
cancel_callback = function() end,
button_width = math.floor(70*Screen:getDPI()/167),
button_width = math.floor(scaleByDPI(70)),
}
function PageCropDialog:init()

@ -6,7 +6,7 @@ ReaderPaging = InputContainer:new{
visible_area = nil,
page_area = nil,
show_overlap_enable = true,
overlap = 20 * Screen:getDPI()/167,
overlap = scaleByDPI(20),
}
function ReaderPaging:init()

@ -10,7 +10,7 @@ function ReaderScreenshot:init()
Screenshot = {
GestureRange:new{
ges = "two_finger_tap",
scale = {diagonal - 80*Screen:getDPI()/167, diagonal},
scale = {diagonal - scaleByDPI(80), diagonal},
rate = 1.0,
}
},

@ -23,8 +23,8 @@ ReaderView = OverlapGroup:new{
page_states = {},
scroll_mode = "vertical",
page_gap = {
width = 8 * Screen:getDPI()/167,
height = 8 * Screen:getDPI()/167,
width = scaleByDPI(8),
height = scaleByDPI(8),
color = 8,
},
-- DjVu page rendering mode (used in djvu.c:drawPage())

@ -99,6 +99,15 @@ function Screen:getDPI()
return Device:getModel() == "KindlePaperWhite" and 212 or 167
end
function Screen:scaleByDPI(px)
return (px * self:getDPI()/167)
end
-- make a shortcut to Screen:scaleByDPI
function scaleByDPI(px)
return Screen:scaleByDPI(px)
end
function Screen:getPitch()
return self.fb:getPitch()
end

@ -159,7 +159,9 @@ function ConfigOption:init()
local default_option_height = 50
local default_option_padding = 15
local vertical_group = VerticalGroup:new{}
table.insert(vertical_group, VerticalSpan:new{ width = default_option_padding * Screen:getDPI()/167 })
table.insert(vertical_group, VerticalSpan:new{
width = scaleByDPI(default_option_padding),
})
for c = 1, #self.options do
if self.options[c].show ~= false then
local name_align = self.options[c].name_align_right and self.options[c].name_align_right or 0.33
@ -168,9 +170,9 @@ function ConfigOption:init()
local name_font_size = self.options[c].name_font_size and self.options[c].name_font_size or default_name_font_size
local item_font_face = self.options[c].item_font_face and self.options[c].item_font_face or "cfont"
local item_font_size = self.options[c].item_font_size and self.options[c].item_font_size or default_item_font_size
local option_height = (self.options[c].height and self.options[c].height or default_option_height) * Screen:getDPI()/167
local option_height = scaleByDPI(self.options[c].height and self.options[c].height or default_option_height)
local items_spacing = HorizontalSpan:new{
width = (self.options[c].spacing and self.options[c].spacing or default_items_spacing) * Screen:getDPI()/167
width = scaleByDPI(self.options[c].spacing and self.options[c].spacing or default_items_spacing)
}
local horizontal_group = HorizontalGroup:new{}
if self.options[c].name_text then

@ -59,7 +59,7 @@ end
TouchMenuBar widget
--]]
TouchMenuBar = InputContainer:new{
height = 70 * Screen:getDPI()/167,
height = scaleByDPI(70),
width = Screen:getWidth(),
icons = {},
-- touch menu that holds the bar, used for trigger repaint on icons
@ -79,12 +79,12 @@ function TouchMenuBar:init()
local icon_sep = LineWidget:new{
dimen = Geom:new{
w = 2,
w = scaleByDPI(2),
h = self.height,
}
}
local icon_span = HorizontalSpan:new{ width = 20 }
local icon_span = HorizontalSpan:new{ width = scaleByDPI(20) }
-- build up image widget for menu icon bar
self.icon_widgets = {}
@ -113,7 +113,7 @@ function TouchMenuBar:init()
self.bar_sep = LineWidget:new{
dimen = Geom:new{
w = self.width,
h = 2,
h = scaleByDPI(2),
},
empty_segments = {
{
@ -159,12 +159,11 @@ TouchMenu widget
TouchMenu = InputContainer:new{
tab_item_table = {},
-- for returnning in multi-level menus
item_table_stack = {},
item_table_stack = nil,
item_table = nil,
--@TODO replace getDPI call (houqp)
item_height = 50 * Screen:getDPI()/167,
bordersize = 2 * Screen:getDPI()/167,
padding = 5 * Screen:getDPI()/167,
item_height = scaleByDPI(50),
bordersize = scaleByDPI(2),
padding = scaleByDPI(5),
width = Screen:getWidth(),
height = nil,
page = 1,
@ -193,6 +192,12 @@ function TouchMenu:init()
}
}
}
self.ges_events.Swipe = {
GestureRange:new{
ges = "swipe",
range = self.dimen,
}
}
local icons = {}
for _,v in ipairs(self.tab_item_table) do
@ -209,15 +214,20 @@ function TouchMenu:init()
align = "left",
}
self.footer_page = TextWidget:new{
face = Font:getFace("ffont", 20),
text = "",
}
self.footer = HorizontalGroup:new{
IconButton:new{
invert = true,
icon_file = "resources/icons/appbar.chevron.left.png",
icon_file = "resources/icons/appbar.chevron.up.png",
show_parent = self.show_parent,
callback = function()
self:backToUpperMenu()
end,
}
},
self.footer_page,
}
self[1] = FrameContainer:new{
@ -277,7 +287,7 @@ function TouchMenu:updateItems()
if c ~= self.perpage then
table.insert(self.item_group, HorizontalGroup:new{
-- pad with spacing
HorizontalSpan:new{width = 10},
HorizontalSpan:new{width = scaleByDPI(10)},
LineWidget:new{
style = "dashed",
dimen = Geom:new{
@ -297,8 +307,9 @@ function TouchMenu:updateItems()
end -- if i <= self.items
end -- for c=1, self.perpage
table.insert(self.item_group, VerticalSpan:new{width = 2})
table.insert(self.item_group, VerticalSpan:new{width = scaleByDPI(2)})
table.insert(self.item_group, self.footer)
self.footer_page.text = "Page "..self.page.."/"..self.page_num
-- FIXME: this is a dirty hack to clear previous menus
-- refert to issue #664
UIManager.repaint_all = true
@ -306,6 +317,10 @@ end
function TouchMenu:switchMenuTab(tab_num)
if self.cur_tab ~= tab_num then
-- it's like getting a new menu everytime we switch tab!
self.page = 1
-- clear item table stack
self.item_table_stack = {}
self.cur_tab = tab_num
self.item_table = self.tab_item_table[tab_num]
self:updateItems()
@ -323,6 +338,30 @@ function TouchMenu:closeMenu()
self.close_callback()
end
function TouchMenu:onNextPage()
if self.page < self.page_num then
self.page = self.page + 1
self:updateItems()
end
return true
end
function TouchMenu:onPrevPage()
if self.page > 1 then
self.page = self.page - 1
self:updateItems()
end
return true
end
function TouchMenu:onSwipe(arg, ges_ev)
if ges_ev.direction == "left" then
self:onNextPage()
elseif ges_ev.direction == "right" then
self:onPrevPage()
end
end
function TouchMenu:onMenuSelect(item)
if item.sub_item_table == nil then
if item.callback then

@ -29,6 +29,19 @@ HomeMenu = InputContainer:new{
},
}
function exitReader()
G_reader_settings:close()
input.closeAll()
if util.isEmulated() ==0 then
if Device:isKindle3() or (Device:getModel() == "KindleDXG") then
-- send double menu key press events to trigger screen refresh
os.execute("echo 'send 139' > /proc/keypad;echo 'send 139' > /proc/keypad")
end
end
end
function HomeMenu:setUpdateItemTable()
function readHistDir(order_arg, re)
local pipe_out = io.popen("ls "..order_arg.." -1 ./history")
@ -59,7 +72,7 @@ function HomeMenu:setUpdateItemTable()
table.insert(self.item_table, {
text = "Exit",
callback = function()
os.exit(0)
exitReader()
end
})
end
@ -96,6 +109,7 @@ function showReader(file, pass)
return
end
G_reader_settings:saveSetting("lastfile", file)
local reader = ReaderUI:new{
dialog = readerwindow,
dimen = Screen:getSize(),
@ -200,7 +214,7 @@ local last_file = G_reader_settings:readSetting("lastfile")
--87712cf0e43fed624f8a9f610be42b1fe174b9fe
if ARGV[argidx] then
if ARGV[argidx] and ARGV[argidx] ~= "" then
if lfs.attributes(ARGV[argidx], "mode") == "directory" then
showHomePage(ARGV[argidx])
elseif lfs.attributes(ARGV[argidx], "mode") == "file" then
@ -214,11 +228,4 @@ else
return showusage()
end
input.closeAll()
if util.isEmulated()==0 then
if Device:isKindle3() or (Device:getModel() == "KindleDXG") then
-- send double menu key press events to trigger screen refresh
os.execute("echo 'send 139' > /proc/keypad;echo 'send 139' > /proc/keypad")
end
end
exitReader()

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="76" height="76" viewBox="0 0 76.00 76.00" enable-background="new 0 0 76.00 76.00" xml:space="preserve">
<path fill="#000000" fill-opacity="1" stroke-width="0.2" stroke-linejoin="round" d="M 37.8516,35.625L 34.6849,38.7917L 23.6016,50.2708L 23.6016,39.9792L 37.8516,24.9375L 52.1016,39.9792L 52.1016,50.2708L 41.0182,38.7917L 37.8516,35.625 Z "/>
</svg>
Loading…
Cancel
Save