by Robin Rowe 11/23/05
GUI-less Plug-in Design in Glasgow
Please explain how a plug-in can have a GUI but not need me to learn FLTK?
You could embed a GUI. You simply won't need to. Let's say you create a gamma plug-in, gamma.dll. It might run like this at the command-line:
% img_img test.ppm .gamma gamma=1.2 brighter.ppm
How will this same plug-in work interactively in CinePaint?
Inside the plug-in there's a method to set metadata:
bool GammaPlugin::SetMetadata(const char* string)
{ // Plug-in author writes this method body:
// string="gamma=1.2"
Substring s=GetParam(string,"gamma");// is "1.2"
// float gamma; is a member of the class
const bool ok=s.Set(gamma);// like gamma=atof(s)
if(!ok)
{ SetErrorMsg("Invalid param",string);
}
return ok;
}
Another plug-in method gets a list of metadata:
virtual const char* GammaPlugin::GetHelpMetadata() const
{ // Plug-in author writes this method body:
return "gamma|range 0-10\n"
"another_param|your tooltip suggestion\n";
}
In CinePaint the user will be able to call up the settings dialog for any plug-in. What happens when the plug-in has no settings dialog defined? From the plug-in's GetHelpMetadata() method CinePaint can figure out what fields to populate a generic dialog with. Using the SetMetadata() method it can later transmit the user data entered back into the plug-in.
As an extreme example, lets say you want to create a plug-in to interactively paint on an image. That will require a custom plugin-defined GUI. You would need to override the default GetHelpMetadata() implicit GUI. However, for ordinary get-and-set plug-in GUIs you won't need to do any GUI programming. It's automatic.