cancel
Showing results for 
Search instead for 
Did you mean: 

dark mode: set bit map dynamically for image widgets in TouchGFX

BGuth.1
Senior

I am trying to implement dark mode in my application. For this, when user selects dark mode, images for all the image widgets need to be changed to dark mode images. I understand this can be done using setBitmap in run time. However, images need to be changed to all the image widgets in current screen as well as other screens. How can I achieve this?

Is it a good idea to check dark mode setting in setupScreen() and then use setBitmap to attach appropriate image to all image widgets in that particular screen?

Any other ways to achieve this?

3 REPLIES 3
Alexandre RENOUX
Principal

Hi BGuth.1,

Yes this is the way to do it.

To have a dark mode, you check the setting in setupScreen() and change the bitmaps accordingly.

When you want to switch to dark mode your current screen, 2 options :

  • you have put all the changes depending on the mode setting in a function that you can call anywhere
  • you perform a screen transition to the current screen so that setupScreen() is called again.

/Alexandre

Maybe better question is how to do this efectively. Now base add to screen Image 1 , but setup replace it with image 2.

@Alexandre RENOUX​ in witch point is this rendered and how is MCU power used for this change?

Better choice is add theme support analogic to language in strings.

Or when rendering is after setup then no problem and only array for IDs is necesary for theme switch.

Hi,

I have also been looking the most swift way of doing this.

I would love to see a "day/night" switch feature, so that all the graphical setup can be done and testet in Designer directly, without the hassle of looking for eg. night png filenames and the need of override each setup screenview.