Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: my next crazy idea... rework the menu system

Re: my next crazy idea... rework the menu system

From: Jonathan Gordon <jdgordy_at_gmail.com>
Date: Fri, 25 Aug 2006 13:03:22 +1000

On 25/08/06, Jonathan Gordon <jdgordy_at_gmail.com> wrote:
> Right, well I've been tweaking it a bit and I think its now useable...
> attached is the diff which starts adding the sound and playback
> menus.. (i've ben testing on the ipod sim, and it compiles
> cleanyly...)
>
> So just quickly, I want to explain the difference between adding a
> menu item in the current and this system..
>
> First to make a menu 2 variables are needed.
> static const struct menu_item_ex *main_menu_items[] =
> {&sound_menu_items, &playback_items};
> static const struct menu_item_ex main_menu = {MT_MENU,
> {main_menu_items},sizeof(main_menu_items)/sizeof(*main_menu_items),"Main
> Menu",0};
>
> The first is a list of all the items in this menu (they can be
> sub-menus, or options, or functions to call.)
> The next just puts it all together so it can be used. Compare that to
> settings_menu.c where the list of items is needed anyway (but they are
> either NULL or a function to call) and ~3 functions are called to run
> the menu)
>
> And to actually add a option to a menu you need (for the CHOICE and
> BOOL options) an array of struct opt_items (which is needed in the old
> system also, so no big deal, BOOL will be able to reuse its array so
> its not so bad). Then you need to use one of the MAKE_*_OPT macros to
> create the 2 vairables needed.
> Lastly, you need to add the variable created by the macro to an array
> holding a list of items.. (e.g the main_menu_items above).
> Whereas in the old system you had to create a function which was
> called by the menu that had to call set_option (or similar).
>
> So, what do you think?
>
>
>
And the last reply for the day...
I'v just added another macro to make adding menus much easier...

#define MAKE_MENU( name, str, id, ... ) \
    s##tatic const struct menu_item_ex *name##_[] = {__VA_ARGS__}; \
    s##tatic const struct menu_item_ex name = {MT_MENU, { name##_},
sizeof( name##_)/sizeof(*name##_),str,id};

MAKE_MENU(playback_menu, "Playback Menu",0, &shuffle ,&repeat); will
create a menu variable names playback_menu whith the name "Playback
Menu", with the shuffle and repeat options in it.
Received on 2006-08-25

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy