fluent-tray
Fluent Design-based GUI Library for System Tray Applications
Loading...
Searching...
No Matches
Public Member Functions | List of all members
fluent_tray::FluentTray Class Reference

Class with information on the entire tray. More...

#include <fluent_tray.hpp>

Public Member Functions

 FluentTray (LONG menu_x_margin=5, LONG menu_y_margin=5, LONG menu_x_pad=10, LONG menu_y_pad=5, unsigned char autofadedborder_from_backcolor=10, int autocolorpick_offset=5, int message_id_offset=25)
 Create tray object.
 
 FluentTray (const FluentTray &)=delete
 
FluentTrayoperator= (const FluentTray &)=delete
 
 FluentTray (FluentTray &&)=default
 
FluentTrayoperator= (FluentTray &&)=default
 
virtual ~FluentTray () noexcept
 
bool create_tray (const std::string &app_name, const std::string &icon_path="", unsigned char opacity=255, bool round_corner=true)
 Initialize tray and create icon on tray.
 
bool add_menu (const std::string &label_text="", const std::string &icon_path="", bool toggleable=false, const std::string &checkmark="✓", const std::function< bool(void)> &callback=[] {return true ;}, const std::function< bool(void)> &unchecked_callback=[] {return true ;})
 Add a menu in order from the top.
 
void add_separator ()
 Add a separator line under the last menu item added.
 
bool update ()
 Get window message and update tray.
 
bool update_with_loop (std::chrono::milliseconds sleep_time=std::chrono::milliseconds(1))
 Create a message loop to update the tray.
 
HWND window_handle () const noexcept
 Refer to the handle of menu window.
 
bool show_menu_window ()
 Show the menu window above the tray icon.
 
bool hide_menu_window ()
 Hide the menu window above the tray icon.
 
bool show_balloon_tip (const std::string &title, const std::string &message)
 Shows a balloon tip that is placed in the notification area.
 
TrayStatus status () const noexcept
 Get the current status of tray.
 
void stop () noexcept
 Exit the tray successfully.
 
std::vector< FluentMenu >::iterator begin () noexcept
 Returns an iterator to the beginning of menus.
 
std::vector< FluentMenu >::iterator end () noexcept
 Returns an iterator to the end of menus.
 
std::vector< FluentMenu >::const_iterator cbegin () const noexcept
 Returns a constant iterator to the beginning of menus.
 
std::vector< FluentMenu >::const_iterator cend () const noexcept
 Returns a constant iterator to the end of menus.
 
FluentMenufront ()
 Returns the reference to the beginning of menus.
 
const FluentMenufront () const
 Returns the const reference to the beginning of menus.
 
FluentMenuback ()
 Returns the reference to the last of menus.
 
const FluentMenuback () const
 Returns the const reference to the last of menus.
 
std::size_t count_menus () const noexcept
 Returns the number of menus.
 
bool set_font (LONG font_size=0, LONG font_weight=0, const std::string &font_name="")
 Set font information to draw menus.
 
bool set_color (COLORREF text_color=CLR_INVALID, COLORREF back_color=CLR_INVALID, COLORREF border_color=CLR_INVALID)
 Set colors to draw menus.
 
bool change_icon (const std::string &icon_path)
 Load the image file and change the icon.
 

Detailed Description

Class with information on the entire tray.

Constructor & Destructor Documentation

◆ FluentTray() [1/3]

fluent_tray::FluentTray::FluentTray ( LONG menu_x_margin = 5,
LONG menu_y_margin = 5,
LONG menu_x_pad = 10,
LONG menu_y_pad = 5,
unsigned char autofadedborder_from_backcolor = 10,
int autocolorpick_offset = 5,
int message_id_offset = 25 )
inlineexplicit

Create tray object.

Parameters
[in]menu_x_marginHorizontal margins outside menus.
[in]menu_y_marginVertical margins outside menus.
[in]menu_x_padHorizontal paddings inside menus.
[in]menu_y_padVertical paddings inside menus.
[in]autofadedborder_from_backcolorDecay value from the background color to determine the background color of the currently selected menu and the color of the separator line.
[in]autocolorpick_offsetPixel offset to determine the background color.
[in]message_id_offsetUnique message identifier.

◆ FluentTray() [2/3]

fluent_tray::FluentTray::FluentTray ( const FluentTray & )
delete

◆ FluentTray() [3/3]

fluent_tray::FluentTray::FluentTray ( FluentTray && )
default

◆ ~FluentTray()

virtual fluent_tray::FluentTray::~FluentTray ( )
inlinevirtualnoexcept

Member Function Documentation

◆ add_menu()

bool fluent_tray::FluentTray::add_menu ( const std::string & label_text = "",
const std::string & icon_path = "",
bool toggleable = false,
const std::string & checkmark = "✓",
const std::function< bool(void)> & callback = [] {return true ;},
const std::function< bool(void)> & unchecked_callback = [] {return true ;} )
inline

Add a menu in order from the top.

Parameters
[in]label_textThe UTF-8 encoded string of the button label.
[in]icon_pathAn icon path to show next to the label.
[in]toggleableCreate a switchable menu
[in]checkmarkA checkmark string.
[in]callbackFunction called when a click on the menu or a check is enabled.
[in]unchecked_callbackFunction called when a check is disabled.
Returns
Returns true on success, false on failure.

◆ add_separator()

void fluent_tray::FluentTray::add_separator ( )
inline

Add a separator line under the last menu item added.

◆ back() [1/2]

FluentMenu & fluent_tray::FluentTray::back ( )
inline

Returns the reference to the last of menus.

Returns
Reference to the first element.

◆ back() [2/2]

const FluentMenu & fluent_tray::FluentTray::back ( ) const
inline

Returns the const reference to the last of menus.

Returns
Const reference to the first element.

◆ begin()

std::vector< FluentMenu >::iterator fluent_tray::FluentTray::begin ( )
inlinenoexcept

Returns an iterator to the beginning of menus.

Returns
Iterator to the first element.

◆ cbegin()

std::vector< FluentMenu >::const_iterator fluent_tray::FluentTray::cbegin ( ) const
inlinenoexcept

Returns a constant iterator to the beginning of menus.

Returns
Constant iterator to the first element.

◆ cend()

std::vector< FluentMenu >::const_iterator fluent_tray::FluentTray::cend ( ) const
inlinenoexcept

Returns a constant iterator to the end of menus.

Returns
Constant iterator to the last element.

◆ change_icon()

bool fluent_tray::FluentTray::change_icon ( const std::string & icon_path)
inline

Load the image file and change the icon.

Returns
Returns true on success, false on failure.

◆ count_menus()

std::size_t fluent_tray::FluentTray::count_menus ( ) const
inlinenoexcept

Returns the number of menus.

Returns
The number of menus.

◆ create_tray()

bool fluent_tray::FluentTray::create_tray ( const std::string & app_name,
const std::string & icon_path = "",
unsigned char opacity = 255,
bool round_corner = true )
inline

Initialize tray and create icon on tray.

Parameters
[in]app_nameThe application name to be displayed as tooltip text.
[in]icon_pathA UTF-8 encoded path to the icon to be displayed in the system tray.
[in]opacityMenu opacity from 0 to 255.
[in]round_cornerOption to round the corners of the menu window (Windows 11 only)
Returns
Returns true on success, false on failure.

◆ end()

std::vector< FluentMenu >::iterator fluent_tray::FluentTray::end ( )
inlinenoexcept

Returns an iterator to the end of menus.

Returns
Iterator to the last element.

◆ front() [1/2]

FluentMenu & fluent_tray::FluentTray::front ( )
inline

Returns the reference to the beginning of menus.

Returns
Reference to the first element.

◆ front() [2/2]

const FluentMenu & fluent_tray::FluentTray::front ( ) const
inline

Returns the const reference to the beginning of menus.

Returns
Const reference to the first element.

◆ hide_menu_window()

bool fluent_tray::FluentTray::hide_menu_window ( )
inline

Hide the menu window above the tray icon.

Returns
Returns true on success, false on failure.

◆ operator=() [1/2]

FluentTray & fluent_tray::FluentTray::operator= ( const FluentTray & )
delete

◆ operator=() [2/2]

FluentTray & fluent_tray::FluentTray::operator= ( FluentTray && )
default

◆ set_color()

bool fluent_tray::FluentTray::set_color ( COLORREF text_color = CLR_INVALID,
COLORREF back_color = CLR_INVALID,
COLORREF border_color = CLR_INVALID )
inline

Set colors to draw menus.

Parameters
[in]text_colorThe color for label text.
[in]back_colorThe color for background.
[in]border_colorThe color for border.
Returns
Returns true on success, false on failure.

◆ set_font()

bool fluent_tray::FluentTray::set_font ( LONG font_size = 0,
LONG font_weight = 0,
const std::string & font_name = "" )
inline

Set font information to draw menus.

Parameters
[in]font_sizeThe height of fonts.
[in]font_weightThe value from 0 to 1000 to determine font weight.
[in]font_nameThe UTF-8 encoded font name for label rendering.
Returns
Returns true on success, false on failure.

For font_weight, you can use the constant value specified for lfWeght in LOGFONT. The default value used is FW_MEDIUM(500).

◆ show_balloon_tip()

bool fluent_tray::FluentTray::show_balloon_tip ( const std::string & title,
const std::string & message )
inline

Shows a balloon tip that is placed in the notification area.

Parameters
[in]titleThe UTF-8 string of title.
[in]messageThe UTF-8 string of message.
Returns
Returns true on success, false on failure.

Titles longer than 48 characters and messages longer than 200 characters will be trimmed.

◆ show_menu_window()

bool fluent_tray::FluentTray::show_menu_window ( )
inline

Show the menu window above the tray icon.

Returns
Returns true on success, false on failure.

◆ status()

TrayStatus fluent_tray::FluentTray::status ( ) const
inlinenoexcept

Get the current status of tray.

Returns
The status.

◆ stop()

void fluent_tray::FluentTray::stop ( )
inlinenoexcept

Exit the tray successfully.

◆ update()

bool fluent_tray::FluentTray::update ( )
inline

Get window message and update tray.

Returns
Returns true on success, false on failure.

◆ update_with_loop()

bool fluent_tray::FluentTray::update_with_loop ( std::chrono::milliseconds sleep_time = std::chrono::milliseconds(1))
inline

Create a message loop to update the tray.

Parameters
[in]sleep_time
Returns
Returns true on success, false on failure.

◆ window_handle()

HWND fluent_tray::FluentTray::window_handle ( ) const
inlinenoexcept

Refer to the handle of menu window.

Returns
The handle of window.

The documentation for this class was generated from the following file: