views:

50

answers:

2

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.

+1  A: 

There are things like Kaleido: http://www.digitalairways.com/kaleido-engine.htm which are very nice, but pricey.

Emwin is simpler and cheaper but nothing like as rich in terms of functionality: http://www.segger.com/cms/emwin.html

Vicky
Both offer much much more than I need. I'll handle the display myself, I'll handle the control myself, I just want the inner menu logic.
Elazar Leibovich
+1  A: 

You may want to look at the Android SDK. This too, may be more than you want to handle, but there may be value in replicating, or possibly using any tools google may have.

simon
That's a good idea. Do you know which part of the Android SDK should I look into? I'll be glad for a reference for the particular component.
Elazar Leibovich
I think you will have download and install the whole SDK. I'm not familiar enough with the SDK to be able to reference a particular part or tool. I do know it uses a xml format for laying out the GUI elements.
simon