SDL_menu.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #ifndef SDL_menu_h_
  19. #define SDL_menu_h_
  20. #include "./SDL_list.h"
  21. typedef enum SDL_MenuItemType
  22. {
  23. SDL_MENU_ITEM_TYPE_NORMAL,
  24. SDL_MENU_ITEM_TYPE_SEPERATOR,
  25. SDL_MENU_ITEM_TYPE_CHECKBOX
  26. } SDL_MenuItemType;
  27. typedef enum SDL_MenuItemFlags
  28. {
  29. SDL_MENU_ITEM_FLAGS_NONE = 0,
  30. SDL_MENU_ITEM_FLAGS_DISABLED = 1 << 0,
  31. SDL_MENU_ITEM_FLAGS_CHECKED = 1 << 1,
  32. SDL_MENU_ITEM_FLAGS_BAR_ITEM = 1 << 2
  33. } SDL_MenuItemFlags;
  34. /* Do not create this struct directly, users of this structure like the DBUSMENU layer use extended versions of it which need to be allocated by specfic functions. */
  35. /* This struct is meant to be in an SDL_List just like sub_menu */
  36. typedef struct SDL_MenuItem
  37. {
  38. /* Basic properties */
  39. const char *utf8;
  40. SDL_MenuItemType type;
  41. SDL_MenuItemFlags flags;
  42. /* Callback */
  43. void *cb_data;
  44. void (*cb)(struct SDL_MenuItem *, void *);
  45. /* Submenu, set to NULL if none */
  46. SDL_ListNode *sub_menu;
  47. /* User data slots */
  48. void *udata;
  49. void *udata2;
  50. void *udata3;
  51. } SDL_MenuItem;
  52. #endif // SDL_menu_h_