Skip to content

Commit cd75009

Browse files
committed
Expose layout hints and hide-label metadata
Read OFX layout hints and propagate them into generated parameter metadata so UIs can better preserve plugin-authored control layout. - map OFX layout hint values to metadata: - no_new_line - divider - mark label-style string params as hide-label in addition to readonly - extend metadata schema with: - layout-hint enum - hide-label boolean (default: false) - include the Nuke OFX public extensions header for layout-hint constants Downloaded from https://github.com/NatronGitHub/openfx/blob/master/include/nuke/fnPublicOfxExtensions.h
1 parent 0543668 commit cd75009

3 files changed

Lines changed: 169 additions & 0 deletions

File tree

src/framework/metaschema.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ mapping:
154154
- text
155155
- textbox # multi-line
156156
- timecode
157+
"layout-hint": # A hint to the UI for relative control placement
158+
type: str
159+
enum:
160+
- divider
161+
- no_new_line
162+
"hide-label": # A hint to the UI to suppress the field label; omitted means false
163+
type: bool
164+
default: no
157165
"minimum": # For numeric types, the minimal value
158166
type: number
159167
"maximum": # For numeric types, the maximal value

src/modules/openfx/mlt_openfx.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#endif
3636

3737
/* OpenFX Header files https://github.com/AcademySoftwareFoundation/openfx/tree/main/include */
38+
#include <nuke/fnPublicOfxExtensions.h>
3839
#include <ofxDrawSuite.h>
3940
#include <ofxGPURender.h>
4041
#include <ofxImageEffect.h>
@@ -3094,6 +3095,22 @@ void *mltofx_fetch_params(OfxPlugin *plugin, mlt_properties params, mlt_properti
30943095
mlt_properties_set(p, "type", "integer");
30953096
}
30963097

3098+
int layout_hint = 0;
3099+
if (propGetInt((OfxPropertySetHandle) ppp, kOfxParamPropLayoutHint, 0, &layout_hint)
3100+
== kOfxStatOK) {
3101+
switch (layout_hint) {
3102+
case kOfxParamPropLayoutHintNoNewLine:
3103+
mlt_properties_set(p, "layout-hint", "no_new_line");
3104+
break;
3105+
case kOfxParamPropLayoutHintDivider:
3106+
mlt_properties_set(p, "layout-hint", "divider");
3107+
break;
3108+
default:
3109+
// Add new layout-hint cases here as they are supported.
3110+
break;
3111+
}
3112+
}
3113+
30973114
if (strcmp(param_type, kOfxParamTypeGroup) != 0) {
30983115
int animation = 1;
30993116
propGetInt((OfxPropertySetHandle) ppp, kOfxParamPropAnimates, 0, &animation);
@@ -3262,6 +3279,7 @@ void *mltofx_fetch_params(OfxPlugin *plugin, mlt_properties params, mlt_properti
32623279
propGetString((OfxPropertySetHandle) ppp, p_name, 0, &str_value);
32633280
if (strcmp(str_value, kOfxParamStringIsLabel) == 0) {
32643281
mlt_properties_set(p, "readonly", "yes");
3282+
mlt_properties_set_int(p, "hide-label", 1);
32653283
}
32663284
} else if (strcmp(p_name, kOfxParamPropParent) == 0) {
32673285
char *str_value = "";
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
//------------------------------------------------------------------------------
2+
// Apps/Nuke/nuke/src/fnPublicOfxExtensions.h
3+
//
4+
// Copyright (c) 2009 The Foundry Visionmongers Ltd. All Rights Reserved.
5+
//------------------------------------------------------------------------------
6+
7+
#ifndef _fnPublicOfxExtensions_h_
8+
#define _fnPublicOfxExtensions_h_
9+
10+
/*
11+
Software License :
12+
13+
Copyright (c) 2009, The Foundry Visionmongers Ltd. All rights reserved.
14+
15+
Redistribution and use in source and binary forms, with or without
16+
modification, are permitted provided that the following conditions are met:
17+
18+
* Redistributions of source code must retain the above copyright notice,
19+
this list of conditions and the following disclaimer.
20+
* Redistributions in binary form must reproduce the above copyright notice,
21+
this list of conditions and the following disclaimer in the documentation
22+
and/or other materials provided with the distribution.
23+
* Neither the name The Foundry Visionmongers Ltd, nor the names of its
24+
contributors may be used to endorse or promote products derived from this
25+
software without specific prior written permission.
26+
27+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
28+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
29+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
31+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
34+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
*/
38+
39+
#include "ofxImageEffect.h"
40+
41+
/** @brief Layout hint for hierarchical layouts
42+
43+
- Type - int X 1
44+
- Property Set - plugin parameter descriptor (read/write) and instance (read only)
45+
- Default - 0
46+
- Valid Values - 0,1 or 2
47+
0 - for a new line after the parameter
48+
1 - for a seperator between this parameter and the one to follow
49+
2 - for no new line, continue the next parameter on the same horizontal level
50+
51+
This is a property on parameters of type ::kOfxParamPropLayoutHint, and tells the group whether it should be open or closed by default.
52+
53+
*/
54+
#define kOfxParamPropLayoutHint "OfxParamPropLayoutHint"
55+
56+
// lay out as normal
57+
#define kOfxParamPropLayoutHintNormal 0
58+
59+
// put a divider after parameter
60+
#define kOfxParamPropLayoutHintDivider 1
61+
62+
// have the next parameter start on the same line as this
63+
#define kOfxParamPropLayoutHintNoNewLine 2
64+
65+
/** @brief Layout padding for hierarchical views, only pertinent with kOfxParamPropLayoutHint==2
66+
67+
- Type - int X 1
68+
- Property Set - plugin parameter descriptor (read/write) and instance (read only)
69+
- Default - 0
70+
- Valid Values - any positive integer value
71+
72+
This is a property on parameters of type ::kOfxParamPropLayoutPadWidth
73+
It tells the host how much space (in pixels) to leave between the current parameter and the next parameter in horizontal layouts.
74+
*/
75+
#define kOfxParamPropLayoutPadWidth "OfxParamPropLayoutPadWidth"
76+
77+
/** @brief The suggested colour of an overlay colour in an interact.
78+
79+
- Type - double X 3
80+
- Property Set - plugin parameter descriptor (read/write) and instance (read only)
81+
- Default - 1.0
82+
- Valid Values - greater than or equal to 0.0
83+
84+
This is a property of an overlay interact instance.
85+
*/
86+
#define kOfxPropOverlayColour "OfxPropOverlayColour"
87+
88+
/** @brief Unique user readable version string for that identifies something from other versions
89+
90+
- Type - string X 1
91+
- Property Set - host descriptor (read only), plugin descriptor (read/write)
92+
- Default - none, the host needs to set this
93+
- Valid Values - ASCII string
94+
*/
95+
#define kOfxPropVersionLabel "OfxPropVersionLabel"
96+
97+
/** @brief The displayed named of the host
98+
99+
- Type - string X 1
100+
- Property Set - host descriptor (read only), plugin descriptor (read/write)
101+
- Default - none
102+
- Valid Values - ASCII string
103+
*/
104+
#define kOfxPropHostProductTitle "OfxPropHostProductTitle"
105+
106+
/** @brief The major version of the host
107+
108+
- Type - int X 1
109+
- Property Set - param set instance (read/write)
110+
- Default - none
111+
- Valid Values - any positive integer values
112+
*/
113+
#define kOfxPropHostMajorVersion "OfxPropHostMajorVersion"
114+
115+
/** @brief The minor version of the host
116+
117+
- Type - int X 1
118+
- Property Set - param set instance (read/write)
119+
- Default - none
120+
- Valid Values - any positive integer values
121+
*/
122+
#define kOfxPropHostMinorVersion "OfxPropHostMinorVersion"
123+
124+
/** @brief The build version of the host
125+
126+
- Type - string X 1
127+
- Property Set - host descriptor (read only), plugin descriptor (read/write)
128+
- Default - none
129+
- Valid Values - ASCII string
130+
*/
131+
#define kOfxPropHostBuildVersion "OfxPropHostBuildVersion"
132+
133+
/** @brief Whether to display a group as a tab
134+
135+
- Type - int X 1
136+
- Property Set - plugin parameter descriptor (read/write) and instance (read only)
137+
- Default - 0
138+
- Valid Values - 0 or 1
139+
*/
140+
#define kFnOfxParamPropGroupIsTab "FnOfxParamPropGroupIsTab"
141+
142+
143+
#endif

0 commit comments

Comments
 (0)