void KnobGuiColor::setPickingEnabledInternal(bool enabled) { KnobColorPtr knob = _knob.lock(); if ( knob->getHolder()->getApp() ) { if (enabled) { getKnobGui()->getGui()->registerNewColorPicker( knob, getView() ); } else { getKnobGui()->getGui()->removeColorPicker( knob, getView() ); } } }
void KnobGuiColor::addExtraWidgets(QHBoxLayout* containerLayout) { containerLayout->addSpacing( TO_DPIX(10) ); KnobColorPtr knob = _knob.lock(); if (!knob) { return; } KnobGuiPtr knobUI = getKnobGui(); if (!knobUI) { return; } _colorLabel = new ColorPickerLabel( _useSimplifiedUI, knobUI->getLayoutType(), this, containerLayout->widget() ); if (!_useSimplifiedUI && knobUI->getLayoutType() != KnobGui::eKnobLayoutTypeTableItemWidget) { _colorLabel->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("To pick a color on a viewer, click this and then press control + left click on any viewer.\n" "You can also pick the average color of a given rectangle by holding control + shift + left click\n. " "To deselect the picker left click anywhere." "Note that by default %1 converts to linear the color picked\n" "because all the processing pipeline is linear, but you can turn this off in the\n" "preferences panel.").arg( QString::fromUtf8(NATRON_APPLICATION_NAME) ), NATRON_NAMESPACE::WhiteSpaceNormal) ); } QSize medSize( TO_DPIX(NATRON_MEDIUM_BUTTON_SIZE), TO_DPIY(NATRON_MEDIUM_BUTTON_SIZE) ); QSize medIconSize( TO_DPIX(NATRON_MEDIUM_BUTTON_ICON_SIZE), TO_DPIY(NATRON_MEDIUM_BUTTON_ICON_SIZE) ); _colorLabel->setFixedSize(medSize); QObject::connect( _colorLabel, SIGNAL(pickingEnabled(bool)), this, SLOT(onColorLabelPickingEnabled(bool)) ); containerLayout->addWidget(_colorLabel); if (_useSimplifiedUI) { containerLayout->addSpacing( TO_DPIX(5) ); } if (knobUI->getLayoutType() != KnobGui::eKnobLayoutTypeTableItemWidget) { QPixmap buttonPix; appPTR->getIcon(NATRON_PIXMAP_COLORWHEEL, NATRON_MEDIUM_BUTTON_ICON_SIZE, &buttonPix); _colorDialogButton = new Button( QIcon(buttonPix), QString(), containerLayout->widget() ); _colorDialogButton->setFixedSize(medSize); _colorDialogButton->setIconSize(medIconSize); _colorDialogButton->setToolTip( NATRON_NAMESPACE::convertFromPlainText(tr("Open the color dialog."), NATRON_NAMESPACE::WhiteSpaceNormal) ); _colorDialogButton->setFocusPolicy(Qt::NoFocus); QObject::connect( _colorDialogButton, SIGNAL(clicked()), this, SLOT(showColorDialog()) ); containerLayout->addWidget(_colorDialogButton); } if (_useSimplifiedUI) { setWidgetsVisibleInternal(false); KnobGuiWidgets::enableRightClickMenu(getKnobGui(), _colorLabel, DimSpec::all(), getView()); } }
void KnobGuiFile::createWidget(QHBoxLayout* layout) { KnobGuiPtr knobUI = getKnobGui(); if (!knobUI) { return; } Gui* gui = knobUI->getGui(); if (!gui) { return; } GuiAppInstancePtr app = gui->getApp(); if (!app) { return; } KnobFilePtr knob = _knob.lock(); if (!knob) { return; } EffectInstancePtr holderIsEffect = toEffectInstance( knob->getHolder() ); if ( holderIsEffect && holderIsEffect->isReader() && (knob->getName() == kOfxImageEffectFileParamName) ) { TimeLinePtr timeline = app->getTimeLine(); QObject::connect( timeline.get(), SIGNAL(frameChanged(SequenceTime,int)), this, SLOT(onTimelineFrameChanged(SequenceTime,int)) ); }
void KnobGuiColor::onDialogCurrentColorChanged(const QColor & color) { KnobColorPtr knob = _knob.lock(); if (!knob) { return; } int nDims = knob->getNDimensions(); std::vector<double> values(nDims); values[0] = color.redF(); convertFromUIToInternalColorspace(&values[0]); if (nDims > 1) { values[1] = color.greenF(); convertFromUIToInternalColorspace(&values[1]); } if (nDims > 2) { values[2] = color.blueF(); convertFromUIToInternalColorspace(&values[2]); } if (nDims > 3) { values[3] = color.alphaF(); } KnobGuiPtr knobUI = getKnobGui(); knob->setValueAcrossDimensions(values, DimIdx(0), getView(), eValueChangedReasonUserEdited); if ( knobUI->getGui() ) { knobUI->getGui()->setDraftRenderEnabled(true); } }
void KnobGuiColor::onDialogCurrentColorChanged(const QColor & color) { KnobColorPtr knob = _knob.lock(); bool isSimple = _useSimplifiedUI; int nDims = knob->getNDimensions(); std::vector<double> values(nDims); values[0] = isSimple ? color.redF() : Color::from_func_srgb( color.redF() ); if (nDims >= 3) { values[1] = isSimple ? color.greenF() : Color::from_func_srgb( color.greenF() ); values[2] = isSimple ? color.blueF() : Color::from_func_srgb( color.blueF() ); if (nDims == 4) { values[3] = color.alphaF(); } } KnobGuiPtr knobUI = getKnobGui(); knob->setValueAcrossDimensions(values, DimIdx(0), getView(), eValueChangedReasonUserEdited); if ( knobUI->getGui() ) { knobUI->getGui()->setDraftRenderEnabled(true); } }
void KnobGuiColor::onColorLabelPickingEnabled(bool enabled) { KnobColorPtr knob = _knob.lock(); KnobGuiPtr knobUI = getKnobGui(); if ( knob->getHolder()->getApp() ) { if (enabled) { knobUI->getGui()->registerNewColorPicker( _knob.lock(), getView() ); } else { knobUI->getGui()->removeColorPicker( _knob.lock(), getView()); } } }
void KnobGuiGroup::createWidget(QHBoxLayout* layout) { _button = new GroupBoxLabel( layout->parentWidget() ); KnobGuiPtr knobUI = getKnobGui(); if ( knobUI->hasToolTip() ) { knobUI->toolTip(_button, getView()); } _checked = _knob.lock()->getValue(DimIdx(0), getView()); _button->setFixedSize(NATRON_MEDIUM_BUTTON_SIZE, NATRON_MEDIUM_BUTTON_SIZE); _button->setChecked(_checked); QObject::connect( _button, SIGNAL(checked(bool)), this, SLOT(onCheckboxChecked(bool)) ); layout->addWidget(_button); }
std::string KnobGuiWidgets::getDescriptionLabel() const { std::string ret; KnobGuiPtr knob = getKnobGui(); if (!knob) { return ret; } KnobIPtr internalKnob = knob->getKnob(); if (!internalKnob) { return ret; } ret = internalKnob->getLabel(); return ret; }
bool KnobGuiGroup::isChecked() const { return getKnobGui()->hasWidgetBeenCreated() ? _button->isChecked() : true; }
void KnobGuiColor::showColorDialog() { QColorDialog dialog( _colorLabel->parentWidget() ); dialog.setOption(QColorDialog::DontUseNativeDialog); KnobColorPtr knob = _knob.lock(); if (!knob) { return; } const int nDims = knob->getNDimensions(); ViewIdx view = getView(); double curR = knob->getValue(DimIdx(0), view, false /*clampToMinmax*/); _lastColor.resize(nDims); _lastColor[0] = curR; double curG = curR; double curB = curR; double curA = 1.; if (nDims > 1) { curG = knob->getValue(DimIdx(1), view, false /*clampToMinmax*/); _lastColor[1] = curG; curB = knob->getValue(DimIdx(2), view, false /*clampToMinmax*/); _lastColor[2] = curB; } if (nDims > 3) { dialog.setOption(QColorDialog::ShowAlphaChannel); curA = knob->getValue(DimIdx(3), view, false /*clampToMinmax*/); _lastColor[3] = curA; } convertFromInternalToUIColorspace(&curR, &curG, &curB); QColor curColor; curColor.setRgbF( Image::clamp<qreal>(curR, 0., 1.), Image::clamp<qreal>(curG, 0., 1.), Image::clamp<qreal>(curB, 0., 1.), Image::clamp<qreal>(curA, 0., 1.) ); dialog.setCurrentColor(curColor); QObject::connect( &dialog, SIGNAL(currentColorChanged(QColor)), this, SLOT(onDialogCurrentColorChanged(QColor)) ); if ( !dialog.exec() ) { knob->setValueAcrossDimensions(_lastColor, DimIdx(0), view, eValueChangedReasonUserEdited); } else { QColor userColor = dialog.currentColor(); std::vector<double> color(nDims); color[0] = userColor.redF(); convertFromUIToInternalColorspace(&color[0]); if (nDims > 1) { color[1] = userColor.greenF(); convertFromUIToInternalColorspace(&color[1]); } if (nDims > 2) { color[2] = userColor.blueF(); convertFromUIToInternalColorspace(&color[2]); } if (nDims > 3) { color[3] = userColor.alphaF(); } for (int i = 0; i < 3; ++i) { SpinBox* sb = 0; getSpinBox(DimIdx(i), &sb); if (sb) { sb->setValue(color[i]); } } std::vector<double> oldColor(nDims); for (int i = 0; i < nDims; ++i) { oldColor[i] = _lastColor[i]; } KnobGuiPtr knobUI = getKnobGui(); knobUI->pushUndoCommand( new KnobUndoCommand<double>(knob, oldColor, color, getView()) ); } KnobGuiPtr knobUI = getKnobGui(); if ( knobUI->getGui() ) { knobUI->getGui()->setDraftRenderEnabled(false); } } // showColorDialog