Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of CheckBoxList : remove dependency to SettingController #1351

Merged
merged 3 commits into from
Oct 11, 2022

Conversation

JF002
Copy link
Collaborator

@JF002 JF002 commented Oct 2, 2022

I'm not completely satisfied of the design of CheckBoxList. It currently depends on SettingsController and receives pointers to function to get and set the setting.

CheckBoxList is a UI component that we should be able to use anywhere. But the current implementation limit the usage of this class to settings that are handled by the Settings controller.

I tried to refactor this class : it now receives the originalValue (which is used to select the corresponding checkbox) and a std::function that is called when the value changes. This allows to completely de-couple CheckBoxList from Settings.

Now, I know that lambda with capture and std::function can have a big overhead (heap allocation, binary size and execution time). I couldn't find any in this specific case, but I wouldn't mind someone cross-checking this!

Any feedback about this refactoring?

…g has changed. This allow to remove the dependency between CheckBoxList (UI component) with SettingController.
@minacode
Copy link
Contributor

minacode commented Oct 2, 2022

For #1339 it would be good to allow any values behind the options (in this case WatchFaces). We could add this with a generic type. Instead of calculating the selected value directly from the index of the option, we would also need an array of values of the generic type corresponding to the options.

I am relatively new to C++ so I can not provide meaningful feedback to your changes, sorry.

@minacode minacode mentioned this pull request Oct 3, 2022
2 tasks
Copy link
Collaborator

@Avamander Avamander left a comment

Choose a reason for hiding this comment

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

Looks good to me. I trust it has been tested on physical hw.

@JF002 JF002 added this to the 1.11.0 milestone Oct 11, 2022
@JF002 JF002 merged commit 8c7be1f into develop Oct 11, 2022
@NeroBurner NeroBurner deleted the refactor-checkboxlist branch October 11, 2022 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants