SDK - Layer Attachments - APPL
Using the APPL meta-type
The APPL attachment (Applet Linkage Data) allows plug-ins that generate content based in a set of input parameters to offer re-editability by saving those parameters to the layer and having Chasys Photo automatically invoke the relevant plug-in when the layer is double-clicked with the Hand tool. The metadata consists of a host-defined header followed by plug-in-defined data of arbitrary length:
| #define META_APPL_VERSION 0x0001 struct meta_APPL_Obj { unsigned short version; //APPL version unsigned short unused_1; //unused, set to zero unsigned char type; unsigned char unused_2[15]; wchar_t name[32]; wchar_t file[32]; char unused_3[256-(4+16+128)]; }; |
The plug-in requests metadata of size sizeof(meta_APPL_Obj)+size_of_plugin_data. The plug-in then proceeds to fill the header with the type, a name (e.g. “Draw Ball”) and its filename minus the path as the file (e.g. “efx_DrawBall.dll”). The plug-in may then use the extra space to store its parameters, which it will use to re-render the image (e.g. a colored ball) when the host invokes it.
It’s not mandatory that you use a magic number in your data structure, but it’s highly advisable.
Sample Code
Here’s some sample code that illustrates the use of APPL metadata:
TAGS: Chasys Photo Source Code, Attachment, Metadata, APPL
|
#define MY_APPL_MAGIC (*((unsigned long*)("Ball"))); meta_APPL_Obj* appl; my_params_tag* opts; data->meta_query("APPL",sizeof(meta_APPL_Obj)+sizeof(my_params_tag)); appl=(meta_APPL_Obj*)data->meta_data; opts=(my_params_tag*)(data->meta_data+sizeof(meta_APPL_Obj)); ... ... appl->version=META_APPL_VERSION; appl->type=META_APPL_TYPE_RUN_EFX; GetModuleFileName(api_inst,str,_countof(str)); StringCchCopy(appl->name,_countof(appl->name),L"Draw Ball"); StringCchCopy(appl->file,_countof(appl->file),GetFilenameFromPath(str)); opts->magic=MY_APPL_MAGIC; opts->radius=parameters.radius; opts->style1=parameters.style1; opts->style2=parameters.style2; opts->color1=parameters.color1; opts->color2=parameters.color2; |