Skip to main content
Inspiring
December 10, 2015
Answered

PF_PUI_DISABLED does not disable slider on setup

  • December 10, 2015
  • 3 replies
  • 1083 views

Newbie question, which I hope have a simpel answer 🙂

When I setup my slider I cannot disable it by default in ParamsSetup:

PF_ADD_FLOAT_SLIDERX( "Custom Aspect Ratio",

1, // min

5, // max

1, // slider min

5, // slider max

1, // default

PF_Precision_HUNDREDTHS,

PF_PUI_DISABLED, //this does nothing, it is still visible

CUSTOM_ASPECT_DISK_ID);

The PF_PUI_DISABLED flag does not disable it, while the other parameters do what they are expected to. I can enable/disable it on events in ParamChange:

AEGP_SuiteHandler suites(in_data->pica_basicP); //Call helper suites (should this be done outside the if-else?)

//Get selected format

FORMAT format = (FORMAT)(params[FIRST_STRETCHFORMAT]->u.pd.value-1);

PF_ParamDef aspectParam = *(params[FIRST_CUSTOM_ASPECT]);

if(format == FORMAT::CUSTOM)

     aspectParam.ui_flags &= ~PF_PUI_DISABLED;

else

     aspectParam.ui_flags |= PF_PUI_DISABLED;

ERR(suites.ParamUtilsSuite3()->PF_UpdateParamUI(in_data->effect_ref, FIRST_CUSTOM_ASPECT, &aspectParam));

I somehow get the feeling, that the disable flag should be set some other way initially rather than in the slider definition.

Help is greatly appreciated 🙂

This topic has been closed for replies.
Correct answer

Well, you could try this code macro:

#define PF_ADD_FLOAT_SLIDERXX(NAME, VALID_MIN, VALID_MAX, SLIDER_MIN, SLIDER_MAX, DFLT, PREC, DISP, FLAGS, UI_FLAGS, ID)    \

    do { \

        AEFX_CLR_STRUCT(def); \

        PF_Err    priv_err = PF_Err_NONE; \

        def.param_type = PF_Param_FLOAT_SLIDER; \

        PF_STRCPY(def.name, (NAME) ); \

        def.flags = (FLAGS); \

        def.ui_flags = (UI_FLAGS); \

        def.u.fs_d.valid_min        = (VALID_MIN); \

        def.u.fs_d.slider_min        = (SLIDER_MIN); \

        def.u.fs_d.valid_max        = (VALID_MAX); \

        def.u.fs_d.slider_max        = (SLIDER_MAX); \

        def.u.fs_d.value        = (DFLT); \

        def.u.fs_d.dephault        = (PF_FpShort)(def.u.fs_d.value); \

        def.u.fs_d.precision        = (PREC); \

        def.u.fs_d.display_flags    = (DISP); \

        def.u.fs_d.fs_flags        = (WANT_PHASE) ? PF_FSliderFlag_WANT_PHASE : 0; \

        def.u.fs_d.curve_tolerance    = AEFX_AUDIO_DEFAULT_CURVE_TOLERANCE;\

        def.uu.id = (ID); \

        if ((priv_err = PF_ADD_PARAM(in_data, -1, &def)) != PF_Err_NONE) return priv_err; \

    } while (0)

And then add the parameter like this:

PF_ADD_FLOAT_SLIDERXX( "Custom Aspect Ratio",

1, // min

5, // max

1, // slider min

5, // slider max

1, // default

PF_Precision_HUNDREDTHS, // precision

0, // display flags

0, // general flags

PF_PUI_DISABLED, //UI flags

CUSTOM_ASPECT_DISK_ID // ID

);

3 replies

December 10, 2015

And a final word of warning:

Both the PF_ADD_FLOAT_SLIDER and PF_ADD_FLOAT_SLIDERX macros are a bit weird or at least inconsistent in the SDK - and have been so for ages without Adobe ever fixing it despite complaints.

Instead there are some funny comments/questions in the official header about that implementation:

"// why does fs_flags get or-ed in? and why is CURVE_TOLERANCE param ignored? and .flags is never set. oy."

I'd recommend writing your own macro (that does proper initialisation of the structure and uses both flags and ui_flags fields) and use that instead.

BrumbazzAuthor
Inspiring
December 10, 2015

Thanks for your help so far, I'm on CC 2015 with latest SDK.

Maybe I'll have to set the flags somewhere else as you suggested. The Supervisor example has some hidden menues, which for what ever reason was only shown the first time, I used the plugin and now I cannot bringe them back, which puzzles me?????

The and/or is just they that specific bit is set, it is done in the same way in the supervisor code.

I don't understand the CURVE_TOLERANCE question?

Correct answer
December 11, 2015

Well, you could try this code macro:

#define PF_ADD_FLOAT_SLIDERXX(NAME, VALID_MIN, VALID_MAX, SLIDER_MIN, SLIDER_MAX, DFLT, PREC, DISP, FLAGS, UI_FLAGS, ID)    \

    do { \

        AEFX_CLR_STRUCT(def); \

        PF_Err    priv_err = PF_Err_NONE; \

        def.param_type = PF_Param_FLOAT_SLIDER; \

        PF_STRCPY(def.name, (NAME) ); \

        def.flags = (FLAGS); \

        def.ui_flags = (UI_FLAGS); \

        def.u.fs_d.valid_min        = (VALID_MIN); \

        def.u.fs_d.slider_min        = (SLIDER_MIN); \

        def.u.fs_d.valid_max        = (VALID_MAX); \

        def.u.fs_d.slider_max        = (SLIDER_MAX); \

        def.u.fs_d.value        = (DFLT); \

        def.u.fs_d.dephault        = (PF_FpShort)(def.u.fs_d.value); \

        def.u.fs_d.precision        = (PREC); \

        def.u.fs_d.display_flags    = (DISP); \

        def.u.fs_d.fs_flags        = (WANT_PHASE) ? PF_FSliderFlag_WANT_PHASE : 0; \

        def.u.fs_d.curve_tolerance    = AEFX_AUDIO_DEFAULT_CURVE_TOLERANCE;\

        def.uu.id = (ID); \

        if ((priv_err = PF_ADD_PARAM(in_data, -1, &def)) != PF_Err_NONE) return priv_err; \

    } while (0)

And then add the parameter like this:

PF_ADD_FLOAT_SLIDERXX( "Custom Aspect Ratio",

1, // min

5, // max

1, // slider min

5, // slider max

1, // default

PF_Precision_HUNDREDTHS, // precision

0, // display flags

0, // general flags

PF_PUI_DISABLED, //UI flags

CUSTOM_ASPECT_DISK_ID // ID

);

December 10, 2015

Oh, and I noticed a wrong thing in your example:

you are using the PF_ADD_FLOAT_SLIDERX macro and set the second to last parameter to PF_PUI_DISABLED.

However, that position in the macro only sets the "flags" field of the param structure. The PF_PUI_DISABLED parameter is a UI flag and should be set as a component of the "ui_flags" member of a PF_ParamDef struct

December 10, 2015

I remember problems setting the hidden state, while disabled was working on setup, but that could have been in an older version.

Anyway, there is another way to set hidden and disabled states for parameters using the stream API functions.

Something like this:

ERR(suites.PFInterfaceSuite1()->AEGP_GetNewEffectForEffect(NULL, in_data->effect_ref, &meH));

ERR(suites.StreamSuite2()->AEGP_GetNewEffectStreamByIndex(NULL, meH, i, &streamH));

ERR(suites.DynamicStreamSuite2()->AEGP_SetDynamicStreamFlag(streamH, AEGP_DynStreamFlag_DISABLED, TRUE, hidden));

if (meH) suites.EffectSuite2()->AEGP_DisposeEffect(meH);

if (streamH) suites.StreamSuite2()->AEGP_DisposeStream(streamH);

However, these functions also don't work on ParamSetup(), but do work on ParamChange() as well as most other locations, so it is probably best to set the desired states using the stream functions in a call after ParamSetup

December 10, 2015

Also, check out the Supervisor sample from the SDK. I think it initialized a parameter in disabled state using the regular function calls (although also not during PF_Cmd_PARAMS_SETUP, but in PF_Cmd_UPDATE_PARAMS_UI).