Jamba C++ API  5.1.1
CustomViewCreator< TView, TBaseView > Class Template Reference

Inherit from this class to provide the factory for a custom view. More...

#include <CustomViewCreator.h>

Inherits TCustomViewCreator< TView >.

Public Member Functions

 CustomViewCreator (char const *iViewName=nullptr, char const *iDisplayName=nullptr, char const *iBaseViewName=VSTGUI::UIViewCreator::kCView)
 
- Public Member Functions inherited from TCustomViewCreator< TView >
bool apply (CView *view, const UIAttributes &attributes, const IUIDescription *description) const override
 Extract all the attribute values and apply them to the view. More...
 
CView * create (const UIAttributes &attributes, const IUIDescription *description) const override
 This is the factory method which will instantiate the view. More...
 
bool getAttributeNames (std::list< std::string > &attributeNames) const override
 
AttrType getAttributeType (const std::string &attributeName) const override
 
IdStringPtr getBaseViewName () const override
 
UTF8StringPtr getDisplayName () const override
 
IdStringPtr getViewName () const override
 
template<typename XView >
void registerAttributes (TCustomViewCreator< XView > const &iOther)
 This method is called to register all the attributes from another CustomViewCreator (used in case of inheritance) More...
 
void registerBitmapAttribute (std::string const &iName, typename BitmapAttribute::Getter iGetter, typename BitmapAttribute::Setter iSetter)
 Registers a bitmap attribute with the given name and getter/setter. More...
 
void registerBooleanAttribute (std::string const &iName, typename BooleanAttribute::Getter iGetter, typename BooleanAttribute::Setter iSetter)
 Registers a boolean attribute with the given name and getter/setter. More...
 
void registerColorAttribute (std::string const &iName, typename ColorAttribute::Getter iGetter, typename ColorAttribute::Setter iSetter)
 Registers a color attribute with the given name and getter/setter. More...
 
void registerDoubleAttribute (std::string const &iName, typename FloatAttribute< double >::Getter iGetter, typename FloatAttribute< double >::Setter iSetter)
 Registers a double attribute with the given name and getter/setter. More...
 
void registerFloatAttribute (std::string const &iName, typename FloatAttribute< float >::Getter iGetter, typename FloatAttribute< float >::Setter iSetter)
 Registers a float attribute with the given name and getter/setter. More...
 
void registerFontAttribute (std::string const &iName, typename FontAttribute::Getter iGetter, typename FontAttribute::Setter iSetter)
 Registers a font attribute with the given name and getter/setter. More...
 
void registerGradientAttribute (std::string const &iName, typename GradientAttribute::Getter iGetter, typename GradientAttribute::Setter iSetter)
 Registers a gradient attribute with the given name and getter/setter. More...
 
void registerIntAttribute (std::string const &iName, typename IntegerAttribute< int32_t >::Getter iGetter, typename IntegerAttribute< int32_t >::Setter iSetter)
 Registers an int attribute with the given name and getter/setter. More...
 
template<typename TInt >
void registerIntegerAttribute (std::string const &iName, typename IntegerAttribute< TInt >::Getter iGetter, typename IntegerAttribute< TInt >::Setter iSetter)
 Registers an Integer (any kind) attribute with the given name and getter/setter. More...
 
template<typename T >
void registerListAttribute (std::string const &iName, typename ListAttribute< T >::Getter iGetter, typename ListAttribute< T >::Setter iSetter, AttrValInitList< T > const &iAttributeValues)
 Registers a list attribute with the given name and getter/setter. More...
 
void registerMarginAttribute (std::string const &iName, typename MarginAttribute::Getter iGetter, typename MarginAttribute::Setter iSetter)
 Registers a Margin attribute with the given name and getter/setter. More...
 
void registerRangeAttribute (std::string const &iName, typename RangeAttribute::Getter iGetter, typename RangeAttribute::Setter iSetter)
 Registers a Range attribute with the given name and getter/setter. More...
 
void registerTagAttribute (std::string const &iName, typename TagAttribute::Getter iGetter, typename TagAttribute::Setter iSetter)
 Registers a tag attribute with the given name and getter/setter. More...
 
void registerVectorStringAttribute (std::string const &iName, typename VectorStringAttribute::Getter iGetter, typename VectorStringAttribute::Setter iSetter, char iDelimiter=',', bool iSkipEmptyEntries=false)
 Registers a Range attribute with the given name and getter/setter. More...
 
 TCustomViewCreator (char const *iViewName=nullptr, char const *iDisplayName=nullptr, char const *iBaseViewName=VSTGUI::UIViewCreator::kCView)
 
 ~TCustomViewCreator () override
 

Detailed Description

template<typename TView, typename TBaseView = void>
class pongasoft::VST::GUI::Views::CustomViewCreator< TView, TBaseView >

Inherit from this class to provide the factory for a custom view.

When creating a custom view, you also need to provide a factory for this view: a way for the framework to instantiate and properly initialize the view.

VSTGUI uses the concept of "attributes" that are read (resp. written) to the xml file that is used to store the look and feel of the plugin. Those "attributes" are also exposed in the VSTGUI editor as texfields, checkboxes and selection list to dynamically change them in a WYSIWYG fashion.

In Jamba, by convention, writing this factory is as simple as writing an inner class of the view which must be called Creator which inherits from this class and with a constructor that simply registers the attribute that the view uses.

// Example
class MyCustomView : public CustomView {
// ....
CColor fMyColor;
CColor const &getMyColor() const { return fMyColor; }
void setMyColor(CColor const &iColor) { fMyColor = iColor; }
public:
class Creator : public CustomViewCreator<MyCustomView, CustomView> {
public:
Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
CustomViewCreator(iViewName, iDisplayName) {
registerColorAttribute("my-color", // name of attribute
&MyCustomView::getMyColor, // pointer to "getter"
&MyCustomView::setMyColor); // pointer to "setter"
}
};
};
// in a .cpp somewhere
// this automatically registers the factory with the framework
MyCustomView::Creator __gMyCustomViewCreator("MyCustomView", "MyCustomView...");

If your custom view inherits from another custom view, you should provide it as the second type parameter (TBaseView).

If you custom view inherits from a VSTGUI view (CustomViewAdapter), you should provide the proper iBaseViewName in the constructor so that your custom view can use the attributes defined by the VSTGUI view.

// Example
class MyCustomView : public CustomViewAdapter<COnOffButton> {
// ...
public:
class Creator : public CustomViewCreator<MyCustomView, CustomViewAdapter<COnOffButton>> {
public:
Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
CustomViewCreator(iViewName,
iDisplayName,
VSTGUI::UIViewCreator::kCOnOffButton) { // <--- iBaseViewName
// ...
}
};
};
}
Note
You can check the TextButtonView class for a complete example of a custom view using a CustomViewAdpater.
Template Parameters
TViewthe type of the view that is being created by this creator (usually the name of the outer class)
TBaseViewoptional parameter specifying the type of the base view

Constructor & Destructor Documentation

◆ CustomViewCreator()

CustomViewCreator ( char const *  iViewName = nullptr,
char const *  iDisplayName = nullptr,
char const *  iBaseViewName = VSTGUI::UIViewCreator::kCView 
)
inlineexplicit

The documentation for this class was generated from the following file: