void KnobGuiButton::createWidget(QHBoxLayout* layout) { KnobGuiPtr knobUI = getKnobGui(); KnobButtonPtr knob = _knob.lock(); _button = new Button( layout->parentWidget() ); if (knobUI->getLayoutType() == KnobGui::eKnobLayoutTypeTableItemWidget) { _button->setIconSize( QSize(TO_DPIX(NATRON_SMALL_BUTTON_ICON_SIZE), TO_DPIY(NATRON_SMALL_BUTTON_ICON_SIZE)) ); } else { _button->setIconSize( QSize(TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE), TO_DPIY(NATRON_MEDIUM_BUTTON_ICON_SIZE)) ); } loadPixmaps(false, QColor()); if (!_button->icon().isNull()) { _button->setFixedSize(TO_DPIX(NATRON_MEDIUM_BUTTON_SIZE), TO_DPIY(NATRON_MEDIUM_BUTTON_SIZE)); } bool checkable = knob->getIsCheckable(); if (checkable) { _button->setCheckable(true); bool checked = knob->getValue(); _button->setChecked(checked); _button->setDown(checked); } QObject::connect( _button, SIGNAL(clicked(bool)), this, SLOT(emitValueChanged(bool)) ); if ( knobUI->hasToolTip() ) { knobUI->toolTip(_button, getView()); } layout->addWidget(_button); } // KnobGuiButton::createWidget
void KnobGuiButton::updateGUI() { KnobButtonPtr k = _knob.lock(); if ( k && k->getIsCheckable() ) { bool checked = k->getValue(); if (_button->isChecked() == checked) { return; } _button->setDown(checked); _button->setChecked(checked); } }
void KnobGuiButton::emitValueChanged(bool clicked) { KnobButtonPtr k = _knob.lock(); assert(k); if ( k->getIsCheckable() ) { _button->setDown(clicked); _button->setChecked(clicked); KnobButtonPtr knob = _knob.lock(); getKnobGui()->pushUndoCommand( new KnobUndoCommand<bool>(knob, knob->getValue(DimIdx(0), getView()), clicked, DimIdx(0), getView()) ); } else { k->trigger(); } }