class ffw::GuiButtonToggle

Class List > ffw :: GuiButtonToggle

Create a basic on/off toggle button with a label. More...

Inherits the following classes: ffw::GuiButton

Inherited by the following classes: ffw::GuiTabs::Button

Public Functions

Type Name
GuiButtonToggle (GuiWindow * context, const std::string & label)
virtual ~GuiButtonToggle () = default
void setValue (bool value)
bool getValue () const

Detailed Description

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

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

auto button = new ffw::GuiButtonToggle(&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! Status: " << e.data.action.value << std::endl;
}, ffw::GuiEventType::ACTION);
auto isPressed = button->getValue(); // Programatically get on/off state
button->setValue(true); // Programatically set on/off state

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 GuiButtonToggle

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

function ~GuiButtonToggle

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

function setValue

void ffw::GuiButtonToggle::setValue (
    bool value
)

function getValue

bool ffw::GuiButtonToggle::getValue () const

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