4#include <SDL3/SDL_tray.h>
5#include "SDL3pp_stdinc.h"
6#include "SDL3pp_surface.h"
48 constexpr explicit operator bool()
const {
return !!
value; }
93 constexpr explicit operator bool()
const {
return !!
value; }
116 SDL_TRAYENTRY_BUTTON;
119 SDL_TRAYENTRY_CHECKBOX;
122 SDL_TRAYENTRY_SUBMENU;
125 SDL_TRAYENTRY_DISABLED;
169 constexpr Tray(std::nullptr_t =
nullptr) noexcept
182 : m_resource(resource)
191 :
Tray(other.release())
223 : m_resource(SDL_CreateTray(icon, tooltip))
228 ~Tray() { SDL_DestroyTray(m_resource); }
233 std::swap(m_resource, other.m_resource);
243 constexpr TrayRaw get() const noexcept {
return m_resource; }
249 m_resource =
nullptr;
257 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
260 constexpr operator TrayParam() const noexcept {
return {m_resource}; }
364 :
Tray(resource.value)
406 : m_trayMenu(trayMenu)
415 constexpr operator TrayMenuRaw() const noexcept {
return m_trayMenu; }
550 : m_resource(resource)
569 std::swap(m_resource, other.m_resource);
583 m_resource =
nullptr;
591 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
861 return Tray(icon, std::move(tooltip));
879 SDL_SetTrayIcon(tray, icon);
902 SDL_SetTrayTooltip(tray, tooltip);
934 return SDL_CreateTrayMenu(tray);
963 return SDL_CreateTraySubmenu(entry);
1021 return SDL_GetTraySubmenu(entry);
1048 auto entries = SDL_GetTrayEntries(menu, &count);
1049 return std::span<TrayEntry>{
reinterpret_cast<TrayEntry*
>(entries),
1106 return SDL_InsertTrayEntryAt(menu, pos, label, flags);
1138 SDL_SetTrayEntryLabel(entry, label);
1165 return SDL_GetTrayEntryLabel(entry);
1192 SDL_SetTrayEntryChecked(entry, checked);
1219 return SDL_GetTrayEntryChecked(entry);
1244 SDL_SetTrayEntryEnabled(entry, enabled);
1269 return SDL_GetTrayEntryEnabled(entry);
1297 SDL_SetTrayEntryCallback(entry, callback, userdata);
1352 return SDL_GetTrayEntryParent(entry);
1380 return SDL_GetTrayMenuParentEntry(menu);
1408 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:534
constexpr TrayEntry & operator=(TrayEntry &&other) noexcept
Assignment operator.
Definition: SDL3pp_tray.h:567
constexpr TrayEntry & operator=(const TrayEntry &other) noexcept=default
Assignment operator.
constexpr TrayEntry(TrayEntry &&other) noexcept
Move constructor.
Definition: SDL3pp_tray.h:558
constexpr TrayEntry(const TrayEntry &other)=default
Copy constructor.
void SetCallback(TrayCB callback)
Sets a callback to be invoked when the entry is selected.
Definition: SDL3pp_tray.h:1435
constexpr TrayEntryRaw get() const noexcept
Retrieves underlying TrayEntryRaw.
Definition: SDL3pp_tray.h:577
constexpr TrayEntry(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_tray.h:539
constexpr TrayEntry(const TrayEntryRaw resource) noexcept
Constructs from TrayEntryParam.
Definition: SDL3pp_tray.h:549
constexpr TrayEntryRaw release() noexcept
Retrieves underlying TrayEntryRaw and clear this.
Definition: SDL3pp_tray.h:580
~TrayEntry()
Destructor.
Definition: SDL3pp_tray.h:564
constexpr auto operator<=>(const TrayEntry &other) const noexcept=default
Comparison.
An opaque handle representing a toplevel system tray object.
Definition: SDL3pp_tray.h:164
constexpr TrayRaw get() const noexcept
Retrieves underlying TrayRaw.
Definition: SDL3pp_tray.h:243
~Tray()
Destructor.
Definition: SDL3pp_tray.h:228
constexpr Tray & operator=(const Tray &other) noexcept=default
Assignment operator.
constexpr Tray(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_tray.h:169
constexpr Tray & operator=(Tray &&other) noexcept
Assignment operator.
Definition: SDL3pp_tray.h:231
constexpr auto operator<=>(const Tray &other) const noexcept=default
Comparison.
Tray(SurfaceParam icon, StringParam tooltip)
Create an icon to be placed in the operating system's tray, or equivalent.
Definition: SDL3pp_tray.h:222
constexpr Tray(Tray &&other) noexcept
Move constructor.
Definition: SDL3pp_tray.h:190
constexpr TrayRaw release() noexcept
Retrieves underlying TrayRaw and clear this.
Definition: SDL3pp_tray.h:246
constexpr Tray(const Tray &other)=delete
Copy constructor.
constexpr Tray(const TrayRaw resource) noexcept
Constructs from TrayParam.
Definition: SDL3pp_tray.h:181
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:341
void(SDLCALL *)(void *userdata, TrayEntryRaw entry) TrayCallback
A callback that is invoked when a tray entry is selected.
Definition: SDL3pp_tray.h:141
TrayMenu CreateSubmenu()
Create a submenu for a system tray entry.
Definition: SDL3pp_tray.h:966
TrayEntry InsertEntry(int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition: SDL3pp_tray.h:1109
SDL_TrayMenu * TrayMenuRaw
Alias to raw representation for TrayMenu.
Definition: SDL3pp_tray.h:61
void SetTooltip(StringParam tooltip)
Updates the system tray icon's tooltip.
Definition: SDL3pp_tray.h:905
void SetTrayEntryEnabled(TrayEntryParam entry, bool enabled)
Sets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1242
void UpdateTrays()
Update the trays.
Definition: SDL3pp_tray.h:1426
bool GetTrayEntryEnabled(TrayEntryParam entry)
Gets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1267
TrayEntry InsertTrayEntryAt(TrayMenu menu, int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition: SDL3pp_tray.h:1101
TrayEntryParam GetParentEntry() const
Gets the entry for which the menu is a submenu, if the current menu is a submenu.
Definition: SDL3pp_tray.h:1383
TrayMenu GetMenu() const
Gets a previously created tray menu.
Definition: SDL3pp_tray.h:995
void DestroyTray(TrayRaw tray)
Destroys a tray object.
Definition: SDL3pp_tray.h:1333
constexpr TrayEntryFlags TRAYENTRY_BUTTON
Make the entry a simple button. Required.
Definition: SDL3pp_tray.h:115
void SetIcon(SurfaceParam icon)
Updates the system tray icon's icon.
Definition: SDL3pp_tray.h:882
void SetChecked(bool checked)
Sets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1195
constexpr TrayEntryFlags TRAYENTRY_DISABLED
Make the entry disabled. Optional.
Definition: SDL3pp_tray.h:124
TrayParam 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:1406
TrayMenu CreateMenu()
Create a menu for a system tray.
Definition: SDL3pp_tray.h:937
void SetTrayEntryCallback(TrayEntryParam entry, TrayCallback callback, void *userdata)
Sets a callback to be invoked when the entry is selected.
Definition: SDL3pp_tray.h:1293
TrayMenu GetParent()
Gets the menu containing a certain tray entry.
Definition: SDL3pp_tray.h:1355
void SetTrayEntryLabel(TrayEntryParam entry, StringParam label)
Sets the label of an entry.
Definition: SDL3pp_tray.h:1136
TrayMenu GetTrayEntryParent(TrayEntryParam entry)
Gets the menu containing a certain tray entry.
Definition: SDL3pp_tray.h:1350
void Click()
Simulate a click on a tray entry.
Definition: SDL3pp_tray.h:1317
std::span< TrayEntry > GetTrayEntries(TrayMenu menu)
Returns a list of entries in the menu, in order.
Definition: SDL3pp_tray.h:1045
void SetTrayIcon(TrayParam tray, SurfaceParam icon)
Updates the system tray icon's icon.
Definition: SDL3pp_tray.h:877
TrayMenu GetTraySubmenu(TrayEntryParam entry)
Gets a previously created tray entry submenu.
Definition: SDL3pp_tray.h:1019
void Destroy()
Destroys a tray object.
Definition: SDL3pp_tray.h:1335
void SetEnabled(bool enabled)
Sets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1247
TrayMenu CreateTrayMenu(TrayParam tray)
Create a menu for a system tray.
Definition: SDL3pp_tray.h:932
void RemoveTrayEntry(TrayEntryRaw entry)
Removes a tray entry.
Definition: SDL3pp_tray.h:1071
void ClickTrayEntry(TrayEntryParam entry)
Simulate a click on a tray entry.
Definition: SDL3pp_tray.h:1315
Tray CreateTray(SurfaceParam icon, StringParam tooltip)
Create an icon to be placed in the operating system's tray, or equivalent.
Definition: SDL3pp_tray.h:859
TrayEntryParam GetTrayMenuParentEntry(TrayMenuRaw menu)
Gets the entry for which the menu is a submenu, if the current menu is a submenu.
Definition: SDL3pp_tray.h:1378
bool GetTrayEntryChecked(TrayEntryParam entry)
Gets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1217
const char * GetTrayEntryLabel(TrayEntryParam entry)
Gets the label of an entry.
Definition: SDL3pp_tray.h:1163
TrayMenu GetSubmenu()
Gets a previously created tray entry submenu.
Definition: SDL3pp_tray.h:1024
const char * GetLabel() const
Gets the label of an entry.
Definition: SDL3pp_tray.h:1168
bool GetChecked() const
Gets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1222
SDL_TrayEntry * TrayEntryRaw
Alias to raw representation for TrayEntry.
Definition: SDL3pp_tray.h:70
std::span< TrayEntry > GetEntries()
Returns a list of entries in the menu, in order.
Definition: SDL3pp_tray.h:1053
bool GetEnabled() const
Gets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1272
void SetTrayTooltip(TrayParam tray, StringParam tooltip)
Updates the system tray icon's tooltip.
Definition: SDL3pp_tray.h:900
TrayParam 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:1411
constexpr TrayEntryFlags TRAYENTRY_CHECKED
Make the entry checked. This is valid only for checkboxes. Optional.
Definition: SDL3pp_tray.h:128
void Remove()
Removes a tray entry.
Definition: SDL3pp_tray.h:1073
Uint32 TrayEntryFlags
Flags that control the creation of system tray entries.
Definition: SDL3pp_tray.h:113
TrayMenu GetTrayMenu(TrayParam tray)
Gets a previously created tray menu.
Definition: SDL3pp_tray.h:993
TrayMenu CreateTraySubmenu(TrayEntryParam entry)
Create a submenu for a system tray entry.
Definition: SDL3pp_tray.h:961
void SetTrayEntryChecked(TrayEntryParam entry, bool checked)
Sets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1190
constexpr TrayEntryFlags TRAYENTRY_SUBMENU
Prepare the entry to have a submenu. Required.
Definition: SDL3pp_tray.h:121
constexpr TrayEntryFlags TRAYENTRY_CHECKBOX
Make the entry a checkbox. Required.
Definition: SDL3pp_tray.h:118
void SetLabel(StringParam label)
Sets the label of an entry.
Definition: SDL3pp_tray.h:1141
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
Safely wrap Surface for non owning parameters.
Definition: SDL3pp_surface.h:46
Safely wrap TrayEntry for non owning parameters.
Definition: SDL3pp_tray.h:77
constexpr TrayEntryParam(TrayEntryRaw value)
Constructs from TrayEntryRaw.
Definition: SDL3pp_tray.h:81
constexpr auto operator<=>(const TrayEntryParam &other) const =default
Comparison.
constexpr TrayEntryParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_tray.h:87
TrayEntryRaw value
parameter's TrayEntryRaw
Definition: SDL3pp_tray.h:78
RAII owning version TrayEntry.
Definition: SDL3pp_tray.h:821
~TrayEntryScoped()
Destructor.
Definition: SDL3pp_tray.h:833
constexpr TrayEntryScoped(TrayEntry &&other) noexcept
Move constructor.
Definition: SDL3pp_tray.h:827
Safely wrap Tray for non owning parameters.
Definition: SDL3pp_tray.h:32
TrayRaw value
parameter's TrayRaw
Definition: SDL3pp_tray.h:33
constexpr auto operator<=>(const TrayParam &other) const =default
Comparison.
constexpr TrayParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_tray.h:42
constexpr TrayParam(TrayRaw value)
Constructs from TrayRaw.
Definition: SDL3pp_tray.h:36
Semi-safe reference for Tray.
Definition: SDL3pp_tray.h:353
TrayRef(const TrayRef &other) noexcept
Copy constructor.
Definition: SDL3pp_tray.h:381
TrayRef(TrayParam resource) noexcept
Constructs from TrayParam.
Definition: SDL3pp_tray.h:363
TrayRef(TrayRaw resource) noexcept
Constructs from TrayParam.
Definition: SDL3pp_tray.h:375
~TrayRef()
Destructor.
Definition: SDL3pp_tray.h:387