4#include <SDL3/SDL_tray.h>
5#include "SDL3pp_stdinc.h"
6#include "SDL3pp_surface.h"
69 SDL_TRAYENTRY_CHECKBOX;
72 SDL_TRAYENTRY_SUBMENU;
75 SDL_TRAYENTRY_DISABLED;
134 :
Tray(other.release())
285 : m_trayMenu(trayMenu)
294 constexpr operator TrayMenuRaw() const noexcept {
return m_trayMenu; }
702 constexpr TrayEntryScoped(
const TrayEntryScoped& other) =
delete;
745 return Tray(icon, std::move(tooltip));
749 :
Tray(SDL_CreateTray(icon, tooltip))
768 SDL_SetTrayIcon(tray, icon);
788 SDL_SetTrayTooltip(tray, tooltip);
820 return SDL_CreateTrayMenu(tray);
849 return SDL_CreateTraySubmenu(entry);
907 return SDL_GetTraySubmenu(entry);
931 auto entries = SDL_GetTrayEntries(menu, &count);
932 return std::span<TrayEntry>{
reinterpret_cast<TrayEntry*
>(entries),
989 return TrayEntry(menu, pos, std::move(label), flags);
996 return TrayEntry(m_trayMenu, pos, std::move(label), flags);
1003 :
TrayEntry(SDL_InsertTrayEntryAt(menu, pos, label, flags))
1010 :
TrayEntry(menu, -1, std::move(label), flags)
1043 return TrayEntry(menu, std::move(label), flags);
1073 SDL_SetTrayEntryLabel(entry, label);
1100 return SDL_GetTrayEntryLabel(entry);
1127 SDL_SetTrayEntryChecked(entry, checked);
1154 return SDL_GetTrayEntryChecked(entry);
1179 SDL_SetTrayEntryEnabled(entry, enabled);
1204 return SDL_GetTrayEntryEnabled(entry);
1232 SDL_SetTrayEntryCallback(entry, callback, userdata);
1311 return SDL_GetTrayEntryParent(entry);
1339 return SDL_GetTrayMenuParentEntry(menu);
1367 return SDL_GetTrayMenuParentTray(menu);
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:53
constexpr RawPointer release() noexcept
Retrieves underlying resource pointer and clear this.
Definition SDL3pp_resource.h:56
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:290
ResourceRef< Surface > SurfaceRef
Reference for Surface.
Definition SDL3pp_surface.h:54
TrayMenu CreateSubmenu()
Create a submenu for a system tray entry.
Definition SDL3pp_tray.h:852
void SetTrayIcon(TrayRef tray, SurfaceRef icon)
Updates the system tray icon's icon.
Definition SDL3pp_tray.h:766
TrayEntry InsertEntry(int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition SDL3pp_tray.h:992
void SetTooltip(StringParam tooltip)
Updates the system tray icon's tooltip.
Definition SDL3pp_tray.h:791
void UpdateTrays()
Update the trays.
Definition SDL3pp_tray.h:1385
TrayEntry InsertTrayEntryAt(TrayMenu menu, int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition SDL3pp_tray.h:984
ResourceRef< Tray > TrayRef
Reference for Tray.
Definition SDL3pp_tray.h:32
TrayMenu GetMenu() const
Gets a previously created tray menu.
Definition SDL3pp_tray.h:881
void DestroyTray(TrayRaw tray)
Destroys a tray object.
Definition SDL3pp_tray.h:1292
constexpr TrayEntryFlags TRAYENTRY_BUTTON
Make the entry a simple button. Required.
Definition SDL3pp_tray.h:65
void SetTrayEntryLabel(TrayEntry entry, StringParam label)
Sets the label of an entry.
Definition SDL3pp_tray.h:1071
void SetChecked(bool checked)
Sets whether or not an entry is checked.
Definition SDL3pp_tray.h:1130
constexpr TrayEntryFlags TRAYENTRY_DISABLED
Make the entry disabled. Optional.
Definition SDL3pp_tray.h:74
void ClickTrayEntry(TrayEntry entry)
Simulate a click on a tray entry.
Definition SDL3pp_tray.h:1274
TrayEntry AppendEntry(StringParam label, TrayEntryFlags flags)
Appends a tray entry.
Definition SDL3pp_tray.h:1046
TrayEntry GetTrayMenuParentEntry(TrayMenuRaw menu)
Gets the entry for which the menu is a submenu, if the current menu is a submenu.
Definition SDL3pp_tray.h:1337
void(SDLCALL *)(void *userdata, TrayEntryRaw entry) TrayCallback
A callback that is invoked when a tray entry is selected.
Definition SDL3pp_tray.h:91
TrayMenu CreateTrayMenu(TrayRef tray)
Create a menu for a system tray.
Definition SDL3pp_tray.h:818
TrayMenu CreateMenu()
Create a menu for a system tray.
Definition SDL3pp_tray.h:823
TrayEntry AppendTrayEntry(TrayMenuRaw menu, StringParam label, TrayEntryFlags flags)
Appends a tray entry.
Definition SDL3pp_tray.h:1039
MakeFrontCallback< void(TrayEntryRaw entry)> TrayCB
A callback that is invoked when a tray entry is selected.
Definition SDL3pp_tray.h:104
TrayMenu GetTraySubmenu(TrayEntry entry)
Gets a previously created tray entry submenu.
Definition SDL3pp_tray.h:905
TrayMenu GetParent()
Gets the menu containing a certain tray entry.
Definition SDL3pp_tray.h:1314
bool GetTrayEntryChecked(TrayEntryRef entry)
Gets whether or not an entry is checked.
Definition SDL3pp_tray.h:1152
void SetTrayEntryChecked(TrayEntry entry, bool checked)
Sets whether or not an entry is checked.
Definition SDL3pp_tray.h:1125
TrayMenu GetTrayMenu(TrayRef tray)
Gets a previously created tray menu.
Definition SDL3pp_tray.h:879
TrayRef GetParentTray() const
Gets the tray for which this menu is the first-level menu, if the current menu isn't a submenu.
Definition SDL3pp_tray.h:1370
void Click()
Simulate a click on a tray entry.
Definition SDL3pp_tray.h:1276
std::span< TrayEntry > GetTrayEntries(TrayMenu menu)
Returns a list of entries in the menu, in order.
Definition SDL3pp_tray.h:928
TrayEntry TrayEntryRef
Alias to TrayEntry for non owning parameters.
Definition SDL3pp_tray.h:50
void SetCallback(TrayCallback callback, void *userdata)
Sets a callback to be invoked when the entry is selected.
Definition SDL3pp_tray.h:1254
const char * GetTrayEntryLabel(TrayEntryRef entry)
Gets the label of an entry.
Definition SDL3pp_tray.h:1098
void SetTrayEntryEnabled(TrayEntry entry, bool enabled)
Sets whether or not an entry is enabled.
Definition SDL3pp_tray.h:1177
void Destroy()
Destroys a tray object.
Definition SDL3pp_tray.h:1294
SDL_Tray * TrayRaw
Alias to raw representation for Tray.
Definition SDL3pp_tray.h:25
Tray CreateTray(SurfaceRef icon, StringParam tooltip)
Create an icon to be placed in the operating system's tray, or equivalent.
Definition SDL3pp_tray.h:743
void SetEnabled(bool enabled)
Sets whether or not an entry is enabled.
Definition SDL3pp_tray.h:1182
SDL_TrayEntry * TrayEntryRaw
Alias to raw representation for TrayEntry.
Definition SDL3pp_tray.h:44
void RemoveTrayEntry(TrayEntryRaw entry)
Removes a tray entry.
Definition SDL3pp_tray.h:954
SDL_TrayMenu * TrayMenuRaw
Alias to raw representation for TrayMenu.
Definition SDL3pp_tray.h:35
TrayMenu GetSubmenu()
Gets a previously created tray entry submenu.
Definition SDL3pp_tray.h:910
TrayMenu CreateTraySubmenu(TrayEntry entry)
Create a submenu for a system tray entry.
Definition SDL3pp_tray.h:847
void SetTrayTooltip(TrayRef tray, StringParam tooltip)
Updates the system tray icon's tooltip.
Definition SDL3pp_tray.h:786
const char * GetLabel() const
Gets the label of an entry.
Definition SDL3pp_tray.h:1103
void SetTrayEntryCallback(TrayEntry entry, TrayCallback callback, void *userdata)
Sets a callback to be invoked when the entry is selected.
Definition SDL3pp_tray.h:1228
void SetIcon(SurfaceRef icon)
Updates the system tray icon's icon.
Definition SDL3pp_tray.h:771
bool GetChecked() const
Gets whether or not an entry is checked.
Definition SDL3pp_tray.h:1157
TrayEntry GetParentEntry() const
Gets the entry for which the menu is a submenu, if the current menu is a submenu.
Definition SDL3pp_tray.h:1342
bool GetTrayEntryEnabled(TrayEntryRef entry)
Gets whether or not an entry is enabled.
Definition SDL3pp_tray.h:1202
std::span< TrayEntry > GetEntries()
Returns a list of entries in the menu, in order.
Definition SDL3pp_tray.h:936
TrayRef GetTrayMenuParentTray(TrayMenuRaw menu)
Gets the tray for which this menu is the first-level menu, if the current menu isn't a submenu.
Definition SDL3pp_tray.h:1365
bool GetEnabled() const
Gets whether or not an entry is enabled.
Definition SDL3pp_tray.h:1207
TrayEntry(TrayMenu menu, int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition SDL3pp_tray.h:999
constexpr TrayEntryFlags TRAYENTRY_CHECKED
Make the entry checked. This is valid only for checkboxes. Optional.
Definition SDL3pp_tray.h:78
void Remove()
Removes a tray entry.
Definition SDL3pp_tray.h:956
TrayMenu GetTrayEntryParent(TrayEntry entry)
Gets the menu containing a certain tray entry.
Definition SDL3pp_tray.h:1309
constexpr TrayEntryFlags TRAYENTRY_SUBMENU
Prepare the entry to have a submenu. Required.
Definition SDL3pp_tray.h:71
constexpr TrayEntryFlags TRAYENTRY_CHECKBOX
Make the entry a checkbox. Required.
Definition SDL3pp_tray.h:68
void SetLabel(StringParam label)
Sets the label of an entry.
Definition SDL3pp_tray.h:1076
Uint32 TrayEntryFlags
Flags that control the creation of system tray entries.
Definition SDL3pp_tray.h:63
Main include header for the SDL3pp library.
Definition SDL3pp_callbackWrapper.h:169
A non-owning reference wrapper for a given resource.
Definition SDL3pp_resource.h:156
RAII owning version TrayEntry.
Definition SDL3pp_tray.h:699
constexpr TrayEntryScoped(TrayEntryScoped &&other) noexcept
Move constructor.
Definition SDL3pp_tray.h:705
~TrayEntryScoped()
Destructor.
Definition SDL3pp_tray.h:717
TrayEntry(TrayMenu menu, int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition SDL3pp_tray.h:999
constexpr TrayEntryScoped(TrayEntry &&other) noexcept
Move constructor.
Definition SDL3pp_tray.h:711
An opaque handle representing an entry on a system tray object.
Definition SDL3pp_tray.h:413
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
An opaque handle representing a toplevel system tray object.
Definition SDL3pp_tray.h:114
constexpr Tray(TrayRaw resource) noexcept
Constructs from raw Tray.
Definition SDL3pp_tray.h:124
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
~Tray()
Destructor.
Definition SDL3pp_tray.h:168
Tray & operator=(const Tray &other)=delete
Assignment operator.
constexpr Tray & operator=(Tray &&other) noexcept
Assignment operator.
Definition SDL3pp_tray.h:171
constexpr Tray(Tray &&other) noexcept
Move constructor.
Definition SDL3pp_tray.h:133
constexpr Tray(const Tray &other)=delete
Copy constructor.