SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables

SDL offers a way to add items to the "system tray" (more correctly called the "notification area" on Windows). More...

Collaboration diagram for System Tray:

Classes

struct  SDL::TrayParam
 Safely wrap Tray for non owning parameters. More...
 
struct  SDL::TrayEntryParam
 Safely wrap TrayEntry for non owning parameters. More...
 
class  SDL::Tray
 An opaque handle representing a toplevel system tray object. More...
 
struct  SDL::TrayRef
 Semi-safe reference for Tray. More...
 
class  SDL::TrayMenu
 An opaque handle representing a menu/submenu on a system tray object. More...
 
class  SDL::TrayEntry
 An opaque handle representing an entry on a system tray object. More...
 
struct  SDL::TrayEntryScoped
 RAII owning version TrayEntry. More...
 

Typedefs

using SDL::TrayRaw = SDL_Tray *
 Alias to raw representation for Tray.
 
using SDL::TrayMenuRaw = SDL_TrayMenu *
 Alias to raw representation for TrayMenu.
 
using SDL::TrayEntryRaw = SDL_TrayEntry *
 Alias to raw representation for TrayEntry.
 
using SDL::TrayEntryFlags = Uint32
 Flags that control the creation of system tray entries. More...
 
using SDL::TrayCallback = SDL_TrayCallback
 A callback that is invoked when a tray entry is selected. More...
 
using SDL::TrayCB = std::function< void(TrayEntryRaw)>
 A callback that is invoked when a tray entry is selected. More...
 

Functions

Tray SDL::CreateTray (SurfaceParam icon, StringParam tooltip)
 Create an icon to be placed in the operating system's tray, or equivalent. More...
 
void SDL::SetTrayIcon (TrayParam tray, SurfaceParam icon)
 Updates the system tray icon's icon. More...
 
void SDL::SetTrayTooltip (TrayParam tray, StringParam tooltip)
 Updates the system tray icon's tooltip. More...
 
TrayMenu SDL::CreateTrayMenu (TrayParam tray)
 Create a menu for a system tray. More...
 
TrayMenu SDL::CreateTraySubmenu (TrayEntryParam entry)
 Create a submenu for a system tray entry. More...
 
TrayMenu SDL::GetTrayMenu (TrayParam tray)
 Gets a previously created tray menu. More...
 
TrayMenu SDL::GetTraySubmenu (TrayEntryParam entry)
 Gets a previously created tray entry submenu. More...
 
std::span< TrayEntrySDL::GetTrayEntries (TrayMenu menu)
 Returns a list of entries in the menu, in order. More...
 
void SDL::RemoveTrayEntry (TrayEntryRaw entry)
 Removes a tray entry. More...
 
TrayEntry SDL::InsertTrayEntryAt (TrayMenu menu, int pos, StringParam label, TrayEntryFlags flags)
 Insert a tray entry at a given position. More...
 
void SDL::SetTrayEntryLabel (TrayEntryParam entry, StringParam label)
 Sets the label of an entry. More...
 
const char * SDL::GetTrayEntryLabel (TrayEntryParam entry)
 Gets the label of an entry. More...
 
void SDL::SetTrayEntryChecked (TrayEntryParam entry, bool checked)
 Sets whether or not an entry is checked. More...
 
bool SDL::GetTrayEntryChecked (TrayEntryParam entry)
 Gets whether or not an entry is checked. More...
 
void SDL::SetTrayEntryEnabled (TrayEntryParam entry, bool enabled)
 Sets whether or not an entry is enabled. More...
 
bool SDL::GetTrayEntryEnabled (TrayEntryParam entry)
 Gets whether or not an entry is enabled. More...
 
void SDL::SetTrayEntryCallback (TrayEntryParam entry, TrayCallback callback, void *userdata)
 Sets a callback to be invoked when the entry is selected. More...
 
void SDL::ClickTrayEntry (TrayEntryParam entry)
 Simulate a click on a tray entry. More...
 
void SDL::DestroyTray (TrayRaw tray)
 Destroys a tray object. More...
 
TrayMenu SDL::GetTrayEntryParent (TrayEntryParam entry)
 Gets the menu containing a certain tray entry. More...
 
TrayEntryParam SDL::GetTrayMenuParentEntry (TrayMenuRaw menu)
 Gets the entry for which the menu is a submenu, if the current menu is a submenu. More...
 
TrayParam SDL::GetTrayMenuParentTray (TrayMenuRaw menu)
 Gets the tray for which this menu is the first-level menu, if the current menu isn't a submenu. More...
 
void SDL::UpdateTrays ()
 Update the trays. More...
 
void SDL::Tray::SetIcon (SurfaceParam icon)
 Updates the system tray icon's icon. More...
 
void SDL::Tray::SetTooltip (StringParam tooltip)
 Updates the system tray icon's tooltip. More...
 
TrayMenu SDL::Tray::CreateMenu ()
 Create a menu for a system tray. More...
 
TrayMenu SDL::TrayEntry::CreateSubmenu ()
 Create a submenu for a system tray entry. More...
 
TrayMenu SDL::Tray::GetMenu () const
 Gets a previously created tray menu. More...
 
TrayMenu SDL::TrayEntry::GetSubmenu ()
 Gets a previously created tray entry submenu. More...
 
std::span< TrayEntrySDL::TrayMenu::GetEntries ()
 Returns a list of entries in the menu, in order. More...
 
void SDL::TrayEntry::Remove ()
 Removes a tray entry. More...
 
TrayEntry SDL::TrayMenu::InsertEntry (int pos, StringParam label, TrayEntryFlags flags)
 Insert a tray entry at a given position. More...
 
void SDL::TrayEntry::SetLabel (StringParam label)
 Sets the label of an entry. More...
 
const char * SDL::TrayEntry::GetLabel () const
 Gets the label of an entry. More...
 
void SDL::TrayEntry::SetChecked (bool checked)
 Sets whether or not an entry is checked. More...
 
bool SDL::TrayEntry::GetChecked () const
 Gets whether or not an entry is checked. More...
 
void SDL::TrayEntry::SetEnabled (bool enabled)
 Sets whether or not an entry is enabled. More...
 
bool SDL::TrayEntry::GetEnabled () const
 Gets whether or not an entry is enabled. More...
 
void SDL::TrayEntry::SetCallback (TrayCallback callback, void *userdata)
 Sets a callback to be invoked when the entry is selected. More...
 
void SDL::TrayEntry::Click ()
 Simulate a click on a tray entry. More...
 
void SDL::Tray::Destroy ()
 Destroys a tray object. More...
 
TrayMenu SDL::TrayEntry::GetParent ()
 Gets the menu containing a certain tray entry. More...
 
TrayEntryParam SDL::TrayMenu::GetParentEntry () const
 Gets the entry for which the menu is a submenu, if the current menu is a submenu. More...
 
TrayParam SDL::TrayMenu::GetParentTray () const
 Gets the tray for which this menu is the first-level menu, if the current menu isn't a submenu. More...
 

Variables

constexpr TrayEntryFlags SDL::TRAYENTRY_BUTTON
 Make the entry a simple button. Required. More...
 
constexpr TrayEntryFlags SDL::TRAYENTRY_CHECKBOX
 Make the entry a checkbox. Required. More...
 
constexpr TrayEntryFlags SDL::TRAYENTRY_SUBMENU
 Prepare the entry to have a submenu. Required. More...
 
constexpr TrayEntryFlags SDL::TRAYENTRY_DISABLED
 Make the entry disabled. Optional. More...
 
constexpr TrayEntryFlags SDL::TRAYENTRY_CHECKED = SDL_TRAYENTRY_CHECKED
 Make the entry checked. This is valid only for checkboxes. Optional.
 

Detailed Description

On platforms that offer this concept, an SDL app can add a tray icon, submenus, checkboxes, and clickable entries, and register a callback that is fired when the user clicks on these pieces.

Typedef Documentation

◆ TrayCallback

using SDL::TrayCallback = typedef SDL_TrayCallback
Parameters
userdataan optional pointer to pass extra data to the callback when it will be invoked.
entrythe tray entry that was selected.
Since
This datatype is available since SDL 3.2.0.
See also
TrayEntry.SetCallback

◆ TrayCB

using SDL::TrayCB = typedef std::function<void(TrayEntryRaw)>
Parameters
entrythe tray entry that was selected.
Since
This datatype is available since SDL 3.2.0.
See also
TrayEntry.SetCallback
TrayCallback

◆ TrayEntryFlags

using SDL::TrayEntryFlags = typedef Uint32

Some of these flags are required; exactly one of them must be specified at the time a tray entry is created. Other flags are optional; zero or more of those can be OR'ed together with the required flag.

Since
This datatype is available since SDL 3.2.0.
See also
TrayMenu.InsertEntry

Function Documentation

◆ Click()

void SDL::TrayEntry::Click ( )
inline
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.

◆ ClickTrayEntry()

void SDL::ClickTrayEntry ( TrayEntryParam  entry)
inline
Parameters
entryThe entry to activate.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.

◆ CreateMenu()

TrayMenu SDL::Tray::CreateMenu ( )
inline

This should be called at most once per tray icon.

This function does the same thing as TrayEntry.CreateSubmenu(), except that it takes a Tray instead of a TrayEntry.

A menu does not need to be destroyed; it will be destroyed with the tray.

Returns
the newly created menu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.Tray
Tray.GetMenu
TrayMenu.GetParentTray

◆ CreateSubmenu()

TrayMenu SDL::TrayEntry::CreateSubmenu ( )
inline

This should be called at most once per tray entry.

This function does the same thing as Tray.CreateMenu, except that it takes a TrayEntry instead of a Tray.

A menu does not need to be destroyed; it will be destroyed with the tray.

Returns
the newly created menu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.InsertEntry
TrayEntry.GetSubmenu
TrayMenu.GetParentEntry

◆ CreateTray()

Tray SDL::CreateTray ( SurfaceParam  icon,
StringParam  tooltip 
)
inline

Many platforms advise not using a system tray unless persistence is a necessary feature. Avoid needlessly creating a tray icon, as the user may feel like it clutters their interface.

Using tray icons require the video subsystem.

Parameters
icona surface to be used as icon. May be nullptr.
tooltipa tooltip to be displayed when the mouse hovers the icon in UTF-8 encoding. Not supported on all platforms. May be nullptr.
Returns
The newly created system tray icon.
Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.
See also
Tray.CreateMenu
Tray.GetMenu
Tray.Destroy

◆ CreateTrayMenu()

TrayMenu SDL::CreateTrayMenu ( TrayParam  tray)
inline

This should be called at most once per tray icon.

This function does the same thing as TrayEntry.CreateSubmenu(), except that it takes a Tray instead of a TrayEntry.

A menu does not need to be destroyed; it will be destroyed with the tray.

Parameters
traythe tray to bind the menu to.
Returns
the newly created menu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.Tray
Tray.GetMenu
TrayMenu.GetParentTray

◆ CreateTraySubmenu()

TrayMenu SDL::CreateTraySubmenu ( TrayEntryParam  entry)
inline

This should be called at most once per tray entry.

This function does the same thing as Tray.CreateMenu, except that it takes a TrayEntry instead of a Tray.

A menu does not need to be destroyed; it will be destroyed with the tray.

Parameters
entrythe tray entry to bind the menu to.
Returns
the newly created menu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.InsertEntry
TrayEntry.GetSubmenu
TrayMenu.GetParentEntry

◆ Destroy()

void SDL::Tray::Destroy ( )
inline

This also destroys all associated menus and entries.

Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.Tray

◆ DestroyTray()

void SDL::DestroyTray ( TrayRaw  tray)
inline

This also destroys all associated menus and entries.

Parameters
traythe tray icon to be destroyed.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.Tray

◆ GetChecked()

bool SDL::TrayEntry::GetChecked ( ) const
inline

The entry must have been created with the TRAYENTRY_CHECKBOX flag.

Returns
true if the entry is checked; false otherwise.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.SetChecked

◆ GetEnabled()

bool SDL::TrayEntry::GetEnabled ( ) const
inline
Returns
true if the entry is enabled; false otherwise.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.SetEnabled

◆ GetEntries()

std::span< TrayEntry > SDL::TrayMenu::GetEntries ( )
inline
Returns
a nullptr-terminated list of entries within the given menu. The pointer becomes invalid when any function that inserts or deletes entries in the menu is called.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayEntry.Remove
TrayMenu.InsertEntry

◆ GetLabel()

const char * SDL::TrayEntry::GetLabel ( ) const
inline

If the returned value is nullptr, the entry is a separator.

Returns
the label of the entry in UTF-8 encoding.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.SetLabel

◆ GetMenu()

TrayMenu SDL::Tray::GetMenu ( ) const
inline

You should have called Tray.CreateMenu() on the tray object. This function allows you to fetch it again later.

This function does the same thing as TrayEntry.GetSubmenu(), except that it takes a Tray instead of a TrayEntry.

A menu does not need to be destroyed; it will be destroyed with the tray.

Returns
the newly created menu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.Tray
Tray.CreateMenu

◆ GetParent()

TrayMenu SDL::TrayEntry::GetParent ( )
inline
Returns
the parent menu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.InsertEntry

◆ GetParentEntry()

TrayEntryParam SDL::TrayMenu::GetParentEntry ( ) const
inline

Either this function or TrayMenu.GetParentTray() will return non-nullptr for any given menu.

Returns
the parent entry, or nullptr if this menu is not a submenu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayEntry.CreateSubmenu
TrayMenu.GetParentTray

◆ GetParentTray()

TrayParam SDL::TrayMenu::GetParentTray ( ) const
inline

Either this function or TrayMenu.GetParentEntry() will return non-nullptr for any given menu.

Returns
the parent tray, or nullptr if this menu is a submenu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.CreateMenu
TrayMenu.GetParentEntry

◆ GetSubmenu()

TrayMenu SDL::TrayEntry::GetSubmenu ( )
inline

You should have called TrayEntry.CreateSubmenu() on the entry object. This function allows you to fetch it again later.

This function does the same thing as Tray.GetMenu(), except that it takes a TrayEntry instead of a Tray.

A menu does not need to be destroyed; it will be destroyed with the tray.

Returns
the newly created menu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.InsertEntry
TrayEntry.CreateSubmenu

◆ GetTrayEntries()

std::span< TrayEntry > SDL::GetTrayEntries ( TrayMenu  menu)
inline
Parameters
menuThe menu to get entries from.
Returns
a nullptr-terminated list of entries within the given menu. The pointer becomes invalid when any function that inserts or deletes entries in the menu is called.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayEntry.Remove
TrayMenu.InsertEntry

◆ GetTrayEntryChecked()

bool SDL::GetTrayEntryChecked ( TrayEntryParam  entry)
inline

The entry must have been created with the TRAYENTRY_CHECKBOX flag.

Parameters
entrythe entry to be read.
Returns
true if the entry is checked; false otherwise.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.SetChecked

◆ GetTrayEntryEnabled()

bool SDL::GetTrayEntryEnabled ( TrayEntryParam  entry)
inline
Parameters
entrythe entry to be read.
Returns
true if the entry is enabled; false otherwise.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.SetEnabled

◆ GetTrayEntryLabel()

const char * SDL::GetTrayEntryLabel ( TrayEntryParam  entry)
inline

If the returned value is nullptr, the entry is a separator.

Parameters
entrythe entry to be read.
Returns
the label of the entry in UTF-8 encoding.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.SetLabel

◆ GetTrayEntryParent()

TrayMenu SDL::GetTrayEntryParent ( TrayEntryParam  entry)
inline
Parameters
entrythe entry for which to get the parent menu.
Returns
the parent menu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.InsertEntry

◆ GetTrayMenu()

TrayMenu SDL::GetTrayMenu ( TrayParam  tray)
inline

You should have called Tray.CreateMenu() on the tray object. This function allows you to fetch it again later.

This function does the same thing as TrayEntry.GetSubmenu(), except that it takes a Tray instead of a TrayEntry.

A menu does not need to be destroyed; it will be destroyed with the tray.

Parameters
traythe tray entry to bind the menu to.
Returns
the newly created menu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.Tray
Tray.CreateMenu

◆ GetTrayMenuParentEntry()

TrayEntryParam SDL::GetTrayMenuParentEntry ( TrayMenuRaw  menu)
inline

Either this function or TrayMenu.GetParentTray() will return non-nullptr for any given menu.

Parameters
menuthe menu for which to get the parent entry.
Returns
the parent entry, or nullptr if this menu is not a submenu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayEntry.CreateSubmenu
TrayMenu.GetParentTray

◆ GetTrayMenuParentTray()

TrayParam SDL::GetTrayMenuParentTray ( TrayMenuRaw  menu)
inline

Either this function or TrayMenu.GetParentEntry() will return non-nullptr for any given menu.

Parameters
menuthe menu for which to get the parent enttrayry.
Returns
the parent tray, or nullptr if this menu is a submenu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.CreateMenu
TrayMenu.GetParentEntry

◆ GetTraySubmenu()

TrayMenu SDL::GetTraySubmenu ( TrayEntryParam  entry)
inline

You should have called TrayEntry.CreateSubmenu() on the entry object. This function allows you to fetch it again later.

This function does the same thing as Tray.GetMenu(), except that it takes a TrayEntry instead of a Tray.

A menu does not need to be destroyed; it will be destroyed with the tray.

Parameters
entrythe tray entry to bind the menu to.
Returns
the newly created menu.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.InsertEntry
TrayEntry.CreateSubmenu

◆ InsertEntry()

TrayEntry SDL::TrayMenu::InsertEntry ( int  pos,
StringParam  label,
TrayEntryFlags  flags 
)
inline

If label is nullptr, the entry will be a separator. Many functions won't work for an entry that is a separator.

An entry does not need to be destroyed; it will be destroyed with the tray.

Parameters
posthe desired position for the new entry. Entries at or following this place will be moved. If pos is -1, the entry is appended.
labelthe text to be displayed on the entry, in UTF-8 encoding, or nullptr for a separator.
flagsa combination of flags, some of which are mandatory.
Returns
the newly created entry, or nullptr if pos is out of bounds.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayEntryFlags
TrayMenu.GetEntries
TrayEntry.Remove
TrayEntry.GetParent

◆ InsertTrayEntryAt()

TrayEntry SDL::InsertTrayEntryAt ( TrayMenu  menu,
int  pos,
StringParam  label,
TrayEntryFlags  flags 
)
inline

If label is nullptr, the entry will be a separator. Many functions won't work for an entry that is a separator.

An entry does not need to be destroyed; it will be destroyed with the tray.

Parameters
menuthe menu to append the entry to.
posthe desired position for the new entry. Entries at or following this place will be moved. If pos is -1, the entry is appended.
labelthe text to be displayed on the entry, in UTF-8 encoding, or nullptr for a separator.
flagsa combination of flags, some of which are mandatory.
Returns
the newly created entry, or nullptr if pos is out of bounds.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayEntryFlags
TrayMenu.GetEntries
TrayEntry.Remove
TrayEntry.GetParent

◆ Remove()

void SDL::TrayEntry::Remove ( )
inline
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry

◆ RemoveTrayEntry()

void SDL::RemoveTrayEntry ( TrayEntryRaw  entry)
inline
Parameters
entryThe entry to be deleted.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry

◆ SetCallback()

void SDL::TrayEntry::SetCallback ( TrayCallback  callback,
void *  userdata 
)
inline
Parameters
callbacka callback to be invoked when the entry is selected.
userdataan optional pointer to pass extra data to the callback when it will be invoked.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry

◆ SetChecked()

void SDL::TrayEntry::SetChecked ( bool  checked)
inline

The entry must have been created with the TRAYENTRY_CHECKBOX flag.

Parameters
checkedtrue if the entry should be checked; false otherwise.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.GetChecked

◆ SetEnabled()

void SDL::TrayEntry::SetEnabled ( bool  enabled)
inline
Parameters
enabledtrue if the entry should be enabled; false otherwise.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.GetEnabled

◆ SetIcon()

void SDL::Tray::SetIcon ( SurfaceParam  icon)
inline
Parameters
iconthe new icon. May be nullptr.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.Tray

◆ SetLabel()

void SDL::TrayEntry::SetLabel ( StringParam  label)
inline

An entry cannot change between a separator and an ordinary entry; that is, it is not possible to set a non-nullptr label on an entry that has a nullptr label (separators), or to set a nullptr label to an entry that has a non-nullptr label. The function will silently fail if that happens.

Parameters
labelthe new label for the entry in UTF-8 encoding.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.GetLabel

◆ SetTooltip()

void SDL::Tray::SetTooltip ( StringParam  tooltip)
inline
Parameters
tooltipthe new tooltip in UTF-8 encoding. May be nullptr.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.Tray

◆ SetTrayEntryCallback()

void SDL::SetTrayEntryCallback ( TrayEntryParam  entry,
TrayCallback  callback,
void *  userdata 
)
inline
Parameters
entrythe entry to be updated.
callbacka callback to be invoked when the entry is selected.
userdataan optional pointer to pass extra data to the callback when it will be invoked.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry

◆ SetTrayEntryChecked()

void SDL::SetTrayEntryChecked ( TrayEntryParam  entry,
bool  checked 
)
inline

The entry must have been created with the TRAYENTRY_CHECKBOX flag.

Parameters
entrythe entry to be updated.
checkedtrue if the entry should be checked; false otherwise.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.GetChecked

◆ SetTrayEntryEnabled()

void SDL::SetTrayEntryEnabled ( TrayEntryParam  entry,
bool  enabled 
)
inline
Parameters
entrythe entry to be updated.
enabledtrue if the entry should be enabled; false otherwise.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.GetEnabled

◆ SetTrayEntryLabel()

void SDL::SetTrayEntryLabel ( TrayEntryParam  entry,
StringParam  label 
)
inline

An entry cannot change between a separator and an ordinary entry; that is, it is not possible to set a non-nullptr label on an entry that has a nullptr label (separators), or to set a nullptr label to an entry that has a non-nullptr label. The function will silently fail if that happens.

Parameters
entrythe entry to be updated.
labelthe new label for the entry in UTF-8 encoding.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
TrayMenu.GetEntries
TrayMenu.InsertEntry
TrayEntry.GetLabel

◆ SetTrayIcon()

void SDL::SetTrayIcon ( TrayParam  tray,
SurfaceParam  icon 
)
inline
Parameters
traythe tray icon to be updated.
iconthe new icon. May be nullptr.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.Tray

◆ SetTrayTooltip()

void SDL::SetTrayTooltip ( TrayParam  tray,
StringParam  tooltip 
)
inline
Parameters
traythe tray icon to be updated.
tooltipthe new tooltip in UTF-8 encoding. May be nullptr.
Thread safety:
This function should be called on the thread that created the tray.
Since
This function is available since SDL 3.2.0.
See also
Tray.Tray

◆ UpdateTrays()

void SDL::UpdateTrays ( )
inline

This is called automatically by the event loop and is only needed if you're using trays but aren't handling SDL events.

Thread safety:
This function should only be called on the main thread.
Since
This function is available since SDL 3.2.0.

Variable Documentation

◆ TRAYENTRY_BUTTON

constexpr TrayEntryFlags SDL::TRAYENTRY_BUTTON
constexpr
Initial value:
=
SDL_TRAYENTRY_BUTTON

◆ TRAYENTRY_CHECKBOX

constexpr TrayEntryFlags SDL::TRAYENTRY_CHECKBOX
constexpr
Initial value:
=
SDL_TRAYENTRY_CHECKBOX

◆ TRAYENTRY_DISABLED

constexpr TrayEntryFlags SDL::TRAYENTRY_DISABLED
constexpr
Initial value:
=
SDL_TRAYENTRY_DISABLED

◆ TRAYENTRY_SUBMENU

constexpr TrayEntryFlags SDL::TRAYENTRY_SUBMENU
constexpr
Initial value:
=
SDL_TRAYENTRY_SUBMENU