cancel
Showing results for 
Search instead for 
Did you mean: 

Global Color Palette / Themes

Dfarr.1
Senior

I would like to use a central color palette for my application. But I haven't found a good example of how to implement that. There doesn't seem to be anything in touchGFX designer to implement this.

My first attempt was to place some colortype variables in the model. But the amount of coding overhead to pass those colors through the presenter, view, then down into several layers of nested custom containers is significant.

So I guess I have 2 questions:

Is there a preferred way of creating centralized application colortypes which can be altered at runtime to support themes?

Am I missing some technique for passing data in/out of nested custom containers that doesn't require so many layers of getters/setters?

2 REPLIES 2
Dfarr.1
Senior

I'm going to try creating an ApplicationColors class with static colortype members. Then instantiate that in every view. Objections?

Dfarr.1
Senior

It seems to be working so far. But I did have to explicitly initialize the static colors to null first in the cpp file, then initialize them AGAIN with their actual colortypes in the contsructor to avoid trying to create the colortypes in a static context. getColorFrom24BitRGB() can't be called until the HAL is initialized I guess.

Now I can instantiate ApplicationColors in my model once. And reference the colors in all my views simply by including the header file and referencing the static colortype ApplicationColors::YourColorNameHere.

I will still have to link up some update functions so the UI knows when to redraw based on color changes. But at least I don't have to pass all those colors through all those layers independently anymore.

Still curious how the developers intended us to implement global application colors if anyone knows.