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
Create constant padding page layout option #5270
base: master
Are you sure you want to change the base?
Conversation
I would not do this in the release branch. This is not fixing a bug: some previous dev went out of their way to get the behaviour we have. A simple grid, which is the result we get with this PR, is much simpler to implement than the current Layout/LayoutMapper implementation. Overall, we should have a debate about what the best behaviour should be. This includes questions:
Those questions should be answered before anything else, and of course 1. will influence the answers to 2. and 3.. As for possible usecases, I guess rotating pages is one. We should also keep in mind something like #3430 (should it ever be implemented). |
Oh I'm sorry, I didn't know this was actually the wanted behavior. The current implementation looks kinda odd: it does include some padding to compensate for different page widths, but not enough to align the pages. I have now also checked the PR that introduced this code (#872), and it doesn't seem to mention a reason for this. About the branch issue, I agree that it isn't a good idea to merge this into the release branch. But the PR I want to build upon afterwards was, and the changes aren't in the master branch. So I wonder: do those get merged into the master branch as well after some time? Why not right away? The use case I have is inserting portrait A4 pages between 3:2 slides to take additional notes. I personally don't actually use the multi-column layout. I just came across it trying to fix another issue. I'm always writing something on a single page, so I rarely have multiple pages in my view anyways. I'd think what is happening between the pages is of little importance to most users. For me, it should just be as pretty as possible. Anyways, I think there's mainly two options you could go about the layout:
One issue with the grid would certainly be that if one has a page that is a lot bigger than the others, it will cause big gaps between other pages. But who would ever do that? I don't know what an infinite canvas would look like, or if there already is an idea about how to implement it. A simple version of that could be just pages with an arbitrarily large, automatically extending size. This could cause wildly different page sizes. I guess a solution to that could then be to crop/scale over-sized pages when zoomed out. |
I agree it is kinda odd. To be clear, I don't think your changes are not a good idea, but I think we should investigate how it'll influence various use cases (if we can find someone actually using it).
We can certainly merge the release branch into the master branch whenever we want. No problem there. You can create a PR for that, containing exactly 1 merge commit, so people can check it out and make sure nothing wrong happened in the process. Then we'll fast forward it onto the master branch.
|
I do use a 1-row or 2-row layout on my external monitor for displaying my solutions when correcting an exam. Usually the pages have all the same format though. Different page formats can appear when you have a document, where some pages are landscape and others are portrait. Another case may appear when the PDF was generated from (camera or scanned) images. There are also some books and journals where some of the first pages have a different format. The solution proposed in this PR looks logical from the point of view that all layout settings are symmetrical with respect to vertical/horizontal. But the current layout method has its advantages, too. |
6e54f26
to
03430b0
Compare
Ok, finally made some progress with this: I implemented constant padding layout. There are some parts of the code that I'm not too fond of (especially the repeated loops in Do also note that this is not fully functional yet: the visual part is good, but it is in some cases not possible to draw on the pages, for example, because most notably I haven't adapted |
46cbf9e
to
ec176f1
Compare
Ok, everything is good now, except for Can't guarantee that I caught everything, but I will put it up for review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are a the main issues I have with my code. I would appreciate feedback on this. It might also explain some of the oddities I wrote.
enum LayoutType { | ||
LAYOUT_TYPE_GRID = 0, | ||
LAYOUT_TYPE_CONST_PADDING = 1, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hesitated between creating a custom enumeration and defining the setting as a simple bool layoutConstPadding
or something. I'm also not really sure the enum declaration is in the right place here
struct PageLayoutDescription { | ||
double paddingLeft = 0.0; | ||
double paddingTop = 0.0; | ||
double width = 0.0; | ||
double height = 0.0; | ||
std::optional<size_t> optionalPage = std::nullopt; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a bit ugly to have that struct definition in the function implementation. Is there a better way?
Also we don't actually need width
and height
at the same time. We could replace it with a single variable size
which would be one or the other, depending on the layout orientation. But that would make the understanding and the control flow a little more complicated, so I figured it's ok like this?
|
||
std::vector<PageLayoutDescription> pages; // access with r * rows + c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be a lot easier to use a C-style 2-dimensional array, but I haven't found a good equivalent in C++. Suggestions?
// Iterate over ALL possible rows and columns 3 times: | ||
// We don't know which page, if any, is to be displayed in each row, column - ask the mapper object! | ||
// Once we know the dimensions of all pages, define the paddings above and left of each page as required. | ||
// Finally, assign page coordinates by propagating page paddings and sizes from the border. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole section (until line 445) is taking a lot of space. Also I'm not sure how good it is to iterate over every page 3 times. This is the shortest code I could come up with for this, but I'm 80% convinced there must be a better way I'm not aware of.
In particular: * Store all grid cell bounds for const padding * Add getGridPositionAt() and use it in updateVisibility()
dc2dbd9
to
c14fc4f
Compare
I've improved some of the things I was unhappy with now, so I'd like to request a review from someone on this :-) |
Fixes #5268.
I'm not too sure what branch to base it on. It's currently on master, but it's possible to rebase it on release-1.2. I took it on as a sub-issue of #5269, as it required knowing all about the padding around the pages. It would be nice to be able to merge this one and then use it as a base for the zoom center fix.