Merge pull request #170 from chrox/master

bugfix: update to latest koreader-base
This commit is contained in:
{Qingping,Dave} Hou
2013-07-23 09:03:23 -07:00
8 changed files with 49 additions and 32 deletions

View File

@@ -108,7 +108,7 @@ function ReaderPaging:initGesListener()
w = Screen:getWidth(),
h = Screen:getHeight(),
},
rate = 5.0,
rate = 4.0,
}
},
PanRelease = {
@@ -246,7 +246,6 @@ function ReaderPaging:onPanRelease(arg, ges)
self:updateFlippingPage(self.current_page)
else
UIManager.full_refresh = true
UIManager:setDirty(self.view.dialog)
end
end
@@ -520,9 +519,7 @@ function ReaderPaging:onScrollPanRel(diff)
-- update current pageno to the very last part in current view
self:gotoPage(self.view.page_states[#self.view.page_states].page, "scrolling")
UIManager.waveform_mode = WAVEFORM_MODE_A2
UIManager.patial_refresh = true
UIManager:setDirty(self.view.dialog, "partial")
UIManager:setDirty(self.view.dialog, "fast")
end
function ReaderPaging:onScrollPageRel(diff)

View File

@@ -24,10 +24,11 @@ WAVEFORM_MODE_AUTO = 0x101
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
waveform_mode = 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,
@@ -189,6 +190,7 @@ function UIManager:run()
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)
@@ -198,54 +200,57 @@ function UIManager:run()
if self._dirty[widget.widget] == "full" then
force_full_refresh = true
end
if self._dirty[widget.widget] == "patial" then
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_patial_refresh then
self.refresh_type = 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
self.refresh_type = 0
else
self.refresh_type = 1
refresh_type = 0
end
if force_fast_refresh then
self.waveform_mode = self.fast_waveform_mode
end
--self.waveform_mode = self.fast_refresh and WAVEFORM_MODE_A2 or WAVEFORM_MODE_GC16
if self.update_region_func then
local update_region = self.update_region_func()
Screen:refresh(self.refresh_type, self.waveform_mode,
Screen:refresh(refresh_type, waveform_mode,
update_region.x, update_region.y,
update_region.w, update_region.h)
else
Screen:refresh(self.refresh_type, self.waveform_mode)
Screen:refresh(refresh_type, waveform_mode)
end
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
-- reset waveform_mode to WAVEFORM_MODE_GC16
self.waveform_mode = WAVEFORM_MODE_GC16
self.update_region_func = nil
end

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,7 +31,11 @@ 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{}
@@ -469,7 +473,6 @@ function ConfigDialog:update()
dimen = Screen:getSize(),
self.dialog_frame,
}
UIManager.repaint_all = true
end
function ConfigDialog:onShowConfigPanel(index)
@@ -478,6 +481,8 @@ function ConfigDialog:onShowConfigPanel(index)
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)

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 = {
{
{
@@ -155,6 +157,7 @@ function DictQuickLookup:update()
self.dict_frame,
}
UIManager.repaint_all = true
UIManager.full_refresh = true
end
function DictQuickLookup:isPrevDictAvaiable()

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)