Is there an easy way to put my program in a dark theme?

Post

Posted
Rating:
#1 (In Topic #1051)
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
Hello everyone

I have my project in light colors since I started it. But now I observe that it is more elegant, more readable and careful to use dark theme to consume less energy.

Anyway, me and my environmentalism. :)

Is there a way to convert my project to a dark theme without dying trying?

I already tried it several times but I gave up because of how huge my project is, full of forms and letters, especially in red and green because they are economic data, as well as icons that I did not take into account their background, etc.

Please, any help would be appreciated.

Greetings

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
I'm not so sure.

Maybe using Color.Invert() in a For loop on the form controls to convert it..

Code (gambas)

  1.  
  2. If bDarkMode Then
  3.  
  4.   For each c as Control In Form.Controls
  5.    c.Foreground = Color.Invert(c.Foreground)
  6.    c.Background = Color.Invert(c.Background)
  7.   Next
  8.  
  9.  
  10.  

Something a bit like that but probably more advanced <EMOJI seq="1f60e" tseq="1f60e">😎</EMOJI>
Online now: No Back to the top

Post

Posted
Rating:
#3
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
It would be interesting. I try it and I'll tell you.
 :shock: How it works is going to be amazing. :shock:

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top

Post

Posted
Rating:
#4
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
 I give up. The code works although in my case very partially.

My problem is that I'm going to have to modify everything, everything, the code to resolve the issue to dark.

Nobody's fault. Only me for not having foreseen this possibility.

Note: It occurred to me now, to change the color in the .Form files but I don't know if it is possible. But even if it is possible, I am sure that within the code I assign colors, with which it will continue to be chaos.

Thanks for that attempt to help me, but I'm at a dead end.

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top

Post

Posted
Rating:
#5
Guru
BruceSteers is in the usergroup ‘Guru’
This kinda works for me…
I have this Public function in my StartUp.class…

Code (gambas)

  1.  
  2. Public DarkMode As Boolean = True
  3.  
  4.  
  5. Public Sub CheckDark(Parent As Object)
  6.  
  7.   If Not DarkMode Then Return
  8.  
  9.   Try Parent.Foreground = If(Parent.Foreground = -1, Color.White, Color.Invert(Parent.Foreground))
  10.   Try Parent.Background = Color.Invert(Parent.Background)
  11.  
  12.   For Each o As Object In Parent.Children
  13.     If o Is Container Then
  14.         CheckDark(o)
  15.     Else
  16.       Try o.Foreground = If(o.Foreground = -1, Color.White, Color.Invert(o.Foreground))
  17.       Try o.Background = Color.Invert(o.Background)
  18.     Endif
  19.   Next
  20.  
  21.  
  22.  

then for each form class file i just add the following in the Form_Open() method…

Code (gambas)

  1.  
  2.  
  3. Public Sub Form_Open()
  4.  
  5.   StartUp.CheckDark(Me)
  6.  
  7.  
  8.  

It'll need more work though i think to check if the desktop is in dark mode.
I think the following code…
o.Foreground = If(o.Foreground = -1, Color.White, Color.Invert(o.Foreground))
may only work on non dark themes where the text is black
Online now: No Back to the top

Post

Posted
Rating:
#6
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
 I haven't tried it yet. I'll tell you, but it works or not. I'm honestly moved and I appreciate your effort. Thanks for your help.

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top

Post

Posted
Rating:
#7
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
 This code works much better. There are little things but it takes less effort to correct my program.

As I always tell you and I will tell you today you have done a little more good than bad. And I hope you are rewarded. Thank you.

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top
1 guest and 0 members have just viewed this.