4#include <SDL3/SDL_tray.h>
5#include "SDL3pp_stdinc.h"
6#include "SDL3pp_surface.h"
76 SDL_TRAYENTRY_CHECKBOX;
79 SDL_TRAYENTRY_SUBMENU;
82 SDL_TRAYENTRY_DISABLED;
220 using TrayBase::TrayBase;
236 :
Tray(other.release())
292 : m_trayMenu(trayMenu)
301 constexpr operator TrayMenuRaw() const noexcept {
return m_trayMenu; }
709 constexpr TrayEntryScoped(
const TrayEntryScoped& other) =
delete;
752 return Tray(icon, tooltip);
756 :
Tray(SDL_CreateTray(icon, tooltip))
775 SDL_SetTrayIcon(tray, icon);
798 SDL_SetTrayTooltip(tray, tooltip);
830 return SDL_CreateTrayMenu(tray);
859 return SDL_CreateTraySubmenu(entry);
917 return SDL_GetTraySubmenu(entry);
941 auto entries = SDL_GetTrayEntries(menu, &count);
942 return std::span<TrayEntry>{
reinterpret_cast<TrayEntry*
>(entries),
999 return TrayEntry(menu, pos, label, flags);
1006 return TrayEntry(m_trayMenu, pos, label, flags);
1013 :
TrayEntry(SDL_InsertTrayEntryAt(menu, pos, label, flags))
1083 SDL_SetTrayEntryLabel(entry, label);
1110 return SDL_GetTrayEntryLabel(entry);
1137 SDL_SetTrayEntryChecked(entry, checked);
1164 return SDL_GetTrayEntryChecked(entry);
1189 SDL_SetTrayEntryEnabled(entry, enabled);
1214 return SDL_GetTrayEntryEnabled(entry);
1242 SDL_SetTrayEntryCallback(entry, callback, userdata);
1321 return SDL_GetTrayEntryParent(entry);
1349 return SDL_GetTrayMenuParentEntry(menu);
1377 return SDL_GetTrayMenuParentTray(menu);
constexpr RawPointer release() noexcept
Retrieves underlying resource pointer and clear this.
Definition SDL3pp_resource.h:57
friend constexpr void swap(ResourceBaseT &lhs, ResourceBaseT &rhs) noexcept
Definition SDL3pp_resource.h:65
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:54
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:58
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:296
ResourceRefT< SurfaceBase > SurfaceRef
Reference for Surface.
Definition SDL3pp_surface.h:57
TrayMenu CreateSubmenu()
Create a submenu for a system tray entry.
Definition SDL3pp_tray.h:862
void SetTrayIcon(TrayRef tray, SurfaceRef icon)
Updates the system tray icon's icon.
Definition SDL3pp_tray.h:773
TrayEntry InsertEntry(int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition SDL3pp_tray.h:1002
void UpdateTrays()
Update the trays.
Definition SDL3pp_tray.h:1395
TrayEntry InsertTrayEntryAt(TrayMenu menu, int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition SDL3pp_tray.h:994
TrayMenu CreateMenu()
Create a menu for a system tray.
Definition SDL3pp_tray.h:833
void DestroyTray(TrayRaw tray)
Destroys a tray object.
Definition SDL3pp_tray.h:1302
constexpr TrayEntryFlags TRAYENTRY_BUTTON
Make the entry a simple button. Required.
Definition SDL3pp_tray.h:72
TrayMenu GetMenu() const
Gets a previously created tray menu.
Definition SDL3pp_tray.h:891
void SetTrayEntryLabel(TrayEntry entry, StringParam label)
Sets the label of an entry.
Definition SDL3pp_tray.h:1081
void SetChecked(bool checked)
Sets whether or not an entry is checked.
Definition SDL3pp_tray.h:1140
constexpr TrayEntryFlags TRAYENTRY_DISABLED
Make the entry disabled. Optional.
Definition SDL3pp_tray.h:81
void ClickTrayEntry(TrayEntry entry)
Simulate a click on a tray entry.
Definition SDL3pp_tray.h:1284
TrayEntry AppendEntry(StringParam label, TrayEntryFlags flags)
Appends a tray entry.
Definition SDL3pp_tray.h:1056
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:1347
void(SDLCALL *)(void *userdata, TrayEntryRaw entry) TrayCallback
A callback that is invoked when a tray entry is selected.
Definition SDL3pp_tray.h:98
TrayMenu CreateTrayMenu(TrayRef tray)
Create a menu for a system tray.
Definition SDL3pp_tray.h:828
TrayEntry AppendTrayEntry(TrayMenuRaw menu, StringParam label, TrayEntryFlags flags)
Appends a tray entry.
Definition SDL3pp_tray.h:1049
MakeFrontCallback< void(TrayEntryRaw entry)> TrayCB
A callback that is invoked when a tray entry is selected.
Definition SDL3pp_tray.h:111
TrayMenu GetTraySubmenu(TrayEntry entry)
Gets a previously created tray entry submenu.
Definition SDL3pp_tray.h:915
TrayMenu GetParent()
Gets the menu containing a certain tray entry.
Definition SDL3pp_tray.h:1324
bool GetTrayEntryChecked(TrayEntryRef entry)
Gets whether or not an entry is checked.
Definition SDL3pp_tray.h:1162
void SetTrayEntryChecked(TrayEntry entry, bool checked)
Sets whether or not an entry is checked.
Definition SDL3pp_tray.h:1135
TrayMenu GetTrayMenu(TrayRef tray)
Gets a previously created tray menu.
Definition SDL3pp_tray.h:889
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:1380
void Click()
Simulate a click on a tray entry.
Definition SDL3pp_tray.h:1286
std::span< TrayEntry > GetTrayEntries(TrayMenu menu)
Returns a list of entries in the menu, in order.
Definition SDL3pp_tray.h:938
TrayEntry TrayEntryRef
Reference for TrayEntry.
Definition SDL3pp_tray.h:57
void SetCallback(TrayCallback callback, void *userdata)
Sets a callback to be invoked when the entry is selected.
Definition SDL3pp_tray.h:1264
const char * GetTrayEntryLabel(TrayEntryRef entry)
Gets the label of an entry.
Definition SDL3pp_tray.h:1108
void SetTrayEntryEnabled(TrayEntry entry, bool enabled)
Sets whether or not an entry is enabled.
Definition SDL3pp_tray.h:1187
SDL_Tray * TrayRaw
Alias to raw representation for Tray.
Definition SDL3pp_tray.h:28
Tray CreateTray(SurfaceRef icon, StringParam tooltip)
Create an icon to be placed in the operating system's tray, or equivalent.
Definition SDL3pp_tray.h:750
void SetEnabled(bool enabled)
Sets whether or not an entry is enabled.
Definition SDL3pp_tray.h:1192
SDL_TrayEntry * TrayEntryRaw
Alias to raw representation for TrayEntry.
Definition SDL3pp_tray.h:47
void RemoveTrayEntry(TrayEntryRaw entry)
Removes a tray entry.
Definition SDL3pp_tray.h:964
void Destroy()
Destroys a tray object.
Definition SDL3pp_tray.h:1304
SDL_TrayMenu * TrayMenuRaw
Alias to raw representation for TrayMenu.
Definition SDL3pp_tray.h:38
TrayMenu GetSubmenu()
Gets a previously created tray entry submenu.
Definition SDL3pp_tray.h:920
TrayMenu CreateTraySubmenu(TrayEntry entry)
Create a submenu for a system tray entry.
Definition SDL3pp_tray.h:857
void SetTooltip(StringParam tooltip)
Updates the system tray icon's tooltip.
Definition SDL3pp_tray.h:801
void SetTrayTooltip(TrayRef tray, StringParam tooltip)
Updates the system tray icon's tooltip.
Definition SDL3pp_tray.h:796
const char * GetLabel() const
Gets the label of an entry.
Definition SDL3pp_tray.h:1113
void SetTrayEntryCallback(TrayEntry entry, TrayCallback callback, void *userdata)
Sets a callback to be invoked when the entry is selected.
Definition SDL3pp_tray.h:1238
bool GetChecked() const
Gets whether or not an entry is checked.
Definition SDL3pp_tray.h:1167
TrayEntry GetParentEntry() const
Gets the entry for which the menu is a submenu, if the current menu is a submenu.
Definition SDL3pp_tray.h:1352
bool GetTrayEntryEnabled(TrayEntryRef entry)
Gets whether or not an entry is enabled.
Definition SDL3pp_tray.h:1212
ResourceRefT< TrayBase > TrayRef
Reference for Tray.
Definition SDL3pp_tray.h:35
void SetIcon(SurfaceRef icon)
Updates the system tray icon's icon.
Definition SDL3pp_tray.h:778
std::span< TrayEntry > GetEntries()
Returns a list of entries in the menu, in order.
Definition SDL3pp_tray.h:946
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:1375
bool GetEnabled() const
Gets whether or not an entry is enabled.
Definition SDL3pp_tray.h:1217
TrayEntry(TrayMenu menu, int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition SDL3pp_tray.h:1009
constexpr TrayEntryFlags TRAYENTRY_CHECKED
Make the entry checked. This is valid only for checkboxes. Optional.
Definition SDL3pp_tray.h:85
void Remove()
Removes a tray entry.
Definition SDL3pp_tray.h:966
TrayMenu GetTrayEntryParent(TrayEntry entry)
Gets the menu containing a certain tray entry.
Definition SDL3pp_tray.h:1319
constexpr TrayEntryFlags TRAYENTRY_SUBMENU
Prepare the entry to have a submenu. Required.
Definition SDL3pp_tray.h:78
constexpr TrayEntryFlags TRAYENTRY_CHECKBOX
Make the entry a checkbox. Required.
Definition SDL3pp_tray.h:75
void SetLabel(StringParam label)
Sets the label of an entry.
Definition SDL3pp_tray.h:1086
Uint32 TrayEntryFlags
Flags that control the creation of system tray entries.
Definition SDL3pp_tray.h:70
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:93
Base class to Tray.
Definition SDL3pp_tray.h:119
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
RAII owning version TrayEntry.
Definition SDL3pp_tray.h:706
constexpr TrayEntryScoped(TrayEntryScoped &&other) noexcept
Move constructor.
Definition SDL3pp_tray.h:712
~TrayEntryScoped()
Destructor.
Definition SDL3pp_tray.h:724
TrayEntry(TrayMenu menu, int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition SDL3pp_tray.h:1009
constexpr TrayEntryScoped(TrayEntry &&other) noexcept
Move constructor.
Definition SDL3pp_tray.h:718
An opaque handle representing an entry on a system tray object.
Definition SDL3pp_tray.h:420
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
An opaque handle representing a toplevel system tray object.
Definition SDL3pp_tray.h:219
constexpr Tray(TrayRaw resource) noexcept
Constructs from raw Tray.
Definition SDL3pp_tray.h:229
~Tray()
Destructor.
Definition SDL3pp_tray.h:266
constexpr Tray & operator=(Tray &&other) noexcept
Assignment operator.
Definition SDL3pp_tray.h:269
constexpr Tray(Tray &&other) noexcept
Move constructor.
Definition SDL3pp_tray.h:235