Skip to content

Add render callbacks to individual MenuItem instances #77

@qbit-

Description

@qbit-

Thanks for the great job implementing this library!
I've easily ported it to MBED framework.

I would like to discuss if having individual rendering callbacks for each MenuItem, instead
of subclassing MenuItem each time is a worthy idea. My use case is as follows. I would
like to have a menu where the user can set time with hours, minutes and seconds.
Each time interval has its own NumericMenuItem. As the user changes the value I would
like to draw it but in different places of the LCD screen. It is problematic to do as all NumericMenuItems call the same rendering function. Ideally I would like to set individual rendering functions for each menuitem, and fallback to default if no callback was provided. What should be a clean solution?

Similar (but limited) functionality is implemented by the formatvaluefnptr argument in NumericMenuItem.

In general, providing the user an option to set callbacks would eliminate the need of a compicated
renderer class. Getting rid of the renderer class altogether will eliminate a circular dependence
of the custom menu item classes and a renderer class (which is seen in the serial_nav example)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions