mirror of
https://github.com/koreader/koreader
synced 2024-11-16 06:12:56 +00:00
use screen for UI color control
This commit is contained in:
parent
4d8da96177
commit
adb5d5a52c
@ -99,6 +99,13 @@ function Device:init()
|
||||
end
|
||||
|
||||
self.screen.isColorScreen = self.hasColorScreen
|
||||
self.screen.isColorEnabled = function()
|
||||
if G_reader_settings:has("color_rendering") then
|
||||
return G_reader_settings:isTrue("color_rendering")
|
||||
else
|
||||
return self.screen.isColorScreen()
|
||||
end
|
||||
end
|
||||
|
||||
self.screen.isBGRFrameBuffer = self.hasBGRFrameBuffer
|
||||
|
||||
|
@ -7,11 +7,11 @@ local _ = require("gettext")
|
||||
return {
|
||||
text = _("Color rendering"),
|
||||
enabled_func = Screen.isColorScreen,
|
||||
checked_func = function() return Runtimectl.is_color_rendering_enabled end,
|
||||
checked_func = Screen.isColorEnabled,
|
||||
callback = function()
|
||||
Runtimectl:setColorRenderingEnabled(not Runtimectl.is_color_rendering_enabled)
|
||||
G_reader_settings:saveSetting(
|
||||
"color_rendering", Runtimectl.is_color_rendering_enabled)
|
||||
local new_val = Screen.isColorEnabled()
|
||||
Runtimectl:setColorRenderingEnabled(new_val)
|
||||
G_reader_settings:saveSetting("color_rendering", new_val)
|
||||
UIManager:broadcastEvent(Event:new("ColorRenderingUpdate"))
|
||||
end
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ local Geom = require("ui/geometry")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local Mupdf = require("ffi/mupdf")
|
||||
local Screen = Device.screen
|
||||
local TimeVal = require("ui/timeval")
|
||||
local logger = require("logger")
|
||||
local util = require("util")
|
||||
local Runtimectl = require("runtimectl")
|
||||
|
||||
local HtmlBoxWidget = InputContainer:new{
|
||||
bb = nil,
|
||||
@ -83,7 +83,7 @@ function HtmlBoxWidget:_render()
|
||||
-- In pdfdocument.lua, color is activated only at the moment of
|
||||
-- rendering and then immediately disabled, for safety with kopt.
|
||||
-- We do the same here.
|
||||
Mupdf.color = Runtimectl.is_color_rendering_enabled
|
||||
Mupdf.color = Screen:isColorEnabled()
|
||||
|
||||
local page = self.document:openPage(self.page_number)
|
||||
local dc = DrawContext.new()
|
||||
|
@ -361,11 +361,11 @@ function TextBoxWidget:_renderText(start_row_idx, end_row_idx)
|
||||
if self._bb then self._bb:free() end
|
||||
local bbtype = nil
|
||||
if self.line_num_to_image and self.line_num_to_image[start_row_idx] then
|
||||
-- Whether Runtimectl.is_color_rendering_enabled or not, it's best to
|
||||
-- Whether Screen:isColorEnabled or not, it's best to
|
||||
-- always use BBRGB32 and alphablitFrom() for the best display of
|
||||
-- various images:
|
||||
-- With greyscale screen TYPE_BB8 (the default, and
|
||||
-- what we would have chosen when not Runtimectl.is_color_rendering_enabled):
|
||||
-- what we would have chosen when not Screen:isColorEnabled):
|
||||
-- alphablitFrom: some images are all white (ex: flags on Milan,
|
||||
-- Ilkhanides on wiki.fr)
|
||||
-- blitFrom: some images have a black background (ex: RDA,
|
||||
|
Loading…
Reference in New Issue
Block a user