unify color specification

colors were a mixture of 4bpp integers (0=white, 15=black) and
fractional blackness levels (0=white, 1.0=black) before. This is
now unified to use the color specification of the Blitbuffer API.
pull/1036/head
Hans-Werner Hilse 10 years ago
parent 03ac887d46
commit 5982e24d57

@ -18,6 +18,7 @@ local Event = require("ui/event")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local util = require("ffi/util") local util = require("ffi/util")
local Blitbuffer = require("ffi/blitbuffer")
local FileManager = InputContainer:extend{ local FileManager = InputContainer:extend{
title = _("FileManager"), title = _("FileManager"),
@ -124,7 +125,7 @@ function FileManager:init()
local fm_ui = FrameContainer:new{ local fm_ui = FrameContainer:new{
padding = 0, padding = 0,
bordersize = 0, bordersize = 0,
background = 0, background = Blitbuffer.COLOR_WHITE,
self.layout, self.layout,
} }

@ -16,6 +16,7 @@ local Event = require("ui/event")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local util = require("ffi/util") local util = require("ffi/util")
local Blitbuffer = require("ffi/blitbuffer")
local OPDSCatalog = InputContainer:extend{ local OPDSCatalog = InputContainer:extend{
title = _("OPDS Catalog"), title = _("OPDS Catalog"),
@ -58,7 +59,7 @@ function OPDSCatalog:init()
self[1] = FrameContainer:new{ self[1] = FrameContainer:new{
padding = 0, padding = 0,
bordersize = 0, bordersize = 0,
background = 0, background = Blitbuffer.COLOR_WHITE,
opds_browser, opds_browser,
} }

@ -13,6 +13,7 @@ local HorizontalSpan = require("ui/widget/horizontalspan")
local Button = require("ui/widget/button") local Button = require("ui/widget/button")
local Math = require("optmath") local Math = require("optmath")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local Blitbuffer = require("ffi/blitbuffer")
local PageCropDialog = VerticalGroup:new{ local PageCropDialog = VerticalGroup:new{
ok_text = "OK", ok_text = "OK",
@ -57,7 +58,7 @@ function PageCropDialog:init()
table.insert(horizontal_group, cancel_container) table.insert(horizontal_group, cancel_container)
self[2] = FrameContainer:new{ self[2] = FrameContainer:new{
horizontal_group, horizontal_group,
background = 0, background = Blitbuffer.COLOR_WHITE,
bordersize = 0, bordersize = 0,
padding = 0, padding = 0,
} }
@ -72,7 +73,7 @@ function ReaderCropping:onPageCrop(mode)
self.orig_view_dimen = Geom:new{w = self.view.dimen.w, h = self.view.dimen.h} self.orig_view_dimen = Geom:new{w = self.view.dimen.w, h = self.view.dimen.h}
-- backup original view bgcolor -- backup original view bgcolor
self.orig_view_bgcolor = self.view.outer_page_color self.orig_view_bgcolor = self.view.outer_page_color
self.view.outer_page_color = 7 -- gray bgcolor self.view.outer_page_color = Blitbuffer.gray(0.5) -- gray bgcolor
-- backup original zoom mode as cropping use "page" zoom mode -- backup original zoom mode as cropping use "page" zoom mode
self.orig_zoom_mode = self.view.zoom_mode self.orig_zoom_mode = self.view.zoom_mode
-- backup original page scroll -- backup original page scroll

@ -14,6 +14,7 @@ local Geom = require("ui/geometry")
local Event = require("ui/event") local Event = require("ui/event")
local Font = require("ui/font") local Font = require("ui/font")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local Blitbuffer = require("ffi/blitbuffer")
local ReaderFooter = InputContainer:new{ local ReaderFooter = InputContainer:new{
mode = 1, mode = 1,
@ -99,7 +100,7 @@ function ReaderFooter:init()
dimen = Geom:new{w = Screen:getWidth(), h = self.height*2}, dimen = Geom:new{w = Screen:getWidth(), h = self.height*2},
FrameContainer:new{ FrameContainer:new{
horizontal_group, horizontal_group,
background = 0, background = Blitbuffer.COLOR_WHITE,
bordersize = 0, bordersize = 0,
padding = 0, padding = 0,
} }

@ -34,7 +34,6 @@ end
function ReaderScreenshot:onScreenshot() function ReaderScreenshot:onScreenshot()
if os.execute("screenshot") ~= 0 then if os.execute("screenshot") ~= 0 then
Screen.bb:invert()
local screenshot_name = os.date("screenshots/Screenshot_%Y-%B-%d_%Hh%M.pam") local screenshot_name = os.date("screenshots/Screenshot_%Y-%B-%d_%Hh%M.pam")
UIManager:show(InfoMessage:new{ UIManager:show(InfoMessage:new{
text = _("Writing screen to ")..screenshot_name, text = _("Writing screen to ")..screenshot_name,
@ -42,7 +41,6 @@ function ReaderScreenshot:onScreenshot()
}) })
Screen.bb:writePAM(screenshot_name) Screen.bb:writePAM(screenshot_name)
DEBUG(screenshot_name) DEBUG(screenshot_name)
Screen.bb:invert()
end end
UIManager.full_refresh = true UIManager.full_refresh = true
return true return true

@ -7,6 +7,7 @@ local Screen = require("ui/screen")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Event = require("ui/event") local Event = require("ui/event")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local Blitbuffer = require("ffi/blitbuffer")
local _ = require("gettext") local _ = require("gettext")
local ReaderView = OverlapGroup:new{ local ReaderView = OverlapGroup:new{
@ -22,10 +23,10 @@ local ReaderView = OverlapGroup:new{
offset = nil, offset = nil,
bbox = nil, bbox = nil,
}, },
outer_page_color = DOUTER_PAGE_COLOR, outer_page_color = Blitbuffer.gray(DOUTER_PAGE_COLOR/15),
-- hightlight with "lighten" or "underscore" or "invert" -- hightlight with "lighten" or "underscore" or "invert"
highlight = { highlight = {
lighten_color = 0.2, -- color range [0.0, 1.0] lighten_factor = 0.2,
temp_drawer = "invert", temp_drawer = "invert",
temp = {}, temp = {},
saved_drawer = "lighten", saved_drawer = "lighten",
@ -34,13 +35,13 @@ local ReaderView = OverlapGroup:new{
highlight_visible = true, highlight_visible = true,
-- PDF/DjVu continuous paging -- PDF/DjVu continuous paging
page_scroll = nil, page_scroll = nil,
page_bgcolor = DBACKGROUND_COLOR, page_bgcolor = Blitbuffer.gray(DBACKGROUND_COLOR/15),
page_states = {}, page_states = {},
scroll_mode = "vertical", scroll_mode = "vertical",
page_gap = { page_gap = {
width = Screen:scaleByDPI(8), width = Screen:scaleByDPI(8),
height = Screen:scaleByDPI(8), height = Screen:scaleByDPI(8),
color = 8, color = Blitbuffer.gray(0.5),
}, },
-- DjVu page rendering mode (used in djvu.c:drawPage()) -- DjVu page rendering mode (used in djvu.c:drawPage())
render_mode = DRENDER_MODE, -- default to COLOR render_mode = DRENDER_MODE, -- default to COLOR
@ -431,12 +432,12 @@ function ReaderView:drawHighlightRect(bb, x, y, rect, drawer)
if drawer == "underscore" then if drawer == "underscore" then
self.highlight.line_width = self.highlight.line_width or 2 self.highlight.line_width = self.highlight.line_width or 2
self.highlight.line_color = self.highlight.line_color or 5 self.highlight.line_color = self.highlight.line_color or Blitbuffer.gray(0.33)
bb:paintRect(x, y+h-1, w, bb:paintRect(x, y+h-1, w,
self.highlight.line_width, self.highlight.line_width,
self.highlight.line_color) self.highlight.line_color)
elseif drawer == "lighten" then elseif drawer == "lighten" then
bb:lightenRect(x, y, w, h, self.highlight.lighten_color) bb:lightenRect(x, y, w, h, self.highlight.lighten_factor)
elseif drawer == "invert" then elseif drawer == "invert" then
bb:invertRect(x, y, w, h) bb:invertRect(x, y, w, h)
end end

@ -119,11 +119,14 @@ end
-- For the Kobo Aura an offset is needed, because the bezel make the -- For the Kobo Aura an offset is needed, because the bezel make the
-- visible screen smaller. -- visible screen smaller.
function Screen:PhoenixBezelCleaner() function Screen:PhoenixBezelCleaner()
-- bb.paintRect(x, y, w, h, color) self.bb:paintRect(0,0, Screen:getWidth(), Screen:offsetY(), Blitbuffer.COLOR_WHITE)
self.bb:paintRect(0,0, Screen:getWidth(), Screen:offsetY() , 0 ) self.bb:paintRect(0,0, Screen:offsetX(), Screen:getHeight(), Blitbuffer.COLOR_WHITE)
self.bb:paintRect(0,0, Screen:offsetX(), Screen:getHeight(), 0 ) self.bb:paintRect(Screen:getWidth() + Screen:offsetX(), 0,
self.bb:paintRect(Screen:getWidth() + Screen:offsetX(), 0 , Screen:getWidth() - Screen:getWidth() - Screen:offsetX(), Screen:getHeight(), 0 ) Screen:getWidth() - Screen:getWidth() - Screen:offsetX(), Screen:getHeight(),
self.bb:paintRect(0, Screen:getHeight() + Screen:offsetY(), Screen:offsetX(), Screen:getWidth(), 0 ) Blitbuffer.COLOR_WHITE)
self.bb:paintRect(0, Screen:getHeight() + Screen:offsetY(),
Screen:offsetX(), Screen:getWidth(),
Blitbuffer.COLOR_WHITE)
end end
function Screen:refresh(refresh_type, waveform_mode, x, y, w, h) function Screen:refresh(refresh_type, waveform_mode, x, y, w, h)

@ -149,9 +149,7 @@ function RenderText:renderUtf8Text(buffer, x, y, face, text, kerning, bold, fgco
end end
if not fgcolor then if not fgcolor then
fgcolor = BlitBuffer.Color8(0xFF) fgcolor = BlitBuffer.COLOR_BLACK
elseif type(fgcolor) == "number" then
fgcolor = BlitBuffer.Color8(fgcolor*0xFF)
end end
-- may still need more adaptive pen placement when kerning, -- may still need more adaptive pen placement when kerning,

@ -10,6 +10,7 @@ local UIManager = require("ui/uimanager")
local Device = require("ui/device") local Device = require("ui/device")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local Blitbuffer = require("ffi/blitbuffer")
--[[ --[[
a button widget that shows text or a icon and handles callback when tapped a button widget that shows text or a icon and handles callback when tapped
@ -22,7 +23,7 @@ local Button = InputContainer:new{
enabled = true, enabled = true,
margin = 0, margin = 0,
bordersize = 3, bordersize = 3,
background = 0, background = Blitbuffer.COLOR_WHITE,
radius = 15, radius = 15,
padding = 2, padding = 2,
width = nil, width = nil,
@ -34,7 +35,7 @@ function Button:init()
if self.text then if self.text then
self.label_widget = TextWidget:new{ self.label_widget = TextWidget:new{
text = self.text, text = self.text,
fgcolor = self.enabled and 1.0 or 0.5, fgcolor = Blitbuffer.gray(self.enabled and 1.0 or 0.5),
bold = true, bold = true,
face = Font:getFace(self.text_font_face, self.text_font_size) face = Font:getFace(self.text_font_face, self.text_font_size)
} }
@ -64,9 +65,9 @@ function Button:init()
} }
} }
if self.preselect then if self.preselect then
self.frame.color = 15 self.frame.color = Blitbuffer.COLOR_BLACK
else else
self.frame.color = 5 self.frame.color = Blitbuffer.gray(0.33)
end end
self.dimen = self.frame:getSize() self.dimen = self.frame:getSize()
self[1] = self.frame self[1] = self.frame
@ -91,19 +92,19 @@ function Button:init()
end end
function Button:onFocus() function Button:onFocus()
self[1].color = 15 self[1].color = Blitbuffer.COLOR_BLACK
return true return true
end end
function Button:onUnfocus() function Button:onUnfocus()
self[1].color = 5 self[1].color = Blitbuffer.gray(0.33)
return true return true
end end
function Button:enable() function Button:enable()
self.enabled = true self.enabled = true
if self.text then if self.text then
self.label_widget.fgcolor = self.enabled and 1.0 or 0.5 self.label_widget.fgcolor = Blitbuffer.gray(self.enabled and 1.0 or 0.5)
else else
self.label_widget.dim = not self.enabled self.label_widget.dim = not self.enabled
end end
@ -112,7 +113,7 @@ end
function Button:disable() function Button:disable()
self.enabled = false self.enabled = false
if self.text then if self.text then
self.label_widget.fgcolor = self.enabled and 1.0 or 0.5 self.label_widget.fgcolor = Blitbuffer.gray(self.enabled and 1.0 or 0.5)
else else
self.label_widget.dim = not self.enabled self.label_widget.dim = not self.enabled
end end

@ -9,6 +9,7 @@ local Input = require("ui/input")
local Screen = require("ui/screen") local Screen = require("ui/screen")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local _ = require("gettext") local _ = require("gettext")
local Blitbuffer = require("ffi/blitbuffer")
local ButtonDialog = InputContainer:new{ local ButtonDialog = InputContainer:new{
buttons = nil, buttons = nil,
@ -41,7 +42,7 @@ function ButtonDialog:init()
buttons = self.buttons, buttons = self.buttons,
show_parent = self, show_parent = self,
}, },
background = 0, background = Blitbuffer.COLOR_WHITE,
bordersize = 2, bordersize = 2,
radius = 7, radius = 7,
padding = 2, padding = 2,

@ -5,6 +5,7 @@ local LineWidget = require("ui/widget/linewidget")
local Button = require("ui/widget/button") local Button = require("ui/widget/button")
local Screen = require("ui/screen") local Screen = require("ui/screen")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Blitbuffer = require("ffi/blitbuffer")
local ButtonTable = VerticalGroup:new{ local ButtonTable = VerticalGroup:new{
width = Screen:getWidth(), width = Screen:getWidth(),
@ -46,7 +47,7 @@ function ButtonTable:init()
} }
local button_dim = button:getSize() local button_dim = button:getSize()
local vertical_sep = LineWidget:new{ local vertical_sep = LineWidget:new{
background = 8, background = Blitbuffer.gray(0.5),
dimen = Geom:new{ dimen = Geom:new{
w = self.sep_width, w = self.sep_width,
h = button_dim.h, h = button_dim.h,
@ -67,7 +68,7 @@ end
function ButtonTable:addHorizontalSep() function ButtonTable:addHorizontalSep()
table.insert(self, VerticalSpan:new{ width = Screen:scaleByDPI(2) }) table.insert(self, VerticalSpan:new{ width = Screen:scaleByDPI(2) })
table.insert(self, LineWidget:new{ table.insert(self, LineWidget:new{
background = 8, background = Blitbuffer.gray(0.5),
dimen = Geom:new{ dimen = Geom:new{
w = self.width, w = self.width,
h = self.sep_width, h = self.sep_width,

@ -24,6 +24,7 @@ local Screen = require("ui/screen")
local Event = require("ui/event") local Event = require("ui/event")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local Blitbuffer = require("ffi/blitbuffer")
local MenuBarItem = InputContainer:new{} local MenuBarItem = InputContainer:new{}
function MenuBarItem:init() function MenuBarItem:init()
@ -97,9 +98,9 @@ end
function OptionTextItem:onTapSelect() function OptionTextItem:onTapSelect()
for _, item in pairs(self.items) do for _, item in pairs(self.items) do
item[1].color = 0 item[1].color = Blitbuffer.COLOR_WHITE
end end
self[1].color = 15 self[1].color = Blitbuffer.COLOR_BLACK
self.config:onConfigChoose(self.values, self.name, self.config:onConfigChoose(self.values, self.name,
self.event, self.args, self.event, self.args,
self.events, self.current_item) self.events, self.current_item)
@ -148,10 +149,10 @@ end
function OptionIconItem:onTapSelect() function OptionIconItem:onTapSelect()
for _, item in pairs(self.items) do for _, item in pairs(self.items) do
--item[1][1].invert = false --item[1][1].invert = false
item[1].color = 0 item[1].color = Blitbuffer.COLOR_WHITE
end end
--self[1][1].invert = true --self[1][1].invert = true
self[1].color = 15 self[1].color = Blitbuffer.COLOR_BLACK
self.config:onConfigChoose(self.values, self.name, self.config:onConfigChoose(self.values, self.name,
self.event, self.args, self.event, self.args,
self.events, self.current_item) self.events, self.current_item)
@ -308,7 +309,7 @@ function ConfigOption:init()
face = Font:getFace(item_font_face, item_font_size[d]), face = Font:getFace(item_font_face, item_font_size[d]),
}, },
padding = 3, padding = 3,
color = d == current_item and 15 or 0, color = d == current_item and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_WHITE,
} }
else else
option_item = OptionTextItem:new{ option_item = OptionTextItem:new{
@ -317,7 +318,7 @@ function ConfigOption:init()
face = Font:getFace(item_font_face, item_font_size), face = Font:getFace(item_font_face, item_font_size),
}, },
padding = -3, padding = -3,
color = d == current_item and 15 or 0, color = d == current_item and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_WHITE,
} }
end end
option_items[d] = option_item option_items[d] = option_item
@ -355,7 +356,7 @@ function ConfigOption:init()
file = self.options[c].item_icons[d] file = self.options[c].item_icons[d]
}, },
padding = -2, padding = -2,
color = d == current_item and 15 or 0, color = d == current_item and Blitbuffer.COLOR_BLACK or Blitbuffer.COLOR_WHITE,
} }
option_items[d] = option_item option_items[d] = option_item
option_item.items = option_items option_item.items = option_items
@ -403,7 +404,7 @@ function ConfigOption:init()
self.dimen = vertical_group:getSize() self.dimen = vertical_group:getSize()
end end
local ConfigPanel = FrameContainer:new{ background = 0, bordersize = 0, } local ConfigPanel = FrameContainer:new{ background = Blitbuffer.COLOR_WHITE, bordersize = 0, }
function ConfigPanel:init() function ConfigPanel:init()
local config_options = self.config_dialog.config_options local config_options = self.config_dialog.config_options
local default_option = config_options.default_options and config_options.default_options local default_option = config_options.default_options and config_options.default_options
@ -416,7 +417,7 @@ function ConfigPanel:init()
table.insert(self, panel) table.insert(self, panel)
end end
local MenuBar = FrameContainer:new{ background = 0, } local MenuBar = FrameContainer:new{ background = Blitbuffer.COLOR_WHITE, }
function MenuBar:init() function MenuBar:init()
local config_options = self.config_dialog.config_options local config_options = self.config_dialog.config_options
local menu_items = {} local menu_items = {}
@ -519,7 +520,7 @@ function ConfigDialog:update()
config_dialog = self, config_dialog = self,
} }
self.dialog_frame = FrameContainer:new{ self.dialog_frame = FrameContainer:new{
background = 0, background = Blitbuffer.COLOR_WHITE,
VerticalGroup:new{ VerticalGroup:new{
self.config_panel, self.config_panel,
self.config_menubar, self.config_menubar,

@ -16,6 +16,7 @@ local Screen = require("ui/screen")
local Font = require("ui/font") local Font = require("ui/font")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local Blitbuffer = require("ffi/blitbuffer")
-- screen -- screen
@ -75,7 +76,7 @@ function ConfirmBox:init()
self[1] = CenterContainer:new{ self[1] = CenterContainer:new{
dimen = Screen:getSize(), dimen = Screen:getSize(),
FrameContainer:new{ FrameContainer:new{
background = 0, background = Blitbuffer.COLOR_WHITE,
margin = self.margin, margin = self.margin,
padding = self.padding, padding = self.padding,
VerticalGroup:new{ VerticalGroup:new{

@ -1,5 +1,6 @@
local WidgetContainer = require("ui/widget/container/widgetcontainer") local WidgetContainer = require("ui/widget/container/widgetcontainer")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Blitbuffer = require("ffi/blitbuffer")
--[[ --[[
A FrameContainer is some graphics content (1 widget) that is surrounded by a A FrameContainer is some graphics content (1 widget) that is surrounded by a
@ -7,7 +8,7 @@ frame
--]] --]]
local FrameContainer = WidgetContainer:new{ local FrameContainer = WidgetContainer:new{
background = nil, background = nil,
color = 15, color = Blitbuffer.COLOR_BLACK,
margin = 0, margin = 0,
radius = 0, radius = 0,
bordersize = 2, bordersize = 2,

@ -1,5 +1,6 @@
local WidgetContainer = require("ui/widget/container/widgetcontainer") local WidgetContainer = require("ui/widget/container/widgetcontainer")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Blitbuffer = require("ffi/blitbuffer")
--[[ --[[
an UnderlineContainer is a WidgetContainer that is able to paint an UnderlineContainer is a WidgetContainer that is able to paint
@ -9,7 +10,8 @@ a line under its child node
local UnderlineContainer = WidgetContainer:new{ local UnderlineContainer = WidgetContainer:new{
linesize = 2, linesize = 2,
padding = 1, padding = 1,
color = 0, -- TODO: shouldn't this default to black instead?
color = Blitbuffer.COLOR_WHITE,
vertical_align = "top", vertical_align = "top",
} }

@ -22,6 +22,7 @@ local Event = require("ui/event")
local Font = require("ui/font") local Font = require("ui/font")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local Blitbuffer = require("ffi/blitbuffer")
--[[ --[[
Display quick lookup word definition Display quick lookup word definition
@ -198,7 +199,7 @@ function DictQuickLookup:update()
show_parent = self, show_parent = self,
} }
local title_bar = LineWidget:new{ local title_bar = LineWidget:new{
--background = 8, --background = Blitbuffer.gray(0.5),
dimen = Geom:new{ dimen = Geom:new{
w = button_table:getSize().w + self.button_padding, w = button_table:getSize().w + self.button_padding,
h = Screen:scaleByDPI(2), h = Screen:scaleByDPI(2),
@ -215,7 +216,7 @@ function DictQuickLookup:update()
bordersize = 3, bordersize = 3,
padding = 0, padding = 0,
margin = 0, margin = 0,
background = 0, background = Blitbuffer.COLOR_WHITE,
VerticalGroup:new{ VerticalGroup:new{
align = "left", align = "left",
self.dict_bar, self.dict_bar,

@ -13,6 +13,7 @@ local Geom = require("ui/geometry")
local Input = require("ui/input") local Input = require("ui/input")
local Screen = require("ui/screen") local Screen = require("ui/screen")
local _ = require("gettext") local _ = require("gettext")
local Blitbuffer = require("ffi/blitbuffer")
--[[ --[[
Widget that displays an informational message Widget that displays an informational message
@ -61,7 +62,7 @@ function InfoMessage:init()
dimen = Screen:getSize(), dimen = Screen:getSize(),
FrameContainer:new{ FrameContainer:new{
margin = 2, margin = 2,
background = 0, background = Blitbuffer.COLOR_WHITE,
HorizontalGroup:new{ HorizontalGroup:new{
align = "center", align = "center",
image_widget, image_widget,

@ -11,6 +11,7 @@ local UIManager = require("ui/uimanager")
local Screen = require("ui/screen") local Screen = require("ui/screen")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Font = require("ui/font") local Font = require("ui/font")
local Blitbuffer = require("ffi/blitbuffer")
local InputDialog = InputContainer:new{ local InputDialog = InputContainer:new{
title = "", title = "",
@ -72,7 +73,7 @@ function InputDialog:init()
show_parent = self, show_parent = self,
} }
self.title_bar = LineWidget:new{ self.title_bar = LineWidget:new{
--background = 8, --background = Blitbuffer.gray(0.5),
dimen = Geom:new{ dimen = Geom:new{
w = self.button_table:getSize().w + self.button_padding, w = self.button_table:getSize().w + self.button_padding,
h = Screen:scaleByDPI(2), h = Screen:scaleByDPI(2),
@ -84,7 +85,7 @@ function InputDialog:init()
bordersize = 3, bordersize = 3,
padding = 0, padding = 0,
margin = 0, margin = 0,
background = 0, background = Blitbuffer.COLOR_WHITE,
VerticalGroup:new{ VerticalGroup:new{
align = "left", align = "left",
self.title, self.title,

@ -11,6 +11,7 @@ local Screen = require("ui/screen")
local Font = require("ui/font") local Font = require("ui/font")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local util = require("ffi/util") local util = require("ffi/util")
local Blitbuffer = require("ffi/blitbuffer")
local InputText = InputContainer:new{ local InputText = InputContainer:new{
text = "", text = "",
@ -51,7 +52,7 @@ end
function InputText:initTextBox(text) function InputText:initTextBox(text)
self.text = text self.text = text
self:initCharlist(text) self:initCharlist(text)
local fgcolor = self.text == "" and 0.5 or 1.0 local fgcolor = Blitbuffer.gray(self.text == "" and 0.5 or 1.0)
local text_widget = nil local text_widget = nil
local show_text = self.text local show_text = self.text
@ -82,7 +83,7 @@ function InputText:initTextBox(text)
bordersize = self.bordersize, bordersize = self.bordersize,
padding = self.padding, padding = self.padding,
margin = self.margin, margin = self.margin,
color = self.focused and 15 or 8, color = Blitbuffer.gray(self.focused and 1.0 or 0.5),
text_widget, text_widget,
} }
self.dimen = self[1]:getSize() self.dimen = self[1]:getSize()
@ -125,12 +126,12 @@ end
function InputText:unfocus() function InputText:unfocus()
self.focused = false self.focused = false
self[1].color = 8 self[1].color = Blitbuffer.gray(0.5)
end end
function InputText:focus() function InputText:focus()
self.focused = true self.focused = true
self[1].color = 15 self[1].color = Blitbuffer.COLOR_BLACK
end end
function InputText:onShowKeyboard() function InputText:onShowKeyboard()

@ -1,8 +1,9 @@
local Widget = require("ui/widget/widget") local Widget = require("ui/widget/widget")
local Blitbuffer = require("ffi/blitbuffer")
local LineWidget = Widget:new{ local LineWidget = Widget:new{
style = "solid", style = "solid",
background = 15, background = Blitbuffer.COLOR_BLACK,
dimen = nil, dimen = nil,
--@TODO replay dirty hack here 13.03 2013 (houqp) --@TODO replay dirty hack here 13.03 2013 (houqp)
empty_segments = nil, empty_segments = nil,

@ -4,10 +4,11 @@ local UIManager = require("ui/uimanager")
local Screen = require("ui/screen") local Screen = require("ui/screen")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Device = require("ui/device") local Device = require("ui/device")
local Blitbuffer = require("ffi/blitbuffer")
local LinkBox = InputContainer:new{ local LinkBox = InputContainer:new{
box = nil, box = nil,
color = 8, color = Blitbuffer.gray(0.5),
radius = 0, radius = 0,
bordersize = 2, bordersize = 2,
} }

@ -8,6 +8,7 @@ local Geom = require("ui/geometry")
local Screen = require("ui/screen") local Screen = require("ui/screen")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local Blitbuffer = require("ffi/blitbuffer")
local LoginDialog = InputDialog:extend{ local LoginDialog = InputDialog:extend{
username = "", username = "",
@ -45,7 +46,7 @@ function LoginDialog:init()
bordersize = 3, bordersize = 3,
padding = 0, padding = 0,
margin = 0, margin = 0,
background = 0, background = Blitbuffer.COLOR_WHITE,
VerticalGroup:new{ VerticalGroup:new{
align = "left", align = "left",
self.title, self.title,

@ -25,6 +25,7 @@ local UIManager = require("ui/uimanager")
local RenderText = require("ui/rendertext") local RenderText = require("ui/rendertext")
local InfoMessage = require("ui/widget/infomessage") local InfoMessage = require("ui/widget/infomessage")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local Blitbuffer = require("ffi/blitbuffer")
local _ = require("gettext") local _ = require("gettext")
--[[ --[[
@ -44,11 +45,11 @@ function ItemShortCutIcon:init()
end end
local radius = 0 local radius = 0
local background = 0 local background = Blitbuffer.COLOR_WHITE
if self.style == "rounded_corner" then if self.style == "rounded_corner" then
radius = math.floor(self.width/2) radius = math.floor(self.width/2)
elseif self.style == "grey_square" then elseif self.style == "grey_square" then
background = 3 background = Blitbuffer.gray(0.2)
end end
--@TODO calculate font size by icon size 01.05 2012 (houqp) --@TODO calculate font size by icon size 01.05 2012 (houqp)
@ -252,13 +253,13 @@ function MenuItem:init()
end end
function MenuItem:onFocus() function MenuItem:onFocus()
self._underline_container.color = 15 self._underline_container.color = Blitbuffer.COLOR_BLACK
self.key_events = self.active_key_events self.key_events = self.active_key_events
return true return true
end end
function MenuItem:onUnfocus() function MenuItem:onUnfocus()
self._underline_container.color = 0 self._underline_container.color = Blitbuffer.COLOR_WHITE
self.key_events = {} self.key_events = {}
return true return true
end end
@ -497,7 +498,7 @@ function Menu:init()
end end
self[1] = FrameContainer:new{ self[1] = FrameContainer:new{
background = 0, background = Blitbuffer.COLOR_WHITE,
bordersize = self.is_borderless and 0 or 2, bordersize = self.is_borderless and 0 or 2,
padding = 0, padding = 0,
margin = 0, margin = 0,

@ -10,6 +10,7 @@ local Screen = require("ui/screen")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local util = require("ffi/util") local util = require("ffi/util")
local Blitbuffer = require("ffi/blitbuffer")
local InfoMessage = require("ui/widget/infomessage") local InfoMessage = require("ui/widget/infomessage")
local input_field local input_field
@ -65,7 +66,7 @@ function MultiInputDialog:init()
bordersize = 3, bordersize = 3,
padding = 0, padding = 0,
margin = 0, margin = 0,
background = 0, background = Blitbuffer.COLOR_WHITE,
VerticalGroupData, VerticalGroupData,
} }

@ -9,6 +9,7 @@ local UIManager = require("ui/uimanager")
local HorizontalGroup = require("ui/widget/horizontalgroup") local HorizontalGroup = require("ui/widget/horizontalgroup")
local Input = require("ui/input") local Input = require("ui/input")
local Screen = require("ui/screen") local Screen = require("ui/screen")
local Blitbuffer = require("ffi/blitbuffer")
--[[ --[[
Widget that displays a tiny notification on top of screen Widget that displays a tiny notification on top of screen
@ -39,7 +40,7 @@ function Notification:init()
h = Screen:getHeight()/10, h = Screen:getHeight()/10,
}, },
FrameContainer:new{ FrameContainer:new{
background = 0, background = Blitbuffer.COLOR_WHITE,
radius = 0, radius = 0,
margin = self.margin, margin = self.margin,
padding = self.padding, padding = self.padding,

@ -1,5 +1,6 @@
local Widget = require("ui/widget/widget") local Widget = require("ui/widget/widget")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Blitbuffer = require("ffi/blitbuffer")
--[[ --[[
ProgressWidget shows a progress bar ProgressWidget shows a progress bar
@ -11,9 +12,9 @@ local ProgressWidget = Widget:new{
margin_v = 1, margin_v = 1,
radius = 2, radius = 2,
bordersize = 1, bordersize = 1,
bordercolor = 15, bordercolor = Blitbuffer.COLOR_BLACK,
bgcolor = 0, bgcolor = Blitbuffer.COLOR_WHITE,
rectcolor = 10, rectcolor = Blitbuffer.gray(0.7),
percentage = nil, percentage = nil,
ticks = {}, ticks = {},
tick_width = 3, tick_width = 3,

@ -8,6 +8,7 @@ local Screen = require("ui/screen")
local HorizontalGroup = require("ui/widget/horizontalgroup") local HorizontalGroup = require("ui/widget/horizontalgroup")
local HorizontalSpan = require("ui/widget/horizontalspan") local HorizontalSpan = require("ui/widget/horizontalspan")
local Device = require("ui/device") local Device = require("ui/device")
local Blitbuffer = require("ffi/blitbuffer")
--[[ --[[
Text widget with vertical scroll bar Text widget with vertical scroll bar
@ -15,7 +16,7 @@ Text widget with vertical scroll bar
local ScrollTextWidget = InputContainer:new{ local ScrollTextWidget = InputContainer:new{
text = nil, text = nil,
face = nil, face = nil,
fgcolor = 1.0, -- [0.0, 1.0] fgcolor = Blitbuffer.COLOR_BLACK,
width = 400, width = 400,
height = 20, height = 20,
scroll_bar_width = Screen:scaleByDPI(6), scroll_bar_width = Screen:scaleByDPI(6),

@ -13,7 +13,7 @@ local TextBoxWidget = Widget:new{
text = nil, text = nil,
face = nil, face = nil,
bold = nil, bold = nil,
fgcolor = 1.0, -- [0.0, 1.0] fgcolor = Blitbuffer.COLOR_BLACK,
width = 400, -- in pixels width = 400, -- in pixels
height = nil, height = nil,
first_line = 1, first_line = 1,

@ -2,6 +2,7 @@ local Widget = require("ui/widget/widget")
local Screen = require("ui/screen") local Screen = require("ui/screen")
local RenderText = require("ui/rendertext") local RenderText = require("ui/rendertext")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Blitbuffer = require("ffi/blitbuffer")
--[[ --[[
A TextWidget puts a string on a single line A TextWidget puts a string on a single line
@ -10,7 +11,7 @@ local TextWidget = Widget:new{
text = nil, text = nil,
face = nil, face = nil,
bold = nil, bold = nil,
fgcolor = 1.0, -- [0.0, 1.0] fgcolor = Blitbuffer.COLOR_BLACK,
_bb = nil, _bb = nil,
_length = 0, _length = 0,
_height = 0, _height = 0,

@ -11,12 +11,13 @@ local Screen = require("ui/screen")
local Device = require("ui/device") local Device = require("ui/device")
local GestureRange = require("ui/gesturerange") local GestureRange = require("ui/gesturerange")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local Blitbuffer = require("ffi/blitbuffer")
local _ = require("gettext") local _ = require("gettext")
local ToggleLabel = TextWidget:new{ local ToggleLabel = TextWidget:new{
bold = true, bold = true,
bgcolor = 0, bgcolor = Blitbuffer.COLOR_WHITE,
fgcolor = 1, fgcolor = Blitbuffer.COLOR_BLACK,
} }
function ToggleLabel:paintTo(bb, x, y) function ToggleLabel:paintTo(bb, x, y)
@ -26,8 +27,8 @@ end
local ToggleSwitch = InputContainer:new{ local ToggleSwitch = InputContainer:new{
width = Screen:scaleByDPI(216), width = Screen:scaleByDPI(216),
height = Screen:scaleByDPI(30), height = Screen:scaleByDPI(30),
bgcolor = 0, -- unfoused item color bgcolor = Blitbuffer.COLOR_WHITE, -- unfoused item color
fgcolor = 7, -- focused item color fgcolor = Blitbuffer.gray(0.5), -- focused item color
} }
function ToggleSwitch:init() function ToggleSwitch:init()
@ -37,7 +38,13 @@ function ToggleSwitch:init()
local label_font_face = "cfont" local label_font_face = "cfont"
local label_font_size = 16 local label_font_size = 16
self.toggle_frame = FrameContainer:new{background = 0, color = 7, radius = 7, bordersize = 1, padding = 2,} self.toggle_frame = FrameContainer:new{
background = Blitbuffer.COLOR_WHITE,
color = Blitbuffer.gray(0.5),
radius = 7,
bordersize = 1,
padding = 2,
}
self.toggle_content = HorizontalGroup:new{} self.toggle_content = HorizontalGroup:new{}
for i=1,#self.toggle do for i=1,#self.toggle do
@ -51,8 +58,8 @@ function ToggleSwitch:init()
label, label,
} }
local button = FrameContainer:new{ local button = FrameContainer:new{
background = 0, background = Blitbuffer.COLOR_WHITE,
color = 7, color = Blitbuffer.gray(0.5),
margin = 0, margin = 0,
radius = 5, radius = 5,
bordersize = 1, bordersize = 1,
@ -91,11 +98,11 @@ function ToggleSwitch:update()
if pos == i then if pos == i then
self.toggle_content[i].color = self.fgcolor self.toggle_content[i].color = self.fgcolor
self.toggle_content[i].background = self.fgcolor self.toggle_content[i].background = self.fgcolor
self.toggle_content[i][1][1].fgcolor = 0.0 self.toggle_content[i][1][1].fgcolor = Blitbuffer.COLOR_WHITE
else else
self.toggle_content[i].color = self.bgcolor self.toggle_content[i].color = self.bgcolor
self.toggle_content[i].background = self.bgcolor self.toggle_content[i].background = self.bgcolor
self.toggle_content[i][1][1].fgcolor = 1.0 self.toggle_content[i][1][1].fgcolor = Blitbuffer.COLOR_BLACK
end end
end end
end end

@ -21,6 +21,7 @@ local Font = require("ui/font")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local _ = require("gettext") local _ = require("gettext")
local NetworkMgr = require("ui/networkmgr") local NetworkMgr = require("ui/networkmgr")
local Blitbuffer = require("ffi/blitbuffer")
--[[ --[[
TouchMenuItem widget TouchMenuItem widget
@ -71,7 +72,7 @@ function TouchMenuItem:init()
self.item_frame = FrameContainer:new{ self.item_frame = FrameContainer:new{
width = self.dimen.w, width = self.dimen.w,
bordersize = 0, bordersize = 0,
color = 15, color = Blitbuffer.COLOR_BLACK,
HorizontalGroup:new { HorizontalGroup:new {
align = "center", align = "center",
CenterContainer:new{ CenterContainer:new{
@ -80,7 +81,7 @@ function TouchMenuItem:init()
}, },
TextWidget:new{ TextWidget:new{
text = self.item.text or self.item.text_func(), text = self.item.text or self.item.text_func(),
fgcolor = item_enabled ~= false and 1.0 or 0.5, fgcolor = Blitbuffer.gray(item_enabled ~= false and 1.0 or 0.5),
face = self.face, face = self.face,
}, },
}, },
@ -362,7 +363,7 @@ function TouchMenu:init()
self[1] = FrameContainer:new{ self[1] = FrameContainer:new{
padding = self.padding, padding = self.padding,
bordersize = self.bordersize, bordersize = self.bordersize,
background = 0, background = Blitbuffer.COLOR_WHITE,
-- menubar and footer will be inserted in -- menubar and footer will be inserted in
-- item_group in updateItems -- item_group in updateItems
self.item_group, self.item_group,

@ -1,5 +1,6 @@
local Widget = require("ui/widget/widget") local Widget = require("ui/widget/widget")
local Geom = require("ui/geometry") local Geom = require("ui/geometry")
local Blitbuffer = require("ffi/blitbuffer")
local VerticalScrollBar = Widget:new{ local VerticalScrollBar = Widget:new{
enable = true, enable = true,
@ -9,9 +10,9 @@ local VerticalScrollBar = Widget:new{
width = 6, width = 6,
height = 50, height = 50,
bordersize = 1, bordersize = 1,
bordercolor = 15, bordercolor = Blitbuffer.COLOR_BLACK,
radius = 0, radius = 0,
rectcolor = 15, rectcolor = Blitbuffer.COLOR_BLACK,
} }
function VerticalScrollBar:getSize() function VerticalScrollBar:getSize()

@ -15,6 +15,7 @@ local Device = require("ui/device")
local GestureRange = require("ui/gesturerange") local GestureRange = require("ui/gesturerange")
local UIManager = require("ui/uimanager") local UIManager = require("ui/uimanager")
local DEBUG = require("dbg") local DEBUG = require("dbg")
local Blitbuffer = require("ffi/blitbuffer")
local VirtualKey = InputContainer:new{ local VirtualKey = InputContainer:new{
key = nil, key = nil,
@ -60,7 +61,7 @@ function VirtualKey:init()
self[1] = FrameContainer:new{ self[1] = FrameContainer:new{
margin = 0, margin = 0,
bordersize = self.bordersize, bordersize = self.bordersize,
background = 0, background = Blitbuffer.COLOR_WHITE,
radius = 5, radius = 5,
padding = 0, padding = 0,
CenterContainer:new{ CenterContainer:new{
@ -266,7 +267,7 @@ function VirtualKeyboard:addKeys()
local keyboard_frame = FrameContainer:new{ local keyboard_frame = FrameContainer:new{
margin = 0, margin = 0,
bordersize = self.bordersize, bordersize = self.bordersize,
background = 0, background = Blitbuffer.COLOR_WHITE,
radius = 0, radius = 0,
padding = self.padding, padding = self.padding,
CenterContainer:new{ CenterContainer:new{

@ -37,6 +37,7 @@ local ReaderUI = require("apps/reader/readerui")
local Dbg = require("dbg") local Dbg = require("dbg")
local Device = require("ui/device") local Device = require("ui/device")
local Screen = require("ui/screen") local Screen = require("ui/screen")
local Blitbuffer = require("ffi/blitbuffer")
----------------------------------------------------- -----------------------------------------------------
-- widget that paints the grid on the background -- widget that paints the grid on the background
@ -50,12 +51,12 @@ function TestGrid:paintTo(bb)
for i=1,h_line do for i=1,h_line do
y_num = i*50 y_num = i*50
RenderText:renderUtf8Text(bb, 0, y_num+10, Font:getFace("ffont", 12), y_num, true) RenderText:renderUtf8Text(bb, 0, y_num+10, Font:getFace("ffont", 12), y_num, true)
bb:paintRect(0, y_num, bb:getWidth(), 1, 10) bb:paintRect(0, y_num, bb:getWidth(), 1, Blitbuffer.gray(0.7))
end end
for i=1,v_line do for i=1,v_line do
x_num = i*50 x_num = i*50
RenderText:renderUtf8Text(bb, x_num, 10, Font:getFace("ffont", 12), x_num, true) RenderText:renderUtf8Text(bb, x_num, 10, Font:getFace("ffont", 12), x_num, true)
bb:paintRect(x_num, 0, 1, bb:getHeight(), 10) bb:paintRect(x_num, 0, 1, bb:getHeight(), Blitbuffer.gray(0.7))
end end
end end
@ -65,7 +66,7 @@ function TestVisible:paintTo(bb)
v_line = math.floor(bb:getWidth() / 50) v_line = math.floor(bb:getWidth() / 50)
h_line = math.floor(bb:getHeight() / 50) h_line = math.floor(bb:getHeight() / 50)
-- Paint white background for higher contrast -- Paint white background for higher contrast
bb:paintRect(0,0,bb:getWidth(),bb:getHeight() , 0) bb:paintRect(0,0,bb:getWidth(),bb:getHeight(), Blitbuffer.COLOR_WHITE)
-- Only render gridtext not lines at a more central postition, so it doesn't interfere with the -- Only render gridtext not lines at a more central postition, so it doesn't interfere with the
for i=1,h_line do for i=1,h_line do
y_num = i*50 y_num = i*50
@ -90,28 +91,28 @@ function TestVisible:paintTo(bb)
RenderText:renderUtf8Text(bb, 100, 500, Font:getFace("ffont", 26), "Visible screen size : "..(x_max-x_min).."x"..(y_max-y_min), true) RenderText:renderUtf8Text(bb, 100, 500, Font:getFace("ffont", 26), "Visible screen size : "..(x_max-x_min).."x"..(y_max-y_min), true)
-- Three parallel lines at the top -- Three parallel lines at the top
bb:paintRect(x_min,y_min, x_max, 1 , 10) bb:paintRect(x_min,y_min, x_max, 1 , Blitbuffer.gray(0.7))
bb:paintRect(x_min,y_min + 3, x_max, 1 , 10) bb:paintRect(x_min,y_min + 3, x_max, 1 , Blitbuffer.gray(0.7))
bb:paintRect(x_min,y_min + 6, x_max, 1 , 10) bb:paintRect(x_min,y_min + 6, x_max, 1 , Blitbuffer.gray(0.7))
-- Three parallel lines at the bottom -- Three parallel lines at the bottom
bb:paintRect(x_min,y_max, x_max, 1 , 10) bb:paintRect(x_min,y_max, x_max, 1 , Blitbuffer.gray(0.7))
bb:paintRect(x_min,y_max - 3, x_max, 1 , 10) bb:paintRect(x_min,y_max - 3, x_max, 1 , Blitbuffer.gray(0.7))
bb:paintRect(x_min,y_max - 6, x_max, 1 , 10) bb:paintRect(x_min,y_max - 6, x_max, 1 , Blitbuffer.gray(0.7))
-- Three parallel lines at the left -- Three parallel lines at the left
bb:paintRect(x_min,y_min, 1, y_max , 10) bb:paintRect(x_min,y_min, 1, y_max , Blitbuffer.gray(0.7))
bb:paintRect(x_min + 3,y_min, 1, y_max, 10) bb:paintRect(x_min + 3,y_min, 1, y_max, Blitbuffer.gray(0.7))
bb:paintRect(x_min + 6,y_min, 1, y_max, 10) bb:paintRect(x_min + 6,y_min, 1, y_max, Blitbuffer.gray(0.7))
-- Three parallel lines at the right -- Three parallel lines at the right
bb:paintRect(x_max,y_min, 1, y_max , 10) bb:paintRect(x_max,y_min, 1, y_max , Blitbuffer.gray(0.7))
bb:paintRect(x_max - 3,y_min, 1, y_max, 10) bb:paintRect(x_max - 3,y_min, 1, y_max, Blitbuffer.gray(0.7))
bb:paintRect(x_max - 6,y_min, 1, y_max, 10) bb:paintRect(x_max - 6,y_min, 1, y_max, Blitbuffer.gray(0.7))
--Two lines spaces 600 pixels --Two lines spaces 600 pixels
bb:paintRect(100,600, 1, 250 , 10) bb:paintRect(100,600, 1, 250 , Blitbuffer.gray(0.7))
bb:paintRect(700,600, 1, 250 , 10) bb:paintRect(700,600, 1, 250 , Blitbuffer.gray(0.7))
RenderText:renderUtf8Text(bb, 150, 670, Font:getFace("ffont", 26), "Measure inches per 600 pixels", true) RenderText:renderUtf8Text(bb, 150, 670, Font:getFace("ffont", 26), "Measure inches per 600 pixels", true)
RenderText:renderUtf8Text(bb, 150, 770, Font:getFace("ffont", 22), "Kobo Aura: 600 pixels/ 2.82 \" = "..(600/2.82).." dpi", true) RenderText:renderUtf8Text(bb, 150, 770, Font:getFace("ffont", 22), "Kobo Aura: 600 pixels/ 2.82 \" = "..(600/2.82).." dpi", true)
end end
@ -170,7 +171,7 @@ Clock = AlphaContainer:new{
alpha = 0.7, alpha = 0.7,
FrameContainer:new{ FrameContainer:new{
background = 0, background = Blitbuffer.COLOR_WHITE,
bordersize = 1, bordersize = 1,
margin = 0, margin = 0,
padding = 1 padding = 1

Loading…
Cancel
Save