4#include <SDL3/SDL_tray.h>
5#include "SDL3pp_stdinc.h"
6#include "SDL3pp_surface.h"
65 SDL_TRAYENTRY_CHECKBOX;
68 SDL_TRAYENTRY_SUBMENU;
71 SDL_TRAYENTRY_DISABLED;
115 constexpr Tray(std::nullptr_t =
nullptr) noexcept
116 : m_resource(
nullptr)
128 : m_resource(resource)
133 constexpr Tray(
const Tray& other)
noexcept =
delete;
137 :
Tray(other.release())
171 ~Tray() { SDL_DestroyTray(m_resource); }
176 std::swap(m_resource, other.m_resource);
184 constexpr TrayRaw get() const noexcept {
return m_resource; }
190 m_resource =
nullptr;
198 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
318 :
Tray(resource.get())
358 constexpr operator TrayRaw() const noexcept {
return get(); }
377 : m_trayMenu(trayMenu)
386 constexpr operator TrayMenuRaw() const noexcept {
return m_trayMenu; }
511 : m_resource(
nullptr)
521 : m_resource(resource)
526 constexpr operator TrayEntryRaw() const noexcept {
return m_resource; }
535 m_resource =
nullptr;
543 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
816 return Tray(icon, std::move(tooltip));
820 : m_resource(SDL_CreateTray(icon, tooltip))
839 SDL_SetTrayIcon(tray, icon);
862 SDL_SetTrayTooltip(tray, tooltip);
894 return SDL_CreateTrayMenu(tray);
923 return SDL_CreateTraySubmenu(entry);
981 return SDL_GetTraySubmenu(entry);
1008 auto entries = SDL_GetTrayEntries(menu, &count);
1009 return std::span<TrayEntry>{
reinterpret_cast<TrayEntry*
>(entries),
1066 return SDL_InsertTrayEntryAt(menu, pos, label, flags);
1098 SDL_SetTrayEntryLabel(entry, label);
1125 return SDL_GetTrayEntryLabel(entry);
1152 SDL_SetTrayEntryChecked(entry, checked);
1179 return SDL_GetTrayEntryChecked(entry);
1204 SDL_SetTrayEntryEnabled(entry, enabled);
1229 return SDL_GetTrayEntryEnabled(entry);
1257 SDL_SetTrayEntryCallback(entry, callback, userdata);
1312 return SDL_GetTrayEntryParent(entry);
1340 return SDL_GetTrayMenuParentEntry(menu);
1368 return SDL_GetTrayMenuParentTray(menu);
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
An opaque handle representing an entry on a system tray object.
Definition: SDL3pp_tray.h:505
constexpr TrayEntry(TrayEntryRaw resource) noexcept
Constructs from raw TrayEntry.
Definition: SDL3pp_tray.h:520
void SetCallback(TrayCB callback)
Sets a callback to be invoked when the entry is selected.
Definition: SDL3pp_tray.h:1395
constexpr TrayEntryRaw get() const noexcept
Retrieves underlying TrayEntryRaw.
Definition: SDL3pp_tray.h:529
constexpr TrayEntry(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_tray.h:510
constexpr TrayEntryRaw release() noexcept
Retrieves underlying TrayEntryRaw and clear this.
Definition: SDL3pp_tray.h:532
constexpr auto operator<=>(const TrayEntry &other) const noexcept=default
Comparison.
An opaque handle representing a toplevel system tray object.
Definition: SDL3pp_tray.h:110
constexpr Tray(const Tray &other) noexcept=delete
Copy constructor.
constexpr TrayRaw get() const noexcept
Retrieves underlying TrayRaw.
Definition: SDL3pp_tray.h:184
constexpr Tray(TrayRaw resource) noexcept
Constructs from raw Tray.
Definition: SDL3pp_tray.h:127
~Tray()
Destructor.
Definition: SDL3pp_tray.h:171
Tray & operator=(const Tray &other)=delete
Assignment operator.
constexpr Tray(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_tray.h:115
constexpr Tray & operator=(Tray &&other) noexcept
Assignment operator.
Definition: SDL3pp_tray.h:174
constexpr auto operator<=>(const Tray &other) const noexcept=default
Comparison.
constexpr Tray(Tray &&other) noexcept
Move constructor.
Definition: SDL3pp_tray.h:136
constexpr TrayRaw release() noexcept
Retrieves underlying TrayRaw and clear this.
Definition: SDL3pp_tray.h:187
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:281
void(SDLCALL *)(void *userdata, TrayEntryRaw entry) TrayCallback
A callback that is invoked when a tray entry is selected.
Definition: SDL3pp_tray.h:87
TrayMenu CreateSubmenu()
Create a submenu for a system tray entry.
Definition: SDL3pp_tray.h:926
void SetTrayIcon(TrayRef tray, SurfaceRef icon)
Updates the system tray icon's icon.
Definition: SDL3pp_tray.h:837
TrayEntry InsertEntry(int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition: SDL3pp_tray.h:1069
SDL_TrayMenu * TrayMenuRaw
Alias to raw representation for TrayMenu.
Definition: SDL3pp_tray.h:31
void SetTooltip(StringParam tooltip)
Updates the system tray icon's tooltip.
Definition: SDL3pp_tray.h:865
void UpdateTrays()
Update the trays.
Definition: SDL3pp_tray.h:1386
TrayEntry InsertTrayEntryAt(TrayMenu menu, int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition: SDL3pp_tray.h:1061
void SetTrayEntryCallback(TrayEntryRef entry, TrayCallback callback, void *userdata)
Sets a callback to be invoked when the entry is selected.
Definition: SDL3pp_tray.h:1253
TrayMenu GetMenu() const
Gets a previously created tray menu.
Definition: SDL3pp_tray.h:955
void DestroyTray(TrayRaw tray)
Destroys a tray object.
Definition: SDL3pp_tray.h:1293
void SetTrayEntryLabel(TrayEntryRef entry, StringParam label)
Sets the label of an entry.
Definition: SDL3pp_tray.h:1096
constexpr TrayEntryFlags TRAYENTRY_BUTTON
Make the entry a simple button. Required.
Definition: SDL3pp_tray.h:61
TrayMenu CreateTraySubmenu(TrayEntryRef entry)
Create a submenu for a system tray entry.
Definition: SDL3pp_tray.h:921
void SetChecked(bool checked)
Sets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1155
constexpr TrayEntryFlags TRAYENTRY_DISABLED
Make the entry disabled. Optional.
Definition: SDL3pp_tray.h:70
TrayMenu CreateTrayMenu(TrayRef tray)
Create a menu for a system tray.
Definition: SDL3pp_tray.h:892
TrayMenu CreateMenu()
Create a menu for a system tray.
Definition: SDL3pp_tray.h:897
TrayEntryRef GetParentEntry() const
Gets the entry for which the menu is a submenu, if the current menu is a submenu.
Definition: SDL3pp_tray.h:1343
void SetTrayEntryChecked(TrayEntryRef entry, bool checked)
Sets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1150
TrayMenu GetParent()
Gets the menu containing a certain tray entry.
Definition: SDL3pp_tray.h:1315
TrayEntryRef GetTrayMenuParentEntry(TrayMenuRaw menu)
Gets the entry for which the menu is a submenu, if the current menu is a submenu.
Definition: SDL3pp_tray.h:1338
bool GetTrayEntryChecked(TrayEntryRef entry)
Gets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1177
TrayMenu GetTrayMenu(TrayRef tray)
Gets a previously created tray menu.
Definition: SDL3pp_tray.h:953
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:1371
void Click()
Simulate a click on a tray entry.
Definition: SDL3pp_tray.h:1277
std::span< TrayEntry > GetTrayEntries(TrayMenu menu)
Returns a list of entries in the menu, in order.
Definition: SDL3pp_tray.h:1005
void SetTrayEntryEnabled(TrayEntryRef entry, bool enabled)
Sets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1202
const char * GetTrayEntryLabel(TrayEntryRef entry)
Gets the label of an entry.
Definition: SDL3pp_tray.h:1123
TrayMenu GetTraySubmenu(TrayEntryRef entry)
Gets a previously created tray entry submenu.
Definition: SDL3pp_tray.h:979
void Destroy()
Destroys a tray object.
Definition: SDL3pp_tray.h:1295
Tray CreateTray(SurfaceRef icon, StringParam tooltip)
Create an icon to be placed in the operating system's tray, or equivalent.
Definition: SDL3pp_tray.h:814
void SetEnabled(bool enabled)
Sets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1207
void RemoveTrayEntry(TrayEntryRaw entry)
Removes a tray entry.
Definition: SDL3pp_tray.h:1031
TrayMenu GetTrayEntryParent(TrayEntryRef entry)
Gets the menu containing a certain tray entry.
Definition: SDL3pp_tray.h:1310
TrayMenu GetSubmenu()
Gets a previously created tray entry submenu.
Definition: SDL3pp_tray.h:984
void SetTrayTooltip(TrayRef tray, StringParam tooltip)
Updates the system tray icon's tooltip.
Definition: SDL3pp_tray.h:860
void ClickTrayEntry(TrayEntryRef entry)
Simulate a click on a tray entry.
Definition: SDL3pp_tray.h:1275
const char * GetLabel() const
Gets the label of an entry.
Definition: SDL3pp_tray.h:1128
void SetIcon(SurfaceRef icon)
Updates the system tray icon's icon.
Definition: SDL3pp_tray.h:842
bool GetChecked() const
Gets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1182
bool GetTrayEntryEnabled(TrayEntryRef entry)
Gets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1227
SDL_TrayEntry * TrayEntryRaw
Alias to raw representation for TrayEntry.
Definition: SDL3pp_tray.h:40
std::span< TrayEntry > GetEntries()
Returns a list of entries in the menu, in order.
Definition: SDL3pp_tray.h:1013
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:1366
bool GetEnabled() const
Gets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1232
constexpr TrayEntryFlags TRAYENTRY_CHECKED
Make the entry checked. This is valid only for checkboxes. Optional.
Definition: SDL3pp_tray.h:74
void Remove()
Removes a tray entry.
Definition: SDL3pp_tray.h:1033
Uint32 TrayEntryFlags
Flags that control the creation of system tray entries.
Definition: SDL3pp_tray.h:59
constexpr TrayEntryFlags TRAYENTRY_SUBMENU
Prepare the entry to have a submenu. Required.
Definition: SDL3pp_tray.h:67
constexpr TrayEntryFlags TRAYENTRY_CHECKBOX
Make the entry a checkbox. Required.
Definition: SDL3pp_tray.h:64
void SetLabel(StringParam label)
Sets the label of an entry.
Definition: SDL3pp_tray.h:1101
SDL_Tray * TrayRaw
Alias to raw representation for Tray.
Definition: SDL3pp_tray.h:25
Main include header for the SDL3pp library.
Definition: SDL3pp_callbackWrapper.h:169
Reference for Surface.
Definition: SDL3pp_surface.h:1975
RAII owning version TrayEntry.
Definition: SDL3pp_tray.h:770
constexpr TrayEntryScoped(TrayEntryScoped &&other) noexcept
Move constructor.
Definition: SDL3pp_tray.h:776
~TrayEntryScoped()
Destructor.
Definition: SDL3pp_tray.h:788
constexpr TrayEntryScoped(TrayEntry &&other) noexcept
Move constructor.
Definition: SDL3pp_tray.h:782
Reference for Tray.
Definition: SDL3pp_tray.h:295
constexpr TrayRef(TrayRaw resource) noexcept
Constructs from raw Tray.
Definition: SDL3pp_tray.h:305
~TrayRef()
Destructor.
Definition: SDL3pp_tray.h:347
constexpr TrayRef(const TrayRef &other) noexcept
Copy constructor.
Definition: SDL3pp_tray.h:335
constexpr TrayRef(const Tray &resource) noexcept
Constructs from Tray.
Definition: SDL3pp_tray.h:317
constexpr TrayRef(Tray &&resource) noexcept
Constructs from Tray.
Definition: SDL3pp_tray.h:329
TrayRef & operator=(const TrayRef &other) noexcept
Assignment operator.
Definition: SDL3pp_tray.h:350
constexpr TrayRef(TrayRef &&other) noexcept
Move constructor.
Definition: SDL3pp_tray.h:341