From 14bbcde4225fc80a20a715a95259d0a8bab7ac3c Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 2 Mar 2013 22:21:18 +0800 Subject: [PATCH 1/7] add multiple slots in gesture detector So that gesture detecting in one slot won't block gestures in the other slots. --- frontend/ui/gesturedetector.lua | 176 +++++++++++++++++--------------- 1 file changed, 92 insertions(+), 84 deletions(-) diff --git a/frontend/ui/gesturedetector.lua b/frontend/ui/gesturedetector.lua index 63de6cbd0..98cf4f762 100644 --- a/frontend/ui/gesturedetector.lua +++ b/frontend/ui/gesturedetector.lua @@ -59,30 +59,30 @@ GestureDetector = { -- distance parameters DOUBLE_TAP_DISTANCE = 50, PAN_THRESHOLD = 50, - - track_id = {}, - tev_stack = {}, - -- latest feeded touch event - last_tev = {}, - is_on_detecting = false, - first_tev = nil, - state = function(self, tev) - self:switchState("initialState", tev) - end, - - last_tap = nil, -- for single/double tap + + -- states are stored in separated slots + states = {}, + track_ids = {}, + tev_stacks = {}, + -- latest feeded touch event in each slots + last_tevs = {}, + first_tevs = {}, + -- detecting status on each slots + detectings = {}, + -- for single/double tap + last_taps = {}, } function GestureDetector:feedEvent(tev) - -- for now, only handle single point touch - if tev.slot ~= 0 then - return nil + local slot = tev.slot + if not self.states[slot] then + self:clearState(slot) -- initiate state end - re = self.state(self, tev) + local ges = self.states[slot](self, tev) if tev.id ~= -1 then - self.last_tev = tev + self.last_tevs[slot] = tev end - return re + return ges end function GestureDetector:deepCopyEv(tev) @@ -111,14 +111,15 @@ function GestureDetector:isDoubleTap(tap1, tap2) end --[[ -compare last_pan with self.first_tev +compare last_pan with first_tev in this slot if it is a swipe, return direction of swipe gesture. --]] -function GestureDetector:isSwipe() - local tv_diff = self.first_tev.timev - self.last_tev.timev +function GestureDetector:isSwipe(tev) + local slot = tev.slot + local tv_diff = self.first_tevs[slot].timev - self.last_tevs[slot].timev if (tv_diff.sec == 0) and (tv_diff.usec < self.SWIPE_INTERVAL) then - x_diff = self.last_tev.x - self.first_tev.x - y_diff = self.last_tev.y - self.first_tev.y + local x_diff = self.last_tevs[slot].x - self.first_tevs[slot].x + local y_diff = self.last_tevs[slot].y - self.first_tevs[slot].y if x_diff == 0 and y_diff == 0 then return nil end @@ -145,32 +146,33 @@ end Warning! this method won't update self.state, you need to do it in each state method! --]] -function GestureDetector:switchState(state_new, tev) +function GestureDetector:switchState(state_new, tev, param) --@TODO do we need to check whether state is valid? (houqp) - return self[state_new](self, tev) + return self[state_new](self, tev, param) end -function GestureDetector:clearState() - self.state = self.initialState - self.last_tev = {} - self.is_on_detecting = false - self.first_tev = nil +function GestureDetector:clearState(slot) + self.states[slot] = self.initialState + self.last_tevs[slot] = {} + self.detectings[slot] = false + self.first_tevs[slot] = nil end function GestureDetector:initialState(tev) + local slot = tev.slot if tev.id then -- a event ends if tev.id == -1 then - self.is_on_detecting = false + self.detectings[slot] = false else - self.track_id[tev.id] = tev.slot + self.track_ids[slot] = tev.id end end if tev.x and tev.y then -- user starts a new touch motion - if not self.is_on_detecting then - self.is_on_detecting = true - self.first_tev = self:deepCopyEv(tev) + if not self.detectings[slot] then + self.detectings[slot] = true + self.first_tevs[slot] = self:deepCopyEv(tev) -- default to tap state return self:switchState("tapState", tev) end @@ -182,14 +184,15 @@ this method handles both single and double tap --]] function GestureDetector:tapState(tev) DEBUG("in tap state...", tev) + local slot = tev.slot if tev.id == -1 then -- end of tap event local ges_ev = { -- default to single tap ges = "tap", pos = Geom:new{ - x = self.last_tev.x, - y = self.last_tev.y, + x = self.last_tevs[slot].x, + y = self.last_tevs[slot].y, w = 0, h = 0, } } @@ -200,57 +203,58 @@ function GestureDetector:tapState(tev) timev = tev.timev, } - if self.last_tap ~= nil and - self:isDoubleTap(self.last_tap, cur_tap) then + if self.last_taps[slot] ~= nil and + self:isDoubleTap(self.last_taps[slot], cur_tap) then -- it is a double tap - self:clearState() + self:clearState(slot) ges_ev.ges = "double_tap" - self.last_tap = nil - DEBUG("double tap detected") + self.last_taps[slot] = nil + DEBUG("double tap detected in slot", slot) return ges_ev end -- set current tap to last tap - self.last_tap = cur_tap + self.last_taps[slot] = cur_tap DEBUG("set up tap timer") - local deadline = self.last_tev.timev + TimeVal:new{ - sec = 0, usec = self.DOUBLE_TAP_INTERVAL, - } + -- deadline should be calculated by adding current tap time and the interval + local deadline = cur_tap.timev + TimeVal:new{ + sec = 0, usec = self.DOUBLE_TAP_INTERVAL, + } Input:setTimeout(function() - DEBUG("in tap timer", self.last_tap ~= nil) + DEBUG("in tap timer", self.last_taps[slot] ~= nil) -- double tap will set last_tap to nil so if it is not, then -- user must only tapped once - if self.last_tap ~= nil then - self.last_tap = nil + if self.last_taps[slot] ~= nil then + self.last_taps[slot] = nil -- we are using closure here - DEBUG("single tap detected") + DEBUG("single tap detected in slot", slot) return ges_ev end end, deadline) -- we are already at the end of touch event -- so reset the state - self:clearState() - elseif self.state ~= self.tapState then + self:clearState(slot) + elseif self.states[slot] ~= self.tapState then -- switched from other state, probably from initialState -- we return nil in this case - self.state = self.tapState + self.states[slot] = self.tapState DEBUG("set up hold timer") local deadline = tev.timev + TimeVal:new{ - sec = 0, usec = self.HOLD_INTERVAL - } + sec = 0, usec = self.HOLD_INTERVAL + } Input:setTimeout(function() - if self.state == self.tapState then + if self.states[slot] == self.tapState then -- timer set in tapState, so we switch to hold - DEBUG("hold gesture detected") - return self:switchState("holdState") + DEBUG("hold gesture detected in slot", slot) + return self:switchState("holdState", tev, true) end end, deadline) else -- it is not end of touch event, see if we need to switch to -- other states - if (tev.x and math.abs(tev.x - self.first_tev.x) >= self.PAN_THRESHOLD) or - (tev.y and math.abs(tev.y - self.first_tev.y) >= self.PAN_THRESHOLD) then + if (tev.x and math.abs(tev.x - self.first_tevs[slot].x) >= self.PAN_THRESHOLD) or + (tev.y and math.abs(tev.y - self.first_tevs[slot].y) >= self.PAN_THRESHOLD) then -- if user's finger moved long enough in X or -- Y distance, we switch to pan state return self:switchState("panState", tev) @@ -259,18 +263,19 @@ function GestureDetector:tapState(tev) end function GestureDetector:panState(tev) - DEBUG("in pan state...") + DEBUG("in pan state...", tev) + local slot = tev.slot if tev.id == -1 then -- end of pan, signal swipe gesture if necessary - swipe_direct = self:isSwipe() + local swipe_direct = self:isSwipe(tev) if swipe_direct then - DEBUG("swipe detected!") + DEBUG("swipe", swipe_direct, "detected in slot", slot) local start_pos = Geom:new{ - x = self.first_tev.x, - y = self.first_tev.y, + x = self.first_tevs[slot].x, + y = self.first_tevs[slot].y, w = 0, h = 0, } - self:clearState() + self:clearState(slot) return { ges = "swipe", direction = swipe_direct, @@ -279,10 +284,10 @@ function GestureDetector:panState(tev) --@TODO add start and end points? (houqp) } end - self:clearState() + self:clearState(slot) else - if self.state ~= self.panState then - self.state = self.panState + if self.states[slot] ~= self.panState then + self.states[slot] = self.panState end local pan_ev = { @@ -294,40 +299,43 @@ function GestureDetector:panState(tev) }, pos = nil, } - pan_ev.relative.x = tev.x - self.last_tev.x - pan_ev.relative.y = tev.y - self.last_tev.y + pan_ev.relative.x = tev.x - self.last_tevs[slot].x + pan_ev.relative.y = tev.y - self.last_tevs[slot].y pan_ev.pos = Geom:new{ - x = self.last_tev.x, - y = self.last_tev.y, + x = self.last_tevs[slot].x, + y = self.last_tevs[slot].y, w = 0, h = 0, } return pan_ev end end -function GestureDetector:holdState(tev) - DEBUG("in hold state...") - -- when we switch to hold state, we pass no ev - -- so ev = nil - if not tev and self.last_tev.x and self.last_tev.y then - self.state = self.holdState +function GestureDetector:holdState(tev, hold) + DEBUG("in hold state...", tev, hold) + local slot = tev.slot + -- when we switch to hold state, we pass additional param "hold" + if tev.id ~= -1 and hold and self.last_tevs[slot].x and self.last_tevs[slot].y then + self.states[slot] = self.holdState return { ges = "hold", pos = Geom:new{ - x = self.last_tev.x, - y = self.last_tev.y, + x = self.last_tevs[slot].x, + y = self.last_tevs[slot].y, w = 0, h = 0, } } end if tev.id == -1 then -- end of hold, signal hold release - self:clearState() + DEBUG("hold_release detected in slot", slot) + local last_x = self.last_tevs[slot].x + local last_y = self.last_tevs[slot].y + self:clearState(slot) return { ges = "hold_release", pos = Geom:new{ - x = self.last_tev.x, - y = self.last_tev.y, + x = last_x, + y = last_y, w = 0, h = 0, } } From 4d4ad5fd4bc57bff9dd6614326b43d56d30500ab Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 2 Mar 2013 22:24:21 +0800 Subject: [PATCH 2/7] cleanup: use local variables in time arithmetic --- frontend/ui/time.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/ui/time.lua b/frontend/ui/time.lua index 90f8eb84d..c4548bf6e 100644 --- a/frontend/ui/time.lua +++ b/frontend/ui/time.lua @@ -59,7 +59,7 @@ function TimeVal:__eq(time_b) end function TimeVal:__sub(time_b) - diff = TimeVal:new{} + local diff = TimeVal:new{} diff.sec = self.sec - time_b.sec diff.usec = self.usec - time_b.usec @@ -76,7 +76,7 @@ function TimeVal:__sub(time_b) end function TimeVal:__add(time_b) - sum = TimeVal:new{} + local sum = TimeVal:new{} sum.sec = self.sec + time_b.sec sum.usec = self.usec + time_b.usec From 94a69b87a774dce1f0edcb104b9563ccea0becad Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 2 Mar 2013 23:11:23 +0800 Subject: [PATCH 3/7] add gesture emitting rate in GestureRange --- frontend/ui/gesturedetector.lua | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/frontend/ui/gesturedetector.lua b/frontend/ui/gesturedetector.lua index 98cf4f762..b28aed3a4 100644 --- a/frontend/ui/gesturedetector.lua +++ b/frontend/ui/gesturedetector.lua @@ -2,7 +2,10 @@ require "ui/geometry" GestureRange = { ges = nil, + -- spatial range limits the gesture emitting position range = nil, + -- temproal range limits the gesture emitting rate + rate = nil, } function GestureRange:new(o) @@ -18,6 +21,15 @@ function GestureRange:match(gs) end if self.range:contains(gs.pos) then + if self.rate then + local last_time = self.last_time or TimeVal:new{} + if gs.time - last_time > TimeVal:new{usec = 1000000 / self.rate} then + self.last_time = gs.time + return true + else + return false + end + end return true end @@ -194,7 +206,8 @@ function GestureDetector:tapState(tev) x = self.last_tevs[slot].x, y = self.last_tevs[slot].y, w = 0, h = 0, - } + }, + time = tev.timev, } -- cur_tap is used for double tap detection local cur_tap = { @@ -281,6 +294,7 @@ function GestureDetector:panState(tev) direction = swipe_direct, -- use first pan tev coordination as swipe start point pos = start_pos, + time = tev.timev, --@TODO add start and end points? (houqp) } end @@ -298,6 +312,7 @@ function GestureDetector:panState(tev) y = 0, }, pos = nil, + time = tev.timev, } pan_ev.relative.x = tev.x - self.last_tevs[slot].x pan_ev.relative.y = tev.y - self.last_tevs[slot].y @@ -322,7 +337,8 @@ function GestureDetector:holdState(tev, hold) x = self.last_tevs[slot].x, y = self.last_tevs[slot].y, w = 0, h = 0, - } + }, + time = tev.timev, } end if tev.id == -1 then @@ -337,7 +353,8 @@ function GestureDetector:holdState(tev, hold) x = last_x, y = last_y, w = 0, h = 0, - } + }, + time = tev.timev, } end end From 27935a2f3cbffd00b939ccb82576150802e85a43 Mon Sep 17 00:00:00 2001 From: chrox Date: Sat, 2 Mar 2013 23:13:29 +0800 Subject: [PATCH 4/7] set rate in pan GestureRange in bbox widget --- frontend/ui/bbox.lua | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/frontend/ui/bbox.lua b/frontend/ui/bbox.lua index e19bd0731..561a49121 100644 --- a/frontend/ui/bbox.lua +++ b/frontend/ui/bbox.lua @@ -24,6 +24,13 @@ function BBoxWidget:init() GestureRange:new{ ges = "pan", range = self.view.dimen, + rate = 3.0, -- emit up to 3 evs per second + } + }, + HoldAdjust = { + GestureRange:new{ + ges = "hold", + range = self.view.dimen, } }, ConfirmAdjust = { @@ -87,7 +94,7 @@ function BBoxWidget:inPageArea(ges) return not ges.pos:notIntersectWith(page_dimen) end -function BBoxWidget:adjustScreenBBox(ges, rate) +function BBoxWidget:adjustScreenBBox(ges) --DEBUG("adjusting crop bbox with pos", ges.pos) if not self:inPageArea(ges) then return end local bbox = self.screen_bbox @@ -135,17 +142,8 @@ function BBoxWidget:adjustScreenBBox(ges, rate) x1 = math.round(bottom_right.x), y1 = math.round(bottom_right.y) } - if rate then - local last_time = self.last_time or {0, 0} - local this_time = { util.gettime() } - local elap_time = (this_time[1] - last_time[1]) * 1000 + (this_time[2] - last_time[2]) / 1000 -- in millisec - if elap_time > 1000 / rate then - UIManager.repaint_all = true - self.last_time = this_time - end - else - UIManager.repaint_all = true - end + + UIManager.repaint_all = true end function BBoxWidget:getModifiedPageBBox() @@ -158,8 +156,12 @@ function BBoxWidget:onTapAdjust(arg, ges) end function BBoxWidget:onPanAdjust(arg, ges) - -- up to 3 updates per second - self:adjustScreenBBox(ges, 3.0) + self:adjustScreenBBox(ges) + return true +end + +function BBoxWidget:onHoldAdjust(arg, ges) + self:adjustScreenBBox(ges) return true end From fcfe82f4a5f13df695341fff29525dadebf3a25d Mon Sep 17 00:00:00 2001 From: chrox Date: Sun, 3 Mar 2013 22:18:38 +0800 Subject: [PATCH 5/7] add direction and distance in pan/swipe gesture --- frontend/ui/gesturedetector.lua | 57 +++++++++++++++++---------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/frontend/ui/gesturedetector.lua b/frontend/ui/gesturedetector.lua index b28aed3a4..d4faa9a58 100644 --- a/frontend/ui/gesturedetector.lua +++ b/frontend/ui/gesturedetector.lua @@ -124,32 +124,31 @@ end --[[ compare last_pan with first_tev in this slot -if it is a swipe, return direction of swipe gesture. +return pan direction and distance --]] +function GestureDetector:getPath(tev) + local slot = tev.slot + local x_diff = self.last_tevs[slot].x - self.first_tevs[slot].x + local y_diff = self.last_tevs[slot].y - self.first_tevs[slot].y + local direction = nil + local distance = math.sqrt(x_diff*x_diff + y_diff*y_diff) + if x_diff == 0 and y_diff == 0 then + elseif (math.abs(x_diff) > math.abs(y_diff)) then + direction = x_diff < 0 and "left" or "right" + else + direction = y_diff < 0 and "up" or "down" + end + return direction, distance +end + function GestureDetector:isSwipe(tev) local slot = tev.slot local tv_diff = self.first_tevs[slot].timev - self.last_tevs[slot].timev if (tv_diff.sec == 0) and (tv_diff.usec < self.SWIPE_INTERVAL) then local x_diff = self.last_tevs[slot].x - self.first_tevs[slot].x local y_diff = self.last_tevs[slot].y - self.first_tevs[slot].y - if x_diff == 0 and y_diff == 0 then - return nil - end - - if (math.abs(x_diff) > math.abs(y_diff)) then - -- left or right - if x_diff < 0 then - return "left" - else - return "right" - end - else - -- up or down - if y_diff < 0 then - return "up" - else - return "down" - end + if x_diff ~= 0 or y_diff ~= 0 then + return true end end end @@ -195,7 +194,7 @@ end this method handles both single and double tap --]] function GestureDetector:tapState(tev) - DEBUG("in tap state...", tev) + DEBUG("in tap state...") local slot = tev.slot if tev.id == -1 then -- end of tap event @@ -276,13 +275,13 @@ function GestureDetector:tapState(tev) end function GestureDetector:panState(tev) - DEBUG("in pan state...", tev) + DEBUG("in pan state...") local slot = tev.slot if tev.id == -1 then -- end of pan, signal swipe gesture if necessary - local swipe_direct = self:isSwipe(tev) - if swipe_direct then - DEBUG("swipe", swipe_direct, "detected in slot", slot) + if self:isSwipe(tev) then + local swipe_direction, swipe_distance = self:getPath(tev) + DEBUG("swipe", swipe_direction, swipe_distance, "detected in slot", slot) local start_pos = Geom:new{ x = self.first_tevs[slot].x, y = self.first_tevs[slot].y, @@ -291,11 +290,11 @@ function GestureDetector:panState(tev) self:clearState(slot) return { ges = "swipe", - direction = swipe_direct, -- use first pan tev coordination as swipe start point pos = start_pos, + direction = swipe_direction, + distance = swipe_distance, time = tev.timev, - --@TODO add start and end points? (houqp) } end self:clearState(slot) @@ -303,7 +302,7 @@ function GestureDetector:panState(tev) if self.states[slot] ~= self.panState then self.states[slot] = self.panState end - + local pan_direction, pan_distance = self:getPath(tev) local pan_ev = { ges = "pan", relative = { @@ -312,6 +311,8 @@ function GestureDetector:panState(tev) y = 0, }, pos = nil, + direction = pan_direction, + distance = pan_distance, time = tev.timev, } pan_ev.relative.x = tev.x - self.last_tevs[slot].x @@ -326,7 +327,7 @@ function GestureDetector:panState(tev) end function GestureDetector:holdState(tev, hold) - DEBUG("in hold state...", tev, hold) + DEBUG("in hold state...") local slot = tev.slot -- when we switch to hold state, we pass additional param "hold" if tev.id ~= -1 and hold and self.last_tevs[slot].x and self.last_tevs[slot].y then From 1bd8dfcee1124e2e718a8bfbecca9d1aae962397 Mon Sep 17 00:00:00 2001 From: chrox Date: Sun, 3 Mar 2013 22:23:28 +0800 Subject: [PATCH 6/7] add flipping mode in pdf/djvu reader By tapping on the upper left corner of the reader one can toggling flipping mode on/off. In flipping mode swiping right/down and left/up will paging backward and forward accordingly with pages proportional to swiping distance. --- frontend/ui/reader/readerflip.lua | 16 +++++++ frontend/ui/reader/readermenu.lua | 5 +- frontend/ui/reader/readerpaging.lua | 74 ++++++++++++++++++++++++++++- frontend/ui/reader/readerview.lua | 11 +++++ 4 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 frontend/ui/reader/readerflip.lua diff --git a/frontend/ui/reader/readerflip.lua b/frontend/ui/reader/readerflip.lua new file mode 100644 index 000000000..9331b3f7c --- /dev/null +++ b/frontend/ui/reader/readerflip.lua @@ -0,0 +1,16 @@ + +ReaderFlipping = LeftContainer:new{} + +function ReaderFlipping:init() + local widget = ImageWidget:new{ + file = "resources/icons/appbar.book.open.png", + } + local icon_size = widget:getSize() + self.dimen = Geom:new{w = Screen:getWidth(), h = icon_size.h} + self[1] = widget +end + +function ReaderFlipping:onSetDogearVisibility(visible) + self.view.dogear_visible = visible + return true +end \ No newline at end of file diff --git a/frontend/ui/reader/readermenu.lua b/frontend/ui/reader/readermenu.lua index 05b613857..1f53b2b0b 100644 --- a/frontend/ui/reader/readermenu.lua +++ b/frontend/ui/reader/readermenu.lua @@ -21,8 +21,9 @@ function ReaderMenu:initGesListener() GestureRange:new{ ges = "tap", range = Geom:new{ - x = 0, y = 0, - w = Screen:getWidth()*7/8, + x = Screen:getWidth()/8, + y = 0, + w = Screen:getWidth()*3/4, h = Screen:getHeight()/4, } } diff --git a/frontend/ui/reader/readerpaging.lua b/frontend/ui/reader/readerpaging.lua index f0cda7905..6c7bba0c3 100644 --- a/frontend/ui/reader/readerpaging.lua +++ b/frontend/ui/reader/readerpaging.lua @@ -68,7 +68,38 @@ function ReaderPaging:initGesListener() h = 5*Screen:getHeight()/8, } } - } + }, + ToggleFlipping = { + GestureRange:new{ + ges = "tap", + range = Geom:new{ + x = 0, y = 0, + w = Screen:getWidth()/8, + h = Screen:getHeight()/8 + } + } + }, + Swipe = { + GestureRange:new{ + ges = "swipe", + range = Geom:new{ + x = 0, y = 0, + w = Screen:getWidth(), + h = Screen:getHeight(), + } + } + }, + Pan = { + GestureRange:new{ + ges = "pan", + range = Geom:new{ + x = 0, y = 0, + w = Screen:getWidth(), + h = Screen:getHeight(), + }, + rate = 4.0, + } + }, } end @@ -95,6 +126,47 @@ function ReaderPaging:onTapBackward() return true end +function ReaderPaging:onToggleFlipping() + self.view.flipping_visible = not self.view.flipping_visible + self.flipping_page = self.view.flipping_visible and self.current_page or nil + UIManager:setDirty(self.view.dialog, "partial") +end + +function ReaderPaging:onSwipe(arg, ges) + if self.flipping_page == nil then + if ges.direction == "left" or ges.direction == "up" then + self:onGotoPageRel(1) + elseif ges.direction == "right" or ges.direction == "down" then + self:onGotoPageRel(-1) + end + elseif self.flipping_page then + self:gotoPage(self.flipping_page) + end + return true +end + +function ReaderPaging:onPan(arg, ges) + if self.flipping_page then + local read = self.flipping_page - 1 + local unread = self.number_of_pages - self.flipping_page + local whole = self.number_of_pages + local rel_proportion = ges.distance / Screen:getWidth() + local abs_proportion = ges.distance / Screen:getHeight() + if ges.direction == "right" then + self:gotoPage(self.flipping_page - math.floor(read*rel_proportion)) + elseif ges.direction == "left" then + self:gotoPage(self.flipping_page + math.floor(unread*rel_proportion)) + elseif ges.direction == "down" then + self:gotoPage(self.flipping_page - math.floor(whole*abs_proportion)) + elseif ges.direction == "up" then + self:gotoPage(self.flipping_page + math.floor(whole*abs_proportion)) + end + + UIManager:setDirty(self.view.dialog, "partial") + end + return true +end + function ReaderPaging:onZoomModeUpdate(new_mode) -- we need to remember zoom mode to handle page turn event self.zoom_mode = new_mode diff --git a/frontend/ui/reader/readerview.lua b/frontend/ui/reader/readerview.lua index 1a3e54ac2..8cc5f2110 100644 --- a/frontend/ui/reader/readerview.lua +++ b/frontend/ui/reader/readerview.lua @@ -1,3 +1,4 @@ +require "ui/reader/readerflip" require "ui/reader/readerfooter" require "ui/reader/readerdogear" @@ -30,6 +31,8 @@ ReaderView = OverlapGroup:new{ footer_visible = false, -- has dogear dogear_visible = false, + -- in flipping state + flipping_visible = false, } function ReaderView:init() @@ -43,8 +46,12 @@ function ReaderView:resetLayout() self.footer = ReaderFooter:new{ view = self, } + self.flipping = ReaderFlipping:new{ + view = self, + } self[1] = self.dogear self[2] = self.footer + self[3] = self.flipping end function ReaderView:paintTo(bb, x, y) @@ -109,6 +116,10 @@ function ReaderView:paintTo(bb, x, y) if self.footer_visible then self.footer:paintTo(bb, x, y) end + -- paint flipping + if self.flipping_visible then + self.flipping:paintTo(bb, x, y) + end end --[[ From 3c1e49253a10fe4fe4643164824f9dd09da01074 Mon Sep 17 00:00:00 2001 From: chrox Date: Sun, 3 Mar 2013 22:33:08 +0800 Subject: [PATCH 7/7] add resources files for page flipping --- resources/icons/appbar.book.open.png | Bin 0 -> 207 bytes resources/icons/src/appbar.book.open.xaml | 4 ++++ 2 files changed, 4 insertions(+) create mode 100644 resources/icons/appbar.book.open.png create mode 100644 resources/icons/src/appbar.book.open.xaml diff --git a/resources/icons/appbar.book.open.png b/resources/icons/appbar.book.open.png new file mode 100644 index 0000000000000000000000000000000000000000..3bfb7a491e74bfa425da5d4fddfe740d787304a9 GIT binary patch literal 207 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnL3?x0byx0z;*aCb)Tm^*q|NsC0#K-d!P=qnb z+uensgH_f8$l)yTh%5$bzYfBTP8zc-fP(BLp1!W^cbS=aWn|8tf20Q#^7nLc4B@z* z{DYr`hvO0dfA;D&{xj@9B<*Z+o~K*gTe~DWM4fbsRq2 literal 0 HcmV?d00001 diff --git a/resources/icons/src/appbar.book.open.xaml b/resources/icons/src/appbar.book.open.xaml new file mode 100644 index 000000000..a25855937 --- /dev/null +++ b/resources/icons/src/appbar.book.open.xaml @@ -0,0 +1,4 @@ + + + +