ALLEGRO_MENU_INFO(3alleg5)
π ALLEGRO_MENU_INFO π
okay bestie, quick vibe check: this is the ALLEGRO_MENU_INFO page from the Allegro 5 API, and it's your cheat sheet for building a whole menu system out of one lil' struct array. no cap. πΈ
β¨ NAME β¨
ALLEGRO_MENU_INFO β it's giving Allegro 5 API, and it's giving menu blueprint π
β¨ SYNOPSIS β¨
#include <allegro5/allegro_native_dialog.h>
typedef struct ALLEGRO_MENU_INFO {
like yes, that's the opening of the struct, she's a typedef and she's iconic π
β¨ DESCRIPTION β¨
So here's the tea β β ALLEGRO_MENU_INFO is the structure that tells Allegro how to build an entire menu system, start to finish. complete menu system, we're talking full main-character energy. π
For your regular, standard menu items, you use this format, exactly:
{ caption, id, flags, icon }
that's it. caption, id, flags, icon. four lil' slots. slay. β¨
π¦ the special-item macros π¦
For the special items (the ones that aren't just a normal clickable thing), these macros are here to help you out, bestie:
ALLEGRO_START_OF_MENU(caption, id)ALLEGRO_MENU_SEPARATORALLEGRO_END_OF_MENU
π how a well-defined menu is shaped π
A well-defined menu begins with ALLEGRO_START_OF_MENU, contains one or more menu items, and ends with ALLEGRO_END_OF_MENU. periodt. and plot twist β a menu can contain sub-menus, so it can nest, like a lil' matryoshka of menus πͺ
Here's an example, verbatim, don't @ me:
ALLEGRO_MENU_INFO menu_info[] = {
ALLEGRO_START_OF_MENU("&File", 1),
{ "&Open", 2, 0, NULL },
ALLEGRO_START_OF_MENU("Open &Recent...", 3),
{ "Recent 1", 4, 0, NULL },
{ "Recent 2", 5, 0, NULL },
ALLEGRO_END_OF_MENU,
ALLEGRO_MENU_SEPARATOR,
{ "E&xit", 6, 0, NULL },
ALLEGRO_END_OF_MENU,
ALLEGRO_START_OF_MENU("&Help", 7),
{"&About", 8, 0, NULL },
ALLEGRO_END_OF_MENU,
ALLEGRO_END_OF_MENU
};
ALLEGRO_MENU *menu = al_build_menu(menu_info);
see how it opens &File, nests Open &Recent..., drops a separator in there, closes out, then does &Help? that's the whole structure doing its thing, and then al_build_menu(menu_info) turns all of it into an actual ALLEGRO_MENU *. ate. π₯
π if you'd rather not do the struct thing π
If you prefer β no judgment, different strokes β you can build the menu without the structure by using al_create_menu(3alleg5) and al_insert_menu_item(3alleg5) instead. do what feels right for your soul π«Ά
β¨ SEE ALSO β¨
okay that's the whole page, you're basically a menu architect now, obsessed with you fr fr πβ¨
signing off from the Allegro reference manual β ALLEGRO_MENU_INFO(3alleg5), Allegro 5 era, kiss kiss mwah π
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms