Exemple #1
0
void
KnobGuiChoice::updateGUI(int /*dimension*/)
{
    ///we don't use setCurrentIndex because the signal emitted by combobox will call onCurrentIndexChanged and
    ///change the internal value of the knob again...
    ///The slot connected to onCurrentIndexChanged is reserved to catch user interaction with the combobox.
    ///This function is called in response to an internal change.
    KnobChoicePtr knob = _knob.lock();
    std::string activeEntry = knob->getActiveEntryText_mt_safe();

    if ( !activeEntry.empty() ) {
        bool activeIndexPresent = knob->isActiveEntryPresentInEntries();
        if (!activeIndexPresent) {
            QString error = tr("The value set to this parameter no longer exist in the menu. Right click and press Refresh Menu to update the menu and then pick a new value.");
            setWarningValue( KnobGui::eKnobWarningChoiceMenuOutOfDate, GuiUtils::convertFromPlainText(error, Qt::WhiteSpaceNormal) );
        } else {
            setWarningValue( KnobGui::eKnobWarningChoiceMenuOutOfDate, QString() );
        }
    }
    if ( _comboBox->isCascading() || activeEntry.empty() ) {
        _comboBox->setCurrentIndex_no_emit( knob->getValue() );
    } else {
        _comboBox->setCurrentText( QString::fromUtf8( activeEntry.c_str() ) );
    }
}
Exemple #2
0
void
OneViewNode::initializeKnobs()
{
    KnobPagePtr page = AppManager::createKnob<KnobPage>( shared_from_this(), tr("Controls") );

    page->setName("controls");

    KnobChoicePtr viewKnob = AppManager::createKnob<KnobChoice>( shared_from_this(), tr("View") );
    viewKnob->setName("view");
    viewKnob->setHintToolTip( tr("View to take from the input") );
    page->addKnob(viewKnob);

    const std::vector<std::string>& views = getApp()->getProject()->getProjectViewNames();
    std::string currentView = viewKnob->getActiveEntryText_mt_safe();
    viewKnob->populateChoices(views);


    _imp->viewKnob = viewKnob;
}
Exemple #3
0
void
KnobGuiChoice::onEntryAppended(const QString& entry,
                               const QString& help)
{
    KnobChoicePtr knob = _knob.lock();

    if ( knob->getHostCanAddOptions() &&
         ( ( knob->getName() == kNatronOfxParamOutputChannels) || ( knob->getName() == kOutputChannelsKnobName) ) ) {
        _comboBox->insertItem(_comboBox->count() - 1, entry, QIcon(), QKeySequence(), help);
    } else {
        _comboBox->addItem(entry, QIcon(), QKeySequence(), help);
    }
    int activeIndex = knob->getValue();
    if (activeIndex >= 0) {
        _comboBox->setCurrentIndex_no_emit(activeIndex);
    } else {
        _comboBox->setCurrentText( QString::fromUtf8( knob->getActiveEntryText_mt_safe().c_str() ) );
    }
}
Exemple #4
0
void
KnobGuiChoice::onEntriesPopulated()
{
    KnobChoicePtr knob = _knob.lock();

    _comboBox->clear();
    std::vector<std::string> entries = knob->getEntries_mt_safe();
    const std::vector<std::string> help =  knob->getEntriesHelp_mt_safe();
    std::string activeEntry = knob->getActiveEntryText_mt_safe();

    for (U32 i = 0; i < entries.size(); ++i) {
        std::string helpStr;
        if ( !help.empty() && !help[i].empty() ) {
            helpStr = help[i];
        }

        _comboBox->addItem( QString::fromUtf8( entries[i].c_str() ), QIcon(), QKeySequence(), QString::fromUtf8( helpStr.c_str() ) );
    }
    // the "New" menu is only added to known parameters (e.g. the choice of output channels)
    if ( knob->getHostCanAddOptions() &&
         ( ( knob->getName() == kNatronOfxParamOutputChannels) || ( knob->getName() == kOutputChannelsKnobName) ) ) {
        _comboBox->addItemNew();
    }
    ///we don't use setCurrentIndex because the signal emitted by combobox will call onCurrentIndexChanged and
    ///we don't want that to happen because the index actually didn't change.
    if ( _comboBox->isCascading() || activeEntry.empty() ) {
        _comboBox->setCurrentIndex_no_emit( knob->getValue() );
    } else {
        _comboBox->setCurrentText_no_emit( QString::fromUtf8( activeEntry.c_str() ) );
    }


    if ( !activeEntry.empty() ) {
        bool activeIndexPresent = knob->isActiveEntryPresentInEntries();
        if (!activeIndexPresent) {
            QString error = tr("The value set to this parameter no longer exist in the menu. Right click and press Refresh Menu to update the menu and then pick a new value.");
            setWarningValue( KnobGui::eKnobWarningChoiceMenuOutOfDate, GuiUtils::convertFromPlainText(error, Qt::WhiteSpaceNormal) );
        } else {
            setWarningValue( KnobGui::eKnobWarningChoiceMenuOutOfDate, QString() );
        }
    }
}
Exemple #5
0
void
OneViewNode::onProjectViewsChanged()
{
    const std::vector<std::string>& views = getApp()->getProject()->getProjectViewNames();
    KnobChoicePtr viewKnob = _imp->viewKnob.lock();
    std::string currentView = viewKnob->getActiveEntryText_mt_safe();

    viewKnob->populateChoices(views);

    bool foundView = false;
    for (std::size_t i = 0; i < views.size(); ++i) {
        if (views[i] == currentView) {
            foundView = true;
            viewKnob->setValue(i);
            break;
        }
    }
    if (!foundView) {
        viewKnob->setValue(0);
    }
}