The btn class would refer to lv_style_t btn such as what you can find in lv_theme_default.c
Property names would map to relevant lv_style_set_ functions: bgColor would map to lv_style_set_bg_color()
The parser would:
Parse the raw input and convert it to tokens (tokenization)
Convert tokens to data structures
Convert data structures to C code
The parser would be written in Python because the existing LVGL scripts are largely written in Python and because it’s available on most platforms.
We’re likely going to make this regardless whether it will become an official LVGL feature, but I’d like to have some input on this proposal.
(We’ll name it “LSS”, spoken as “less”. It’s tongue-in-cheek towards “less css” and stands for “LVGL Style Sheets”)
There is a conceptual difference between LVGL and CSS. In CSS you set the pseudo classes and selectors when you define the style sheet. (e.g. scrollbar: scrolled {}). In LVGL you assign styles to parts/states on the given widget.
So I wonder how you export scrollbar: scrolled {}?
Also in LVGL you can define only “classes”. But you can can’t do something like button {} or div{} to target all buttons and divs.
Thanks for the input! I think I confused parts and substates, and what I thought I knew about substates. This means I have to rethink the syntax, so I have the following proposal:
1. Differentiate between class styles and part/substate styles:
Substate/part styles have a period in front of them:
I’ve worked on it a bit more and this is what I came up with.
The below content generates code that relates to static void theme_apply() in lv_theme_default.c
Inside the apply() filtering function, it is looking for a widget that originates from a tabview with any child that has a child of type obj.
“*” signifies “a non-null child that is of any type”.
It applies the pad_normal and rotary_scroll styles always.
It applies the scrollbar style when the part is a scrollbar.
It applies scrollbar_scrolled style when the part is a scrollbar and the state is scrolled.