class ffw::GuiSwitch

Class List > ffw :: GuiSwitch

Create a switch widget. More...

Inherits the following classes: ffw::GuiWidget

Classes

Type Name
struct Style

Protected Attributes

Type Name
const GuiWidget::Style * styleButton

Public Functions

Type Name
GuiSwitch (GuiWindow * context)
virtual ~GuiSwitch () = default
void setValue (bool value)
bool getValue () const
virtual ffw::Pointf getMinimumWrapSize () override
void setStyle (const GuiSwitch::Style * style, bool defaults = false)

Detailed Description

This widget acts exactly as the ffw::GuiButtonToggle

auto gui = ffw::GuiWindowNanoVG(nvg);
auto root = gui.getLayout();

auto button = new ffw::GuiSwitch(&gui);
button->setSize(ffw::guiPixels(50.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 the gui window!

while(true){
    // Render the gui
}

Protected Attributes Documentation

variable styleButton

const GuiWidget::Style* ffw::GuiSwitch::styleButton;

Public Functions Documentation

function GuiSwitch

ffw::GuiSwitch::GuiSwitch (
    GuiWindow * context
)

function ~GuiSwitch

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

function setValue

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

function getValue

bool ffw::GuiSwitch::getValue () const

function getMinimumWrapSize

virtual ffw::Pointf ffw::GuiSwitch::getMinimumWrapSize ()

Implements GuiWidget::getMinimumWrapSize

function setStyle

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

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