This commit is contained in:
Giorgio Micotti
2013-07-23 19:41:16 +02:00
16 changed files with 181 additions and 83 deletions

View File

@@ -74,6 +74,17 @@ function Geom:transformByScale(zx, zy)
self:scaleBy(zx, zy)
end
--[[
return size of geom
]]--
function Geom:sizeof()
if not self.w or not self.h then
return 0
else
return self.w * self.h
end
end
--[[
enlarges or shrinks dimensions or rectangles
@@ -91,7 +102,8 @@ return the outer rectangle that contains both us and a given rectangle
works for rectangles, dimensions and points
]]--
function Geom:combine(rect_b)
local combined = Geom:new(self)
local combined = self:copy()
if not rect_b or rect_b:sizeof() == 0 then return combined end
if combined.x > rect_b.x then
combined.x = rect_b.x
end

View File

@@ -596,7 +596,7 @@ function GestureDetector:holdState(tev, hold)
}
else
local ges_ev = self:handlePan(tev)
ges_ev.ges = "hold_pan"
if ges_ev ~= nil then ges_ev.ges = "hold_pan" end
return ges_ev
end
end

View File

@@ -36,7 +36,7 @@ end
function ReaderFrontLight:onAdjust(arg, ges)
if self.lipc_handle and self.intensity ~=nil then
local rel_proportion = ges.distance / Screen:getWidth()
local delta_int = self.steps[math.ceil(#self.steps*rel_proportion)]
local delta_int = self.steps[math.ceil(#self.steps*rel_proportion)] or self.steps[#self.steps]
local msg = ""
if ges.direction == "north" then
msg = _("Increase front light intensity to ")
@@ -55,6 +55,7 @@ function ReaderFrontLight:setIntensity(intensity, msg)
if self.lipc_handle then
intensity = intensity < 0 and 0 or intensity
intensity = intensity > 24 and 24 or intensity
self.intensity = intensity
self.lipc_handle:set_int_property("com.lab126.powerd", "flIntensity", intensity)
UIManager:show(Notification:new{
text = msg..intensity,

View File

@@ -244,6 +244,8 @@ end
function ReaderPaging:onPanRelease(arg, ges)
if self.flipping_mode then
self:updateFlippingPage(self.current_page)
else
UIManager.full_refresh = true
end
end
@@ -516,7 +518,8 @@ function ReaderPaging:onScrollPanRel(diff)
end
-- update current pageno to the very last part in current view
self:gotoPage(self.view.page_states[#self.view.page_states].page, "scrolling")
UIManager:setDirty(self.view.dialog)
UIManager:setDirty(self.view.dialog, "fast")
end
function ReaderPaging:onScrollPageRel(diff)

View File

@@ -72,19 +72,38 @@ function Screen:init()
self.cur_rotation_mode = self.native_rotation_mode
end
function Screen:refresh(refesh_type)
if self.native_rotation_mode == self.cur_rotation_mode then
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 > self.width and self.width or math.ceil(w) end
if h then h = h > self.height and self.height 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)
self.fb:refresh(refesh_type, waveform_mode, x, y, w, h)
end
function Screen:getSize()

View File

@@ -10,18 +10,34 @@ Screen:init()
-- initialize the input handling
Input:init()
WAVEFORM_MODE_INIT = 0x0 -- Screen goes to white (clears)
WAVEFORM_MODE_DU = 0x1 -- Grey->white/grey->black
WAVEFORM_MODE_GC16 = 0x2 -- High fidelity (flashing)
WAVEFORM_MODE_GC4 = WAVEFORM_MODE_GC16 -- For compatibility
WAVEFORM_MODE_GC16_FAST = 0x3 -- Medium fidelity
WAVEFORM_MODE_A2 = 0x4 -- Faster but even lower fidelity
WAVEFORM_MODE_GL16 = 0x5 -- High fidelity from white transition
WAVEFORM_MODE_GL16_FAST = 0x6 -- Medium fidelity from white transition
WAVEFORM_MODE_AUTO = 0x101
-- there is only one instance of this
UIManager = {
-- change this to set refresh type for next refresh
-- defaults to 1 initially and will be set to 1 after each refresh
refresh_type = 1,
default_refresh_type = 1,
-- change this to set refresh waveform for next refresh
-- default to WAVEFORM_MODE_GC16
default_waveform_mode = WAVEFORM_MODE_GC16,
fast_waveform_mode = WAVEFORM_MODE_A2,
-- force to repaint all the widget is stack, will be reset to false
-- after each ui loop
repaint_all = false,
-- force to do full refresh, will be reset to false
-- after each ui loop
full_refresh = false,
-- force to do patial refresh, will be reset to false
-- after each ui loop
patial_refresh = false,
-- trigger a full refresh when counter reaches FULL_REFRESH_COUNT
FULL_REFRESH_COUNT = DRCOUNTMAX,
refresh_count = 0,
@@ -173,6 +189,8 @@ function UIManager:run()
local dirty = false
local request_full_refresh = false
local force_full_refresh = false
local force_patial_refresh = false
local force_fast_refresh = false
for _, widget in ipairs(self._window_stack) do
if self.repaint_all or self._dirty[widget.widget] then
widget.widget:paintTo(Screen.bb, widget.x, widget.y)
@@ -182,37 +200,58 @@ function UIManager:run()
if self._dirty[widget.widget] == "full" then
force_full_refresh = true
end
if self._dirty[widget.widget] == "partial" then
force_patial_refresh = true
end
if self._dirty[widget.widget] == "fast" then
force_fast_refresh = true
end
-- and remove from list after painting
self._dirty[widget.widget] = nil
-- trigger repaint
dirty = true
end
end
if self.full_refresh then
dirty = true
force_full_refresh = true
end
if self.patial_refresh then
dirty = true
force_patial_refresh = true
end
self.repaint_all = false
self.full_refresh = false
self.patial_refresh = false
local refresh_type = self.default_refresh_type
local waveform_mode = self.default_waveform_mode
if dirty then
if force_full_refresh then
self.refresh_count = self.FULL_REFRESH_COUNT - 1
if force_patial_refresh or force_fast_refresh then
refresh_type = 1
elseif force_full_refresh or self.refresh_count == self.FULL_REFRESH_COUNT - 1 then
refresh_type = 0
end
if self.refresh_count == self.FULL_REFRESH_COUNT - 1 then
self.refresh_type = 0
if force_fast_refresh then
self.waveform_mode = self.fast_waveform_mode
end
if self.update_region_func then
local update_region = self.update_region_func()
Screen:refresh(refresh_type, waveform_mode,
update_region.x, update_region.y,
update_region.w, update_region.h)
else
self.refresh_type = 1
Screen:refresh(refresh_type, waveform_mode)
end
-- refresh FB
Screen:refresh(self.refresh_type) -- TODO: refresh explicitly only repainted area
-- increase refresh_count only when full refresh is requested or performed
local refresh_increment = (request_full_refresh or self.refresh_type == 0) and 1 or 0
self.refresh_count = (self.refresh_count + refresh_increment)%self.FULL_REFRESH_COUNT
-- reset refresh_type
self.refresh_type = 1
if self.refresh_type == 0 then
self.refresh_count = 0
elseif not force_patial_refresh and not force_full_refresh then
self.refresh_count = (self.refresh_count + 1)%self.FULL_REFRESH_COUNT
end
self.update_region_func = nil
end
self:checkTasks()

View File

@@ -13,6 +13,8 @@ ButtonTable = VerticalGroup:new{
padding = scaleByDPI(2),
zero_sep = false,
button_font_face = "cfont",
button_font_size = 20,
}
function ButtonTable:init()
@@ -33,8 +35,8 @@ function ButtonTable:init()
bordersize = 0,
margin = 0,
padding = 0,
text_font_face = "cfont",
text_font_size = 18,
text_font_face = self.button_font_face,
text_font_size = self.button_font_size,
}
local button_dim = button:getSize()
local vertical_sep = LineWidget:new{

View File

@@ -31,18 +31,23 @@ end
function MenuBarItem:invert(invert)
self[1].invert = invert
UIManager:setDirty(self.config, "partial")
UIManager.update_region_func = function()
DEBUG("update icon region", self[1].dimen)
return self[1].dimen
end
UIManager:setDirty(self.config, "full")
end
OptionTextItem = InputContainer:new{}
function OptionTextItem:init()
local text_widget = self[1]
self.dimen = text_widget:getSize()
self[1] = UnderlineContainer:new{
text_widget,
padding = self.padding,
color = self.color,
}
}
self.dimen = self[1]:getSize()
-- we need this table per-instance, so we declare it here
if Device:isTouchDevice() then
self.ges_events = {
@@ -255,7 +260,6 @@ function ConfigOption:init()
end
end
end
if self.options[c].item_text then
for d = 1, #self.options[c].item_text do
local option_item = nil
@@ -421,13 +425,10 @@ function ConfigDialog:init()
------------------------------------------
-- start to set up widget layout ---------
------------------------------------------
self.config_panel = ConfigPanel:new{
config_dialog = self,
}
self.config_menubar = MenuBar:new{
config_dialog = self,
}
self:makeDialog()
self:update()
------------------------------------------
-- start to set up input event callback --
------------------------------------------
@@ -449,19 +450,17 @@ function ConfigDialog:init()
self.key_events.FocusRight = nil
end
self.key_events.Select = { {"Press"}, doc = _("select current menu item") }
UIManager:setDirty(self, "partial")
end
function ConfigDialog:updateConfigPanel(index)
self.panel_index = index
self.config_panel = ConfigPanel:new{
index = index,
config_dialog = self,
}
end
function ConfigDialog:makeDialog()
function ConfigDialog:update()
self.config_panel = ConfigPanel:new{
index = self.panel_index,
config_dialog = self,
}
self.dialog_frame = FrameContainer:new{
background = 0,
VerticalGroup:new{
@@ -477,9 +476,18 @@ function ConfigDialog:makeDialog()
end
function ConfigDialog:onShowConfigPanel(index)
self:updateConfigPanel(index)
self:makeDialog()
self.panel_index = index
local orig_dimen = self.dialog_frame and self.dialog_frame.dimen or Geom:new{}
self:update()
UIManager.repaint_all = true
UIManager.full_refresh = true
UIManager.update_region_func = function()
local update_region = self.dialog_frame.dimen:combine(orig_dimen)
DEBUG("update region", update_region)
return update_region
end
return true
end
@@ -487,12 +495,13 @@ function ConfigDialog:onConfigChoice(option_name, option_value)
--DEBUG("config option value", option_name, option_value)
self.configurable[option_name] = option_value
self.ui:handleEvent(Event:new("StartActivityIndicator"))
return true
end
function ConfigDialog:onConfigEvent(option_event, option_arg)
--DEBUG("config option event", option_event, option_arg)
self.ui:handleEvent(Event:new(option_event, option_arg))
self:onShowConfigPanel(self.panel_index)
return true
end
function ConfigDialog:closeDialog()

View File

@@ -204,16 +204,12 @@ UnderlineContainer = WidgetContainer:new{
}
function UnderlineContainer:getSize()
if self.dimen then
return { w = self.dimen.w, h = self.dimen.h }
else
return self:getContentSize()
end
return self:getContentSize()
end
function UnderlineContainer:getContentSize()
local contentSize = self[1]:getSize()
return {
return Geom:new{
w = contentSize.w,
h = contentSize.h + self.linesize + self.padding
}

View File

@@ -10,9 +10,9 @@ DictQuickLookup = InputContainer:new{
dictionary = nil,
definition = nil,
dict_index = 1,
title_face = Font:getFace("tfont", 20),
word_face = Font:getFace("tfont", 18),
content_face = Font:getFace("cfont", 18),
title_face = Font:getFace("tfont", 22),
word_face = Font:getFace("tfont", 20),
content_face = Font:getFace("cfont", 20),
width = nil,
title_padding = scaleByDPI(5),
@@ -81,6 +81,8 @@ function DictQuickLookup:update()
}
local button_table = ButtonTable:new{
width = math.max(self.width, definition:getSize().w),
button_font_face = "cfont",
button_font_size = 20,
buttons = {
{
{
@@ -154,6 +156,8 @@ function DictQuickLookup:update()
dimen = Screen:getSize(),
self.dict_frame,
}
UIManager.repaint_all = true
UIManager.full_refresh = true
end
function DictQuickLookup:isPrevDictAvaiable()
@@ -177,8 +181,15 @@ function DictQuickLookup:changeDictionary(index)
self.dictionary = self.results[index].dict
self.lookupword = self.results[index].word
self.definition = self.results[index].definition
local orig_dimen = self.dict_frame and self.dict_frame.dimen or Geom:new{}
self:update()
UIManager.repaint_all = true
UIManager.update_region_func = function()
local update_region = self.dict_frame.dimen:combine(orig_dimen)
DEBUG("update region", update_region)
return update_region
end
end
function DictQuickLookup:changeToDefaultDict()

View File

@@ -29,6 +29,11 @@ end
function ImageWidget:paintTo(bb, x, y)
local size = self:getSize()
self.dimen = Geom:new{
x = x, y = y,
w = size.w,
h = size.h
}
bb:blitFrom(self._bb, x, y, 0, 0, size.w, size.h)
if self.invert then
bb:invertRect(x, y, size.w, size.h)

View File

@@ -118,7 +118,7 @@ function TextBoxWidget:_render()
local font_height = self.face.size
local line_height_px = self.line_height * font_height
local space_w = sizeUtf8Text(0, Screen:getWidth(), self.face, " ", true).x
local h = (font_height + line_height_px) * #v_list - line_height_px
local h = (font_height + line_height_px) * #v_list
self._bb = Blitbuffer.new(self.width, h)
local y = font_height
local pen_x = 0
@@ -127,7 +127,7 @@ function TextBoxWidget:_render()
for _,w in ipairs(l) do
--@TODO Don't use kerning for monospaced fonts. (houqp)
-- refert to cb25029dddc42693cc7aaefbe47e9bd3b7e1a750 in master tree
renderUtf8Text(self._bb, pen_x, y*0.8, self.face, w.word,
renderUtf8Text(self._bb, pen_x, y, self.face, w.word,
true, self.bgcolor, self.fgcolor)
local is_ascii = not w.word:match("[%z\194-\244][\128-\191]*")
pen_x = pen_x + w.width + (is_ascii and space_w or 0)

View File

@@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: KOReader\n"
"Report-Msgid-Bugs-To: https://github.com/koreader/koreader-base/issues\n"
"POT-Creation-Date: 2013-06-16 04:18+0000\n"
"PO-Revision-Date: 2013-07-01 07:58+0000\n"
"PO-Revision-Date: 2013-07-18 13:07+0000\n"
"Last-Translator: automaticjack <automaticjack@hotmail.it>\n"
"Language-Team: Italian (Italy) (http://www.transifex.com/projects/p/koreader/language/it_IT/)\n"
"MIME-Version: 1.0\n"
@@ -212,7 +212,7 @@ msgstr "Interlinea"
#: frontend/ui/reader/readerhighlight.lua:198
msgid "More"
msgstr ""
msgstr "Più opzioni"
#: reader.lua:127
msgid "No reader engine for this file"

View File

@@ -4,13 +4,14 @@
# Translators:
# Antoine Kamel <antoine12@gmail.com>, 2013
# Carcara <tiagoprudente@gmail.com>, 2013
# Carcara <tiagoprudente@gmail.com>, 2013
msgid ""
msgstr ""
"Project-Id-Version: KOReader\n"
"Report-Msgid-Bugs-To: https://github.com/koreader/koreader-base/issues\n"
"POT-Creation-Date: 2013-06-16 04:18+0000\n"
"PO-Revision-Date: 2013-07-07 02:08+0000\n"
"Last-Translator: Antoine Kamel <antoine12@gmail.com>\n"
"PO-Revision-Date: 2013-07-23 06:55+0000\n"
"Last-Translator: houqp <dave2008713@gmail.com>\n"
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/projects/p/koreader/language/pt_BR/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -84,7 +85,7 @@ msgstr "Cancelar"
#: frontend/ui/reader/readerhyphenation.lua:21
msgid "Change Hyphenation to "
msgstr "Mudar hifenação para"
msgstr "Mudar hifenação para "
#: frontend/ui/reader/readerfont.lua:5
msgid "Change font"
@@ -100,19 +101,19 @@ msgstr "Contraste"
#: frontend/ui/reader/readerfont.lua:124
msgid "Decrease font size to "
msgstr "Diminuir tamanho de fonte para"
msgstr "Diminuir tamanho de fonte para "
#: frontend/ui/reader/readerfrontlight.lua:42
msgid "Decrease front light intensity to "
msgstr "Diminuir intensidade da luz para"
msgstr "Diminuir intensidade da luz para "
#: frontend/ui/reader/readerfont.lua:192
msgid "Decrease gamma to "
msgstr "Diminuir gamute para"
msgstr "Diminuir gamute para "
#: frontend/ui/reader/readerfont.lua:163
msgid "Decrease line space to "
msgstr "Diminuir entrelinhas para"
msgstr "Diminuir entrelinhas para "
#: frontend/ui/data/strings.lua:15
msgid "Defect Size"
@@ -184,19 +185,19 @@ msgstr "Se você der o nome de um diretório ao invés de um caminho para um arq
#: frontend/ui/reader/readerfont.lua:126
msgid "Increase font size to "
msgstr "Aumentar tamanho de fonte para"
msgstr "Aumentar tamanho de fonte para "
#: frontend/ui/reader/readerfrontlight.lua:38
msgid "Increase front light intensity to "
msgstr "Aumentar intensidade da luz para"
msgstr "Aumentar intensidade da luz para "
#: frontend/ui/reader/readerfont.lua:189
msgid "Increase gamma to "
msgstr "Aumentar gamute para"
msgstr "Aumentar gamute para "
#: frontend/ui/reader/readerfont.lua:167
msgid "Increase line space to "
msgstr "Aumentar entrelinhas para"
msgstr "Aumentar entrelinhas para "
#: frontend/ui/data/strings.lua:18
msgid "Indentation"
@@ -250,7 +251,7 @@ msgstr "Leia todos os livros no seu aparelho e-ink"
#: frontend/ui/reader/readerfont.lua:215
msgid "Redrawing with font "
msgstr "Redesenhar com fonte"
msgstr "Redesenhar com fonte "
#: frontend/ui/data/koptoptions.lua:146 frontend/ui/data/strings.lua:12
msgid "Reflow"
@@ -282,7 +283,7 @@ msgstr "Selecionar Item de Opção"
#: frontend/ui/reader/readerfont.lua:148
msgid "Set font size to "
msgstr "Mudar tamanho de fonte para"
msgstr "Mudar tamanho de fonte para "
#: frontend/ui/reader/readertypeset.lua:2
msgid "Set render style"
@@ -571,7 +572,7 @@ msgstr "ligado"
#: frontend/ui/data/strings.lua:47
msgid "page"
msgstr "página "
msgstr "página"
#: frontend/ui/widget/menu.lua:431
msgid "page "

View File

@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://github.com/koreader/koreader-base/issues\n"
"POT-Creation-Date: 2013-06-16 04:18+0000\n"
"POT-Creation-Date: 2013-06-26 05:35+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"

View File

@@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: KOReader\n"
"Report-Msgid-Bugs-To: https://github.com/koreader/koreader-base/issues\n"
"POT-Creation-Date: 2013-06-16 04:18+0000\n"
"PO-Revision-Date: 2013-06-18 13:46+0000\n"
"PO-Revision-Date: 2013-07-14 06:22+0000\n"
"Last-Translator: chrox <chrox.huang@gmail.com>\n"
"Language-Team: Chinese (China) (http://www.transifex.com/projects/p/koreader/language/zh_CN/)\n"
"MIME-Version: 1.0\n"
@@ -84,7 +84,7 @@ msgstr "取消"
#: frontend/ui/reader/readerhyphenation.lua:21
msgid "Change Hyphenation to "
msgstr "断字设置为"
msgstr "Hyphenation设置为"
#: frontend/ui/reader/readerfont.lua:5
msgid "Change font"
@@ -100,19 +100,19 @@ msgstr "字体黑度"
#: frontend/ui/reader/readerfont.lua:124
msgid "Decrease font size to "
msgstr "字体大小减小为"
msgstr "字体大小设置为"
#: frontend/ui/reader/readerfrontlight.lua:42
msgid "Decrease front light intensity to "
msgstr " 前光亮度调低至"
msgstr " 前光亮度设置为"
#: frontend/ui/reader/readerfont.lua:192
msgid "Decrease gamma to "
msgstr "灰度系数减小为"
msgstr "灰度系数设置为"
#: frontend/ui/reader/readerfont.lua:163
msgid "Decrease line space to "
msgstr "行距减小为"
msgstr "行距设置为"
#: frontend/ui/data/strings.lua:15
msgid "Defect Size"
@@ -184,19 +184,19 @@ msgstr "如果提供的是路径参数,"
#: frontend/ui/reader/readerfont.lua:126
msgid "Increase font size to "
msgstr "字体大小增加为"
msgstr "字体大小设置为"
#: frontend/ui/reader/readerfrontlight.lua:38
msgid "Increase front light intensity to "
msgstr " 前光亮度调高至"
msgstr " 前光亮度设置为"
#: frontend/ui/reader/readerfont.lua:189
msgid "Increase gamma to "
msgstr "灰度系数增加为"
msgstr "Gamma校正为"
#: frontend/ui/reader/readerfont.lua:167
msgid "Increase line space to "
msgstr "行距增加为"
msgstr "行距设置为"
#: frontend/ui/data/strings.lua:18
msgid "Indentation"
@@ -242,7 +242,7 @@ msgstr "页边距"
msgid ""
"Please report bugs to https://github.com/koreader/ koreader/issues, Click at"
" the bottom of the page for more options"
msgstr "Bug反馈请访问https://github.com/koreader/ koreader/issues。获取更多选项请点击页面下方。"
msgstr "Bug反馈请访问 https://github.com/koreader/ koreader/issues。更多设置选项请点击屏幕下方。"
#: reader.lua:196
msgid "Read all the books on your E-Ink reader"