Page browser: show nightmode thumbnails when in nightmode (#11091)

Just prevent page thumbnails ImageWidgets to be nightmode
inverted, unlike all other ones which are expected to be
double inverted to get their original colors shown.
The same thumbnail can be used and cached in both day and
night modes, unless "nightmode_images" is enabled and have
crengine itself invert images, making thumbnails different.
reviewable/pr11103/r1
poire-z 6 months ago committed by GitHub
parent 4044c81a5a
commit 894cb3190d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -250,6 +250,10 @@ end
function ReaderThumbnail:getPageThumbnail(page, width, height, batch_id, when_generated_callback)
self:setupCache()
self.current_target_size_tag = string.format("w%d_h%d", width, height)
if self.ui.rolling and Screen.night_mode and self.ui.document.configurable.nightmode_images == 1 then
-- We'll get a different bb in this case: it needs its own cache hash
self.current_target_size_tag = self.current_target_size_tag .. "_nm"
end
local hash = string.format("p%d-%s", page, self.current_target_size_tag)
local tile = self.tile_cache and self.tile_cache:check(hash)
if tile then
@ -431,7 +435,7 @@ function ReaderThumbnail:_getPageImage(page)
self.ui.document:setGammaIndex(30) -- as downscaling will make text grayer
end
self.ui.document:setImageScaling(false) -- No need for smooth scaling as all will be downscaled
self.ui.document:setNightmodeImages(false) -- We don't invert page images even if nightmode set: keep images as-is
-- (We keep "nighmode_images" as it was set: we may get and cache a different bb whether nightmode is on or off)
self.ui.view.state.page = page -- Be on requested page
self.ui.document:gotoPage(page) -- Current xpointer needs to be updated for some of what follows
self.ui.bookmark:onPageUpdate(page) -- Update dogear state for this page

@ -74,6 +74,7 @@ local ImageWidget = Widget:extend{
dim = nil,
alpha = false, -- honors alpha values from the image
is_icon = false, -- set to true by sub-class IconWidget
original_in_nightmode = true, -- defaults to display the original image colors in nightmode
-- When rotation_angle is not 0, native image is rotated by this angle
-- before scaling.
@ -578,7 +579,7 @@ function ImageWidget:paintTo(bb, x, y)
--- but we currently don't, as we don't really trickle down
--- a way to discriminate them from the B&W ones.
--- Currently, this is *only* the KOReader icon in Help, AFAIK.
if Screen.night_mode and not self.is_icon then
if Screen.night_mode and self.original_in_nightmode and not self.is_icon then
bb:invertRect(x, y, size.w, size.h)
end
end

@ -749,6 +749,7 @@ function PageBrowserWidget:showTile(grid_idx, page, tile, do_refresh)
ImageWidget:new{
image = tile.bb,
image_disposable = false,
original_in_nightmode = false, -- we want our page thumbnail nightmode'd when in nighmtmode
},
}
item_container[1] = thumb_frame

Loading…
Cancel
Save