Jamba C++ API  5.1.1
TCustomViewCreator< TView > Class Template Reference

Generic custom view creator base class. More...

#include <CustomViewCreator.h>

Inherits ViewCreatorAdapter.

Inherited by CustomViewAdapter< TView >::Creator, and CustomViewCreator< TView, TBaseView >.

Classes

class  BitmapAttribute
 Specialization for a bitmap attribute. More...
 
class  BooleanAttribute
 Specialization for the boolean attribute. More...
 
class  ColorAttribute
 Specialization for the color attribute. More...
 
class  FloatAttribute
 Specialization for an float attribute (which can be a double or a float, etc..). More...
 
class  FontAttribute
 Specialization for a bitmap attribute. More...
 
class  GradientAttribute
 Specialization for the color attribute. More...
 
class  IntegerAttribute
 Specialization for an Integer attribute (which can be any kind of integer, like short, int32_t, etc..). More...
 
class  ListAttribute
 Specialization for a list of possible values defined by the AttributeMap More...
 
class  MarginAttribute
 Specialization for the margin attribute. More...
 
class  RangeAttribute
 Specialization for the range attribute. More...
 
class  TagAttribute
 Specialization for a tag attribute (vst type TagID). More...
 
class  TAttribute
 Generic base class that implements the logic for a ViewAttribute that uses a getter and setter in TView. More...
 
class  VectorStringAttribute
 Specialization for a vector of strings. More...
 

Public Member Functions

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
 

Private Types

template<typename T >
using ByRefAttribute = TAttribute< T, T const &(TView::*)() const, void(TView::*)(T const &)>
 ByRefAttribute defines getter/setter by const reference. More...
 
template<typename T >
using ByValAttribute = TAttribute< T, T(TView::*)() const, void(TView::*)(T)>
 ByValAttribute defines getter/setter by value (copy) More...
 

Private Member Functions

void registerAttribute (std::shared_ptr< ViewAttribute > iAttribute)
 Internal method to register an attribute... More...
 
template<typename TViewAttribute , typename... Args>
void registerAttribute (std::string const &iName, typename TViewAttribute::Getter iGetter, typename TViewAttribute::Setter iSetter, Args &&...iArgs)
 Generic register attribute. More...
 

Private Attributes

std::map< std::string, std::shared_ptr< ViewAttribute > > fAttributes
 
char const * fBaseViewName
 
char const * fDisplayName
 
char const * fViewName
 

Friends

template<typename XView >
class TCustomViewCreator
 

Detailed Description

template<typename TView>
class pongasoft::VST::GUI::Views::TCustomViewCreator< TView >

Generic custom view creator base class.

Inherit from it and call the various "registerXX" methods in the constructor.

In case of inheritance, you do the following:

class CustomView1 : public CControl { ... };
class CustomView2 : public CustomView1 { ... };
class CustomView1Creator : public TCustomViewCreator<CustomView1> {
public:
explicit CustomView1Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
TCustomViewCreator(iViewName, iDisplayName)
{
... register CustomView1 attributes here ...
}
};
class CustomView2Creator : public TCustomViewCreator<CustomView2> {
public:
explicit CustomView2Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
TCustomViewCreator(iViewName, iDisplayName)
{
registerAttributes(CustomView1Creator());
... register CustomView2 attributes here ...
}
};
Note
It is recommended to follow the convention that the view has an inner class called Creator in which case you should use the more convenient class CustomViewCreator instead.

Member Typedef Documentation

◆ ByRefAttribute

using ByRefAttribute = TAttribute<T, T const &(TView::*)() const, void (TView::*)(T const &)>
private

ByRefAttribute defines getter/setter by const reference.

◆ ByValAttribute

using ByValAttribute = TAttribute<T, T (TView::*)() const, void (TView::*)(T)>
private

ByValAttribute defines getter/setter by value (copy)

Constructor & Destructor Documentation

◆ TCustomViewCreator()

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

◆ ~TCustomViewCreator()

~TCustomViewCreator ( )
inlineoverride

Member Function Documentation

◆ apply()

bool apply ( CView *  view,
const UIAttributes &  attributes,
const IUIDescription *  description 
) const
inlineoverride

Extract all the attribute values and apply them to the view.

This is for example what happens when the xml file is read to populate the view with the stored values

◆ create()

CView* create ( const UIAttributes &  attributes,
const IUIDescription *  description 
) const
inlineoverride

This is the factory method which will instantiate the view.

◆ getAttributeNames()

bool getAttributeNames ( std::list< std::string > &  attributeNames) const
inlineoverride

◆ getAttributeType()

AttrType getAttributeType ( const std::string &  attributeName) const
inlineoverride

◆ getBaseViewName()

IdStringPtr getBaseViewName ( ) const
inlineoverride

◆ getDisplayName()

UTF8StringPtr getDisplayName ( ) const
inlineoverride

◆ getViewName()

IdStringPtr getViewName ( ) const
inlineoverride

◆ registerAttribute() [1/2]

void registerAttribute ( std::shared_ptr< ViewAttribute iAttribute)
inlineprivate

Internal method to register an attribute...

check that names are not duplicate!

◆ registerAttribute() [2/2]

void registerAttribute ( std::string const &  iName,
typename TViewAttribute::Getter  iGetter,
typename TViewAttribute::Setter  iSetter,
Args &&...  iArgs 
)
inlineprivate

Generic register attribute.

◆ registerAttributes()

void registerAttributes ( TCustomViewCreator< XView > const &  iOther)
inline

This method is called to register all the attributes from another CustomViewCreator (used in case of inheritance)

◆ registerBitmapAttribute()

void registerBitmapAttribute ( std::string const &  iName,
typename BitmapAttribute::Getter  iGetter,
typename BitmapAttribute::Setter  iSetter 
)
inline

Registers a bitmap attribute with the given name and getter/setter.

◆ registerBooleanAttribute()

void registerBooleanAttribute ( std::string const &  iName,
typename BooleanAttribute::Getter  iGetter,
typename BooleanAttribute::Setter  iSetter 
)
inline

Registers a boolean attribute with the given name and getter/setter.

◆ registerColorAttribute()

void registerColorAttribute ( std::string const &  iName,
typename ColorAttribute::Getter  iGetter,
typename ColorAttribute::Setter  iSetter 
)
inline

Registers a color attribute with the given name and getter/setter.

◆ registerDoubleAttribute()

void registerDoubleAttribute ( std::string const &  iName,
typename FloatAttribute< double >::Getter  iGetter,
typename FloatAttribute< double >::Setter  iSetter 
)
inline

Registers a double attribute with the given name and getter/setter.

◆ registerFloatAttribute()

void registerFloatAttribute ( std::string const &  iName,
typename FloatAttribute< float >::Getter  iGetter,
typename FloatAttribute< float >::Setter  iSetter 
)
inline

Registers a float attribute with the given name and getter/setter.

◆ registerFontAttribute()

void registerFontAttribute ( std::string const &  iName,
typename FontAttribute::Getter  iGetter,
typename FontAttribute::Setter  iSetter 
)
inline

Registers a font attribute with the given name and getter/setter.

◆ registerGradientAttribute()

void registerGradientAttribute ( std::string const &  iName,
typename GradientAttribute::Getter  iGetter,
typename GradientAttribute::Setter  iSetter 
)
inline

Registers a gradient attribute with the given name and getter/setter.

◆ registerIntAttribute()

void registerIntAttribute ( std::string const &  iName,
typename IntegerAttribute< int32_t >::Getter  iGetter,
typename IntegerAttribute< int32_t >::Setter  iSetter 
)
inline

Registers an int attribute with the given name and getter/setter.

◆ registerIntegerAttribute()

void registerIntegerAttribute ( std::string const &  iName,
typename IntegerAttribute< TInt >::Getter  iGetter,
typename IntegerAttribute< TInt >::Setter  iSetter 
)
inline

Registers an Integer (any kind) attribute with the given name and getter/setter.

◆ registerListAttribute()

void registerListAttribute ( std::string const &  iName,
typename ListAttribute< T >::Getter  iGetter,
typename ListAttribute< T >::Setter  iSetter,
AttrValInitList< T > const &  iAttributeValues 
)
inline

Registers a list attribute with the given name and getter/setter.

This kind of attribute is represented in the editor with a drop down list of values: for example "vertical" / "horizontal" and usually maps to an enum of some kind (or in other words, in general T is an enum). The iAttributeValues parameter is an initializer list of pairs (string,T) which makes it easy to initialize. This list is also used to populate the dropdown (in the editor) in the order defined.

Example:

registerListAttribute<EOrientation>("orientation", &MyView::getOrientation, &MyView::setOrientation,
{
{ "vertical", EOrientation::kVertical },
{ "horizontal", EOrientation::kHorizontal }
}

◆ registerMarginAttribute()

void registerMarginAttribute ( std::string const &  iName,
typename MarginAttribute::Getter  iGetter,
typename MarginAttribute::Setter  iSetter 
)
inline

Registers a Margin attribute with the given name and getter/setter.

◆ registerRangeAttribute()

void registerRangeAttribute ( std::string const &  iName,
typename RangeAttribute::Getter  iGetter,
typename RangeAttribute::Setter  iSetter 
)
inline

Registers a Range attribute with the given name and getter/setter.

◆ registerTagAttribute()

void registerTagAttribute ( std::string const &  iName,
typename TagAttribute::Getter  iGetter,
typename TagAttribute::Setter  iSetter 
)
inline

Registers a tag attribute with the given name and getter/setter.

◆ registerVectorStringAttribute()

void registerVectorStringAttribute ( std::string const &  iName,
typename VectorStringAttribute::Getter  iGetter,
typename VectorStringAttribute::Setter  iSetter,
char  iDelimiter = ',',
bool  iSkipEmptyEntries = false 
)
inline

Registers a Range attribute with the given name and getter/setter.

Friends And Related Function Documentation

◆ TCustomViewCreator

friend class TCustomViewCreator
friend

Member Data Documentation

◆ fAttributes

std::map<std::string, std::shared_ptr<ViewAttribute> > fAttributes
private

◆ fBaseViewName

char const* fBaseViewName
private

◆ fDisplayName

char const* fDisplayName
private

◆ fViewName

char const* fViewName
private

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