lighterowl / transgui

A fork of Transmission Remote GUI
GNU General Public License v2.0
152 stars 3 forks source link

UI color issue after switching between light/dark mode on macOS #57

Closed kailiu42 closed 1 year ago

kailiu42 commented 1 year ago

Some UI element remains dark background after the OS switched from dark to light mode, make the text unreadable and the UI look strange. Would you please take a look?

Snipaste-20231014-091437 Snipaste-20231014-091448
lighterowl commented 1 year ago

Thanks, it can't be a coincidence that it's every 2nd row.

wayward-turnip commented 1 year ago

This was reported here, and your fix @xavery would also fix the issue on the upstream project. As described here, it has something to do with when day/night mode switch — the app does not notice. https://github.com/transmission-remote-gui/transgui/issues/1366

          Also in Dark Mode, hyperlink color is almost unreadable at night.
Screen Shot 2021-03-17 at 9 32 49 PM

Originally posted by @wayward-turnip in https://github.com/transmission-remote-gui/transgui/issues/1366#issuecomment-801550193

lighterowl commented 1 year ago

The colour used to draw even-numbered rows is called AlternateColor in Lazarus' TGrid classes, and transgui sets it for (almost) all grids used in the program inside TMainForm.FormCreate :

gTorrents.AlternateColor:=FAlterColor;
lvPeers.AlternateColor:=FAlterColor;
lvTrackers.AlternateColor:=FAlterColor;
gStats.AlternateColor:=FAlterColor;

The problem is that TMainForm.FormCreate is only called once so this value remains the same throughout the whole program, without taking into account any potential dark/light theme changes.

There is a solution available which gets a "theme changed" notification straight from the OS so it sounds like it's going to be possible to set those colours to new theme-appropriate values.

lighterowl commented 1 year ago

Dark/light theme transitions should be now fixed. Hyperlinks now use a lighter shade of blue in dark mode which is much more readable : foo

The latest build from master incorporates these changes : https://github.com/xavery/transgui/suites/17484835100/artifacts/999179257

kailiu42 commented 1 year ago

The torrent list view is OK with the latest build now. However the downloaded progress bar in the general panel still has problem.

The bar after switched from dark to light:

Snipaste-20231022-091456

The bar after restarted transgui, which should be the correct color:

Snipaste-20231022-091516
lighterowl commented 1 year ago

Thanks @kailiu42 , great catch.

The progress bar uses a custom drawing procedure which needs the data from the currently selected torrent. This means that the colour change will be a bit delayed to the app's theme change but will happen eventually (depending on your refresh interval) :

https://github.com/xavery/transgui/assets/127875/594397aa-c099-4805-ba20-d5673538a56a

I'm sure there's a way to call this procedure from the theme change callback but I kept getting weird crashes that I couldn't figure out.

These changes are available in https://github.com/xavery/transgui/suites/17499778981/artifacts/999844573.

kailiu42 commented 1 year ago

It works now. Thanks a lot @xavery for your great help!