mirror of
https://github.com/koreader/koreader
synced 2024-11-16 06:12:56 +00:00
e8aab49ee9
* [device][kindle4] add fake event to kindle4 * modify focusmanager to allow for more complex layout The focusmanager now naviguate the layout by avoiding nil value instead of relying on table lenght. It should be completely backward compatible * add Dpad naviguation to the touchmenu * fix crash because virtualkeyboard on non touch device the kindle4NT has no keyboard nor touch, the fix open the virtual keyboard so koreader dont crash but it's not useable * Enable device with keys to use the touchmenu * Don't get stuck in reader progress statistics plugin * [underlinecontainer] Fix and remove unused function References #1898.
48 lines
1.4 KiB
Lua
48 lines
1.4 KiB
Lua
--[[--
|
|
An UnderlineContainer is a WidgetContainer that is able to paint
|
|
a line under its child node.
|
|
--]]
|
|
|
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
|
local Geom = require("ui/geometry")
|
|
local Size = require("ui/size")
|
|
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
|
|
|
local UnderlineContainer = WidgetContainer:new{
|
|
linesize = Size.line.thick,
|
|
padding = Size.padding.tiny,
|
|
-- TODO: shouldn't this default to black instead?
|
|
color = Blitbuffer.COLOR_WHITE,
|
|
vertical_align = "top",
|
|
}
|
|
|
|
function UnderlineContainer:getSize()
|
|
local contentSize = self[1]:getSize()
|
|
return Geom:new{
|
|
w = contentSize.w,
|
|
h = contentSize.h + self.linesize + 2*self.padding
|
|
}
|
|
end
|
|
|
|
function UnderlineContainer:paintTo(bb, x, y)
|
|
local container_size = self:getSize()
|
|
self.dimen = Geom:new{
|
|
x = x, y = y,
|
|
w = container_size.w,
|
|
h = container_size.h
|
|
}
|
|
local content_size = self[1]:getSize()
|
|
local p_y = y
|
|
if self.vertical_align == "center" then
|
|
p_y = math.floor((container_size.h - content_size.h) / 2) + y
|
|
elseif self.vertical_align == "bottom" then
|
|
p_y = (container_size.h - content_size.h) + y
|
|
end
|
|
self[1]:paintTo(bb, x, p_y)
|
|
bb:paintRect(x, y + container_size.h - self.linesize,
|
|
container_size.w, self.linesize, self.color)
|
|
end
|
|
|
|
return UnderlineContainer
|