The IPlug framework with its associated gui makes it fairly easy to allow audio engineers to type plugin parameter values directly. Using the IPlug gui you can right click any control (default behavior, but we also covered how to allow editing with the left mouse button too) and get an input box to type your parameter value. The problem I have with the default behavior is the size of the default edit box. The width is a hard coded value that doesn’t look good over any of my plugin’s parameters. They always seemed to leave the text underneath poking out behind the sides of the edit boxes. Here is a simple fix to make the edit boxes match the width of your parameter displays.
Here is a look at the default implementation of creating the edit box:
int w = PARAM_EDIT_W, h = PARAM_EDIT_H; mParamEditWnd = CreateWindow("EDIT", currentText, WS_CHILD | WS_VISIBLE | ES_CENTER | ES_MULTILINE, cX - w/2, cY - h/2, w, h, mPlugWnd, (HMENU) PARAM_EDIT_ID, mHInstance, 0);
The first line of code contains the most important information for us with our current task. There you can see the width variable begin set to a hard-coded value PARAM_EDIT_W. The next lines create the edit window with a typically Microsoft-ian, multi-line list of arguments, including the width. What we will do instead is to read the width of the control this edit box is created on. We have a pointer to this control through the pControl argument passed into this method. Rewrite the code to look like this:
int w = MAX(PARAM_EDIT_W, pR->W()); int h = MAX(PARAM_EDIT_H, pR->H()); mParamEditWnd = CreateWindow("EDIT", currentText, WS_CHILD | WS_VISIBLE | ES_CENTER | ES_MULTILINE, cX - w/2, cY - h/2, w, h, mPlugWnd, (HMENU) PARAM_EDIT_ID, mHInstance, 0);
We use the pR variable which is the IRECT dimensions already looked up for this control. You’ll notice I’m using the MAX macro to enforce a minimum size for the edit box. Having the edit box be a little too wide is acceptable for the user experience. I also altered the height calculation to use the control size but this step is optional. It may be undesirable especially on tall controls where it will make the edit box look strange. You can make the call about whether or not this is appropriate for your plugin.
With this small modification your VST plugins will be able to present user editable parameters with style and polish. Have fun developing your plugins!