Skip to content

Commit

Permalink
Remove Choice param option hiding based on negative Order values
Browse files Browse the repository at this point in the history
This turned out to be complicated for some hosts, so we will not
mandate it in the spec. The spec now recommends plugins only use
non-negative values for Order, thus preserving the option for hosts to
hide negative values if they can.

Signed-off-by: Gary Oberbrunner <[email protected]>
  • Loading branch information
garyo committed Mar 9, 2024
1 parent 5c0914f commit 881f3ca
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
22 changes: 8 additions & 14 deletions Documentation/sources/Reference/ofxParameter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,9 @@ so the options are displayed in their natural order.

Values may be arbitrary 32-bit integers. The same value must not occur
more than once in the order list; behavior is undefined if the same
value occurs twice in the list.

If an Order value is negative, the host should hide the
corresponding option in the UI. This can be useful for a plugin to
deprecate certain options. When a host loads a project which includes
a hidden option, the host should show that option in that effect
instance. If a host cannot dynamically hide or show options, it may
instead show hidden options (with negative Order values) as grayed out
or inactive. A plugin should not set the choice param's default value
to a hidden option.
value occurs twice in the list. Plugins should use non-negative
values; some hosts may choose to hide options with negative Order
values.

Note that :c:macro:`kOfxParamPropChoiceOrder` does not affect project
storage or operation; it is only used by the host UI. This way it is 100%
Expand All @@ -251,9 +244,10 @@ property and check the return status. If the host does not support
values into the middle of the options list, nor reorder the options,
in a new version, otherwise old projects will not load properly.

Note: this property does not help if a plugin wants to *remove* an option. One way to
handle that case is to define a new choice param in v2 and hide the old v1 param, then use some
custom logic to populate the v2 param appropriately.
Note: this property does not help if a plugin wants to *remove* an
option. One way to handle that case is to define a new choice param in
v2 and hide the old v1 param, then use some custom logic to populate
the v2 param appropriately.

Also in 1.5, see the new :c:macro:`kOfxParamTypeStrChoice` param type
for another way to do this: the plugin specifies a set of string
Expand Down Expand Up @@ -305,7 +299,7 @@ that the host use the default value in that case.
To check for availability of this param type, a plugin may check the
host property :c:macro:`kOfxParamHostPropSupportsStrChoice`.

StrChoice parameters may also be reordered and/or hidden using
StrChoice parameters may also be reordered using
:c:macro:`kOfxParamPropChoiceOrder`; see the previous section.

Available since 1.5.
Expand Down
8 changes: 1 addition & 7 deletions Examples/ChoiceParams/choiceparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ describeInContext( OfxImageEffectHandle effect, OfxPropertySetHandle inArgs)


// Second choice param: using order.
// This will produce incorrect results in hosts that don't support order.
// This will produce incorrect ordering in hosts that don't support order.
// Note that index 1 here is "lots", index 2 is "some"
gParamHost->paramDefine(paramSet, kOfxParamTypeChoice, "green_choice", &props);
gPropHost->propSetInt(props, kOfxParamPropDefault, 0, 0);
Expand All @@ -585,16 +585,13 @@ describeInContext( OfxImageEffectHandle effect, OfxPropertySetHandle inArgs)
gPropHost->propSetString(props, kOfxParamPropChoiceOption, 0, "Green: none");
gPropHost->propSetString(props, kOfxParamPropChoiceOption, 1, "Green: lots");
gPropHost->propSetString(props, kOfxParamPropChoiceOption, 2, "Green: some");
gPropHost->propSetString(props, kOfxParamPropChoiceOption, 3, "Green: TOO MUCH (hidden)");
// Order sets the display order: choices will be displayed in this order
auto stat = gPropHost->propSetInt(props, kOfxParamPropChoiceOrder, 0, 0); // first
if (stat == kOfxStatOK) {
gPropHost->propSetInt(props, kOfxParamPropChoiceOrder, 1, 2); // last
gPropHost->propSetInt(props, kOfxParamPropChoiceOrder, 2, 1); // middle
gPropHost->propSetInt(props, kOfxParamPropChoiceOrder, 3, -1); // negative order: should be hidden in UI
} else {
gHostSupportsChoiceOrder = false;
std::cout << "Host does not support kOfxParamPropChoiceOrder: green results will look wrong\n";
}

// Third choice param: using StrChoice, string-valued choice param
Expand All @@ -606,17 +603,14 @@ describeInContext( OfxImageEffectHandle effect, OfxPropertySetHandle inArgs)
gPropHost->propSetString(props, kOfxParamPropChoiceOption, 0, "Blue: none");
gPropHost->propSetString(props, kOfxParamPropChoiceOption, 1, "Blue: some");
gPropHost->propSetString(props, kOfxParamPropChoiceOption, 2, "Blue: lots");
gPropHost->propSetString(props, kOfxParamPropChoiceOption, 3, "Blue: TOO MUCH");
// host will return and store these values
gPropHost->propSetString(props, kOfxParamPropChoiceEnum, 0, "blue_0.0");
gPropHost->propSetString(props, kOfxParamPropChoiceEnum, 1, "blue_0.5");
gPropHost->propSetString(props, kOfxParamPropChoiceEnum, 2, "blue_1.0");
gPropHost->propSetString(props, kOfxParamPropChoiceEnum, 3, "blue_HIDDEN");

gPropHost->propSetInt(props, kOfxParamPropChoiceOrder, 0, 0);
gPropHost->propSetInt(props, kOfxParamPropChoiceOrder, 1, 1);
gPropHost->propSetInt(props, kOfxParamPropChoiceOrder, 2, 2);
gPropHost->propSetInt(props, kOfxParamPropChoiceOrder, 3, -1); // hide this one
}

// make a page of controls and add my parameters to it
Expand Down
2 changes: 0 additions & 2 deletions Support/Plugins/ChoiceParams/choiceparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,15 +650,13 @@ void ChoiceParamsExamplePluginFactory::describeInContext(OFX::ImageEffectDescrip
choice2->appendOption("green: none", "", 0);
choice2->appendOption("green: lots", "", 2);
choice2->appendOption("green: some", "", 1);
choice2->appendOption("green: TOO MUCH (hidden)", "", -1);
page->addChild(*choice2);

if (getImageEffectHostDescription()->supportsStrChoice) {
auto *choice3 = desc.defineStrChoiceParam("blue_choice");
choice3->appendOption("blue_0.0", "blue: none", 0);
choice3->appendOption("blue_0.5", "blue: some", 1);
choice3->appendOption("blue_1.0", "blue: lots", 2);
choice3->appendOption("blue_HIDDEN", "blue: TOO MUCH", -1); // hide this one
page->addChild(*choice3);
}
}
Expand Down
6 changes: 3 additions & 3 deletions cmake/OpenFX.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
if(APPLE)
set(PLUGINDIR "/Library/OFX/Plugins")
set(PLUGINDIR "/Library/OFX/Plugins/OpenFX Examples")
set(ARCHDIR "MacOS")
elseif(WIN32)
set(PLUGINDIR "C:/Program Files (x86)/Common Files/OFX/Plugins")
set(PLUGINDIR "C:/Program Files (x86)/Common Files/OFX/Plugins/OpenFX Examples")
set(ARCHDIR "Win64")
elseif(UNIX)
set(PLUGINDIR "/usr/OFX/Plugins")
set(PLUGINDIR "/usr/OFX/Plugins/OpenFX Examples")
set(ARCHDIR "Linux-x86-64")
else()
set(PLUGINDIR "/unknown-os")
Expand Down
4 changes: 3 additions & 1 deletion scripts/build-cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ done
shift $((OPTIND -1))

# First positional argument as BUILDTYPE
BUILDTYPE=$1; shift
if [[ $# -gt 0 ]]; then
BUILDTYPE=$1; shift
fi

ARGS="$@"

Expand Down

0 comments on commit 881f3ca

Please sign in to comment.