I'm looking for a library to manage menus. I'm looking for something which is based on configuration files. It doesn't have to manage keyboard input or display, just the menu logic. What I have in mind something like:
//menu.xml
<menu>
<Start />
<Stop />
<Configuration displayname="Configure System">
<Sound type="toggle" />
<Speed display="Speed related settings">
<Speedy type="toggle" default="on" />
<Optimizations type="toggle" />
</Speed>
</Configuration>
<Filesystem>
<SaveSnapshot />
<LoadSnapshot />
</Filesystem>
</menu>
In the code we would have:
//menu.cpp
Menu menu("menu.xml");
menu.bind("SaveSnapshot",saveSnapshotPressed);
menu.bind("LoadSnapshot",loadSnapshotPressed);
menu.bind("Sound",soundSetTo);
...
void onKeyPressed(key_t key) {
...
switch (key) {
case KEY_UP:
menu.goUp();
break;
case KEY_DOWN:
menu.goDown();
break;
case KEY_ENTER:
menu.action();
break;
}
// display.cpp
void render(...) {
for (int i=0;i<menu.items().size();++i) {
renderText(getMenuCoord(i),menu.items()[i].c_str());
}
...
}
Such a library could be very useful to display menus in embedded device.
I'll be glad to hear if such library exists, or is there a better idea for this library.