Conversation
|
Build size and comparison to main:
|
src/displayapp/InfiniTimeTheme.cpp
Outdated
| style_init_reset(&style_bg); | ||
| lv_style_set_bg_opa(&style_bg, LV_STATE_DEFAULT, LV_OPA_COVER); | ||
| lv_style_set_bg_color(&style_bg, LV_STATE_DEFAULT, LV_COLOR_BLACK); | ||
| lv_style_set_bg_color(&style_bg, LV_STATE_DEFAULT, Colors::Color(Colors::Named::Black)); |
There was a problem hiding this comment.
Is there a way to achieve this otherwise great refactor without requiring developers to say the word Color three times in a row? Maybe having "Named" expose Colors::Color instances and having the raw numeric value be less exposed but available?
There was a problem hiding this comment.
Well, I was hoping that, by letting every constructors and cast operators be implicit, I could write lv_style_set_bg_color(&style_bg, LV_STATE_DEFAULT, Colors::Named::Black);
But it didn't work, I didn't figure out exactly why. This implies that the compiler realize all the following implicit cast : Colors::Named => uint32_t => Colors::Color => lv_color_t. Maybe one of the cast is ambiguous, or maybe it's simply too much, idk.
I was thinking that it's not a big problem, because it can be less verbose by using the using namespace instruction
So we can write lv_style_set_bg_color(&style_bg, LV_STATE_DEFAULT, Color(Named::Black)); which could be acceptable.
There was a problem hiding this comment.
Let me know what you think. If you like it, you can merge it on your side which will then update this PR. Happy to iterate with you.
3b28cb8 to
b38f7d4
Compare
Use constexpr values instead of a nested enum.
|
Sounds like a good refactoring, but why is the size difference so huge? Would this be possible with less impact? |
Ok, I don't know, I will investigate. I suspect that the impact comes from numerous usage of the Color class that calls inline ctor and then inline cast. Maybe it'll be solve by not inlining them. |
Please don't get me wrong. For me it's less about setting a specific number and more about understanding what is happening there. |
|
One thing that also immediately comes to my mind is to use the theme everywhere and to challenge how many colors we really need. But that would better be a separate PR, because it may restyle the UI. |
Bring the PineTime colors, the Settings colors, the InfiniTimeTheme colors and the LVGL colors in one and unique place so it is easier for developper to be consistent between different screens and bring their own colors.
Fix #559