4#include <SDL3/SDL_tray.h>
5#include "SDL3pp_stdinc.h"
6#include "SDL3pp_surface.h"
100 SDL_TRAYENTRY_BUTTON;
103 SDL_TRAYENTRY_CHECKBOX;
106 SDL_TRAYENTRY_SUBMENU;
109 SDL_TRAYENTRY_DISABLED;
217 static void reset(SDL_Tray* resource) { SDL_DestroyTray(resource); }
256 return Tray(SDL_CreateTray(icon, tooltip));
339 SDL_TrayMenu* m_trayMenu;
348 : m_trayMenu(trayMenu)
370 constexpr operator SDL_TrayMenu*()
const {
return m_trayMenu; }
377 constexpr explicit operator bool()
const {
return m_trayMenu !=
nullptr; }
587 const char*
GetLabel()
const {
return SDL_GetTrayEntryLabel(
get()); }
689 SDL_SetTrayEntryCallback(
get(), callback, userdata);
730 static void reset(SDL_TrayEntry* resource) { SDL_RemoveTrayEntry(resource); }
798 auto entries = SDL_GetTrayEntries(m_trayMenu, &count);
799 return std::span<TrayEntry>{
reinterpret_cast<TrayEntry*
>(entries),
808 SDL_InsertTrayEntryAt(m_trayMenu, pos, label, flags));
813 return SDL_GetTrayMenuParentEntry(m_trayMenu);
818 return SDL_GetTrayMenuParentTray(m_trayMenu);
846 [](
void* userdata, SDL_TrayEntry* entry) {
849 Wrapper::Wrap(
get(), std::move(callback)));
852#pragma endregion impl
A detached reference to resource that might be transformed into an owned handle.
Definition SDL3pp_resource.h:373
RESOURCE release()
Returns reference and reset this.
Definition SDL3pp_resource.h:178
Implement shared ownership for a resource.
Definition SDL3pp_resource.h:283
Implement unique ownership for a resource.
Definition SDL3pp_resource.h:226
constexpr ResourceUnique(std::nullptr_t=nullptr)
Default constructor.
Definition SDL3pp_resource.h:231
void reset()
Resets the value, destroying the resource if not nullptr.
Definition SDL3pp_resource.h:265
A dumb pointer to resource.
Definition SDL3pp_resource.h:197
constexpr ResourceUnsafe()=default
Default constructor.
Implement weak ownership for a resource.
Definition SDL3pp_resource.h:328
A SDL managed resource.
Definition SDL3pp_resource.h:29
constexpr Resource(T resource={})
Constructs from the underlying resource.
Definition SDL3pp_resource.h:37
constexpr SDL_Tray * get() const
Return contained resource;.
Definition SDL3pp_resource.h:76
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
DetachedTrayEntry InsertEntry(int pos, StringParam label, TrayEntryFlags flags)
Insert a tray entry at a given position.
Definition SDL3pp_tray.h:803
TrayMenu CreateMenu()
Create a menu for a system tray.
Definition SDL3pp_tray.h:791
DetachedResource< TrayEntryRef, TrayEntry > DetachedTrayEntry
A trayEntry result that will be owned only if assigned to a TrayEntry.
Definition SDL3pp_tray.h:84
ResourceShared< TrayEntry > TrayEntryShared
Handle to a shared trayEntry.
Definition SDL3pp_tray.h:66
void UpdateTrays()
Update the trays.
Definition SDL3pp_tray.h:831
TrayEntryShared share()
Move this trayEntry into a TrayEntryShared.
Definition SDL3pp_tray.h:764
constexpr TrayEntryFlags TRAYENTRY_BUTTON
Make the entry a simple button. Required.
Definition SDL3pp_tray.h:99
TrayMenu GetMenu() const
Gets a previously created tray menu.
Definition SDL3pp_tray.h:793
constexpr TrayEntryFlags TRAYENTRY_DISABLED
Make the entry disabled. Optional.
Definition SDL3pp_tray.h:108
TrayEntryRef GetParentEntry() const
Gets the entry for which the menu is a submenu, if the current menu is a submenu.
Definition SDL3pp_tray.h:811
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:816
ResourceShared< Tray > TrayShared
Handle to a shared tray.
Definition SDL3pp_tray.h:40
TrayShared share()
Move this tray into a TrayShared.
Definition SDL3pp_tray.h:280
std::span< TrayEntry > GetEntries()
Returns a list of entries in the menu, in order.
Definition SDL3pp_tray.h:795
SDL_TrayCallback TrayCallback
A callback that is invoked when a tray entry is selected.
Definition SDL3pp_tray.h:318
constexpr TrayEntryFlags TRAYENTRY_CHECKED
Make the entry checked.
Definition SDL3pp_tray.h:114
Uint32 TrayEntryFlags
Flags that control the creation of system tray entries.
Definition SDL3pp_tray.h:97
constexpr TrayEntryFlags TRAYENTRY_SUBMENU
Prepare the entry to have a submenu. Required.
Definition SDL3pp_tray.h:105
constexpr TrayEntryFlags TRAYENTRY_CHECKBOX
Make the entry a checkbox. Required.
Definition SDL3pp_tray.h:102
std::function< void(TrayEntryRef)> TrayCB
A callback that is invoked when a tray entry is selected.
Definition SDL3pp_tray.h:330
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
Store callbacks by key.
Definition SDL3pp_callbackWrapper.h:222
A collection of pixels used in software blitting.
Definition SDL3pp_surface.h:153
An opaque handle representing an entry on a system tray object.
Definition SDL3pp_tray.h:501
TrayMenu GetSubmenu()
Gets a previously created tray entry submenu.
Definition SDL3pp_tray.h:548
void SetChecked(bool checked)
Sets whether or not an entry is checked.
Definition SDL3pp_tray.h:605
void SetCallback(TrayCB callback)
Sets a callback to be invoked when the entry is selected.
Definition SDL3pp_tray.h:842
TrayMenu CreateSubmenu()
Create a submenu for a system tray entry.
Definition SDL3pp_tray.h:525
static void reset(SDL_TrayEntry *resource)
Removes a tray entry.
Definition SDL3pp_tray.h:730
void Click()
Simulate a click on a tray entry.
Definition SDL3pp_tray.h:701
void SetLabel(StringParam label)
Sets the label of an entry.
Definition SDL3pp_tray.h:569
void SetCallback(TrayCallback callback, void *userdata)
Sets a callback to be invoked when the entry is selected.
Definition SDL3pp_tray.h:687
TrayMenu GetParent()
Gets the menu containing a certain tray entry.
Definition SDL3pp_tray.h:715
const char * GetLabel() const
Gets the label of an entry.
Definition SDL3pp_tray.h:587
void SetEnabled(bool enabled)
Sets whether or not an entry is enabled.
Definition SDL3pp_tray.h:639
bool GetEnabled() const
Gets whether or not an entry is enabled.
Definition SDL3pp_tray.h:655
bool GetChecked() const
Gets whether or not an entry is checked.
Definition SDL3pp_tray.h:623
Unsafe Handle to trayEntry.
Definition SDL3pp_tray.h:779
constexpr TrayEntryUnsafe(TrayEntry &&other)
Constructs TrayEntryUnsafe from TrayEntry.
Definition SDL3pp_tray.h:785
Handle to an owned trayEntry.
Definition SDL3pp_tray.h:741
void Remove()
Removes a tray entry.
Definition SDL3pp_tray.h:755
An opaque handle representing a toplevel system tray object.
Definition SDL3pp_tray.h:126
void SetIcon(SurfaceRef icon)
Updates the system tray icon's icon.
Definition SDL3pp_tray.h:141
void SetTooltip(StringParam tooltip)
Updates the system tray icon's tooltip.
Definition SDL3pp_tray.h:155
static void reset(SDL_Tray *resource)
Destroys a tray object.
Definition SDL3pp_tray.h:217
Unsafe Handle to tray.
Definition SDL3pp_tray.h:295
constexpr TrayUnsafe(Tray &&other)
Constructs TrayUnsafe from Tray.
Definition SDL3pp_tray.h:301
Handle to an owned tray.
Definition SDL3pp_tray.h:228
void Destroy()
Destroys a tray object.
Definition SDL3pp_tray.h:271
static Tray Create(SurfaceRef icon, StringParam tooltip)
Create an icon to be placed in the operating system's tray, or equivalent.
Definition SDL3pp_tray.h:254