Re: [AD] native menus

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sun, 2011-06-19 at 15:42 -0500, Matthew Leverton wrote:
> Attached is a sample implementation of native system menus for
> Windows. I put it in the native dialog addon and updated the
> native_file_chooser example. The API is functional, but not complete:
> 
> ALLEGRO_MENU *al_create_menu(void);
> bool al_append_menu (ALLEGRO_MENU *parent, ALLEGRO_MENU *popup, char
> const *title, int id);
> void al_set_display_menu(ALLEGRO_DISPLAY *display, ALLEGRO_MENU *menu);
> 
> Basic usage:
> 
> ALLEGRO_MENU *menu = al_create_menu();
> ALLEGRO_MENU *file = al_create_menu();
> al_append_menu(file, NULL, "Open", OPEN_ID);
> al_append_menu(file, NULL, "Exit", EXIT_ID);
> al_append_menu(menu, file, "File", 0);
> al_set_display_menu(display, menu);
> 

Nice. Will be especially important under OSX since if I remember right
the MAC Store guidelines require you to have certain menu entries to
pass validation.

> A higher level function could take some sort of A4-like structure to
> make creating the menu less verbose.
> 
> Events are sent via the display's event source:
> 
> if (event.type == ALLEGRO_EVENT_MENU_CLICK && event.menu.id == EXIT_ID)
> 

I wonder if that can work under OSX - the menu seems to be per-process
and not per-window there. E.g. in XCode with all its separate windows
the menu stays mostly the same no matter which window is selected. If
someone implements this for OSX and this really is a problem we probably
need to tell the user to call al_set_display_menu again in response to
window-activated messages.

> 
> Now to the dirty implementation details:
> 
[..]
> 3) I don't know about OS X or GTK menus, but I assume they could use
> the same sort of API as above.
> 

I might do the GTK version (if I don't forget).

-- 
Elias Pschernig <elias.pschernig@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/