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

Hey! Nice work on V7! It feels much snappier than V6 on ESP32!

I am facing a similar issue. I’d also just like to have a template that I can use on any project as kind of a drop in replacement, without having to deal with manual styling. It just feels more right to me - although same as peeji73 feels i might just suffer from a lack of IQ …

I have added my theme include as LV_THEME_DEFAULT_INCLUDE (if I understood this correctly) and there is only one thing that breaks compiling for me. It’s on line 880 of material theme: LV_GC_ROOT(_lv_theme_material_styles) = lv_mem_alloc(sizeof(theme_styles_t));. Specifically _lv_theme_material_styles is defined in lv_misc/lv_gc.h, which is inside the library. I’ve made the mistake of modifying the library on my V6 implemenation and made updating an unnecessary pain. How would I best solve this problem? I am not even using GC …

I’ve added some comments to clarify this: