ASPiK SDK
|
With the object designed and the ICustomView interface implemented, you can turn your attention to the plugingui.cpp file. The function that is called to give the object the first opportunity to create a custom view is named createView( ):
CView* PluginGUI::createView(const UIAttributes& attributes, const IUIDescription* description)
The attributes and description arguments come from the GUI class factory that calls the method and contains all the information gleaned from the XML description file. One piece of that information is the custom view name, which is what we use to decode the data and instantiate the view. We’ve already setup a secondary function createUserCustomView( ) that will do some of the decoding work for you. You may either append your custom views to that function, or modify the function above. In the case of the waveform and spectrum views we’ll use the secondary function. For other controls, you will need to work inside of createView( ) where you can have access to all of the attribute and description information. You can see that this function is simple - we just decode the name string and then create a new object.
CView* PluginGUI::createUserCustomView(std::string viewname, const CRect rect, IControlListener* listener, int32_t tag)
{
if (viewname.compare("CustomWaveView") == 0)
{
// — create our custom view
return new WaveView(rect, listener, tag);
}
return nullptr;
}
The part of createView that calls this function is shown here. This is where the ICustomView pointer is obtained from the newly created object and safely sent to the plugin shell using the IGUIPluginConnector interface pointer that it obtained during its creation:
// — try a user view first
CView* userCV = createUserCustomView(viewname, rect, listener, tag);
if (userCV)
{
// — register custom view it with the plugin for updates if (hasICustomView(userCV))
{
if (guiPluginConnector)
guiPluginConnector->registerCustomView(viewname, dynamic_cast<ICustomView*>(userCV));
}
return userCV;
}
In this case, the ICustomView is obtained by simply casting the custom view object and that is registered with the IGUIPluginConnector interface.
The SpectrumView object is designed in a similar manner but uses a double-ring-free-buffer scheme (mostly as an example) in its implementation. The createUserCustomView function is then modified to decode the custom view name "CustomSpectrumView" and similarly creates and registers the custom view - see the demo project example for all of the details.
The custom knob view object is designed by subclassing CAnimKnob from VSGUI4 and deriving it from ICustomView so that it exposes the interface. For the knob example, we are just going to show how to set up a communication system with ANY custom view so it does not contain any specialized drawing code. We will simply "talk" to the knob object and get a reply from it as proof of concept for your own custom views. You can find the code that decodes, creates and registers this custom knob in the PluginGUI::createView( ) function, just below the portion of code that calls our added function createUserCustomView( ) above.