Skip to content

Conversation

@leroivi
Copy link

@leroivi leroivi commented Mar 19, 2025

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

@github-actions
Copy link

github-actions bot commented Mar 19, 2025

Build size and comparison to main:

Section Size Difference
text 383748B 3616B
data 944B 0B
bss 25064B 2520B

Run in InfiniEmu

@mark9064 mark9064 added the maintenance Background work label Mar 19, 2025
@mark9064 mark9064 added this to the 1.17.0 milestone May 16, 2025
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));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leroivi#1

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.

Use constexpr values instead of a nested enum.
@minacode
Copy link
Contributor

minacode commented Nov 8, 2025

Sounds like a good refactoring, but why is the size difference so huge? Would this be possible with less impact?

@leroivi
Copy link
Author

leroivi commented Nov 10, 2025

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.
Which impact would be acceptable ?

@minacode
Copy link
Contributor

Which impact would be acceptable ?

Please don't get me wrong. For me it's less about setting a specific number and more about understanding what is happening there.
I can imagine a unified interface to be more efficient than three different ones. But even if it's not, I would like us to think about it.

@minacode
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Background work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make color definitions more global in source code

4 participants