ReaderDogEar: Enforce a minimum size, too (#7369)

* Add a semi-transparent version of the dogear icon
* Ensure the dogear won't become too tiny to be useful
reviewable/pr7371/r1
NiLuJe 3 years ago committed by GitHub
parent f9635bc41b
commit 5303165bf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,7 +17,8 @@ function ReaderDogear:init()
-- to not overwrite the book text.
-- For other documents, there is no easy way to know if valuable content
-- may be hidden by the icon (kopt's page_margin is quite obscure).
self.dogear_max_size = math.ceil( math.min(Screen:getWidth(), Screen:getHeight()) / 32)
self.dogear_min_size = math.ceil(math.min(Screen:getWidth(), Screen:getHeight()) / 40)
self.dogear_max_size = math.ceil(math.min(Screen:getWidth(), Screen:getHeight()) / 32)
self.dogear_size = nil
self.dogear_y_offset = 0
self.top_pad = nil
@ -38,10 +39,11 @@ function ReaderDogear:setupDogear(new_dogear_size)
self.vgroup = VerticalGroup:new{
self.top_pad,
IconWidget:new{
icon = "dogear.opaque",
icon = "dogear.alpha",
rotation_angle = BD.mirroredUILayout() and 90 or 0,
width = self.dogear_size,
height = self.dogear_size,
alpha = true, -- Keep the alpha layer intact
}
}
self[1] = RightContainer:new{
@ -79,7 +81,7 @@ function ReaderDogear:onSetPageMargins(margins)
-- top & right margins and be sure no text is hidden by the icon
-- (the provided margins are not scaled, so do as ReaderTypeset)
local margin = Screen:scaleBySize(math.max(margin_top, margin_right))
local new_dogear_size = math.min(self.dogear_max_size, margin)
local new_dogear_size = math.min(self.dogear_max_size, math.max(self.dogear_min_size, margin))
self:setupDogear(new_dogear_size)
end

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="48"
height="48"
viewBox="0 0 48 48"
enable-background="new 0 0 24.00 24.00"
xml:space="preserve"
id="svg4"
sodipodi:docname="dogear.alpha.svg"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
inkscape:export-filename="/home/niluje/MPLAYER/koreader/resources/icons/mdlight/dogear.opaque.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="2560"
inkscape:window-height="1381"
id="namedview6"
showgrid="true"
inkscape:zoom="16.610526"
inkscape:cx="23.798479"
inkscape:cy="21.341888"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg4"
inkscape:document-rotation="0"><inkscape:grid
type="xygrid"
id="grid856" /></sodipodi:namedview><metadata
id="metadata10"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs id="defs8"></defs>
<path
id="path871"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.12;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.999901"
d="M 48,46 V 0 H 2 Z"
sodipodi:nodetypes="cccc" /><path
style="opacity:1;fill:#ffffff;fill-opacity:0.5;stroke:#000000;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="M 1.9999949,2 V 45.999919 H 46 Z"
id="path1127"
sodipodi:nodetypes="cccc"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96" /></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

Loading…
Cancel
Save