Dawn/src/ui/menulist.h

57 lines
1.3 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
#include "label.h"
#include "menu.h"
#include "frame.h"
#include "rectangle.h"
/** Callback to listen for when the menu is selected. */
void _menuListMenuOnSelect(menu_t *menu, menuitem_t *item, uint8_t i, void *u);
/**
* Initialize a menu list.
*
* @param ml Menu List to initialize.
* @param texture Texture to use for the frame.
*/
void menuListInit(menulist_t *ml, texture_t *texture);
/**
* Add an item to the menu list.
*
* @param ml Menu list to add to.
* @param font Font to use for the label.
* @param text Text to add.
* @return Index that refers to the label/menu item.
*/
uint8_t menuListAdd(menulist_t *ml, font_t *font, char *text);
/**
* Tick the menu list and listen for input changes.
*
* @param ml Menu list to update.
* @param engine Engine to update with.
*/
void menuListUpdate(menulist_t *ml, engine_t *engine);
/**
* Render a menu list.
*
* @param ml Menu list to render.
* @param shader Shader to use.
*/
void menuListRender(menulist_t *ml, shader_t *shader);
/**
* Cleanup a previously created menu list.
*
* @param ml Menu list to clean up.
*/
void menuListDispose(menulist_t *ml);