MCPcopy Create free account
hub / github.com/MrKepzie/Natron / OfxStringInstance

Method OfxStringInstance

Engine/OfxParamInstance.cpp:3786–3866  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3784};
3785
3786OfxStringInstance::OfxStringInstance(const boost::shared_ptr<OfxEffectInstance>& node,
3787 OFX::Host::Param::Descriptor & descriptor)
3788 : OfxParamToKnob(node)
3789 , OFX::Host::Param::StringInstance( descriptor, node->effectInstance() )
3790 , _imp( new OfxStringInstancePrivate() )
3791{
3792 const OFX::Host::Property::Set &properties = getProperties();
3793 std::string mode = properties.getStringProperty(kOfxParamPropStringMode);
3794 bool richText = mode == kOfxParamStringIsRichTextFormat;
3795
3796 if (mode == kOfxParamStringIsFilePath) {
3797 int fileIsImage = ( ( node->isReader() ||
3798 node->isWriter() ) &&
3799 (getScriptName() == kOfxImageEffectFileParamName ||
3800 getScriptName() == kOfxImageEffectProxyParamName) );
3801 int fileIsOutput = !properties.getIntProperty(kOfxParamPropStringFilePathExists);
3802 int filePathSupportsImageSequences = getCanAnimate();
3803
3804
3805 if (!fileIsOutput) {
3806 _imp->fileKnob = checkIfKnobExistsWithNameOrCreate<KnobFile>(descriptor.getName(), this, 1);
3807 if (fileIsImage) {
3808 _imp->fileKnob.lock()->setAsInputImage();
3809 }
3810 if (!filePathSupportsImageSequences) {
3811 _imp->fileKnob.lock()->setAnimationEnabled(false);
3812 }
3813 } else {
3814 _imp->outputFileKnob = checkIfKnobExistsWithNameOrCreate<KnobOutputFile>(descriptor.getName(), this, 1);
3815 if (fileIsImage) {
3816 _imp->outputFileKnob.lock()->setAsOutputImageFile();
3817 } else {
3818 _imp->outputFileKnob.lock()->turnOffSequences();
3819 }
3820 if (!filePathSupportsImageSequences) {
3821 _imp->outputFileKnob.lock()->setAnimationEnabled(false);
3822 }
3823 }
3824 } else if (mode == kOfxParamStringIsDirectoryPath) {
3825 _imp->pathKnob = checkIfKnobExistsWithNameOrCreate<KnobPath>(descriptor.getName(), this, 1);
3826 _imp->pathKnob.lock()->setMultiPath(false);
3827 } else if ( (mode == kOfxParamStringIsSingleLine) || (mode == kOfxParamStringIsLabel) || (mode == kOfxParamStringIsMultiLine) || richText ) {
3828 _imp->stringKnob = checkIfKnobExistsWithNameOrCreate<KnobString>(descriptor.getName(), this, 1);
3829 if (mode == kOfxParamStringIsLabel) {
3830 _imp->stringKnob.lock()->setAllDimensionsEnabled(false);
3831 _imp->stringKnob.lock()->setAsLabel();
3832 }
3833 if ( (mode == kOfxParamStringIsMultiLine) || richText ) {
3834 ///only QTextArea support rich text anyway
3835 _imp->stringKnob.lock()->setUsesRichText(richText);
3836 _imp->stringKnob.lock()->setAsMultiLine();
3837 }
3838 }
3839 std::string defaultVal = properties.getStringProperty(kOfxParamPropDefault);
3840 if ( !defaultVal.empty() ) {
3841 if ( _imp->fileKnob.lock() ) {
3842 projectEnvVar_setProxy(defaultVal);
3843 boost::shared_ptr<KnobFile> k = _imp->fileKnob.lock();

Callers

nothing calls this directly

Calls 15

effectInstanceMethod · 0.80
getNameMethod · 0.80
setAsOutputImageFileMethod · 0.80
turnOffSequencesMethod · 0.80
setMultiPathMethod · 0.80
setAsLabelMethod · 0.80
setUsesRichTextMethod · 0.80
setAsMultiLineMethod · 0.80
emptyMethod · 0.80
blockValueChangesMethod · 0.80
unblockValueChangesMethod · 0.80

Tested by

no test coverage detected