Skip to main content
Participating Frequently
September 12, 2023
Answered

Unable to update UI with PF_Cmd_UPDATE_PARAMS_UI

  • September 12, 2023
  • 1 reply
  • 1147 views

Can someone please help me? I'm a beginner and I've been trying to test updating the UI using PF_Cmd_UPDATE_PARAMS_UI, but it doesn't seem to be working at all.

```

...

static PF_Err 
GlobalSetup (
PF_InData *in_data,
PF_OutData *out_data,
PF_ParamDef *params[],
PF_LayerDef *output )
{
out_data->my_version = PF_VERSION( MAJOR_VERSION, 
MINOR_VERSION,
BUG_VERSION, 
STAGE_VERSION, 
BUILD_VERSION);
 
out_data->out_flags  = PF_OutFlag_DEEP_COLOR_AWARE; // just 16bpc, not 32bpc
out_data->out_flags |= PF_OutFlag_SEND_UPDATE_PARAMS_UI;
 
return PF_Err_NONE;
}
 
static PF_Err 
ParamsSetup (
PF_InData *in_data,
PF_OutData *out_data,
PF_ParamDef *params[],
PF_LayerDef *output )
{
PF_Err err = PF_Err_NONE;
PF_ParamDef def;
 
AEFX_CLR_STRUCT(def);
//def.flags = PF_ParamFlag_SUPERVISE;
PF_ADD_POINT       ( STR(StrID_Point_Param_Name),
0, 
0, 
NULL,
POINT_DISK_ID);
 
AEFX_CLR_STRUCT(def);
def.flags = PF_ParamFlag_SUPERVISE;
PF_ADD_COLOR( STR(StrID_Color_Param_Name), 
PF_HALF_CHAN8,
PF_MAX_CHAN8,
PF_MAX_CHAN8,
COLOR_DISK_ID);
 
AEFX_CLR_STRUCT(def);
def.flags = PF_ParamFlag_SUPERVISE;
PF_ADD_SLIDER(STR(StrID_Slider_Param_Name),
0,
255,
0,
255,
128,
SLIDER_DISK_ID);
 
out_data->num_params = SKELETON_NUM_PARAMS;
return err;
}

....

 
PF_Err
EffectMain(
PF_Cmd cmd,
PF_InData *in_data,
PF_OutData *out_data,
PF_ParamDef *params[],
PF_LayerDef *output,
void *extra)
{
PF_Err err = PF_Err_NONE;
 
 
try {
switch (cmd) {
case PF_Cmd_ABOUT:
 
err = About(in_data,
out_data,
params,
output);
break;
 
case PF_Cmd_GLOBAL_SETUP:
 
err = GlobalSetup( in_data,
out_data,
params,
output);
break;
 
case PF_Cmd_PARAMS_SETUP:
 
err = ParamsSetup( in_data,
out_data,
params,
output);
break;
 
case PF_Cmd_UPDATE_PARAMS_UI:
err = UpdateUI(in_data, out_data, params);
break;
 
 
case PF_Cmd_USER_CHANGED_PARAM:
//err = UpdateUI(in_data, out_data, params);
break;
 
case PF_Cmd_RENDER:
 
err = Render( in_data,
out_data,
params,
output);
break;
 
 
}
}
catch(PF_Err &thrown_err){
err = thrown_err;
}
return err;
}
 


```

I have already set the PF_OutFlag_SEND_UPDATE_PARAMS_UI. I've confirmed that the code does reach the UpdateUI() function, but no changes are reflected.

When testing with PF_Cmd_USER_CHANGED_PARAM, I observed that the UI updates correctly. Is it not possible to achieve this with only PF_Cmd_UPDATE_PARAMS_UI?

My ultimate goal is to create a plugin similar to the expression 'sampleImage'. I want to fetch the color from a PF_Param_POINT location and update it in a PF_Param_COLOR.

This topic has been closed for replies.
Correct answer shachar carmi

a couple of things:

1. during UPDATE_PARAMS_UI you should change only appearance (hidden, disabled, ect...) and not values. it's not strictly forbidden, it just doesn't play well into AE's instance application scheme... you should set param's proper default values during PARAM_SETUP.

2. you shouldn't chage values and flags directly on the original params array. instead you should make a copy of the parad struct, modify the copy, and pass the copy back to PF_UpdateParamUI.

 

take a look at the "Supervisor" SDK sample project. it's a bit convoluted, but the first few lines of it's UpdateParameterUI() function show the correct inplementation.

1 reply

Community Expert
September 12, 2023

you didn't post the implementation of your UpdateUI() function.

did you set "out_data->out_flags = PF_OutFlag_REFRESH_UI;" before returning?

naazqAuthor
Participating Frequently
September 12, 2023

I'm sorry. I missed an important part.

 

static PF_Err
UpdateUI(
PF_InData* in_data,
PF_OutData* out_data,
PF_ParamDef* params[]
)
{
PF_Err err = PF_Err_NONE;
AEGP_SuiteHandler suites(in_data->pica_basicP);
 
params[SKELETON_COLOR]->u.cd.value.red = 0;
params[SKELETON_COLOR]->u.cd.value.green = 0;
params[SKELETON_COLOR]->u.cd.value.blue = 0;
 
params[SKELETON_SLIDR]->u.sd.value = 0;
 
params[SKELETON_COLOR]->uu.change_flags = PF_ChangeFlag_CHANGED_VALUE;
params[SKELETON_SLIDR]->uu.change_flags = PF_ChangeFlag_CHANGED_VALUE;
 
 
ERR(suites.ParamUtilsSuite3()->PF_UpdateParamUI(in_data->effect_ref, SKELETON_COLOR, params[SKELETON_COLOR]));
ERR(suites.ParamUtilsSuite3()->PF_UpdateParamUI(in_data->effect_ref, SKELETON_SLIDR, params[SKELETON_SLIDR]));
out_data->out_flags |= PF_OutFlag_REFRESH_UI;
return err;
}

 

Did I place the PF_OutFlag_REFRESH_UI in the wrong location?

shachar carmiCommunity ExpertCorrect answer
Community Expert
September 12, 2023

a couple of things:

1. during UPDATE_PARAMS_UI you should change only appearance (hidden, disabled, ect...) and not values. it's not strictly forbidden, it just doesn't play well into AE's instance application scheme... you should set param's proper default values during PARAM_SETUP.

2. you shouldn't chage values and flags directly on the original params array. instead you should make a copy of the parad struct, modify the copy, and pass the copy back to PF_UpdateParamUI.

 

take a look at the "Supervisor" SDK sample project. it's a bit convoluted, but the first few lines of it's UpdateParameterUI() function show the correct inplementation.