From 912a8a496b0b2fb61952d4ec91c1158acd1110ec Mon Sep 17 00:00:00 2001 From: chrox Date: Sun, 15 Dec 2013 17:02:52 +0800 Subject: [PATCH] add customizable tap zones for tap forward/backward and config --- defaults.lua | 9 +++++++++ frontend/ui/reader/readerconfig.lua | 8 ++++---- frontend/ui/reader/readerpaging.lua | 16 ++++++++-------- frontend/ui/reader/readerrolling.lua | 16 ++++++++-------- frontend/ui/readerui.lua | 26 +++++++++++++------------- 5 files changed, 42 insertions(+), 33 deletions(-) diff --git a/defaults.lua b/defaults.lua index 9fdce7758..0b75ca58a 100644 --- a/defaults.lua +++ b/defaults.lua @@ -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 diff --git a/frontend/ui/reader/readerconfig.lua b/frontend/ui/reader/readerconfig.lua index 693148882..ecc255a72 100644 --- a/frontend/ui/reader/readerconfig.lua +++ b/frontend/ui/reader/readerconfig.lua @@ -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, } } } diff --git a/frontend/ui/reader/readerpaging.lua b/frontend/ui/reader/readerpaging.lua index fcf551ec6..28f632ef0 100644 --- a/frontend/ui/reader/readerpaging.lua +++ b/frontend/ui/reader/readerpaging.lua @@ -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, } } }, diff --git a/frontend/ui/reader/readerrolling.lua b/frontend/ui/reader/readerrolling.lua index 1b3b5dfc5..1f8e4aec0 100644 --- a/frontend/ui/reader/readerrolling.lua +++ b/frontend/ui/reader/readerrolling.lua @@ -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, } } }, diff --git a/frontend/ui/readerui.lua b/frontend/ui/readerui.lua index 80120da6d..50e97ba04 100644 --- a/frontend/ui/readerui.lua +++ b/frontend/ui/readerui.lua @@ -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,