From 2154e7e852ced883f4e61518cada9a58c0612b6b Mon Sep 17 00:00:00 2001 From: HW Date: Tue, 22 Oct 2013 17:11:31 +0200 Subject: [PATCH] Further refactoring This should finish the work to make all globals to local variables. That allows LuaJIT to properly compile things by interning the references to the relevant parts (rather than looking up globals all the time which stops a trace). --- .../apps/filemanager/filemanagerhistory.lua | 2 + frontend/document/credocument.lua | 4 +- frontend/document/koptinterface.lua | 3 + frontend/ui/device.lua | 22 +- frontend/ui/device/screen.lua | 211 +++++++++++++++++ frontend/ui/gesturerange.lua | 2 +- frontend/ui/reader/readercoptlistener.lua | 1 + frontend/ui/reader/readercropping.lua | 3 +- frontend/ui/reader/readerdictionary.lua | 1 + frontend/ui/reader/readerfont.lua | 5 + frontend/ui/reader/readerfrontlight.lua | 3 + frontend/ui/reader/readerhighlight.lua | 6 + frontend/ui/reader/readermenu.lua | 2 + frontend/ui/reader/readerrolling.lua | 2 + frontend/ui/reader/readerrotation.lua | 1 + frontend/ui/reader/readertoc.lua | 1 + frontend/ui/reader/readertypeset.lua | 1 + frontend/ui/screen.lua | 212 +----------------- frontend/ui/widget/bboxwidget.lua | 5 + frontend/ui/widget/configdialog.lua | 1 + frontend/ui/widget/confirmbox.lua | 10 + .../ui/widget/container/inputcontainer.lua | 1 + frontend/ui/widget/dictquicklookup.lua | 6 + frontend/ui/widget/focusmanager.lua | 3 +- frontend/ui/widget/infomessage.lua | 5 + frontend/ui/widget/menu.lua | 1 + frontend/ui/widget/notification.lua | 3 + frontend/ui/widget/scrolltextwidget.lua | 3 + 28 files changed, 296 insertions(+), 224 deletions(-) create mode 100644 frontend/ui/device/screen.lua diff --git a/frontend/apps/filemanager/filemanagerhistory.lua b/frontend/apps/filemanager/filemanagerhistory.lua index 479b96ac2..549eea46e 100644 --- a/frontend/apps/filemanager/filemanagerhistory.lua +++ b/frontend/apps/filemanager/filemanagerhistory.lua @@ -1,4 +1,6 @@ local InputContainer = require("ui/widget/container/inputcontainer") +local CenterContainer = require("ui/widget/container/centercontainer") +local Menu = require("ui/widget/menu") local Screen = require("ui/screen") local UIManager = require("ui/uimanager") local DocSettings = require("docsettings") diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index 6f0b2e002..687ba9986 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -2,6 +2,8 @@ local Geom = require("ui/geometry") local CreOptions = require("ui/data/creoptions") local Document = require("document/document") local Configurable = require("ui/reader/configurable") +local Font = require("ui/font") +local Screen = require("ui/screen") -- TBD: DrawContext local CreDocument = Document:new{ @@ -22,7 +24,7 @@ local CreDocument = Document:new{ } -- NuPogodi, 20.05.12: inspect the zipfile content -function CreDocument:zipContentExt(fname) +function CreDocument.zipContentExt(self, fname) local outfile = "./data/zip_content" local s = "" os.execute("unzip ".."-l \""..fname.."\" > "..outfile) diff --git a/frontend/document/koptinterface.lua b/frontend/document/koptinterface.lua index f318b9c26..02455b141 100644 --- a/frontend/document/koptinterface.lua +++ b/frontend/document/koptinterface.lua @@ -2,6 +2,9 @@ local Document = require("document/document") local Cache = require("cache") local CacheItem = require("cacheitem") local Screen = require("ui/screen") +local Geom = require("ui/geometry") +local TileCacheItem = require("document/tilecacheitem") +local Dbg = require("dbg") -- TBD: KOPTContext local KoptInterface = { diff --git a/frontend/ui/device.lua b/frontend/ui/device.lua index 6a8f985ff..28ba2f474 100644 --- a/frontend/ui/device.lua +++ b/frontend/ui/device.lua @@ -1,8 +1,7 @@ local KindleFrontLight = require("ui/device/kindlefrontlight") local KoboFrontLight = require("ui/device/kobofrontlight") local BaseFrontLight = require("ui/device/basefrontlight") - --- Screen +local Screen = require("ui/device/screen") -- util -- lfs @@ -14,8 +13,11 @@ local Device = { model = nil, firmware_rev = nil, frontlight = nil, + screen = Screen } +Screen.device = Device + function Device:getModel() if self.model then return self.model end if util.isEmulated() then @@ -117,7 +119,7 @@ end function Device:intoScreenSaver() --os.execute("echo 'screensaver in' >> /mnt/us/event_test.txt") if self.charging_mode == false and self.screen_saver_mode == false then - Screen:saveCurrentBB() + self.screen:saveCurrentBB() --UIManager:show(InfoMessage:new{ --text = "Going into screensaver... ", --timeout = 2, @@ -135,8 +137,8 @@ function Device:outofScreenSaver() -- Blitbuffer. util.usleep(1500000) --os.execute("killall -stop cvm") - Screen:restoreFromSavedBB() - Screen:refresh(0) + self.screen:restoreFromSavedBB() + self.screen:refresh(0) self.survive_screen_saver = true end self.screen_saver_mode = false @@ -147,7 +149,7 @@ function Device:prepareSuspend() -- currently only used for kobo devices if fl ~= nil then fl.fl:sleep() end - Screen:refresh(0) + self.screen:refresh(0) self.screen_saver_mode = true end @@ -157,7 +159,7 @@ end function Device:Resume() -- currently only used for kobo devices os.execute("echo 0 > /sys/power/state-extended") - Screen:refresh(0) + self.screen:refresh(0) local fl = self:getFrontlight() if fl ~= nil then fl.fl:restore() @@ -168,7 +170,7 @@ end function Device:usbPlugIn() --os.execute("echo 'usb in' >> /mnt/us/event_test.txt") if self.charging_mode == false and self.screen_saver_mode == false then - Screen:saveCurrentBB() + self.screen:saveCurrentBB() --UIManager:show(InfoMessage:new{ --text = "Going into USB mode... ", --timeout = 2, @@ -184,8 +186,8 @@ function Device:usbPlugOut() if self.charging_mode == true and self.screen_saver_mode == false then --util.usleep(1500000) --os.execute("killall -stop cvm") - Screen:restoreFromSavedBB() - Screen:refresh(0) + self.screen:restoreFromSavedBB() + self.screen:refresh(0) end --@TODO signal filemanager for file changes 13.06 2012 (houqp) diff --git a/frontend/ui/device/screen.lua b/frontend/ui/device/screen.lua new file mode 100644 index 000000000..9a1b929c5 --- /dev/null +++ b/frontend/ui/device/screen.lua @@ -0,0 +1,211 @@ +local Geom = require("ui/geometry") + +-- Blitbuffer +-- einkfb + +--[[ +Codes for rotation modes: + +1 for no rotation, +2 for landscape with bottom on the right side of screen, etc. + + 2 + +--------------+ + | +----------+ | + | | | | + | | Freedom! | | + | | | | + | | | | + 3 | | | | 1 + | | | | + | | | | + | +----------+ | + | | + | | + +--------------+ + 0 +--]] + + +local Screen = { + width = 0, + height = 0, + native_rotation_mode = nil, + cur_rotation_mode = 0, + + bb = nil, + saved_bb = nil, + + fb = einkfb.open("/dev/fb0"), + -- will be set upon loading by Device class: + device = nil, +} + +function Screen:init() + -- for unknown strange reason, pitch*2 is 10 px more than screen width in KPW + self.width, self.height = self.fb:getSize() + -- Blitbuffer still uses inverted 4bpp bitmap, so pitch should be + -- (self.width / 2) + self.bb = Blitbuffer.new(self.width, self.height, self.width/2) + if self.width > self.height then + -- For another unknown strange reason, self.fb:getOrientation always + -- return 0 in KPW, even though we are in landscape mode. + -- Seems like the native framework change framebuffer on the fly when + -- starting booklet. Starting KPV from ssh and KPVBooklet will get + -- different framebuffer height and width. + -- + --self.native_rotation_mode = self.fb:getOrientation() + self.native_rotation_mode = 1 + else + self.native_rotation_mode = 0 + end + self.cur_rotation_mode = self.native_rotation_mode +end + +function Screen:refresh(refesh_type, waveform_mode, x, y, w, h) + if x then x = x < 0 and 0 or math.floor(x) end + if y then y = y < 0 and 0 or math.floor(y) end + if w then w = w + x > self.width and self.width - x or math.ceil(w) end + if h then h = h + y > self.height and self.height - y or math.ceil(h) end + if self.native_rotation_mode == self.cur_rotation_mode then + self.fb.bb:blitFrom(self.bb, 0, 0, 0, 0, self.width, self.height) + elseif self.native_rotation_mode == 0 and self.cur_rotation_mode == 1 then + self.fb.bb:blitFromRotate(self.bb, 270) + if x and y and w and h then + x, y = y, self.width - w - x + w, h = h, w + end + elseif self.native_rotation_mode == 0 and self.cur_rotation_mode == 3 then + self.fb.bb:blitFromRotate(self.bb, 90) + if x and y and w and h then + x, y = self.height - h - y, x + w, h = h, w + end + elseif self.native_rotation_mode == 1 and self.cur_rotation_mode == 0 then + self.fb.bb:blitFromRotate(self.bb, 90) + if x and y and w and h then + x, y = self.height - h - y, x + w, h = h, w + end + elseif self.native_rotation_mode == 1 and self.cur_rotation_mode == 3 then + self.fb.bb:blitFromRotate(self.bb, 180) + if x and y and w and h then + x, y = self.width - w - x, self.height - h - y + end + end + self.fb:refresh(refesh_type, waveform_mode, x, y, w, h) +end + +function Screen:getSize() + return Geom:new{w = self.width, h = self.height} +end + +function Screen:getWidth() + return self.width +end + +function Screen:getHeight() + return self.height +end + +function Screen:getDPI() + if(self.device:getModel() == "KindlePaperWhite") or (self.device:getModel() == "Kobo_kraken") then + return 212 + elseif self.device:getModel() == "Kobo_dragon" then + return 265 + elseif self.device:getModel() == "Kobo_pixie" then + return 200 + else + return 167 + end +end + +function Screen:scaleByDPI(px) + return math.floor(px * self:getDPI()/167) +end + +function Screen:rescaleByDPI(px) + return math.ceil(px * 167/self:getDPI()) +end + +function Screen:getPitch() + return self.fb:getPitch() +end + +function Screen:getNativeRotationMode() + -- in EMU mode, you will always get 0 from getOrientation() + return self.fb:getOrientation() +end + +function Screen:getRotationMode() + return self.cur_rotation_mode +end + +function Screen:getScreenMode() + if self.width > self.height then + return "landscape" + else + return "portrait" + end +end + +function Screen:setRotationMode(mode) + if mode > 3 or mode < 0 then + return + end + + -- mode 0 and mode 2 has the same width and height, so do mode 1 and 3 + if (self.cur_rotation_mode % 2) ~= (mode % 2) then + self.width, self.height = self.height, self.width + end + self.cur_rotation_mode = mode + self.bb:free() + self.bb = Blitbuffer.new(self.width, self.height, self.width/2) +end + +function Screen:setScreenMode(mode) + if mode == "portrait" then + if self.cur_rotation_mode ~= 0 then + self:setRotationMode(0) + end + elseif mode == "landscape" then + if self.cur_rotation_mode == 0 or self.cur_rotation_mode == 2 then + self:setRotationMode(1) + elseif self.cur_rotation_mode == 1 or self.cur_rotation_mode == 3 then + self:setRotationMode((self.cur_rotation_mode + 2) % 4) + end + end +end + +function Screen:saveCurrentBB() + local width, height = self:getWidth(), self:getHeight() + + if not self.saved_bb then + self.saved_bb = Blitbuffer.new(width, height, self.width/2) + end + if self.saved_bb:getWidth() ~= width then + self.saved_bb:free() + self.saved_bb = Blitbuffer.new(width, height, self.width/2) + end + self.saved_bb:blitFullFrom(self.bb) +end + +function Screen:restoreFromSavedBB() + self:restoreFromBB(self.saved_bb) +end + +function Screen:getCurrentScreenBB() + local bb = Blitbuffer.new(self:getWidth(), self:getHeight()) + bb:blitFullFrom(self.bb) + return bb +end + +function Screen:restoreFromBB(bb) + if bb then + self.bb:blitFullFrom(bb) + else + DEBUG("Got nil bb in restoreFromSavedBB!") + end +end + +return Screen diff --git a/frontend/ui/gesturerange.lua b/frontend/ui/gesturerange.lua index f299998b0..4b7d7363d 100644 --- a/frontend/ui/gesturerange.lua +++ b/frontend/ui/gesturerange.lua @@ -1,4 +1,4 @@ --- TimeVal +local TimeVal = require("ui/timeval") local GestureRange = { ges = nil, diff --git a/frontend/ui/reader/readercoptlistener.lua b/frontend/ui/reader/readercoptlistener.lua index 8b21b7b2c..78fd4e2fd 100644 --- a/frontend/ui/reader/readercoptlistener.lua +++ b/frontend/ui/reader/readercoptlistener.lua @@ -1,4 +1,5 @@ local EventListener = require("ui/widget/eventlistener") +local Event = require("ui/event") local ReaderCoptListener = EventListener:new{} diff --git a/frontend/ui/reader/readercropping.lua b/frontend/ui/reader/readercropping.lua index 368b7aa29..b27eb2ac7 100644 --- a/frontend/ui/reader/readercropping.lua +++ b/frontend/ui/reader/readercropping.lua @@ -8,8 +8,9 @@ local RightContainer = require("ui/widget/container/rightcontainer") local FrameContainer = require("ui/widget/container/framecontainer") local VerticalGroup = require("ui/widget/verticalgroup") local HorizontalGroup = require("ui/widget/horizontalgroup") +local BBoxWidget = require("ui/widget/bboxwidget") +local HorizontalSpan = require("ui/widget/horizontalspan") local Button = require("ui/widget/button") -local _ = require("gettext") local PageCropDialog = VerticalGroup:new{ ok_text = "OK", diff --git a/frontend/ui/reader/readerdictionary.lua b/frontend/ui/reader/readerdictionary.lua index 731e7ae64..75de3e792 100644 --- a/frontend/ui/reader/readerdictionary.lua +++ b/frontend/ui/reader/readerdictionary.lua @@ -1,6 +1,7 @@ local EventListener = require("ui/widget/eventlistener") local UIManager = require("ui/uimanager") local DictQuickLookup = require("ui/widget/dictquicklookup") +local Screen = require("ui/screen") local JSON = require("JSON") local ReaderDictionary = EventListener:new{} diff --git a/frontend/ui/reader/readerfont.lua b/frontend/ui/reader/readerfont.lua index ae77c3db6..8078eb558 100644 --- a/frontend/ui/reader/readerfont.lua +++ b/frontend/ui/reader/readerfont.lua @@ -1,6 +1,11 @@ local InputContainer = require("ui/widget/container/inputcontainer") +local CenterContainer = require("ui/widget/container/centercontainer") +local Menu = require("ui/widget/menu") +local Notification = require("ui/widget/notification") local Device = require("ui/device") local Screen = require("ui/screen") +local Input = require("ui/input") +local Event = require("ui/event") local UIManager = require("ui/uimanager") local _ = require("gettext") diff --git a/frontend/ui/reader/readerfrontlight.lua b/frontend/ui/reader/readerfrontlight.lua index f88c3319d..6addd2072 100644 --- a/frontend/ui/reader/readerfrontlight.lua +++ b/frontend/ui/reader/readerfrontlight.lua @@ -3,6 +3,9 @@ local Geom = require("ui/geometry") local Screen = require("ui/screen") local Device = require("ui/device") local GestureRange = require("ui/gesturerange") +local InputDialog = require("ui/widget/inputdialog") +local UIManager = require("ui/uimanager") +local Notification = require("ui/widget/notification") local _ = require("gettext") local ReaderFrontLight = InputContainer:new{ diff --git a/frontend/ui/reader/readerhighlight.lua b/frontend/ui/reader/readerhighlight.lua index c7e043a1e..edd7e9838 100644 --- a/frontend/ui/reader/readerhighlight.lua +++ b/frontend/ui/reader/readerhighlight.lua @@ -1,8 +1,14 @@ local InputContainer = require("ui/widget/container/inputcontainer") +local CenterContainer = require("ui/widget/container/centercontainer") +local FrameContainer = require("ui/widget/container/framecontainer") local GestureRange = require("ui/gesturerange") local Geom = require("ui/geometry") local Screen = require("ui/screen") local Device = require("ui/device") +local Event = require("ui/event") +local UIManager = require("ui/uimanager") +local ButtonTable = require("ui/widget/buttontable") +local Input = require("ui/input") local _ = require("gettext") local ReaderHighlight = InputContainer:new{} diff --git a/frontend/ui/reader/readermenu.lua b/frontend/ui/reader/readermenu.lua index 5a32c5ba7..70f0391d1 100644 --- a/frontend/ui/reader/readermenu.lua +++ b/frontend/ui/reader/readermenu.lua @@ -7,6 +7,8 @@ local GestureRange = require("ui/gesturerange") local Geom = require("ui/geometry") local Event = require("ui/event") local Screen = require("ui/screen") +local Menu = require("ui/widget/menu") +local InfoMessage = require("ui/widget/infomessage") local _ = require("gettext") local ReaderMenu = InputContainer:new{ diff --git a/frontend/ui/reader/readerrolling.lua b/frontend/ui/reader/readerrolling.lua index 7bc2fd6eb..a89e2b35e 100644 --- a/frontend/ui/reader/readerrolling.lua +++ b/frontend/ui/reader/readerrolling.lua @@ -1,7 +1,9 @@ local InputContainer = require("ui/widget/container/inputcontainer") local Screen = require("ui/screen") +local Device = require("ui/device") local Geom = require("ui/geometry") local Input = require("ui/input") +local Event = require("ui/event") local GestureRange = require("ui/gesturerange") local ReaderPanning = require("ui/reader/readerpanning") local _ = require("gettext") diff --git a/frontend/ui/reader/readerrotation.lua b/frontend/ui/reader/readerrotation.lua index 8876505cb..7cb1ae1d0 100644 --- a/frontend/ui/reader/readerrotation.lua +++ b/frontend/ui/reader/readerrotation.lua @@ -2,6 +2,7 @@ local InputContainer = require("ui/widget/container/inputcontainer") local Screen = require("ui/screen") local Geom = require("ui/geometry") local Device = require("ui/device") +local Event = require("ui/event") local GestureRange = require("ui/gesturerange") local _ = require("gettext") diff --git a/frontend/ui/reader/readertoc.lua b/frontend/ui/reader/readertoc.lua index 8f043f1e6..57fa4f48b 100644 --- a/frontend/ui/reader/readertoc.lua +++ b/frontend/ui/reader/readertoc.lua @@ -4,6 +4,7 @@ local Menu = require("ui/widget/menu") local Screen = require("ui/screen") local Device = require("ui/device") local UIManager = require("ui/uimanager") +local Event = require("ui/event") local _ = require("gettext") local ReaderToc = InputContainer:new{ diff --git a/frontend/ui/reader/readertypeset.lua b/frontend/ui/reader/readertypeset.lua index cfd1c698a..215b1e6cf 100644 --- a/frontend/ui/reader/readertypeset.lua +++ b/frontend/ui/reader/readertypeset.lua @@ -1,4 +1,5 @@ local InputContainer = require("ui/widget/container/inputcontainer") +local Event = require("ui/event") local _ = require("gettext") -- lfs diff --git a/frontend/ui/screen.lua b/frontend/ui/screen.lua index cbb24c5ce..784a9eac9 100644 --- a/frontend/ui/screen.lua +++ b/frontend/ui/screen.lua @@ -1,210 +1,2 @@ -local Device = require("ui/device") -local Geom = require("ui/geometry") - --- Blitbuffer --- einkfb - ---[[ -Codes for rotation modes: - -1 for no rotation, -2 for landscape with bottom on the right side of screen, etc. - - 2 - +--------------+ - | +----------+ | - | | | | - | | Freedom! | | - | | | | - | | | | - 3 | | | | 1 - | | | | - | | | | - | +----------+ | - | | - | | - +--------------+ - 0 ---]] - - -local Screen = { - width = 0, - height = 0, - native_rotation_mode = nil, - cur_rotation_mode = 0, - - bb = nil, - saved_bb = nil, - - fb = einkfb.open("/dev/fb0"), -} - -function Screen:init() - -- for unknown strange reason, pitch*2 is 10 px more than screen width in KPW - self.width, self.height = self.fb:getSize() - -- Blitbuffer still uses inverted 4bpp bitmap, so pitch should be - -- (self.width / 2) - self.bb = Blitbuffer.new(self.width, self.height, self.width/2) - if self.width > self.height then - -- For another unknown strange reason, self.fb:getOrientation always - -- return 0 in KPW, even though we are in landscape mode. - -- Seems like the native framework change framebuffer on the fly when - -- starting booklet. Starting KPV from ssh and KPVBooklet will get - -- different framebuffer height and width. - -- - --self.native_rotation_mode = self.fb:getOrientation() - self.native_rotation_mode = 1 - else - self.native_rotation_mode = 0 - end - self.cur_rotation_mode = self.native_rotation_mode -end - -function Screen:refresh(refesh_type, waveform_mode, x, y, w, h) - if x then x = x < 0 and 0 or math.floor(x) end - if y then y = y < 0 and 0 or math.floor(y) end - if w then w = w + x > self.width and self.width - x or math.ceil(w) end - if h then h = h + y > self.height and self.height - y or math.ceil(h) end - if self.native_rotation_mode == self.cur_rotation_mode then - self.fb.bb:blitFrom(self.bb, 0, 0, 0, 0, self.width, self.height) - elseif self.native_rotation_mode == 0 and self.cur_rotation_mode == 1 then - self.fb.bb:blitFromRotate(self.bb, 270) - if x and y and w and h then - x, y = y, self.width - w - x - w, h = h, w - end - elseif self.native_rotation_mode == 0 and self.cur_rotation_mode == 3 then - self.fb.bb:blitFromRotate(self.bb, 90) - if x and y and w and h then - x, y = self.height - h - y, x - w, h = h, w - end - elseif self.native_rotation_mode == 1 and self.cur_rotation_mode == 0 then - self.fb.bb:blitFromRotate(self.bb, 90) - if x and y and w and h then - x, y = self.height - h - y, x - w, h = h, w - end - elseif self.native_rotation_mode == 1 and self.cur_rotation_mode == 3 then - self.fb.bb:blitFromRotate(self.bb, 180) - if x and y and w and h then - x, y = self.width - w - x, self.height - h - y - end - end - self.fb:refresh(refesh_type, waveform_mode, x, y, w, h) -end - -function Screen:getSize() - return Geom:new{w = self.width, h = self.height} -end - -function Screen:getWidth() - return self.width -end - -function Screen:getHeight() - return self.height -end - -function Screen:getDPI() - if(Device:getModel() == "KindlePaperWhite") or (Device:getModel() == "Kobo_kraken") then - return 212 - elseif Device:getModel() == "Kobo_dragon" then - return 265 - elseif Device:getModel() == "Kobo_pixie" then - return 200 - else - return 167 - end -end - -function Screen:scaleByDPI(px) - return math.floor(px * self:getDPI()/167) -end - -function Screen:rescaleByDPI(px) - return math.ceil(px * 167/self:getDPI()) -end - -function Screen:getPitch() - return self.fb:getPitch() -end - -function Screen:getNativeRotationMode() - -- in EMU mode, you will always get 0 from getOrientation() - return self.fb:getOrientation() -end - -function Screen:getRotationMode() - return self.cur_rotation_mode -end - -function Screen:getScreenMode() - if self.width > self.height then - return "landscape" - else - return "portrait" - end -end - -function Screen:setRotationMode(mode) - if mode > 3 or mode < 0 then - return - end - - -- mode 0 and mode 2 has the same width and height, so do mode 1 and 3 - if (self.cur_rotation_mode % 2) ~= (mode % 2) then - self.width, self.height = self.height, self.width - end - self.cur_rotation_mode = mode - self.bb:free() - self.bb = Blitbuffer.new(self.width, self.height, self.width/2) -end - -function Screen:setScreenMode(mode) - if mode == "portrait" then - if self.cur_rotation_mode ~= 0 then - self:setRotationMode(0) - end - elseif mode == "landscape" then - if self.cur_rotation_mode == 0 or self.cur_rotation_mode == 2 then - self:setRotationMode(1) - elseif self.cur_rotation_mode == 1 or self.cur_rotation_mode == 3 then - self:setRotationMode((self.cur_rotation_mode + 2) % 4) - end - end -end - -function Screen:saveCurrentBB() - local width, height = self:getWidth(), self:getHeight() - - if not self.saved_bb then - self.saved_bb = Blitbuffer.new(width, height, self.width/2) - end - if self.saved_bb:getWidth() ~= width then - self.saved_bb:free() - self.saved_bb = Blitbuffer.new(width, height, self.width/2) - end - self.saved_bb:blitFullFrom(self.bb) -end - -function Screen:restoreFromSavedBB() - self:restoreFromBB(self.saved_bb) -end - -function Screen:getCurrentScreenBB() - local bb = Blitbuffer.new(self:getWidth(), self:getHeight()) - bb:blitFullFrom(self.bb) - return bb -end - -function Screen:restoreFromBB(bb) - if bb then - self.bb:blitFullFrom(bb) - else - DEBUG("Got nil bb in restoreFromSavedBB!") - end -end - -return Screen +-- compatibility wrapper +return require("ui/device").screen diff --git a/frontend/ui/widget/bboxwidget.lua b/frontend/ui/widget/bboxwidget.lua index d164fd80c..295bc906b 100644 --- a/frontend/ui/widget/bboxwidget.lua +++ b/frontend/ui/widget/bboxwidget.lua @@ -1,4 +1,9 @@ local InputContainer = require("ui/widget/container/inputcontainer") +local Geom = require("ui/geometry") +local Event = require("ui/event") +local UIManager = require("ui/uimanager") +local Device = require("ui/device") +local GestureRange = require("ui/gesturerange") --[[ BBoxWidget shows a bbox for page cropping diff --git a/frontend/ui/widget/configdialog.lua b/frontend/ui/widget/configdialog.lua index 824ec7a29..6c3589e27 100644 --- a/frontend/ui/widget/configdialog.lua +++ b/frontend/ui/widget/configdialog.lua @@ -7,6 +7,7 @@ local UnderlineContainer = require("ui/widget/container/underlinecontainer") local ImageWidget = require("ui/widget/imagewidget") local TextWidget = require("ui/widget/textwidget") local FixedTextWidget = require("ui/widget/fixedtextwidget") +local ProgressWidget = require("ui/widget/progresswidget") local ToggleSwitch = require("ui/widget/toggleswitch") local Font = require("ui/font") local Device = require("ui/device") diff --git a/frontend/ui/widget/confirmbox.lua b/frontend/ui/widget/confirmbox.lua index 127e6b353..bed5e6322 100644 --- a/frontend/ui/widget/confirmbox.lua +++ b/frontend/ui/widget/confirmbox.lua @@ -2,6 +2,16 @@ local CenterContainer = require("ui/widget/container/centercontainer") local FrameContainer = require("ui/widget/container/centercontainer") local FocusManager = require("ui/widget/focusmanager") local Button = require("ui/widget/button") +local VerticalGroup = require("ui/widget/verticalgroup") +local ImageWidget = require("ui/widget/imagewidget") +local TextBoxWidget = require("ui/widget/textboxwidget") +local Font = require("ui/font") +local UIManager = require("ui/uimanager") +local Screen = require("ui/screen") +local HorizontalGroup = require("ui/widget/horizontalgroup") +local VerticalSpan = require("ui/widget/verticalspan") +local HorizontalSpan = require("ui/widget/horizontalspan") +local _ = require("gettext") -- screen diff --git a/frontend/ui/widget/container/inputcontainer.lua b/frontend/ui/widget/container/inputcontainer.lua index 2d5583abf..a7ae4925f 100644 --- a/frontend/ui/widget/container/inputcontainer.lua +++ b/frontend/ui/widget/container/inputcontainer.lua @@ -1,5 +1,6 @@ local WidgetContainer = require("ui/widget/container/widgetcontainer") local Event = require("ui/event") +local Geom = require("ui/geometry") --[[ an InputContainer is an WidgetContainer that handles input events diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua index 6fc2a1e58..f02fe0174 100644 --- a/frontend/ui/widget/dictquicklookup.lua +++ b/frontend/ui/widget/dictquicklookup.lua @@ -9,6 +9,12 @@ local Screen = require("ui/screen") local GestureRange = require("ui/gesturerange") local Geom = require("ui/geometry") local Font = require("ui/font") +local Event = require("ui/event") +local UIManager = require("ui/uimanager") +local ButtonTable = require("ui/widget/buttontable") +local Device = require("ui/device") +local VerticalGroup = require("ui/widget/verticalgroup") +local _ = require("gettext") --[[ Display quick lookup word definition diff --git a/frontend/ui/widget/focusmanager.lua b/frontend/ui/widget/focusmanager.lua index aac793c71..8de7d2532 100644 --- a/frontend/ui/widget/focusmanager.lua +++ b/frontend/ui/widget/focusmanager.lua @@ -1,5 +1,6 @@ local InputContainer = require("ui/widget/container/inputcontainer") --- UIManager +local Event = require("ui/event") +local UIManager = require("ui/uimanager") --[[ Wrapper Widget that manages focus for a whole dialog diff --git a/frontend/ui/widget/infomessage.lua b/frontend/ui/widget/infomessage.lua index b44985f6e..e390e8afc 100644 --- a/frontend/ui/widget/infomessage.lua +++ b/frontend/ui/widget/infomessage.lua @@ -8,6 +8,11 @@ local ImageWidget = require("ui/widget/imagewidget") local TextBoxWidget = require("ui/widget/textboxwidget") local HorizontalSpan = require("ui/widget/horizontalspan") local UIManager = require("ui/uimanager") +local Geom = require("ui/geometry") +local CenterContainer = require("ui/widget/container/centercontainer") +local Input = require("ui/input") +local Screen = require("ui/screen") +local _ = require("gettext") --[[ Widget that displays an informational message diff --git a/frontend/ui/widget/menu.lua b/frontend/ui/widget/menu.lua index 0c66773b8..0e715f61c 100644 --- a/frontend/ui/widget/menu.lua +++ b/frontend/ui/widget/menu.lua @@ -19,6 +19,7 @@ local Screen = require("ui/screen") local Input = require("ui/input") local UIManager = require("ui/uimanager") local RenderText = require("ui/rendertext") +local InfoMessage = require("ui/widget/infomessage") local _ = require("gettext") --[[ diff --git a/frontend/ui/widget/notification.lua b/frontend/ui/widget/notification.lua index 59c8675ba..7414b743b 100644 --- a/frontend/ui/widget/notification.lua +++ b/frontend/ui/widget/notification.lua @@ -6,6 +6,9 @@ local Font = require("ui/font") local Geom = require("ui/geometry") local Device = require("ui/device") local UIManager = require("ui/uimanager") +local HorizontalGroup = require("ui/widget/horizontalgroup") +local Input = require("ui/input") +local Screen = require("ui/screen") --[[ Widget that displays a tiny notification on top of screen diff --git a/frontend/ui/widget/scrolltextwidget.lua b/frontend/ui/widget/scrolltextwidget.lua index a93fb9e45..9f9c03b23 100644 --- a/frontend/ui/widget/scrolltextwidget.lua +++ b/frontend/ui/widget/scrolltextwidget.lua @@ -5,6 +5,9 @@ local Geom = require("ui/geometry") local GestureRange = require("ui/gesturerange") local UIManager = require("ui/uimanager") local Screen = require("ui/screen") +local HorizontalGroup = require("ui/widget/horizontalgroup") +local HorizontalSpan = require("ui/widget/horizontalspan") +local Device = require("ui/device") --[[ Text widget with vertical scroll bar