2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

Added InfoMessage:drawTopMsg() method

Displaying a pop-up window for operations like adding a bookmark seems a
bit of an overkill for simple messages like "Bookmark added" or
"Bookmark already exists". Therefore, based on the suggestion by
@dracodoc I have implemented an InfoMessage:drawTopMsg() for this
purpose which just renders the text in the top left corner on a gray
background of auto-calculated appropriate width.
This commit is contained in:
Tigran Aivazian 2012-11-19 20:07:47 +00:00
parent d3b0be1bf4
commit 93a0db59a1
3 changed files with 12 additions and 4 deletions

View File

@ -625,9 +625,9 @@ function CREReader:adjustCreReaderCommands()
function(self)
ok = self:addBookmark(self.doc:getXPointer())
if not ok then
InfoMessage:inform("Page already marked ", DINFO_DELAY, 1, MSG_WARN)
InfoMessage:drawTopMsg("Bookmark already exists")
else
InfoMessage:inform("Page marked ", DINFO_DELAY, 1, MSG_WARN)
InfoMessage:drawTopMsg("Bookmark added")
end
end
)

View File

@ -261,3 +261,11 @@ function InfoMessage:saveInfoMessageSettings()
G_reader_settings:saveSetting("sound_volume", self.SoundVolume-1)
G_reader_settings:saveSetting("tts_speed", self.TTSspeed)
end
function InfoMessage:drawTopMsg(msg)
local face = Font:getFace("rifont", 18)
local len = sizeUtf8Text(0, G_width, face, msg, true).x + 20
fb.bb:paintRect(0, 0, len, 15+6*2, 4)
renderUtf8Text(fb.bb, 10, 15+6, face, msg, true)
fb:refresh(1)
end

View File

@ -2815,9 +2815,9 @@ function UniReader:addAllCommands()
function(unireader)
ok = unireader:addBookmark(self.pageno)
if not ok then
InfoMessage:inform("Page already marked ", DINFO_DELAY, 1, MSG_WARN)
InfoMessage:drawTopMsg("Bookmark already exists")
else
InfoMessage:inform("Page marked ", DINFO_DELAY, 1, MSG_WARN)
InfoMessage:drawTopMsg("Bookmark added")
end
end)
self.commands:addGroup(MOD_ALT.."K/L",{