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

Dark Theme Visibility Fixes #5646

Merged
merged 7 commits into from
Nov 24, 2019
Merged

Dark Theme Visibility Fixes #5646

merged 7 commits into from
Nov 24, 2019

Conversation

ageofadz
Copy link
Contributor

There had been some visibility issues with the interface when in dark theme.

  • Changed the color of the vertical scroll bar in dark mode to allow it to be more visible against the other colors.

  • Changed the color of the accent behind the number selected which appears in the group tree when an item in a group is selected to allow for the number inside to be more readable.

fixes #5522

Then:

Now:
Screen Shot 2019-11-19 at 5 44 54 PM

@ageofadz
Copy link
Contributor Author

Sorry if I did anything wrong, this is my first pull request on a public repo.

Also happy birthday if you're reading this dad!

@@ -52,6 +52,7 @@ cd "$(dirname "$(readlink -f "$BASH_SOURCE")")/.."
Samin Muhammad Ridwanul Karim
Stefan Robert
Bernhard Tempel
Samuel Robertson
Copy link
Member

Choose a reason for hiding this comment

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

No need to add yourself. You'll be added correctly by generate-authors.sh based on the data in your commit, In this place in generate-authors.sh, the authors contributing in our subversion times on sourceforge are tracked. With git, we don't need that system any more.

@koppor
Copy link
Member

koppor commented Nov 20, 2019

@ageofadz Thank you for being brave and submitting a pull request. This is how open source should work 🎉

Regarding the red cross. It's because our test coverage checker sometimes fails due to time outs. You can ignore this error. (Refs #5618).

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 20, 2019
@Siedlerchr
Copy link
Member

Thank you very much for your contribution! 🥇 Looks good to me! Would you mind fixing the preview (ciation styles) panel for OpenOffice/LibreOffice as well? This is the same one as in the entry editor, so it should be easy to adapt.

@AEgit
Copy link

AEgit commented Nov 20, 2019

Just for clarification: @Siedlerchr is referring to the issue mentioned here:
#5522 (comment)

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

Thanks for your first contribution!

The changes look good to me, but I have two suggestions that make the code a bit more maintainable in the future.

@@ -64,3 +64,16 @@
-fx-background-color: -fx-light-text-color, -fx-control-inner-background;
}

.scroll-bar:horizontal .track,
Copy link
Member

Choose a reason for hiding this comment

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

Similar code is already in the Base.css file:

.scroll-bar:horizontal .track,
.scroll-bar:vertical .track {
-fx-background-color: -jr-scrollbar-track;
-fx-opacity: 0.6;
-fx-background-radius: 0em;
}
.scroll-bar:horizontal .thumb,
.scroll-bar:vertical .thumb {
-fx-background-color: -jr-scrollbar-thumb;
-fx-background-insets: 0, 0, 0;
-fx-background-radius: 0em;
}

Thus, it should be sufficient if you overwrite the following color specifications:

/* Specs for the scrollbars */
-jr-scrollbar-thumb: derive(-fx-outer-border, -30%);
-jr-scrollbar-track: derive(-fx-control-inner-background, -10%);

here in the root part of Dark.css.

@@ -30,13 +30,12 @@
}

.numberColumn > .hits:any-selected {
-fx-background-color: derive(-jr-green, 70%);
-fx-background-color: derive(-jr-gray-3, 70%);
Copy link
Member

Choose a reason for hiding this comment

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

With these changes, the number column is now also displayed in gray in the light theme. This is probably also not that readable.

I would propose to add two colors (-jr-groups-any-hits and -jr-groups-all-hits), which are used here. Then the dark theme can overwrite them.

@ageofadz
Copy link
Contributor Author

Thank you very much for your contribution! 🥇 Looks good to me! Would you mind fixing the preview (ciation styles) panel for OpenOffice/LibreOffice as well? This is the same one as in the entry editor, so it should be easy to adapt.

Thanks so much for the feedback everyone!
Started working on a few of the changes. As for the changes to the OpenOffice style selection, there's a method in /gui/preview/PreviewViewer.java called setTheme() that can apply a theme to previewArticle and previewBook in /gui/openoffice/StyleSelectDialogView.java, with a note about an open issue on openJDK. I was able to add previewArticle.setTheme("DARK_CSS"); to get the text in the OpenOffice style selection to fit the dark mode, but because it only takes strings, I haven't been able to get a string value for the current theme applied so that the style selection's appearance matches the theme selected.
Here's the method's code:

public void setTheme(String theme) {
if (theme.equals(ThemeLoader.DARK_CSS)) {
// We need to load the css file manually, due to a bug in the jdk
// TODO: Remove this workaround as soon as https://github.com/openjdk/jfx/pull/22 is merged
URL url = JabRefFrame.class.getResource(ThemeLoader.DARK_CSS);
String dataUrl = "data:text/css;charset=utf-8;base64," +
`Base64.getEncoder().encodeToString(StringUtil.getResourceFileAsString(url).getBytes());`
previewView.getEngine().setUserStyleSheetLocation(dataUrl);
}
}

@tobiasdiez
Copy link
Member

What do you mean with the following?

but because it only takes strings, I haven't been able to get a string value for the current theme applied so that the style selection's appearance matches the theme selected.

The method allows you to load the Dark.css, in which you then can add/change the necessary style information.

@ageofadz
Copy link
Contributor Author

What do you mean with the following?

but because it only takes strings, I haven't been able to get a string value for the current theme applied so that the style selection's appearance matches the theme selected.

The method allows you to load the Dark.css, in which you then can add/change the necessary style information.

Because it checks if "Dark.css" is passed in as an argument and switches to dark theme if it is, it needs a string that says which theme is active for it to change according to what theme the user selected.
At the time I couldn't find one, but I found the hashmap in JabrRefPreferences and passed that into it now with JabRefPreferences prefs = JabRefPreferences.getInstance(); and previewArticle.setTheme(prefs.get(JabRefPreferences.FX_THEME));, which appear to work!

Testing right now, will update my pull requests later today with that addition and your earlier suggestions.

ageofadz added 2 commits November 21, 2019 15:32
Edited dark theme scrollbar fix to dark.css to overwrite color -jr-scrollbar-thumb and -jr-scrollbar-track in dark.css. Switched base theme background for group selection number highlight back to green. Added dark theme to OO/Libreoffice style selection pane.

fixes #5646
@Siedlerchr
Copy link
Member

JabRefPreferences prefs = JabRefPreferences.getInstance(); and previewArticle.setTheme(prefs.get(JabRefPreferences.FX_THEME));, which appear to work!

In the Style Select DialogView you have access to the preferences via the Preferences Service which is a wrapper (for dependency injection via the FXML loader) for the JabRefPreferences.
We try to pass dependencies always as constructor arguments (Inversion of Control principle) to avoid direct dependency calls.
So the idea would be to add a method e.g. getActiveTheme to the PreferencesService which returns the theme for the preferences. Then you can call setTheme on the PreviewViewer.

Edited dark theme scrollbar fix to dark.css to overwrite color -jr-scrollbar-thumb and -jr-scrollbar-track in dark.css. Switched base theme background for group selection number highlight back to green. Added dark theme to OO/Libreoffice style selection pane.

fixes #5646
@ageofadz
Copy link
Contributor Author

Hey, many thanks once again for everyone's feedback!
The newest commit has updates to dark.css based on @TobiasDiaz's suggestion to overwrite scroll bar and group hit colors, in addition to @Siedlerchr's suggestion to update the StyleSelectDialogView using the Preferences Services wrapper injection as opposed to a hard dependency to JabRefPreferences.

Attached is a screenshot displaying the changes to scrollbar and group selected indicator (visually unchanged since first commit) and the OO style selection dialog view.

Screen Shot 2019-11-23 at 12 08 20 PM

[] Tests created for changes
[x] Manually tested changed features in running JabRef
[x] Screenshots added in PR description (for bigger UI changes)
[x] Checked documentation: Is the information available and up to date? If not: Issue created at https://github.com/JabRef/user-documentation/issues.

@tobiasdiez
Copy link
Member

This looks good! Thanks for the follow-up.

I think you latest commit reverted the changes in the previous commit ageofadz@b812b62. You can use git cherry-pick to integrate these changes as well.

@ageofadz
Copy link
Contributor Author

This looks good! Thanks for the follow-up.

I think you latest commit reverted the changes in the previous commit ageofadz@b812b62. You can use git cherry-pick to integrate these changes as well.

To fix that, should I use git cherry-pick ^aa06737230927cd0c9cd32a9860d26e20c367797..b812b62b6b854795fc9c012aa458959ed581bcfe?
The commit from two hours ago should have just added getTheme() to preferencesServices and jabRefPreferences and updated the StyleSelectDialogView to remove directly calling jabRefPreferences to refer to the preferencesServices getTheme().

@tobiasdiez
Copy link
Member

Mr. @koppor git wizard, can you please assist with the git issue.

@koppor
Copy link
Member

koppor commented Nov 24, 2019

If it is only the commit b812b62, git cherry-pick b812b62b6b854795fc9c012aa458959ed581bcfe is enough (no need for commit ranges). Possibly, conflicts have to be resolved. Just resolve it with the IDE and then commit the result. I use git gui and click on the envelope buttons at the upper left.

changelog.md (63)
StyleSelectDialogView (83-84)
@ageofadz
Copy link
Contributor Author

Newest commit cherry-picks b812b62 and resolved conflicts in CHANGELOG.md and StyleSelectDialogView.java.
Thank you git wizard @koppor!

@koppor
Copy link
Member

koppor commented Nov 24, 2019

I think a git push is missing? Maybe you cherry-picked on the wrong branch? You can always check the current overall branch status with gitk --all&. Then, it displays where which branch currently points to. (Maybe the articleh https://lostechies.com/joshuaflanagan/2010/09/03/use-gitk-to-understand-git/ helps a bit?)

@ageofadz
Copy link
Contributor Author

The latest commit is, 4411dce. gitk --all&, shows it as HEAD with 508c2be as parent, git status says I'm up to date.

Unsure why it isn't appearing in the PR, but appears on my fork

@tobiasdiez
Copy link
Member

You pushed it to your master branch but not to the base branch of this PR.

@tobiasdiez
Copy link
Member

This looks good now. Thanks again and looking forward to your next PR 😄 !

@tobiasdiez tobiasdiez merged commit 8780a56 into JabRef:master Nov 24, 2019
@ageofadz
Copy link
Contributor Author

Couldn’t wish for a better first PR. Learned a lot and had a blast, I’m stoked to do many more.
Thank you all very much for being so helpful and patient commit after commit 😂

@ageofadz ageofadz deleted the fix-for-issue-5522 branch November 25, 2019 16:01
koppor pushed a commit that referenced this pull request Oct 15, 2021
3a6a0a7 Update masarykova-univerzita-pravnicka-fakulta.csl (#5655)
136653a Corrections for Conservation Biology style (#5661)
af148f8 Update biophysics-and-physicobiology.csl (#5646)
8842ed1 Create production-and-operations-management.csl (#5654)
6b4965f update style file (#5656)
e5f6066 Update to Ruby 3.0.2 (#5657)
61c530c Reindent/reorder (#5653)
118c217 Update gems (#5652)
46cd9ab harvard-university-of-bath.csl: correct et-al-min (#5651)
37ba705 Create focaal-journal-of-global-and-historical-anthropology.csl (#5649)
e22b8a5 Create developmental-medicine-and-child-neurology.csl (#5644)
f7bc32c Bump nokogiri from 1.11.4 to 1.12.5 (#5640)

git-subtree-dir: buildres/csl/csl-styles
git-subtree-split: 3a6a0a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dark theme: Visibility problems with current colouring scheme (group colouring and scroll bars)
5 participants