ALLEGRO_MENU_INFO(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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_SEPARATOR
  • ALLEGRO_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