Skip to content

Commit 9bce875

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
1 parent 57dfaa4 commit 9bce875

3 files changed

Lines changed: 63 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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef _fnPublicOfxExtensions_h_
2+
#define _fnPublicOfxExtensions_h_
3+
4+
#include "ofxImageEffect.h"
5+
6+
/** @brief Layout hint for hierarchical layouts.
7+
*
8+
* - Type - int X 1
9+
* - Property Set - plugin parameter descriptor (read/write) and instance (read only)
10+
* - Default - 0
11+
* - Valid Values - 0, 1, or 2
12+
* - 0 - for a new line after the parameter
13+
* - 1 - for a separator between this parameter and the one to follow
14+
* - 2 - for no new line, continue the next parameter on the same horizontal level
15+
*/
16+
#define kOfxParamPropLayoutHint "OfxParamPropLayoutHint"
17+
18+
// lay out as normal
19+
#define kOfxParamPropLayoutHintNormal 0
20+
21+
// put a divider after parameter
22+
#define kOfxParamPropLayoutHintDivider 1
23+
24+
// have the next parameter start on the same line as this
25+
#define kOfxParamPropLayoutHintNoNewLine 2
26+
27+
/** @brief Layout padding for hierarchical views, only pertinent when
28+
* kOfxParamPropLayoutHint == 2.
29+
*
30+
* - Type - int X 1
31+
* - Property Set - plugin parameter descriptor (read/write) and instance (read only)
32+
* - Default - 0
33+
* - Valid Values - any positive integer value
34+
*/
35+
#define kOfxParamPropLayoutPadWidth "OfxParamPropLayoutPadWidth"
36+
37+
#endif

0 commit comments

Comments
 (0)