Define colors by file type: Wrong automatic colors in dark mode

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: white, Hacker, petermad, Stefan2

User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Define colors by file type: Wrong automatic colors in dark mode

Post by *Usher »

Run TC in normal mode, open Configuration on Color, click "Define colors by file type…" button and add some new colors (more ore less) typical for classic color styles (Norton Commander or DOS Navigator):

Code: Select all

Filetype    R   G   B Bright  DarkMode
----------------------------------------
*.magenta 255  84 255  160   255 255 255
*.blue     84  84 255  160   255 255 255
*.cyan    117 223 223  160   255 255 255
*.green    99 241  99  160   255 255 255
*.yellow  255 255  84  160   255 255 255
*.orange  255 170  84  160   255 255 255

*.orange1 253 193  32  134   255 251 239
*.orange2 255 205  33  136   255 251 239
Input provided RGB values and notice resulting Brightness values. Now click "Dark<->Normal" button and check new colors automatically calculated by TC for dark mode. Here's what you should observe:

1. As you can see on the first 6 types (from magenta to orange), all colors bright in normal mode go white in dark mode. You can test other colors - any color with Brightness>=160 will go white. You must remember color settings for normal mode to properly change respective values for dark mode. I suspect that TC simply ignores base "Font color" settings for normal mode and blindly bumps values for other colors which are obviously related to the base color.

2. Now observe the last two types (orange1 and orange2). They are darker and they have different brightness in normal mode, yet similar colors go the same in dark mode. You may say "I can't see no difference in normal mode, they are already almost the same". Yes, but imagine two similar colors with visible difference in normal mode (for example for files with compressed attribute and for archives) which go almost the same in dark mode - it's wrong. It looks like TC bumps colors to a certain level rather than calculate some mean value.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *ghisler(Author) »

This isn't a bug. TC expects that the colors by file type in normal mode are quite dark, so they must be made brighter for dark mode. If you use bright colors for fonts in normal mode, you will have to change the colors yourself in dark mode. There is no automatic adjustment which works well in all cases.

Currently I convert the RGB value to HSL (hue, saturation, lightness):
https://en.wikipedia.org/wiki/HSL_and_HSV

The lightness has a value between 0 and 10000. Then I make it ligher this way:
L1=(hsl.Lightness/10000)*3000+8000; // 0..10000 -> 8000..10000
if (L1>10000)
L1=10000;

I tried a few options, and this looked best with the usual dark colors used for colors by file type.
If you have a better idea, please let me know.
Author of Total Commander
https://www.ghisler.com
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *Usher »

ghisler(Author) wrote: 2020-02-24, 09:32 UTC This isn't a bug. TC expects that the colors by file type in normal mode are quite dark, so they must be made brighter for dark mode.
It's wrong assumption.
1. Many people use classic color style in normal mode.
2. Colors listed in my examples are bright, but not all of them are seen as light as it's assumed from the formal brightness/lightness value. They are saturated rather than pale. White color has ZERO saturation.
3. Some people use bright saturated colors on white background as WARNING! In any case such colors shouldn't go neutral white in dark mode.

ghisler(Author) wrote: 2020-02-24, 09:32 UTC I tried a few options, and this looked best with the usual dark colors used for colors by file type.
If you have a better idea, please let me know.
Now I understand why it works wrong way.

If you want to simply modify existing formulas, don't allow results > 10000 - they lead to irreversible loss of color. Any wider range below 10000 (for example 7000…9500) is better than 8000…10000 – color distortion will be less noticeable. Don't forget that users can easy make proper colors brighter on their own but they can't easy revert white to the proper color.

Now another suggestion: Either keep saturation unchanged (which may be too dark) or make some calculations also for saturation (for example S1=0.7*S).

I think these two changes will be good enough. More light and less saturated is more pale, whiter as needed for dark mode.

And I have already describe other option: Use "Font color" settings from normal mode to modify formulas for colors in dark mode - subtract it, or make some proportional change…

I will take a closer look at your formulas this evening, maybe other users will find better solution earlier…
Andrzej P. Wozniak
Polish subforum moderator
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *Usher »

Well, I did some tests and here's my solution:

L1=0.4*L+6000
S1=0.8*S

where L, S - Lightness and Saturation in normal mode
L1, S1 - Lightness and Saturation in dark mode

It never goes white for non-white colors. It gives Lightness in range 6000…10000 (in original case it's 8000…11000 cut to 8000…10000) and saturation good enough to notice color differences.
Almost the same colors may still go the same because of rounding during calculations and converting HSL back to RGB - it's impossible to convert a broad range of natural numbers into narrower one without loss.
Last edited by Usher on 2020-02-27, 01:08 UTC, edited 1 time in total.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
petermad
Power Member
Power Member
Posts: 14741
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *petermad »

I would like an option in wincmd.ini to NOT change the Dark colors automatically.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *Hacker »

BTW, why not simply invert lightness? I.e. DarkModeLightness := 255 - NormalModeLightness?

TIA
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *Usher »

In dark mode NO font should be dark. You must make them all easy visible no matter what color style is in use in normal mode.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *ghisler(Author) »

I did test with inverted lightness, it didn't work well.
Author of Total Commander
https://www.ghisler.com
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *Usher »

2ghisler(Author)
What about my suggestion?
https://www.ghisler.ch/board/viewtopic.php?f=32&t=57819#p370735
Andrzej P. Wozniak
Polish subforum moderator
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *ghisler(Author) »

Sorry, I must have missed your post. I will try it.
Author of Total Commander
https://www.ghisler.com
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *StatusQuo »

petermad wrote:I would like an option in wincmd.ini to NOT change the Dark colors automatically.
Support++ (for my setup this would probably work).
ghisler(Author) wrote:I tried a few options, and this looked best with the usual dark colors used for colors by file type.
If you have a better idea, please let me know.
My suggestion: test/examples and algorithm. This works OK for the tested both dark and light font colors.
(Original color type is kept if possible, extremely dark colors get a fixed lightness, black goes explicitly to white.)

For MaxVal=100%=240, like tested:

Code: Select all

L1 = Min(240, Round( hsl.Lightness / 240 * 180 + 60
 +((BGR.blue + BGR.green)/ 2-BGR.red)   / 2,75
 +((BGR.blue + BGR.red)  / 2-BGR.green) / 3
 +((BGR.green +BGR.red)  / 2-BGR.blue)  / 3
 ; 0));
if (hsl.Lightness < 70) then
 L1 = 140;
if (BGR.blue + BGR.green + BGR.red < 20) then
 L1 = 240;
 
For MaxVal=100%=10000, not tested, just converted the values:

Code: Select all

L1 = Min(10000, Round( hsl.Lightness / 10000 * 7500 + 2500
 +((BGR.blue + BGR.green)/ 2-BGR.red)   / 2,75
 +((BGR.blue + BGR.red)  / 2-BGR.green) / 3
 +((BGR.green +BGR.red)  / 2-BGR.blue)  / 3
 ; 0));
if (hsl.Lightness < 2900) then
L1 = 5800;
if (BGR.blue + BGR.green + BGR.red < 20) then
 L1 = 10000;
Who the hell is General Failure, and why is he reading my disk?
-- TC starter menu: Fast yet descriptive command access!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *ghisler(Author) »

2StatusQuo
Only using fixed values for lightness doesn't take into account when a user uses for example several steps of brightness (e.g. very dark red, less dark red etc) for different states.
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *ghisler(Author) »

In my tests, the suggested formula
L1=0.4*L+6000
S1=0.8*S
results in colors which are a bit too dark. I will use this instead:
L1=0.3*L+7000
S1=0.9*S
Author of Total Commander
https://www.ghisler.com
StatusQuo
Power Member
Power Member
Posts: 1524
Joined: 2007-01-17, 21:36 UTC
Location: Germany

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *StatusQuo »

2ghisler(Author)
Only using fixed values for lightness
My suggestion was not "only fixed values", just the lowest 30% of lightness were kept on a minimum level.
But I see you focus primarily on dark font colors, so I agree my suggestion doesn't fit.

For me TC 9.51 RC4 still turns TC colors into black and white, I'll have to keep my manual "keep colors" configuration (currently requiring one manual INI line for each ColorFilter). Hoping for a switch in a future release to achieve this easier (for different configurations).
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Define colors by file type: Wrong automatic colors in dark mode

Post by *ghisler(Author) »

Just change them yourself. An automatism can never be 100% perfect.
Author of Total Commander
https://www.ghisler.com
Post Reply