d_menu_proc(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

d_menu_proc πŸ’…

okay bestie, so this is a page from the Allegro manual β€” the Allegro game programming library, yes that Allegro β€” and it's all about a little function called d_menu_proc. It's a dialog procedure that literally is a menu bar. iconic behavior honestly.


✨ SYNOPSIS ✨

#include <allegro.h>

int d_menu_proc(int msg, DIALOG *d, int c);

πŸŽ€ DESCRIPTION πŸŽ€

so. this object right here? it's a menu bar. and the way it works is so satisfying: it drops down its child menus when you click it, OR when you hit alt + a key that matches one of the shortcuts sitting in the menu. keyboard girlies and mouse girlies both get fed. 🫢

now, the tea: this thing is lowkey picky and ignores a lot of the fields in the dialog structure. specifically, the color is pulled from the gui_*_color variables β€” not from you β€” and the width and height are calculated automatically. the w and h fields from the DIALOG are only used as a minimum size. so don't come in here thinking you're in charge of the dimensions, because you are not. 😭

the dp field points to an array of menu structures β€” go read do_menu() if you want the full lore on that one, iykyk.

here's the aesthetic switch-up that makes it chef's kiss: the top level menu gets displayed as a horizontal bar, but the moment child menus drop down from it, they're in the normal vertical format used by do_menu(). horizontal top, vertical babies. the range. πŸ’…

and when a menu item gets selected? the return value from the menu callback function gets passed straight back to the dialog manager. so your callbacks need to return one of these three, no exceptions:

  • D_O_K
  • D_REDRAW
  • D_CLOSE

that's the whole vibe check. return one of those or you're doing it wrong fr fr.

bestie warning: the color and size fields you set on the DIALOG are not going to save you here. gui_*_color runs the palette, and w/h are just a floor. plan accordingly. πŸ™ˆ

🌸 SEE ALSO 🌸


okay that's the whole page, you ate it, you understood it, periodt. πŸ‘‘

this was brought to you by Allegro, version 4.4.3 β€” mwah, go write something cute with it. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from