Nothing Special   »   [go: up one dir, main page]

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

Issue #4624 add page numbers #4693

Merged
merged 13 commits into from
Apr 22, 2023

Conversation

CruzeBlade
Copy link
Contributor
@CruzeBlade CruzeBlade commented Mar 3, 2023

Hi, I would like to submit this pull request.

I have implemented that the page numbers are displayed on the sidebar for the page previews.

This is the first time I'm doing a pull request. I hope that I have done everything right, otherwise please let me know.

Related issue: (#4624)

@CruzeBlade CruzeBlade changed the title Issue 4624 add page numbers Issue #4624 add page numbers Mar 3, 2023
Copy link
Collaborator
@bhennion bhennion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, thanks a lot for this PR! This is a very nice (and long overdue) feature.

I went through a couple of files (not all of them yet) and I have some comments, mainly about the implementation of drawStyle# functions. Could you have a look, and make the requested changes? (also in drawStyle2 and drawStyle3, although I did not repeat the comments therein)

src/core/control/settings/Settings.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Show resolved Hide resolved
src/core/control/settings/SettingsEnums.h Outdated Show resolved Hide resolved
@CruzeBlade
Copy link
Contributor Author
CruzeBlade commented Mar 10, 2023

Hi, thank you for the feedback about this PR. I have gone through all the change requests and tried to implement them or leave a comment. Those, I'm not sure about, I left unresolved. I hope the changes suit you well.

src/core/control/settings/Settings.cpp Outdated Show resolved Hide resolved
src/core/control/settings/Settings.cpp Outdated Show resolved Hide resolved
src/core/control/settings/SettingsEnums.h Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/sidebar/previews/page/SidebarPreviewPages.cpp Outdated Show resolved Hide resolved
src/core/gui/sidebar/previews/page/SidebarPreviewPages.cpp Outdated Show resolved Hide resolved
src/core/gui/sidebar/previews/page/SidebarPreviewPages.cpp Outdated Show resolved Hide resolved
@Technius Technius added this to the v1.2.0 milestone Mar 12, 2023
Copy link
Member
@Technius Technius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a nice feature. I did a quick skim through the code, will do a more detailed review after some of @bhennion's comments are also addressed.

src/core/control/settings/SettingsEnums.h Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
@CruzeBlade CruzeBlade force-pushed the issue-4624-add-page-numbers branch 2 times, most recently from 40c3e90 to b780889 Compare March 16, 2023 17:44
@CruzeBlade
Copy link
Contributor Author

I think I have implemented all requested changes. But now for some reason the clang format pipeline fails, and I can't figure out what is causing this.

Copy link
Collaborator
@bhennion bhennion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still some magic constants that should be defined (altogether) somewhere, with a descriptive name.

About the clang check: which version of clang-format did you use?
The check uses clang-format 17, which I think is not really stable. We should change that.

src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
src/core/gui/PagePreviewDecoration.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator
@bhennion bhennion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

Thanks a lot for the very nice feature and for accommodating all our requests!

@bhennion
Copy link
Collaborator
bhennion commented Mar 18, 2023

Ah, if you rebase onto latest master, the clang-format check should be working properly (and hopefully validate this PR).

Then I'll squash and merge this!

@CruzeBlade CruzeBlade force-pushed the issue-4624-add-page-numbers branch 2 times, most recently from c590d04 to 596ff69 Compare March 18, 2023 20:21
@CruzeBlade
Copy link
Contributor Author

Ok now clang-format is also passing, just had to add some more commits for formatting. Looks like my local formatter was not setup correctly.

Thank you for your reviews and suggestions on how to improve the code.

@CruzeBlade
Copy link
Contributor Author

Just realized that after rebasing onto the current master branch, I cannot build the project anymore.

I get the following error:
image

I can solve this issue by adding #include <memory> to the TinyVector.h file, but this wasn't required before.

Could this issue be linked to the rebase?

@rolandlo
Copy link
Member
rolandlo commented Mar 19, 2023

Just realized that after rebasing onto the current master branch, I cannot build the project anymore.

I get the following error: image

I can solve this issue by adding #include <memory> to the TinyVector.h file, but this wasn't required before.

Could this issue be linked to the rebase?

Interesting. The cppreference says that std::destroy and std::destroy_at are defined in the memory.h header. It seems to get included via the stdexcept header (included in TinyVector.h), that in turn includes the string header. Running g++ -E TinyVector.h > TinyVector.preprocessed I see in it:

# 41 "/usr/include/c++/12/string" 2 3
# 1 "/usr/include/c++/12/bits/allocator.h" 1 3
# 46 "/usr/include/c++/12/bits/allocator.h" 3
# 1 "/usr/include/x86_64-linux-gnu/c++/12/bits/c++allocator.h" 1 3
# 33 "/usr/include/x86_64-linux-gnu/c++/12/bits/c++allocator.h" 3
# 1 "/usr/include/c++/12/bits/new_allocator.h" 1 3
# 41 "/usr/include/c++/12/bits/new_allocator.h" 3

and the last listed file indeed includes a definition of destroy.

Similarly via

# 52 "/usr/include/c++/12/string" 2 3

# 1 "/usr/include/c++/12/bits/basic_string.h" 1 3
# 37 "/usr/include/c++/12/bits/basic_string.h" 3
       
# 38 "/usr/include/c++/12/bits/basic_string.h" 3

# 1 "/usr/include/c++/12/ext/alloc_traits.h" 1 3
# 32 "/usr/include/c++/12/ext/alloc_traits.h" 3
       
# 33 "/usr/include/c++/12/ext/alloc_traits.h" 3

# 1 "/usr/include/c++/12/bits/alloc_traits.h" 1 3
# 33 "/usr/include/c++/12/bits/alloc_traits.h" 3
# 1 "/usr/include/c++/12/bits/stl_construct.h" 1 3
# 73 "/usr/include/c++/12/bits/stl_construct.h" 3

we get a definition of destroy_at.

@Technius
Copy link
Member

I think the root problem is that TinyVector.h implicilty depends on <memory>; the simplest fix is to insert #include <memory>. I would do this as a separate commit.

@bhennion bhennion force-pushed the issue-4624-add-page-numbers branch from 8729fb1 to f85e518 Compare March 19, 2023 08:02
@bhennion
Copy link
Collaborator

I think the root problem is that TinyVector.h implicilty depends on <memory>; the simplest fix is to insert #include <memory>. I would do this as a separate commit.

I just did that via #4743.
I also rebase this onto it (and squashed the commits together) so the pipeline can check is all works out.

Merging in 24 hours unless an obstruction is raised (or the pipeline complains).

@bhennion bhennion added the merge proposed Merge was proposed by maintainer label Mar 19, 2023
@CruzeBlade
Copy link
Contributor Author

⚠️ Please do not merge yet ! ⚠️

I have just tested all changes again and found several new issues.

  • The selected style is not saved in the settings.xml correctly (because of the static_cast)
  • "Magical constant" in SidebarPreviewPageEntry::getWidgetHeight()
  • For some reason, the circle and the square background are drawn some pixel too high now
    grafik
  • Very low text contrast for the page numbers in Light Theme
    grafik

I will try to push fixes for these issues asap, but merging the current state would be bad. Sorry about the inconvenience!

@bhennion bhennion removed the merge proposed Merge was proposed by maintainer label Mar 19, 2023
@CruzeBlade CruzeBlade requested a review from bhennion March 19, 2023 22:07
@CruzeBlade
Copy link
Contributor Author

OK, now all the issues should be fixed. Sorry about the late intervention yesterday.

Copy link
Collaborator
@bhennion bhennion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it out again, and I found issues. I took the screen shot with GDK_SCALE=2 to make the problem more appearent, but they also occur without it.

  1. Style 1: The bottom of the numbers get truncated.
    Screenshot_20230320_185934
  2. Style 2: The numbers are not centered in the circle. We'd also need to adapt the circle for numbers with several digits. One idea is to make it oblong (i.e. like a rectangle with two half-disks on the sides)
    Screenshot_20230320_190059
  3. Style 3: Same problem here. Moreover, the grey frame is missplaced by a couple pixels (we should not be seeing a black line between the page and the frame)
    Screenshot_20230320_190350

ui/settings.glade Outdated Show resolved Hide resolved
@CruzeBlade
Copy link
Contributor Author

For some reason, I cannot reproduce the first issue with the truncated page numbers, neither with GDK_SCALE=2 nor without.
Does this appear all the time or only under certain circumstances? Which display resolution do you use?

@bhennion
Copy link
Collaborator

For some reason, I cannot reproduce the first issue with the truncated page numbers, neither with GDK_SCALE=2 nor without. Does this appear all the time or only under certain circumstances? Which display resolution do you use?

It appears all the time. It seems to go away for the number of a given page if I change the page's size.

@CruzeBlade
Copy link
Contributor Author
CruzeBlade commented Mar 20, 2023

Do you mean changing the page zoom scaling or changing the paper format?

@bhennion
Copy link
Collaborator

Do you mean changing the page zoom scaling or changing the paper format?

The paper format

@CruzeBlade
Copy link
Contributor Author

So the second issue should be fixed now.
image

I still cannot reproduce the first issue. What display resolution are you using?

@CruzeBlade
Copy link
Contributor Author

I have also reworked the third style now. Here is what it looks like now:

Light Theme Dark Theme
grafik grafik

I prefer this darker gray color over the previous one, but please let me know what you think.

@CruzeBlade
Copy link
Contributor Author

Regarding the issue with the truncated page numbers. I think I found what was causing this. It was that the page preview widget were never properly resized to handle the additional number at the bottom. I have fixed this now.

But when the style is changed in the preferences, it does not immediately update the widget size. In that case, it can be that either the widget is displayed too large or the page number is truncated until the sidebar is redrawn and layouted the next time.

A solution would be to always layout the sidebar immediately after the preferences were saved.

@bhennion
Copy link
Collaborator

I had a couple minutes to test this this morning. Most of the issues seen gone. The truncated page numbers seem fixed as well.

You are mentioning another minor issue though: I agree the layout should be updated whenever the setting is changed.

I'll try to have a look at the code later today.

@CruzeBlade
Copy link
Contributor Author

The layout issue after changing styles in the preferences should be fixed now.

Copy link
Collaborator
@bhennion bhennion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay.

I disagree with your solution for updating the sidebar when the parameter is changed in Settings. See below. (you can start by reverting your last commit)

src/core/control/settings/Settings.cpp Outdated Show resolved Hide resolved
@CruzeBlade CruzeBlade force-pushed the issue-4624-add-page-numbers branch from d897b3e to 6e2b526 Compare April 14, 2023 08:39
@CruzeBlade CruzeBlade force-pushed the issue-4624-add-page-numbers branch from 6e2b526 to 01d0b85 Compare April 14, 2023 08:59
Copy link
Collaborator
@bhennion bhennion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

@bhennion
Copy link
Collaborator
bhennion commented Apr 16, 2023

Thanks a lot for the hard work!
If that's ok with everyone, I'll be squashing and merging this in 72 hours (unless someone objects)

@bhennion bhennion added the merge proposed Merge was proposed by maintainer label Apr 16, 2023
@Technius Technius linked an issue Apr 16, 2023 that may be closed by this pull request
@bhennion bhennion merged commit 3242208 into xournalpp:master Apr 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge proposed Merge was proposed by maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add page numbers to the page overview sidebar
4 participants