Button Manager - Horizon-NTH/HorizonGUI GitHub Wiki
The ButtonManager
class, located in the hgui
namespace, is a versatile tool for
managing Buttons
creation in your graphical application.
The class can be found inside the header file ButtonManager.h
.
-
std::shared_ptr<hgui::kernel::Button> create(const std::function<void()>& function, const size& size, const point& position, const std::shared_ptr<kernel::Texture>& texture = nullptr, const std::variant<std::tuple<color, color, color>, color>& color = HGUI_COLOR_WHITE, float borderRadius = 100.f, bool blurrOnHover = true, const std::string& text = "", const std::shared_ptr<kernel::Font>& font = nullptr, const hgui::color& textColor = HGUI_COLOR_BLACK)
: Creates a new button with the specified parameters.
Note: If you want to use the default look for the button, please set the texture as nullptr and if you want to add text you must give a font.
#include <hgui/header/ButtonManager.h>
{ // Example Usage of ButtonManager
std::function<void()> buttonFunction = /* initialize button action */;
hgui::size buttonSize(100, 40);
hgui::point buttonPosition(200, 200);
// Create a button
std::shared_ptr<hgui::kernel::Button> myButton = hgui::ButtonManager::create(buttonFunction, buttonSize, buttonPosition);
myButton->press();
// (Apply button effects here)
} // Here the destructor of myButton is called
Note: In the "Example Usage" section, we demonstrate how to create a button with the
ButtonManager
class.