Bug 141566 - Implement os/DE theme support in Basic Editor, allow for dark mode when used
Summary: Implement os/DE theme support in Basic Editor, allow for dark mode when used
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.2.0.0.alpha0+
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: target:7.2.0
Keywords: difficultyInteresting, easyHack, skillCpp, skillDesign, topicUI
Depends on:
Blocks: Options-Dialog-Colors
  Show dependency treegraph
 
Reported: 2021-04-08 16:48 UTC by Rafael Lima
Modified: 2021-08-07 13:32 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Basic Editor in Dark Mode (147.38 KB, image/png)
2021-04-08 16:48 UTC, Rafael Lima
Details
Screenshots describing the issue (274.32 KB, application/vnd.oasis.opendocument.graphics)
2021-04-14 11:21 UTC, Rafael Lima
Details
Screenshots describing the issue (275.17 KB, application/vnd.oasis.opendocument.graphics)
2021-04-14 11:24 UTC, Rafael Lima
Details
Writer Document created in a Dark Background (49.43 KB, application/vnd.oasis.opendocument.text)
2021-04-14 12:23 UTC, Rafael Lima
Details
Screenshots of the File in Dark and White document background (332.39 KB, application/vnd.oasis.opendocument.graphics)
2021-04-14 12:24 UTC, Rafael Lima
Details
Screenshot with dark background (149.13 KB, image/png)
2021-04-23 08:30 UTC, Heiko Tietze
Details
Basic Editor Colors (117.60 KB, application/vnd.oasis.opendocument.graphics)
2021-05-03 18:58 UTC, Rafael Lima
Details
Patchset 3 (197.29 KB, image/png)
2021-05-04 18:33 UTC, Heiko Tietze
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Lima 2021-04-08 16:48:54 UTC
Created attachment 171033 [details]
Basic Editor in Dark Mode

Hi! I would like to discuss the possibility of having Dark Mode support in LO Basic Editor.

I am using LO 7.1.1.2 in KDE and my System Theme is set to Breeze Dark. In LO all UI elements use system colors, except for LO Basic Editor. I have uploaded a screenshot showing that, even on dark mode, the Basic Editor has white background and default font colors.

So, the idea would be to implement it in one of the 2 possible ways:
1) Detect system colors and apply them to the Basic Editor, or:
2) Have a toggle in Tools > Options > LibreOffice > General with something like "Use dark mode in Basic Editor" and then apply a predefined set of colors to the Editor and Syntax Highlighter

Currently the Basic Editor seems to get its color from the "Document Background" setting under Tools > Options > LibreOffice > Application Colors. Hence, to implement dark mode support we would have to dissociate Basic Editor's color from this setting, defining a new Color for "Basic Editor Background Color".

Other text editors in LO such as Math's formula editor respond to dark mode as expected.
Comment 1 Heiko Tietze 2021-04-12 09:32:54 UTC
Generic dark mode requests are in bug 118320 (Windows) and bug 118017 (macOS).

Linux/KDE/Breeze Dark work fine for me and I don't see what you want to improve. The white canvas, which comes from Writer (blank) or Calc (grid)? That's an option in Tools > Options > Application colors and actually better working than white on black.

Similar request in bug 114147 was rejected. So my take => WF
Comment 2 Adolfo Jayme 2021-04-12 12:43:47 UTC
From using e.g. VS Code, to me it’s obvious that the default editor background should match the environment without having to fiddle with settings.
Comment 3 Rafael Lima 2021-04-12 13:46:30 UTC
> Linux/KDE/Breeze Dark work fine for me and I don't see what you want to
> improve. The white canvas, which comes from Writer (blank) or Calc (grid)?
> That's an option in Tools > Options > Application colors and actually better
> working than white on black.

Hi Heiko. I think the main problem is that the color of the Basic Editor is the same as the one used in the Background of Writer documents. I think these colors should be treated separately, because users may want to keep their white background in Writer/Calc documents while programming on a dark background in the Basic Editor.

For example, most Writer documents are created with white-colored background in mind, because later they'll be printed or exported to PDF. So, even on a dark theme, the user may want to keep white background in Writer.

I believe the easiest way to implement this is to create a new color entry named "Basic Editor Background Color" in Tools > Options > LibreOffice > Application Colors. It could be placed near the other Basic color settings that already exist in the dialog.

Later, we could think of implementing more convenient ways for the user to apply a dark theme to the Basic Editor, by defining color presets for syntax highlighting in light and dark modes.
Comment 4 Heiko Tietze 2021-04-13 07:34:32 UTC
(In reply to Rafael Lima from comment #3)
> ...is the same as the one used in the Background of Writer documents.

Please start Math from Calc (Insert > Object > Formula) and revise your comment.
Comment 5 Rafael Lima 2021-04-14 11:21:11 UTC
Created attachment 171189 [details]
Screenshots describing the issue

(In reply to Heiko Tietze from comment #4)
> Please start Math from Calc (Insert > Object > Formula) and revise your
> comment.

Heiko, I'm not sure what you would like me to revise. As I pointed out in my first message: "Other text editors in LO such as Math's formula editor respond to dark mode as expected". You can see in the first image of the ODG file I've just attached that indeed the Formula Editor in Math follows system colors and gets a dark background and white font color.

As for this part: "is the same as the one used in the Background of Writer documents", what I meant is that Basic's Editor does not respond to dark mode because it gets its color from the "Document Background" color in the Options menu (see the 2nd image in the attached ODG file).

What I'm proposing is to have a separate color setting for the Basic IDE, so that the user can set different colors for "Document Background" and "Basic Editor Background Color".
Comment 6 Rafael Lima 2021-04-14 11:24:15 UTC
Created attachment 171190 [details]
Screenshots describing the issue

Consider this ODG file for the message above.
Comment 7 Heiko Tietze 2021-04-14 11:29:25 UTC
Apologies, you talk about Basic. But still, why should it use a different color than other modules?
Comment 8 Rafael Lima 2021-04-14 12:22:48 UTC
Even in dark mode, there are many reasons to stick with a white background in Writer:

1) I write papers in contribution with other authors and they create their documents using white background. This is the default in academic writing, because later the paper will be published as a PDF (with white background) or printed in paper (white too).

2) In Writer, if you chose a dark background and start adding images from other sources (which were created with white background in mind), they will produce a weird looking document (everything is black and all of a sudden there is a white image, which was supposed to blend with the document if the document background were white too - see example in the attached ODG).

3) Font colors are a problem too. If you start setting font colors with dark background in mind (using direct formatting) and then send the file to someone with a white background (which is still a majority), the recipient won't be able to read parts of the text formatted using direct formatting (I know that it's best to use styles, but most people still use direct formatting for basic things as setting font colors).

I created a sample Writer file (using a dark background) and added a few screenshots with it rendered in dark and light background to illustrate my point.

It should be noted that when using the Default character style, LO already switches font colors from black to white to respond to dark mode. However, the problem arises with direct formatting.

On the other hand, users programing in the Basic Editor will probably want to stick with a dark background when system theme is in dark mode, even while maintaining a white background for Writer documents.
Comment 9 Rafael Lima 2021-04-14 12:23:21 UTC
Created attachment 171192 [details]
Writer Document created in a Dark Background
Comment 10 Rafael Lima 2021-04-14 12:24:01 UTC
Created attachment 171193 [details]
Screenshots of the File in Dark and White document background
Comment 11 Heiko Tietze 2021-04-14 13:01:03 UTC
Sorry for the confusion with Math. But it's the same for Basic: you get the canvas in application background color. And besides the fact that a dark background as Kate has is bad IMHO, you can configure it and the question is why you need a special handling for Basic.
Comment 12 Rafael Lima 2021-04-14 13:53:22 UTC
(In reply to Heiko Tietze from comment #11)
> Sorry for the confusion with Math. But it's the same for Basic: you get the
> canvas in application background color. And besides the fact that a dark
> background as Kate has is bad IMHO, you can configure it and the question is
> why you need a special handling for Basic.

The reason is because users may want, at the same time, to have a dark background in the Basic Editor while maintaining a white background for Writer/Calc documents.

In my previous message I used Writer examples to explain why Writer users might want to keep a white background even on a dark theme.

I myself do a lot of Basic programming and I would love to use dark background in the Basic editor, while keeping the white background in Writer/Calc.
Comment 13 QA Administrators 2021-04-15 03:45:04 UTC Comment hidden (obsolete)
Comment 14 Heiko Tietze 2021-04-23 08:30:23 UTC
Created attachment 171366 [details]
Screenshot with dark background

Topic was on the agenda for the design meeting but no further input.

Personally, I dislike dark input canvases (running dark system theme myself) and wouldn't add more UI options. But if we follow Adolfo's suggestion to obey the system theme, an option to revert to bright is desirable to me too. However, I'm not convinced that Basic is special just because the entered text has much more structure.

The background color is a simple easy hack in basctl/source/basicide/baside2b.cxx EditorWindow::EditorWindow() -> SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetDialogColor()));
(the additional option makes it a bit more tricky.

The dark background requires brighter font colors. So in addition we need another preset in Tools > Options > Colors like "LibreOffice Dark" (there are many tickets on this) and now something like "LibreOffice Basic Dark" too.
Comment 15 Rafael Lima 2021-05-03 18:58:02 UTC
Created attachment 171617 [details]
Basic Editor Colors

Heiko, you'll find in the attached file a suggestion of colors to be used in the Basic Editor in dark mode (screenshot and details in the ODG file)

Identifier: dde8cb
Comment: eeeeee
Number: ffa6a6
String: ffa6a6
Operator: b4c7dc
Reserved Expression: b4c7dc
Error: ff3838

These suggestions are based in the hardcoded document background color "333333" used the the proposed patch.
Comment 16 Heiko Tietze 2021-05-04 18:33:04 UTC
Created attachment 171635 [details]
Patchset 3

Really these colors?
Comment 17 Rafael Lima 2021-05-05 11:54:19 UTC
(In reply to Heiko Tietze from comment #16)
> 
> Really these colors?

Hi Heiko... Yes, these are the colors I suggested. But off course it's still up for debate.

Where do you think changes are necessary? I can come up with a different proposal.
Comment 18 Commit Notification 2021-05-06 07:55:36 UTC
Heiko Tietze committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6dfc49bb6a72bf6bb79167b12f0d2d0c5a155d06

Resolves tdf#141986, related tdf#141566 - Dark theme

It will be available in 7.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 19 stragu 2021-08-07 13:32:42 UTC
Verified that the code editor panel in the Basic IDE now can easily be set to use a "dark theme" by changing the LO Application Colors scheme to "LibreOffice Dark". The background uses the "Document background" colour, in the "General" section.

Noting that it is not a fix for automatically following the OS dark theme, but the discussion here made it clear that this is out of scope for the part of the application where the user edits the file.

Also noting that Rafael's concern about changing the Basic IDE's background colour independently from the document background in other applications hasn't been resolved. I agree that, the Basic IDE being a code editor (i.e. not usually printed) and not a "document" editor (i.e. commonly printed), it would make sense to be able to set that colour to something dark (very common in IDEs) while keeping Writer, Calc, Impress and Draw with a white background.

Should an easy hack be opened to expose a new Basic background option in the Application Colors dialog, with the pointers Heiko offered in Comment 14?

Version: 7.2.0.2 / LibreOffice Community
Build ID: 614be4f5c67816389257027dc5e56c801a547089
CPU threads: 4; OS: Linux 5.4; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
Calc: threaded