Merge pull request #396 from chrox/master

add customizable tap zones for tap forward/backward and config
This commit is contained in:
Qingping Hou
2013-12-15 19:03:50 -08:00
8 changed files with 86 additions and 39 deletions

View File

@@ -38,6 +38,15 @@ DSHOWOVERLAP = false
-- default to false
DSHOWHIDDENFILES = false
-- customizable tap zones(rectangles)
-- x: x coordinate of top left corner in proportion of screen width
-- y: y coordinate of top left corner in proportion of screen height
-- w: width of tap zone in proportion of screen width
-- h: height of tap zone in proportion of screen height
DTAP_ZONE_FORWARD = {x = 1/4, y = 0, w = 3/4, h = 1}
DTAP_ZONE_BACKWARD = {x = 0, y = 0, w = 1/4, h = 1}
DTAP_ZONE_CONFIG = {x = 0, y = 11/12, w = 1, h = 1/12}
-- koptreader config defaults
DKOPTREADER_CONFIG_FONT_SIZE = 1.0 -- range from 0.1 to 3.0
DKOPTREADER_CONFIG_TEXT_WRAP = 0 -- 1 = on, 0 = off

View File

@@ -29,10 +29,10 @@ function ReaderConfig:initGesListener()
GestureRange:new{
ges = "tap",
range = Geom:new{
x = 0,
y = 11*Screen:getHeight()/12,
w = Screen:getWidth(),
h = Screen:getHeight()/12,
x = Screen:getWidth()*DTAP_ZONE_CONFIG.x,
y = Screen:getHeight()*DTAP_ZONE_CONFIG.y,
w = Screen:getWidth()*DTAP_ZONE_CONFIG.w,
h = Screen:getHeight()*DTAP_ZONE_CONFIG.h,
}
}
}

View File

@@ -4,17 +4,23 @@ local RightContainer = require("ui/widget/container/rightcontainer")
local BottomContainer = require("ui/widget/container/bottomcontainer")
local FrameContainer = require("ui/widget/container/framecontainer")
local ProgressWidget = require("ui/widget/progresswidget")
local HorizontalGroup = require("ui/widget/horizontalgroup")
local TextWidget = require("ui/widget/textwidget")
local GestureRange = require("ui/gesturerange")
local UIManager = require("ui/uimanager")
local Device = require("ui/device")
local Screen = require("ui/screen")
local Geom = require("ui/geometry")
local Font = require("ui/font")
local HorizontalGroup = require("ui/widget/horizontalgroup")
local DEBUG = require("dbg")
local ReaderFooter = InputContainer:new{
visible = true,
pageno = nil,
pages = nil,
progress_percentage = 0.0,
progress_text = "0 / 0",
show_time = false,
bar_width = 0.88,
text_width = 0.12,
text_font_face = "ffont",
@@ -57,15 +63,25 @@ function ReaderFooter:init()
self.pageno = self.view.state.page
self.pages = self.view.document.info.number_of_pages
self:updateFooter()
end
function ReaderFooter:paintTo(bb, x, y)
self[1]:paintTo(bb, x, y)
if Device:isTouchDevice() then
self.ges_events = {
TapFooter = {
GestureRange:new{
ges = "tap",
range = self[1]:contentRange(),
},
},
}
end
end
function ReaderFooter:updateFooter()
self.progress_bar.percentage = self.pageno / self.pages
self.progress_text.text = string.format("%d / %d", self.pageno, self.pages)
if self.show_time then
self.progress_text.text = os.date("%H:%M")
else
self.progress_text.text = string.format("%d / %d", self.pageno, self.pages)
end
end
function ReaderFooter:onPageUpdate(pageno)
@@ -74,4 +90,14 @@ function ReaderFooter:onPageUpdate(pageno)
self:updateFooter()
end
function ReaderFooter:onTapFooter(arg, gev)
self.show_time = not self.show_time
self:updateFooter()
UIManager:setDirty(self.view.dialog)
-- consume this tap when footer is visible
if self.visible then
return true
end
end
return ReaderFooter

View File

@@ -62,10 +62,10 @@ function ReaderPaging:initGesListener()
GestureRange:new{
ges = "tap",
range = Geom:new{
x = Screen:getWidth()/4,
y = Screen:getHeight()/4,
w = 3*Screen:getWidth()/4,
h = 2*Screen:getHeight()/3,
x = Screen:getWidth()*DTAP_ZONE_FORWARD.x,
y = Screen:getHeight()*DTAP_ZONE_FORWARD.y,
w = Screen:getWidth()*DTAP_ZONE_FORWARD.w,
h = Screen:getHeight()*DTAP_ZONE_FORWARD.h,
}
}
},
@@ -73,10 +73,10 @@ function ReaderPaging:initGesListener()
GestureRange:new{
ges = "tap",
range = Geom:new{
x = 0,
y = Screen:getHeight()/4,
w = Screen:getWidth()/4,
h = 2*Screen:getHeight()/3,
x = Screen:getWidth()*DTAP_ZONE_BACKWARD.x,
y = Screen:getHeight()*DTAP_ZONE_BACKWARD.y,
w = Screen:getWidth()*DTAP_ZONE_BACKWARD.w,
h = Screen:getHeight()*DTAP_ZONE_BACKWARD.h,
}
}
},

View File

@@ -81,10 +81,10 @@ function ReaderRolling:initGesListener()
GestureRange:new{
ges = "tap",
range = Geom:new{
x = Screen:getWidth()/4,
y = Screen:getHeight()/4,
w = 3*Screen:getWidth()/4,
h = 5*Screen:getHeight()/8,
x = Screen:getWidth()*DTAP_ZONE_FORWARD.x,
y = Screen:getHeight()*DTAP_ZONE_FORWARD.y,
w = Screen:getWidth()*DTAP_ZONE_FORWARD.w,
h = Screen:getHeight()*DTAP_ZONE_FORWARD.h,
}
}
},
@@ -92,10 +92,10 @@ function ReaderRolling:initGesListener()
GestureRange:new{
ges = "tap",
range = Geom:new{
x = 0,
y = Screen:getHeight()/4,
w = Screen:getWidth()/4,
h = 5*Screen:getHeight()/8,
x = Screen:getWidth()*DTAP_ZONE_BACKWARD.x,
y = Screen:getHeight()*DTAP_ZONE_BACKWARD.y,
w = Screen:getWidth()*DTAP_ZONE_BACKWARD.w,
h = Screen:getHeight()*DTAP_ZONE_BACKWARD.h,
}
}
},

View File

@@ -71,6 +71,7 @@ function ReaderView:resetLayout()
}
self.footer = ReaderFooter:new{
view = self,
visible = self.footer_visible,
}
self.flipping = ReaderFlipping:new{
view = self,

View File

@@ -138,18 +138,27 @@ function ReaderUI:init()
ui = self
}
table.insert(self.active_widgets, reader_ss)
-- frontlight controller
if Device:getFrontlight() then
-- frontlight controller
table.insert(self, ReaderFrontLight:new{
dialog = self.dialog,
view = self[1],
ui = self
})
end
-- config panel controller
if self.document.info.configurable then
local config_dialog = ReaderConfig:new{
configurable = self.document.configurable,
options = self.document.options,
dialog = self.dialog,
view = self[1],
ui = self
}
table.insert(self, config_dialog)
end
-- for page specific controller
if self.document.info.has_pages then
-- for page specific controller
-- if needed, insert a paging container
local pager = ReaderPaging:new{
dialog = self.dialog,
@@ -225,15 +234,6 @@ function ReaderUI:init()
})
end
if self.document.info.configurable then
-- configurable controller
local config_dialog = ReaderConfig:new{
configurable = self.document.configurable,
options = self.document.options,
dialog = self.dialog,
view = self[1],
ui = self
}
table.insert(self, config_dialog)
-- kopt option controller
local koptlistener = ReaderKoptListener:new{
dialog = self.dialog,

View File

@@ -1,4 +1,5 @@
local WidgetContainer = require("ui/widget/container/widgetcontainer")
local Geom = require("ui/geometry")
--[[
BottomContainer contains its content (1 widget) at the bottom of its own
@@ -17,4 +18,14 @@ function BottomContainer:paintTo(bb, x, y)
y + (self.dimen.h - contentSize.h))
end
function BottomContainer:contentRange()
local contentSize = self[1]:getSize()
return Geom:new{
x = (self.dimen.x or 0) + math.floor((self.dimen.w - contentSize.w)/2),
y = (self.dimen.y or 0) + self.dimen.h - contentSize.h,
w = contentSize.w,
h = contentSize.h
}
end
return BottomContainer