Modify flags or states of widgets based on previous state.
Take my recent project (a complex menu) for instance. Multiple buttons and corresponding operational panels are designed within a screen. In this situation, I must handle flags and states of buttons and panels very carefully.
- When button A is clicked, corresponding panel A will appear (remove hidden flag);
- Remove “
Clickable” flag of Button A, add “
Clickable” flag and remove “
Checked” state to all other buttons since I don’t know whether it is the first time that a user click Button A or it is clicked after other button.
- Add “
Hidden” flag to all other panels (again, you don’t know user operation sequence).
All steps have to be done in the
CLICK event of each button.
I exported the code to testing platform and do a trial run, it turns out that the screen response is very slow. I have to optimize the “
State” and “
Flag” handling in the event function.
If the flag, state modification is conditional, event handling function will be more efficient without code modification.
Currently, you can only do conditional flag/state modification in the exported LVGL code.
Complex menu GUI design.