Custom themes and V7.0

Hello! Again getting acquainted with version 7 :slight_smile:

I’d like to establish a theme of my own, just like the existing theme “material”. In the config file there’s a hint that this kind of custom theme has been thought by the authors, as there is “LV_USE_THEME_TEMPLATE”.

Now, as the docs are not finished yet, I decided to try my luck. I extracted the “material” theme sources and put those to my application tree, not tainting lvgl core.

Good … but then, there is define LV_THEME_DEFAULT_INIT declaring the init function.

Well, some C linkers are happy with the fact that this function is defined somewhere, as long as it is accessible by it.

But then, for instance ESP-IDF toolchain, the C compiler HAS to have a prototype of it, otherwise it issues an error. Now, there is no way to officially get the correct include file to be included in “lv_obj.c”, where the style init is being called.

I circumvented this by defining “LV_GC_INCLUDE” containing my include, where my theme_init() is declared --> compiles OK.

But, that is a dirty hack. Should we have a separate config item for this? Or … how a custom theme is supposed to be implemented?

More on custom themes:

I also read a discussion (Questions about Version 7.0 styles and theme) in which @kisvegabor states that we are not supposed to overwrite themes directly, instead cascading the required stuff on existing themes. However, by replacing the unwanted theme definitions to be like “ready to use” we might gain some memory estate, both ROM (initializers) and RAM (no need for so many “style extensions”).

Or … is it only my IQ too low to understand this?

Thanks - once again!

I’m sure it’s NOT the case. :smiley:

First of all you are right about the including of the theme init function. I’ve just added LV_THEME_DEFAULT_INCLUDE to lv_conf.h.

Regarding to overwriting styles. True, it has a memory impact, however it’s usually small because probably you add only a few colors and sizes. If you needs something completely different than it should be better to create a custom theme. Let me know if you see it differently. Everybody is still new to v7, so every feedback and thought are very welcome! :slight_smile:

1 Like

Thanks for your response!

Regarding to “look and feel” of a UI application: I think there are as many requirements as there are users. Some company might like that all of their product look the same: fonts, colors etc. That’s why I’d like to see that with LvGL there is an easy-to-use method to customize … well, everything :slight_smile: Just tune it to meet the requirements and voilà, you are done having a re-usable theme package at your hand.

I cannot state any real figures regarding to themes and memory consumption, but in general I think the smaller the better :smiley:

Thanks!

That’s the goal of the themes! The default themes purpose it to add a default appearance when you create a widget. Although, I think some people who use LVGL in a personal project will be fine with the default theme too. However, if you need something different you should create your own my_company_theme and use it projects.

1 Like