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)
188 constexpr Tray(
const Tray& other)
noexcept =
default;
193 :
Tray(other.release())
225 : m_resource(SDL_CreateTray(icon, tooltip))
230 ~Tray() { SDL_DestroyTray(m_resource); }
235 std::swap(m_resource, other.m_resource);
245 constexpr TrayRaw get() const noexcept {
return m_resource; }
251 m_resource =
nullptr;
259 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
262 constexpr operator TrayParam() const noexcept {
return {m_resource}; }
366 :
Tray(resource.value)
405 : m_trayMenu(trayMenu)
414 constexpr operator TrayMenuRaw() const noexcept {
return m_trayMenu; }
549 : m_resource(resource)
568 std::swap(m_resource, other.m_resource);
582 m_resource =
nullptr;
590 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
860 return Tray(icon, std::move(tooltip));
878 SDL_SetTrayIcon(tray, icon);
901 SDL_SetTrayTooltip(tray, tooltip);
933 return SDL_CreateTrayMenu(tray);
962 return SDL_CreateTraySubmenu(entry);
1020 return SDL_GetTraySubmenu(entry);
1047 auto entries = SDL_GetTrayEntries(menu, &count);
1048 return std::span<TrayEntry>{
reinterpret_cast<TrayEntry*
>(entries),
1105 return SDL_InsertTrayEntryAt(menu, pos, label, flags);
1137 SDL_SetTrayEntryLabel(entry, label);
1164 return SDL_GetTrayEntryLabel(entry);
1191 SDL_SetTrayEntryChecked(entry, checked);
1218 return SDL_GetTrayEntryChecked(entry);
1243 SDL_SetTrayEntryEnabled(entry, enabled);
1268 return SDL_GetTrayEntryEnabled(entry);
1296 SDL_SetTrayEntryCallback(entry, callback, userdata);
1351 return SDL_GetTrayEntryParent(entry);
1379 return SDL_GetTrayMenuParentEntry(menu);
1407 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:533
constexpr TrayEntry & operator=(TrayEntry &&other) noexcept
Assignment operator.
Definition: SDL3pp_tray.h:566
constexpr TrayEntry & operator=(const TrayEntry &other) noexcept=default
Assignment operator.
constexpr TrayEntry(TrayEntry &&other) noexcept
Move constructor.
Definition: SDL3pp_tray.h:557
void SetCallback(TrayCB callback)
Sets a callback to be invoked when the entry is selected.
Definition: SDL3pp_tray.h:1434
constexpr TrayEntryRaw get() const noexcept
Retrieves underlying TrayEntryRaw.
Definition: SDL3pp_tray.h:576
constexpr TrayEntry(const TrayEntry &other) noexcept=default
Copy constructor.
constexpr TrayEntry(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_tray.h:538
constexpr TrayEntry(const TrayEntryRaw resource) noexcept
Constructs from TrayEntryParam.
Definition: SDL3pp_tray.h:548
constexpr TrayEntryRaw release() noexcept
Retrieves underlying TrayEntryRaw and clear this.
Definition: SDL3pp_tray.h:579
~TrayEntry()
Destructor.
Definition: SDL3pp_tray.h:563
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:245
constexpr Tray(const Tray &other) noexcept=default
Copy constructor.
~Tray()
Destructor.
Definition: SDL3pp_tray.h:230
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:233
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:224
constexpr Tray(Tray &&other) noexcept
Move constructor.
Definition: SDL3pp_tray.h:192
constexpr TrayRaw release() noexcept
Retrieves underlying TrayRaw and clear this.
Definition: SDL3pp_tray.h:248
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:965
TrayEntry InsertEntry(int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition: SDL3pp_tray.h:1108
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:904
void SetTrayEntryEnabled(TrayEntryParam entry, bool enabled)
Sets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1241
void UpdateTrays()
Update the trays.
Definition: SDL3pp_tray.h:1425
bool GetTrayEntryEnabled(TrayEntryParam entry)
Gets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1266
TrayEntry InsertTrayEntryAt(TrayMenu menu, int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition: SDL3pp_tray.h:1100
TrayEntryParam GetParentEntry() const
Gets the entry for which the menu is a submenu, if the current menu is a submenu.
Definition: SDL3pp_tray.h:1382
TrayMenu GetMenu() const
Gets a previously created tray menu.
Definition: SDL3pp_tray.h:994
void DestroyTray(TrayRaw tray)
Destroys a tray object.
Definition: SDL3pp_tray.h:1332
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:881
void SetChecked(bool checked)
Sets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1194
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:1405
TrayMenu CreateMenu()
Create a menu for a system tray.
Definition: SDL3pp_tray.h:936
void SetTrayEntryCallback(TrayEntryParam entry, TrayCallback callback, void *userdata)
Sets a callback to be invoked when the entry is selected.
Definition: SDL3pp_tray.h:1292
TrayMenu GetParent()
Gets the menu containing a certain tray entry.
Definition: SDL3pp_tray.h:1354
void SetTrayEntryLabel(TrayEntryParam entry, StringParam label)
Sets the label of an entry.
Definition: SDL3pp_tray.h:1135
TrayMenu GetTrayEntryParent(TrayEntryParam entry)
Gets the menu containing a certain tray entry.
Definition: SDL3pp_tray.h:1349
void Click()
Simulate a click on a tray entry.
Definition: SDL3pp_tray.h:1316
std::span< TrayEntry > GetTrayEntries(TrayMenu menu)
Returns a list of entries in the menu, in order.
Definition: SDL3pp_tray.h:1044
void SetTrayIcon(TrayParam tray, SurfaceParam icon)
Updates the system tray icon's icon.
Definition: SDL3pp_tray.h:876
TrayMenu GetTraySubmenu(TrayEntryParam entry)
Gets a previously created tray entry submenu.
Definition: SDL3pp_tray.h:1018
void Destroy()
Destroys a tray object.
Definition: SDL3pp_tray.h:1334
void SetEnabled(bool enabled)
Sets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1246
TrayMenu CreateTrayMenu(TrayParam tray)
Create a menu for a system tray.
Definition: SDL3pp_tray.h:931
void RemoveTrayEntry(TrayEntryRaw entry)
Removes a tray entry.
Definition: SDL3pp_tray.h:1070
void ClickTrayEntry(TrayEntryParam entry)
Simulate a click on a tray entry.
Definition: SDL3pp_tray.h:1314
Tray CreateTray(SurfaceParam icon, StringParam tooltip)
Create an icon to be placed in the operating system's tray, or equivalent.
Definition: SDL3pp_tray.h:858
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:1377
bool GetTrayEntryChecked(TrayEntryParam entry)
Gets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1216
const char * GetTrayEntryLabel(TrayEntryParam entry)
Gets the label of an entry.
Definition: SDL3pp_tray.h:1162
TrayMenu GetSubmenu()
Gets a previously created tray entry submenu.
Definition: SDL3pp_tray.h:1023
const char * GetLabel() const
Gets the label of an entry.
Definition: SDL3pp_tray.h:1167
bool GetChecked() const
Gets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1221
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:1052
bool GetEnabled() const
Gets whether or not an entry is enabled.
Definition: SDL3pp_tray.h:1271
void SetTrayTooltip(TrayParam tray, StringParam tooltip)
Updates the system tray icon's tooltip.
Definition: SDL3pp_tray.h:899
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:1410
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:1072
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:992
TrayMenu CreateTraySubmenu(TrayEntryParam entry)
Create a submenu for a system tray entry.
Definition: SDL3pp_tray.h:960
void SetTrayEntryChecked(TrayEntryParam entry, bool checked)
Sets whether or not an entry is checked.
Definition: SDL3pp_tray.h:1189
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:1140
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:53
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:820
~TrayEntryScoped()
Destructor.
Definition: SDL3pp_tray.h:832
constexpr TrayEntryScoped(TrayEntry &&other) noexcept
Move constructor.
Definition: SDL3pp_tray.h:826
Safely wrap Tray for non owning parameters.
Definition: SDL3pp_tray.h:32
constexpr TrayParam(std::nullptr_t=nullptr)
Constructs null/invalid.
Definition: SDL3pp_tray.h:42
TrayRaw value
parameter's TrayRaw
Definition: SDL3pp_tray.h:33
constexpr auto operator<=>(const TrayParam &other) const =default
Comparison.
constexpr TrayParam(TrayRaw value)
Constructs from TrayRaw.
Definition: SDL3pp_tray.h:36
Semi-safe reference for Tray.
Definition: SDL3pp_tray.h:355
TrayRef(TrayParam resource) noexcept
Constructs from TrayParam.
Definition: SDL3pp_tray.h:365
constexpr TrayRef(const TrayRef &other) noexcept=default
Copy constructor.
TrayRef(TrayRaw resource) noexcept
Constructs from TrayParam.
Definition: SDL3pp_tray.h:377
~TrayRef()
Destructor.
Definition: SDL3pp_tray.h:386