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;
252 void reset(SDL_Tray* newResource = {})
254 SDL_DestroyTray(
release(newResource));
273 constexpr explicit Tray(SDL_Tray* resource = {})
278 constexpr Tray(
const Tray& other) =
delete;
331 SDL_TrayMenu* m_trayMenu;
340 : m_trayMenu(trayMenu)
362 constexpr operator SDL_TrayMenu*()
const {
return m_trayMenu; }
369 constexpr explicit operator bool()
const {
return m_trayMenu !=
nullptr; }
580 const char*
GetLabel()
const {
return SDL_GetTrayEntryLabel(
get()); }
682 SDL_SetTrayEntryCallback(
get(), callback, userdata);
721 using TrayEntryBase::TrayEntryBase;
764 void reset(SDL_TrayEntry* newResource = {})
766 SDL_RemoveTrayEntry(
release(newResource));
798 constexpr explicit TrayEntry(SDL_TrayEntry* resource = {})
803 constexpr TrayEntry(
const TrayEntry& other) =
delete;
832 auto entries = SDL_GetTrayEntries(m_trayMenu, &count);
833 return std::span<TrayEntry>{
reinterpret_cast<TrayEntry*
>(entries),
841 return SDL_InsertTrayEntryAt(m_trayMenu, pos, label, flags);
846 return SDL_GetTrayMenuParentEntry(m_trayMenu);
851 return SDL_GetTrayMenuParentTray(m_trayMenu);
879 [](
void* userdata, SDL_TrayEntry* entry) {
882 Wrapper::Wrap(
get(), std::move(callback)));
885#pragma endregion impl
A SDL managed resource.
Definition SDL3pp_resource.h:17
constexpr SDL_Tray * release(SDL_Tray * newResource={})
Return contained resource and empties or replace value.
Definition SDL3pp_resource.h:60
constexpr Resource(T resource={})
Constructs the underlying resource.
Definition SDL3pp_resource.h:22
constexpr SDL_Tray * get() const
Return contained resource;.
Definition SDL3pp_resource.h:57
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:206
DetachedTrayEntry InsertEntry(int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition SDL3pp_tray.h:837
void UpdateTrays()
Update the trays.
Definition SDL3pp_tray.h:864
TrayMenu CreateMenu()
Create a menu for a system tray.
Definition SDL3pp_tray.h:825
constexpr TrayEntryFlags TRAYENTRY_BUTTON
Make the entry a simple button. Required.
Definition SDL3pp_tray.h:65
TrayMenu GetMenu() const
Gets a previously created tray menu.
Definition SDL3pp_tray.h:827
constexpr TrayEntryFlags TRAYENTRY_DISABLED
Make the entry disabled. Optional.
Definition SDL3pp_tray.h:74
TrayEntryRef GetParentEntry() const
Gets the entry for which the menu is a submenu, if the current menu is a submenu.
Definition SDL3pp_tray.h:844
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:849
std::span< TrayEntry > GetEntries()
Returns a list of entries in the menu, in order.
Definition SDL3pp_tray.h:829
SDL_TrayCallback TrayCallback
A callback that is invoked when a tray entry is selected.
Definition SDL3pp_tray.h:311
constexpr TrayEntryFlags TRAYENTRY_CHECKED
Make the entry checked.
Definition SDL3pp_tray.h:80
Uint32 TrayEntryFlags
Flags that control the creation of system tray entries.
Definition SDL3pp_tray.h:63
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
std::function< void(TrayEntryRef)> TrayCB
A callback that is invoked when a tray entry is selected.
Definition SDL3pp_tray.h:322
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
A detached reference to resource that might be transformed into an owned handle.
Definition SDL3pp_resource.h:156
Store callbacks by key.
Definition SDL3pp_callbackWrapper.h:222
A collection of pixels used in software blitting.
Definition SDL3pp_surface.h:138
An opaque handle representing a toplevel system tray object.
Definition SDL3pp_tray.h:93
TrayBase(SurfaceBase &icon, StringParam tooltip)
Create an icon to be placed in the operating system's tray, or equivalent.
Definition SDL3pp_tray.h:118
void SetTooltip(StringParam tooltip)
Updates the system tray icon's tooltip.
Definition SDL3pp_tray.h:149
void SetIcon(SurfaceBase &icon)
Updates the system tray icon's icon.
Definition SDL3pp_tray.h:135
An opaque handle representing an entry on a system tray object.
Definition SDL3pp_tray.h:494
void SetEnabled(bool enabled)
Sets whether or not an entry is enabled.
Definition SDL3pp_tray.h:632
TrayMenu GetSubmenu()
Gets a previously created tray entry submenu.
Definition SDL3pp_tray.h:541
void SetLabel(StringParam label)
Sets the label of an entry.
Definition SDL3pp_tray.h:562
bool GetEnabled() const
Gets whether or not an entry is enabled.
Definition SDL3pp_tray.h:648
TrayMenu CreateSubmenu()
Create a submenu for a system tray entry.
Definition SDL3pp_tray.h:518
const char * GetLabel() const
Gets the label of an entry.
Definition SDL3pp_tray.h:580
bool GetChecked() const
Gets whether or not an entry is checked.
Definition SDL3pp_tray.h:616
void SetCallback(TrayCB callback)
Sets a callback to be invoked when the entry is selected.
Definition SDL3pp_tray.h:875
void SetCallback(TrayCallback callback, void *userdata)
Sets a callback to be invoked when the entry is selected.
Definition SDL3pp_tray.h:680
TrayMenu GetParent()
Gets the menu containing a certain tray entry.
Definition SDL3pp_tray.h:708
void Click()
Simulate a click on a tray entry.
Definition SDL3pp_tray.h:694
void SetChecked(bool checked)
Sets whether or not an entry is checked.
Definition SDL3pp_tray.h:598
Handle to a non owned trayEntry.
Definition SDL3pp_tray.h:720
constexpr TrayEntryRef(TrayEntryRef &&other)
Move constructor.
Definition SDL3pp_tray.h:734
void reset(SDL_TrayEntry *newResource={})
Removes a tray entry.
Definition SDL3pp_tray.h:764
TrayEntryRef & operator=(TrayEntryRef other)
Assignment operator.
Definition SDL3pp_tray.h:747
constexpr TrayEntryRef(const TrayEntryRef &other)
Copy constructor.
Definition SDL3pp_tray.h:726
constexpr ~TrayEntryRef()=default
Default constructor.
void Remove()
Removes a tray entry.
Definition SDL3pp_tray.h:780
Handle to an owned trayEntry.
Definition SDL3pp_tray.h:792
constexpr TrayEntry(SDL_TrayEntry *resource={})
Constructs from the underlying resource.
Definition SDL3pp_tray.h:798
TrayEntry & operator=(TrayEntry other)
Assignment operator.
Definition SDL3pp_tray.h:818
constexpr TrayEntry(TrayEntry &&other)=default
Move constructor.
~TrayEntry()
Frees up resource when object goes out of scope.
Definition SDL3pp_tray.h:813
Handle to a non owned tray.
Definition SDL3pp_tray.h:207
TrayRef & operator=(TrayRef other)
Assignment operator.
Definition SDL3pp_tray.h:234
void reset(SDL_Tray *newResource={})
Destroys a tray object.
Definition SDL3pp_tray.h:252
constexpr ~TrayRef()=default
Default constructor.
constexpr TrayRef(const TrayRef &other)
Copy constructor.
Definition SDL3pp_tray.h:213
constexpr TrayRef(TrayRef &&other)
Move constructor.
Definition SDL3pp_tray.h:221
Handle to an owned tray.
Definition SDL3pp_tray.h:267
constexpr Tray(Tray &&other)=default
Move constructor.
~Tray()
Frees up resource when object goes out of scope.
Definition SDL3pp_tray.h:288
constexpr Tray(SDL_Tray *resource={})
Constructs from the underlying resource.
Definition SDL3pp_tray.h:273
Tray & operator=(Tray other)
Assignment operator.
Definition SDL3pp_tray.h:293