| 2143 | } |
| 2144 | |
| 2145 | void |
| 2146 | Node::findOrCreateChannelEnabled(const KnobPagePtr& mainPage) |
| 2147 | { |
| 2148 | //Try to find R,G,B,A parameters on the plug-in, if found, use them, otherwise create them |
| 2149 | static const std::string channelLabels[4] = {kNatronOfxParamProcessRLabel, kNatronOfxParamProcessGLabel, kNatronOfxParamProcessBLabel, kNatronOfxParamProcessALabel}; |
| 2150 | static const std::string channelNames[4] = {kNatronOfxParamProcessR, kNatronOfxParamProcessG, kNatronOfxParamProcessB, kNatronOfxParamProcessA}; |
| 2151 | static const std::string channelHints[4] = {kNatronOfxParamProcessRHint, kNatronOfxParamProcessGHint, kNatronOfxParamProcessBHint, kNatronOfxParamProcessAHint}; |
| 2152 | KnobBoolPtr foundEnabled[4]; |
| 2153 | const KnobsVec & knobs = _imp->effect->getKnobs(); |
| 2154 | |
| 2155 | for (int i = 0; i < 4; ++i) { |
| 2156 | KnobBoolPtr enabled; |
| 2157 | for (std::size_t j = 0; j < knobs.size(); ++j) { |
| 2158 | if (knobs[j]->getOriginalName() == channelNames[i]) { |
| 2159 | foundEnabled[i] = std::dynamic_pointer_cast<KnobBool>(knobs[j]); |
| 2160 | break; |
| 2161 | } |
| 2162 | } |
| 2163 | } |
| 2164 | |
| 2165 | bool foundAll = foundEnabled[0] && foundEnabled[1] && foundEnabled[2] && foundEnabled[3]; |
| 2166 | bool isWriter = _imp->effect->isWriter(); |
| 2167 | |
| 2168 | if (foundAll) { |
| 2169 | for (int i = 0; i < 4; ++i) { |
| 2170 | // Writers already have their checkboxes places correctly |
| 2171 | if (!isWriter) { |
| 2172 | if (foundEnabled[i]->getParentKnob() == mainPage) { |
| 2173 | //foundEnabled[i]->setAddNewLine(i == 3); |
| 2174 | mainPage->removeKnob( foundEnabled[i].get() ); |
| 2175 | mainPage->insertKnob(i, foundEnabled[i]); |
| 2176 | } |
| 2177 | } |
| 2178 | _imp->enabledChan[i] = foundEnabled[i]; |
| 2179 | } |
| 2180 | } |
| 2181 | |
| 2182 | bool pluginDefaultPref[4]; |
| 2183 | _imp->hostChannelSelectorEnabled = _imp->effect->isHostChannelSelectorSupported(&pluginDefaultPref[0], &pluginDefaultPref[1], &pluginDefaultPref[2], &pluginDefaultPref[3]); |
| 2184 | |
| 2185 | |
| 2186 | if (_imp->hostChannelSelectorEnabled) { |
| 2187 | if (foundAll) { |
| 2188 | std::cerr << getScriptName_mt_safe() << ": WARNING: property " << kNatronOfxImageEffectPropChannelSelector << " is different of " << kOfxImageComponentNone << " but uses its own checkboxes" << std::endl; |
| 2189 | } else { |
| 2190 | //Create the selectors |
| 2191 | for (int i = 0; i < 4; ++i) { |
| 2192 | foundEnabled[i] = AppManager::createKnob<KnobBool>(_imp->effect.get(), channelLabels[i], 1, false); |
| 2193 | foundEnabled[i]->setName(channelNames[i]); |
| 2194 | foundEnabled[i]->setAnimationEnabled(false); |
| 2195 | foundEnabled[i]->setAddNewLine(i == 3); |
| 2196 | foundEnabled[i]->setDefaultValue(pluginDefaultPref[i]); |
| 2197 | foundEnabled[i]->setHintToolTip(channelHints[i]); |
| 2198 | mainPage->insertKnob(i, foundEnabled[i]); |
| 2199 | _imp->enabledChan[i] = foundEnabled[i]; |
| 2200 | } |
| 2201 | foundAll = true; |
| 2202 | } |
nothing calls this directly
no test coverage detected