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

Method OfxStringInstance

Engine/OfxParamInstance.cpp:3782–3862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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