Example #1
0
void ofxUIDropDownList::loadState(ofxXmlSettings *XML)
{
    selected.clear();
    selectedIndeces.clear();
    singleSelected = nullptr;
    
    int value = XML->getValue("Open", (isOpen() ? 1 : 0), 0);
    if(value) { open(); } else { close(); }
    XML->pushTag("Selected", 0);
    int widgetTags = XML->getNumTags("Name");
    for(int i = 0; i < widgetTags; ++i) {
        string selName = XML->getValue("Name", "NULL", i);
        if(selName != "NULL"){
            if(allowMultiple) {
                for(unsigned int i = 0; i < toggles.size(); i++) {
                    ofxUILabelToggle *t = toggles[i];
                    if(t->getName() == selName) {
                        t->setValue(true);
                        selected.push_back(t);
                        selectedIndeces.push_back(i);
                    }
                }
            } else {
                activateToggle(selName);
            }
        }
    }
    XML->popTag();
}
Example #2
0
void ofxUIRadio::addToggle(ofxUIToggle *toggle)
{
    toggle->setParent(this);
    toggles.push_back(toggle);
    if(toggle->getValue())
    {
        activateToggle(toggle->getName());
    }
}
void ofxUIToggleMatrix::triggerEvent(ofxUIWidget *child)
{
    if(!allowMultiple)
    {
        activateToggle(child->getName().c_str());
    }
    if(parent != NULL)
    {
        parent->triggerEvent(child);
    }
}
Example #4
0
void ofxUIDropDownList::triggerEvent(ofxUIWidget *child)
{
    if(child == this)
    {
        parent->triggerEvent(child);
        return;
    }
    
    if(autoClose)
    {
        if(isOpen())
        {
            close();
        }
    }
    
    if(!allowMultiple)
    {
        activateToggle(child->getName().c_str());
    }
    
    selected.clear();
    selectedIndeces.clear();
    for(unsigned int i = 0; i < toggles.size(); i++)
    {
        ofxUILabelToggle *t = toggles[i];
        if(t->getValue())
        {
            selected.push_back(t);
            selectedIndeces.push_back(i);
        }
    }
    
    checkAndSetTitleLabel();
    
    if(parent != NULL)
    {
        parent->triggerEvent(this);
        parent->triggerEvent(child);
    }
}