Cursor Manager - Horizon-NTH/HorizonGUI GitHub Wiki
CursorManager
Overview
The CursorManager
class, located in the hgui
namespace, provides a flexible
way to manage Cursors
in your graphical application.
The class can be found inside the header file CursorManager.h
.
Member Functions
-
std::shared_ptr<kernel::Cursor> create(std::shared_ptr<kernel::Image>& cursor, const point& clickPosition)
: Creates a new cursor with a custom image and a specified click position. -
std::shared_ptr<kernel::Cursor> create(cursors cursor)
: Creates a new cursor using one of the predefined cursor types. -
void hide()
: Hides the cursor from view. -
void reveal()
: Reveals the hidden cursor. -
void disable()
: Disable the cursor. -
void enable()
: Enable the cursor. -
void use(const std::shared_ptr<kernel::Cursor>& cursor)
: Use the specified cursor. -
std::shared_ptr<kernel::Cursor> get_cursor_used()
: Retrieve the cursor currently used.
Example Usage
#include <hgui/header/CursorManager.h>
{ // Example Usage of CursorManager
std::shared_ptr<hgui::kernel::Image> customCursor = /* initialize custom cursor image */;
hgui::point clickPosition(10, 10);
// Create a custom cursor
std::shared_ptr<hgui::kernel::Cursor> customCursor = hgui::CursorManager::create(customCursor, clickPosition);
hgui::CursorManager::use(customCursor);
} // Here the custom cursor is destroyed
{ // Create a predefined cursor
std::shared_ptr<hgui::kernel::Cursor> predefinedCursor = hgui::CursorManager::create(cursors::HAND);
hgui::CursorManager::hide();
// (Change cursor behavior here)
hgui::CursorManager::reveal();
} // Here the predefined cursor is destroyed
Note: In the "Example Usage" section, we demonstrate how to create custom and predefined cursors with the
CursorManager
class in DYNAMIC mode.