Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-dev] Enabling dark theme support for SWT stand-alone applications on Windows

Hi Lars,

Moving away from simply using the SWT library isn't really an option for me, especially given that everything works well on Linux and OSX.

Explicitly setting each widget's properties after creation, as suggested by Alexandr, is also not an option due to codebase complexity, so I've investigated using the SWT.Skin event to apply theme changes (on top of the existing hacks activated by calling OS.setTheme(true)).

This doesn't work too badly although due to the delayed nature of the event dispatch any overrides the existing code has applied tend to get trashed.

Also code that attempts to set colours back to "defaults" (e.g. widget.setBackground(null)) will remove any applied theme.

Composite borders are also not included in the OS.setTheme hacks so I had to create a separate composite and draw the border in the themed colour myself.

The ExpandBar widget looks particularly bad but I guess I'll have to live with that.

cheers

Paul

On 12/01/2023 14:54, Lars Vogel wrote:
Hi Paul,



IIRC in pure SWT apps you will have to style your widgets using the regular SWT API, I primary work with RCP clients for which we use the CSS engine.

Best regards, Lars



Best regards, Lars

On Thu, Jan 12, 2023 at 3:44 PM Paul Gardner <gardnerpar@xxxxxxxxx> wrote:

I have a stand-alone SWT application (BiglyBT, https://github.com/BiglySoftware/BiglyBT) that runs with a dark theme on Linux and OSX just fine. However, on Windows I am stuck trying to figure out how to do this.

I've been following the [Win32][DarkTheme]... discussions on Bugzilla for a while, and see that the Eclipse IDE itself is working well with a dark theme on Windows 10/11, so it seems to me that SWT support is pretty complete.

As an example, what would I need to do to get

    java -classpath swt.jar org.eclipse.swt.examples.controlexample.ControlExample

to run with a dark theme? If I add

    OS.setTheme(true);

to the main method and run with SWT 4956r13 I end up with the attached.

If I understand the comment in setTheme correctly ( "just some tweaks to tailor things that SWT can't color properly" ) then all I am seeing are the tweaks and the underlying SWT controls are not picking up the theme at all.

Kind regards,

Paul


_______________________________________________
eclipse-dev mailing list
eclipse-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/eclipse-dev


--
Eclipse Platform project co-lead
CEO vogella GmbH

Haindaalwisch 17a, 22395 Hamburg
Amtsgericht Hamburg: HRB 127058
Geschäftsführer: Lars Vogel, Jennifer Nerlich de Vogel
USt-IdNr.: DE284122352
Fax (040) 5247 6322, Email: lars.vogel@xxxxxxxxxxx, Web: http://www.vogella.com

_______________________________________________
eclipse-dev mailing list
eclipse-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/eclipse-dev

Back to the top