create table for the button/menuitem states
add a class for states as menuitems and buttons are more or less equal
Button states:
- Default
- Active
- Disabled
- Highlighted
create table for the button/menuitem states
add a class for states as menuitems and buttons are more or less equal
Button states:
Hello, I've started working on this.
Here is the progress this far:
https://github.com/apertus-open-source-cinema/AXIOM-Remote/pull/35
It's not finished yet, but I figured it might be a good idea to get some feedback on it.
This ended up being quite a wall of text. Read New functions first, the rest is mostly implementation details.
About the implementation
I've gone with implementing the state switching as part of the IButton interface.
Since the only functionality associated with different ButtonTypes at the moment
is what color to use, this has been integrated into IButton as well.
What differs between different button type is how many colors they need
per state, and (perhaps?) how many states they have.
The way this is implemented is that IButton holds a pointer
to an array of the correct size in the derived class.
Changes for derived classes
All derived classes need to implement and specify the following,
in order to use the color and state management:
Regarding the valid states:
At the moment, there is no way to specify which states are valid,
and it's instead assumed that the first n states in enum class ButtonState are to be used.
New functions
A couple of new functions are exposed for users of IButton derived classes:
Possible problems with this implementation
Adding this functionality to IButton directly does bloat what should
be just an interface class. At the moment though, all buttons need
this functionality anyway, so this doesn't seem to be that much of an issue.
If need be, one can always extract the implementations in IButton
into a separate class at a later date.
Currently, the allowed states use the same enum class for all buttons.
One might want to do something similar to the current solution with color definitions,
that is to allow each Button to define its own states using an enum.
This would sacrifice some type safety.
Work left
I had some issues with the MainPageButtons in MainPage.
Since they weren't initialized in the initializer list,
but rather in SetupButtons(), the pointers to their respective
arrays didn't update properly. This has been temporarily fixed
by initializing the buttons in the initializer list, but this bug should definitely be investigated.
Until then, I've made some member variables in IButton const,
which forces all button initializations to be done with initializer lists.