|
|
|
Re: How to get SWT stand-alone app to render UI in "dark mode" [message #1852287 is a reply to message #1852171] |
Mon, 09 May 2022 00:37 |
Andy Maleh Messages: 75 Registered: March 2020 Location: Montreal, Quebec, Canada |
Member |
|
|
TreeViewer is not a widget. It is only the JFace MVC view model adapter (wrapper) for the Tree widget in SWT, so it does not affect the look of the widget directly either way yet the content and selection. All viewers extend org.eclipse.jface.viewers.Viewer, which are described in the Javadoc as "a model-based adapter on a widget."
In any case, automatic support for Dark Mode only started in SWT 4.21 as far as I know (although it might have existed without automatic support since 4.18), so you are right that it now works without any special "Dark Mode" code.
Here is my Hello, Tree! sample application running on the Mac (using SWT 4.23) in Light Mode:
I closed the app, switched my MacOS "Appearance" System Preferences to Dark Mode, and then restarted the app. I got the following look that demonstrates that Dark Mode does work in SWT with the Tree widget (automatically):
One thing to note is that I am using Glimmer DSL for SWT, which does NOT need TreeViewer or JFace because Glimmer offers its own Ruby-based alternative to JFace and JFace Data-Binding that is a lot simpler, terser, and more declarative (leveraging JRuby on the Java Virtual Machine). You can literally data-bind the entire tree with one line of code:
items <= [Employee, :ceo, tree_properties: {children: :subordinates, text: :to_s}]
That said, I did notice an issue when I tried to switch from Light Mode to Dark Mode WITHOUT restarting the app:
A similar issue occurs if I switch from Dark Mode to Light Mode WITHOUT restarting the app:
So, it seems that SWT's support for Dark Mode is not quite complete. For example, if I switch Light Mode to Dark Mode (or vice versa) with a non-SWT desktop app like Google Chrome WITHOUT restarting, it switches colors correctly without any problems.
SWT oughta support LIVE switching between Light Mode and Dark Mode eventually.
EclipseCon / EclipseWorld / Agile Conference Speaker
Open-Source Software Author of Glimmer DSL for SWT
[Updated on: Mon, 09 May 2022 00:57] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03778 seconds