Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I modify arrow of page overlap function? #9181

Closed
omer-faruq opened this issue Jun 7, 2022 · 11 comments
Closed

How can I modify arrow of page overlap function? #9181

omer-faruq opened this issue Jun 7, 2022 · 11 comments
Labels
enhancement User patch available Request is odd, specific, or complicated to do properly - but a user patch is provided

Comments

@omer-faruq
Copy link

omer-faruq commented Jun 7, 2022

When I read PDFs with two columns page overlap function makes it better to read docs. I want to add some white and black border to arrow to make it more visible at first sight . Where can I find it? is it customizable? Is there a way to do this? Thanks .
Arrow

@omer-faruq omer-faruq changed the title Arrow of page overlap function How can I modify arrow of page overlap function Jun 7, 2022
@omer-faruq omer-faruq changed the title How can I modify arrow of page overlap function How can I modify arrow of page overlap function? Jun 7, 2022
@poire-z
Copy link
Contributor

poire-z commented Jun 7, 2022

There is not setting for this in the menus, the icon and size are hardcoded.

Currently, you could just override the icon used (control.expand.alpha) with something different, which must be a SVG file, that you could drop in a (create this directoty) koreader/icons/ by giving it the name control.expand.alpha.svg.
It will still have the current small size.
image

local arrow_size = Screen:scaleBySize(16)
self.arrow = IconWidget:new{
icon = "control.expand.alpha",
width = arrow_size,
height = arrow_size,
alpha = true, -- Keep the alpha layer intact, the fill opacity is set at 75%
}

Once #9104 is merged (soon), you could hack the above bit code that builds the thing to give it another name and size. Something like this, put in patches/2-my-overlap_arrow.lua could work:

local IconWidget = require("ui/widget/iconwidget")
local ReaderView = require("apps/reader/modules/readerview")
local addWidgets_orig = ReaderView.addWidgets
ReaderView:addWidgets = function(self)
    -- Run original code
    addWidgets_orig(self)
    local arrow_size = Screen:scaleBySize(16 * 2)
    self.arrow = IconWidget:new{
        icon = "the_name_of_my_svg_file",
        width = arrow_size,
        height = arrow_size,
        alpha = true, -- or false, if you don't want transparency with your big solid black icon
    }
end

@omer-faruq
Copy link
Author

omer-faruq commented Jun 8, 2022

thanks for the reply, I'll try to modify the image control.expand.alpha , also the size.

@omer-faruq
Copy link
Author

omer-faruq commented Jun 10, 2022

I made these modifications to the icon file: 1- increase size to 32*32 , 2- add some white space to above and below 3- fill background with solid white (only left part), 2- made arrow %100 black.

modified the code to be able to use the icon with size 32 (as descirbed above)
( also created the user patch file )

control expand 32

@poire-z
Copy link
Contributor

poire-z commented Jul 2, 2022

also created the user patch file

Feel free to share its code here :)

@omer-faruq
Copy link
Author

omer-faruq commented Jul 3, 2022

Oh, I mean with the code you already shared
( didn't test it yet )

@poire-z
Copy link
Contributor

poire-z commented Jul 3, 2022

Oh, right, I posted some code :) I haven't tested it, I see that it is missing something at top:
local Screen = require("device").screen
(still not tested :)

@omer-faruq
Copy link
Author

omer-faruq commented Jul 3, 2022

To test the user patches I switched to Developer Upgrade mode, Now when It restarts it says:

Error appying patch:
 ./patches/2-overlap_arror_32.lua 

Unfortunately I don't know how to look at the error logs if any.

@poire-z
Copy link
Contributor

poire-z commented Jul 3, 2022

there should be a file koreader/crash.log in which there may be more details (it's actually just the full log)

@omer-faruq
Copy link
Author

omer-faruq commented Jul 3, 2022

It says:
WARN Patching failed: ./patches/2-overlap_arrow_32.lua:5: function arguments expected near '='

5th line:
ReaderView:addWidgets = function(self)

I didn't get the reason of error, if you have an idea I can try :)

@poire-z
Copy link
Contributor

poire-z commented Jul 3, 2022

Right. Replace this : with ., beween ReaderView and addWidgets
ReaderView.addWidgets = function(self)

@omer-faruq
Copy link
Author

omer-faruq commented Jul 3, 2022

Yes this fixed the problem, thanks appreciated your help on this.

Here is the working patch:

2-overlap_arrow_32.lua.txt

@poire-z poire-z added the User patch available Request is odd, specific, or complicated to do properly - but a user patch is provided label Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement User patch available Request is odd, specific, or complicated to do properly - but a user patch is provided
Projects
None yet
Development

No branches or pull requests

2 participants