Toolbar and menu
Adding a menu to an nk window is accomplished using NkMenubarBegin(), NkMenuBeginLabel(), and NkMenuItemLabel(), among others. The only difficult step in setting up a menu is that we also need to add an appropriate layout for the bar and its items. It's important (in fact, mandatory) that the bar is in a layout where y=0, so we immediately add a new row layout using dynamic sizing with NkLayoutRowBegin(). Then, we push the cell size for this layout using NLayoutRowPush().
A menu item is opened using NkMenuBeginLabel() and we must check the return value for this function—0 means that the menu is hidden. If it returns a non-zero value then we should lay out the menu below the bar. We start a new dynamic row layout with a single ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access