mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
fixed menu info displaying, replaced debug() by DEBUG()
the replacement of debug() was necessary to be able to access the lua library "debug" (for backtraces etc.)
This commit is contained in:
@@ -88,7 +88,7 @@ function Document:getPageDimensions(pageno, zoom, rotation)
|
||||
native_dimen.w, native_dimen.h = native_dimen.h, native_dimen.w
|
||||
end
|
||||
native_dimen:scaleBy(zoom)
|
||||
debug("dimen for pageno", pageno, "zoom", zoom, "rotation", rotation, "is", native_dimen)
|
||||
DEBUG("dimen for pageno", pageno, "zoom", zoom, "rotation", rotation, "is", native_dimen)
|
||||
return native_dimen
|
||||
end
|
||||
|
||||
|
||||
@@ -89,10 +89,10 @@ function PdfDocument:renderPage(pageno, rect, zoom, rotation)
|
||||
-- we prefer to render the full page, if it fits into cache
|
||||
if not Cache:willAccept(size.w * size.h / 2) then
|
||||
-- whole page won't fit into cache
|
||||
debug("rendering only part of the page")
|
||||
DEBUG("rendering only part of the page")
|
||||
-- TODO: figure out how to better segment the page
|
||||
if not rect then
|
||||
debug("aborting, since we do not have a specification for that part")
|
||||
DEBUG("aborting, since we do not have a specification for that part")
|
||||
-- required part not given, so abort
|
||||
return
|
||||
end
|
||||
@@ -145,11 +145,11 @@ function PdfDocument:drawPage(target, x, y, rect, pageno, zoom, rotation)
|
||||
if not tile then
|
||||
tile = Cache:check(hash_excerpt)
|
||||
if not tile then
|
||||
debug("rendering")
|
||||
DEBUG("rendering")
|
||||
tile = self:renderPage(pageno, rect, zoom, rotation)
|
||||
end
|
||||
end
|
||||
debug("now painting", tile)
|
||||
DEBUG("now painting", tile)
|
||||
target:blitFrom(tile.bb, x, y, rect.x - tile.excerpt.x, rect.y - tile.excerpt.y, rect.w, rect.h)
|
||||
end
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ function dump(data)
|
||||
return table.concat(out)
|
||||
end
|
||||
|
||||
function debug(...)
|
||||
function DEBUG(...)
|
||||
local line = ""
|
||||
for i,v in ipairs(arg) do
|
||||
if type(v) == "table" then
|
||||
|
||||
@@ -193,7 +193,7 @@ function ConfirmBox:onClose()
|
||||
end
|
||||
|
||||
function ConfirmBox:onSelect()
|
||||
debug("selected:", self.selected.x)
|
||||
DEBUG("selected:", self.selected.x)
|
||||
if self.selected.x == 1 then
|
||||
self:ok_callback()
|
||||
else
|
||||
@@ -324,11 +324,6 @@ MenuItem = InputContainer:new{
|
||||
shortcut = nil,
|
||||
shortcut_style = "square",
|
||||
_underline_container = nil,
|
||||
|
||||
key_events = {
|
||||
Select = { {"Press"}, doc = "chose selected item" },
|
||||
ShowItemDetail = { {"Right"}, doc = "show item detail" }
|
||||
}
|
||||
}
|
||||
|
||||
function MenuItem:init()
|
||||
@@ -343,8 +338,14 @@ function MenuItem:init()
|
||||
-- 15 for HorizontalSpan,
|
||||
self.content_width = self.width - shortcut_icon_w - 15
|
||||
|
||||
-- we need this table per-instance, so we declare it here
|
||||
self.active_key_events = {
|
||||
Select = { {"Press"}, doc = "chose selected item" },
|
||||
}
|
||||
|
||||
w = sizeUtf8Text(0, self.width, self.face, self.text, true).x
|
||||
if w >= self.content_width then
|
||||
self.active_key_events.ShowItemDetail = { {"Right"}, doc = "show item detail" }
|
||||
indicator = " >>"
|
||||
indicator_w = sizeUtf8Text(0, self.width, self.face, indicator, true).x
|
||||
self.text = getSubTextByWidth(self.text, self.face,
|
||||
@@ -381,15 +382,17 @@ end
|
||||
|
||||
function MenuItem:onFocus()
|
||||
self._underline_container.color = 10
|
||||
self.key_events = self.active_key_events
|
||||
return true
|
||||
end
|
||||
|
||||
function MenuItem:onUnfocus()
|
||||
self._underline_container.color = 0
|
||||
self.key_events = { }
|
||||
return true
|
||||
end
|
||||
|
||||
function MenuItem:onShowDetail()
|
||||
function MenuItem:onShowItemDetail()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text=self.detail,
|
||||
})
|
||||
@@ -554,13 +557,6 @@ function Menu:onPrevPage()
|
||||
return true
|
||||
end
|
||||
|
||||
function Menu:onShowItemDetail()
|
||||
self.layout[self.selected.y][self.selected.x]:handleEvent(
|
||||
Event:new("ShowDetail")
|
||||
)
|
||||
return true
|
||||
end
|
||||
|
||||
function Menu:onSelect()
|
||||
UIManager:close(self)
|
||||
self.on_select_callback(self.item_table[(self.page-1)*self.perpage+self.selected.y])
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require "settings" -- for debug()
|
||||
require "settings" -- for DEBUG()
|
||||
|
||||
Font = {
|
||||
fontmap = {
|
||||
@@ -54,11 +54,11 @@ function Font:getFace(font, size)
|
||||
realname = self.fontdir.."/"..realname
|
||||
ok, face = pcall(freetype.newFace, realname, size)
|
||||
if not ok then
|
||||
debug("#! Font "..font.." ("..realname..") not supported: "..face)
|
||||
DEBUG("#! Font "..font.." ("..realname..") not supported: "..face)
|
||||
return nil
|
||||
end
|
||||
self.faces[font..size] = face
|
||||
--debug("getFace, found: "..realname.." size:"..size)
|
||||
--DEBUG("getFace, found: "..realname.." size:"..size)
|
||||
end
|
||||
return { size = size, ftface = face, hash = font..size }
|
||||
end
|
||||
|
||||
@@ -174,12 +174,12 @@ end
|
||||
check if our size is smaller than the size of the given dimension/rectangle
|
||||
]]--
|
||||
function Geom:__lt(rect_b)
|
||||
debug("lt:",self,rect_b)
|
||||
DEBUG("lt:",self,rect_b)
|
||||
if self.w < rect_b.w and self.h < rect_b.h then
|
||||
debug("lt+")
|
||||
DEBUG("lt+")
|
||||
return true
|
||||
end
|
||||
debug("lt-")
|
||||
DEBUG("lt-")
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ function Input:waitEvent(timeout_us, timeout_s)
|
||||
ev = nil
|
||||
break
|
||||
end
|
||||
debug("got error waiting for events:", ev)
|
||||
DEBUG("got error waiting for events:", ev)
|
||||
if ev ~= "Waiting for input failed: 4\n" then
|
||||
-- we abort if the error is not EINTR
|
||||
break
|
||||
|
||||
@@ -31,7 +31,7 @@ function ReaderPaging:gotoPage(number)
|
||||
or number < 1 then
|
||||
return false
|
||||
end
|
||||
debug("going to page number", number)
|
||||
DEBUG("going to page number", number)
|
||||
|
||||
-- this is an event to allow other controllers to be aware of this change
|
||||
self.ui:handleEvent(Event:new("PageUpdate", number))
|
||||
@@ -44,7 +44,7 @@ function ReaderPaging:onPageUpdate(new_page_no)
|
||||
end
|
||||
|
||||
function ReaderPaging:onGotoPercent(percent)
|
||||
debug("goto document offset in percent:", percent)
|
||||
DEBUG("goto document offset in percent:", percent)
|
||||
local dest = math.floor(self.number_of_pages * percent / 100)
|
||||
if dest < 1 then dest = 1 end
|
||||
if dest > self.number_of_pages then
|
||||
@@ -55,7 +55,7 @@ function ReaderPaging:onGotoPercent(percent)
|
||||
end
|
||||
|
||||
function ReaderPaging:onGotoPageRel(diff)
|
||||
debug("goto relative page:", diff)
|
||||
DEBUG("goto relative page:", diff)
|
||||
self:gotoPage(self.current_page + diff)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -22,7 +22,7 @@ end
|
||||
|
||||
function ReaderPanning:onPanning(args, key)
|
||||
local dx, dy = unpack(args)
|
||||
debug("key =", key)
|
||||
DEBUG("key =", key)
|
||||
-- for now, bounds checking/calculation is done in the view
|
||||
self.view:PanningUpdate(
|
||||
dx * self.panning_steps.normal * self.dimen.w / 100,
|
||||
|
||||
@@ -16,7 +16,7 @@ ReaderView = WidgetContainer:new{
|
||||
}
|
||||
|
||||
function ReaderView:paintTo(bb, x, y)
|
||||
debug("painting", self.visible_area, "to", x, y)
|
||||
DEBUG("painting", self.visible_area, "to", x, y)
|
||||
local inner_offset = Geom:new{x = 0, y = 0}
|
||||
|
||||
-- draw surrounding space, if any
|
||||
@@ -61,14 +61,14 @@ function ReaderView:onSetDimensions(dimensions)
|
||||
end
|
||||
|
||||
function ReaderView:PanningUpdate(dx, dy)
|
||||
debug("pan by", dx, dy)
|
||||
DEBUG("pan by", dx, dy)
|
||||
local old = Geom:copy(self.visible_area)
|
||||
self.visible_area:offsetWithin(self.page_area, dx, dy)
|
||||
if self.visible_area ~= old then
|
||||
-- flag a repaint
|
||||
UIManager:setDirty(self.dialog)
|
||||
debug(self.page_area)
|
||||
debug(self.visible_area)
|
||||
DEBUG(self.page_area)
|
||||
DEBUG(self.visible_area)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -63,13 +63,13 @@ function ReaderZooming:setZoom()
|
||||
end
|
||||
|
||||
function ReaderZooming:onZoom(direction)
|
||||
debug("zoom", direction)
|
||||
DEBUG("zoom", direction)
|
||||
if direction == "in" then
|
||||
self.zoom = self.zoom * 1.333333
|
||||
elseif direction == "out" then
|
||||
self.zoom = self.zoom * 0.75
|
||||
end
|
||||
debug("zoom is now at", self.zoom)
|
||||
DEBUG("zoom is now at", self.zoom)
|
||||
self:onSetZoomMode("free")
|
||||
self.view:ZoomUpdate(self.zoom)
|
||||
return true
|
||||
@@ -77,7 +77,7 @@ end
|
||||
|
||||
function ReaderZooming:onSetZoomMode(what)
|
||||
if self.zoom_mode ~= what then
|
||||
debug("setting zoom mode to", what)
|
||||
DEBUG("setting zoom mode to", what)
|
||||
self.zoom_mode = what
|
||||
self:setZoom()
|
||||
end
|
||||
|
||||
@@ -76,7 +76,7 @@ function ReaderUI:init()
|
||||
end
|
||||
|
||||
function ReaderUI:onClose()
|
||||
debug("closing reader")
|
||||
DEBUG("closing reader")
|
||||
if self.document then
|
||||
self.document:close()
|
||||
self.document = false
|
||||
|
||||
@@ -13,7 +13,7 @@ function getGlyph(face, charcode)
|
||||
end
|
||||
local rendered_glyph = face.ftface:renderGlyph(charcode)
|
||||
if not rendered_glyph then
|
||||
debug("error rendering glyph (charcode=", charcode, ") for face", face)
|
||||
DEBUG("error rendering glyph (charcode=", charcode, ") for face", face)
|
||||
return
|
||||
end
|
||||
glyph = CacheItem:new{rendered_glyph}
|
||||
@@ -48,7 +48,7 @@ end
|
||||
|
||||
function sizeUtf8Text(x, width, face, text, kerning)
|
||||
if text == nil then
|
||||
debug("sizeUtf8Text called without text");
|
||||
DEBUG("sizeUtf8Text called without text");
|
||||
return
|
||||
end
|
||||
-- may still need more adaptive pen placement when kerning,
|
||||
@@ -64,14 +64,14 @@ function sizeUtf8Text(x, width, face, text, kerning)
|
||||
if kerning and prevcharcode then
|
||||
local kern = face.ftface:getKerning(prevcharcode, charcode)
|
||||
pen_x = pen_x + kern
|
||||
--debug("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." kern:"..kern)
|
||||
--DEBUG("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." kern:"..kern)
|
||||
else
|
||||
--debug("curr:"..string.char(charcode))
|
||||
--DEBUG("curr:"..string.char(charcode))
|
||||
end
|
||||
pen_x = pen_x + glyph.ax
|
||||
pen_y_top = math.max(pen_y_top, glyph.t)
|
||||
pen_y_bottom = math.max(pen_y_bottom, glyph.bb:getHeight() - glyph.t)
|
||||
--debug("ax:"..glyph.ax.." t:"..glyph.t.." r:"..glyph.r.." h:"..glyph.bb:getHeight().." w:"..glyph.bb:getWidth().." yt:"..pen_y_top.." yb:"..pen_y_bottom)
|
||||
--DEBUG("ax:"..glyph.ax.." t:"..glyph.t.." r:"..glyph.r.." h:"..glyph.bb:getHeight().." w:"..glyph.bb:getWidth().." yt:"..pen_y_top.." yb:"..pen_y_bottom)
|
||||
prevcharcode = charcode
|
||||
end
|
||||
end
|
||||
@@ -80,7 +80,7 @@ end
|
||||
|
||||
function renderUtf8Text(buffer, x, y, face, text, kerning)
|
||||
if text == nil then
|
||||
debug("renderUtf8Text called without text");
|
||||
DEBUG("renderUtf8Text called without text");
|
||||
return 0
|
||||
end
|
||||
-- may still need more adaptive pen placement when kerning,
|
||||
@@ -94,10 +94,10 @@ function renderUtf8Text(buffer, x, y, face, text, kerning)
|
||||
if kerning and prevcharcode then
|
||||
local kern = face.ftface:getKerning(prevcharcode, charcode)
|
||||
pen_x = pen_x + kern
|
||||
--debug("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." pen_x:"..pen_x.." kern:"..kern)
|
||||
--DEBUG("prev:"..string.char(prevcharcode).." curr:"..string.char(charcode).." pen_x:"..pen_x.." kern:"..kern)
|
||||
buffer:addblitFrom(glyph.bb, x + pen_x + glyph.l, y - glyph.t, 0, 0, glyph.bb:getWidth(), glyph.bb:getHeight())
|
||||
else
|
||||
--debug(" curr:"..string.char(charcode))
|
||||
--DEBUG(" curr:"..string.char(charcode))
|
||||
buffer:blitFrom(glyph.bb, x + pen_x + glyph.l, y - glyph.t, 0, 0, glyph.bb:getWidth(), glyph.bb:getHeight())
|
||||
end
|
||||
pen_x = pen_x + glyph.ax
|
||||
|
||||
@@ -103,6 +103,6 @@ function Screen:restoreFromBB(bb)
|
||||
if bb then
|
||||
fb.bb:blitFullFrom(bb)
|
||||
else
|
||||
debug("Got nil bb in restoreFromSavedBB!")
|
||||
DEBUG("Got nil bb in restoreFromSavedBB!")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@ require "ui/inputevent"
|
||||
require "ui/widget"
|
||||
require "ui/screen"
|
||||
require "ui/dialog"
|
||||
require "settings" -- for debug(), TODO: put debug() somewhere else
|
||||
require "settings" -- for DEBUG(), TODO: put DEBUG() somewhere else
|
||||
|
||||
|
||||
-- we also initialize the framebuffer
|
||||
@@ -136,11 +136,11 @@ function UIManager:run()
|
||||
end
|
||||
until all_tasks_checked
|
||||
|
||||
--debug("---------------------------------------------------")
|
||||
--debug("exec stack", self._execution_stack)
|
||||
--debug("window stack", self._window_stack)
|
||||
--debug("dirty stack", self._dirty)
|
||||
--debug("---------------------------------------------------")
|
||||
--DEBUG("---------------------------------------------------")
|
||||
--DEBUG("exec stack", self._execution_stack)
|
||||
--DEBUG("window stack", self._window_stack)
|
||||
--DEBUG("dirty stack", self._dirty)
|
||||
--DEBUG("---------------------------------------------------")
|
||||
|
||||
-- stop when we have no window to show (bug)
|
||||
if #self._window_stack == 0 then
|
||||
|
||||
Reference in New Issue
Block a user