refactor: add touch zone subsystem to inputcontainer

Touch zone decouples screen size from gesture event registration.

The win here is each individual widget does not need to update
gesture range on screen rotate/resize anymore.

Another advantage is we now have a centralized ordered array to handle
all registered touch event listeners, makes it much easier to resolve
gesture range conflicts between multiple widgets.

This patch also includes the following changes:

* migrate readerpaging to use readerui's touch zone
* migrate readerfooter to use readerui's touch zone
* move inverse read direction setting to touch menu's setting tab
* moved kobolight widget from readerview into readerui
* various dead code cleanups and comments
This commit is contained in:
Qingping Hou
2016-12-03 22:57:57 -08:00
parent 8799b4b6b1
commit 0c49b915de
9 changed files with 355 additions and 201 deletions

View File

@@ -12,7 +12,6 @@ local Event = require("ui/event")
local dbg = require("dbg")
local Blitbuffer = require("ffi/blitbuffer")
local _ = require("gettext")
local ReaderKoboLight = require("apps/reader/modules/readerkobolight")
local ReaderView = OverlapGroup:new{
document = nil,
@@ -115,13 +114,6 @@ function ReaderView:addWidgets()
self[1] = self.dogear
self[2] = self.footer
self[3] = self.flipping
if (Device:isKobo() and Device:hasFrontlight()) then
self.kobolight = ReaderKoboLight:new{
view = self,
ui = self.ui,
}
self[4] = self.kobolight
end
end
function ReaderView:resetLayout()
@@ -609,7 +601,9 @@ function ReaderView:onSetScreenMode(new_mode, rotation)
Screen:setScreenMode(new_mode)
end
UIManager:setDirty(self.dialog, "full")
self.ui:handleEvent(Event:new("SetDimensions", Screen:getSize()))
local new_screen_size = Screen:getSize()
self.ui:handleEvent(Event:new("SetDimensions", new_screen_size))
self.ui:onScreenResize(new_screen_size)
self.ui:handleEvent(Event:new("InitScrollPageStates"))
end
self.cur_rotation_mode = Screen.cur_rotation_mode