class ffw::GuiButton

Class List > ffw :: GuiButton

Create a basic button with a label. More...

Inherits the following classes: ffw::GuiWidget

Inherited by the following classes: ffw::GuiButtonPrimary, ffw::GuiButtonToggle, ffw::GuiScrollBar::ButtonBottom, ffw::GuiScrollBar::ButtonLeft, ffw::GuiScrollBar::ButtonRight, ffw::GuiScrollBar::ButtonTop

Classes

Type Name
struct Style

Public Functions

Type Name
GuiButton (GuiWindow * context, const std::string & label)
virtual ~GuiButton () = default
void setLabel (const std::string & label)
const std::string & getLabel () const
virtual ffw::Pointf getMinimumWrapSize () override
void setStyle (const GuiButton::Style * style, bool defaults = false)

Detailed Description

Creates a basic button with a label. A click callback can be added, see example below.

// Example creating a button
auto gui = ffw::GuiWindowNanoVG(nvg);
auto root = gui.getLayout();

auto button = new ffw::GuiButton(&gui, "Button");
button->setLabel("Button #1"); // Overwrites "Button"
button->setSize(ffw::guiPercent(100.0f), ffw::guiPixels(25.0f));
button->addEventCallback([](ffw::GuiEvent e) {
    std::cout << "Clicked!" << std::endl;
}, ffw::GuiEventType::ACTION);

root->addWidget(button);
// Do not free the created widgets! They will be deleted by window itself!

while(true){
    // Render the gui
}

Public Functions Documentation

function GuiButton

ffw::GuiButton::GuiButton (
    GuiWindow * context,
    const std::string & label
)

function ~GuiButton

virtual ffw::GuiButton::~GuiButton () = default

function setLabel

void ffw::GuiButton::setLabel (
    const std::string & label
)

function getLabel

const std::string & ffw::GuiButton::getLabel () const

function getMinimumWrapSize

virtual ffw::Pointf ffw::GuiButton::getMinimumWrapSize ()

Implements GuiWidget::getMinimumWrapSize

function setStyle

void ffw::GuiButton::setStyle (
    const GuiButton::Style * style,
    bool defaults = false
)

The documentation for this class was generated from the following file: include/ffw/gui/guibutton.h