cancel
Showing results for 
Search instead for 
Did you mean: 

multiple events or multiple mixins in touchgfx

Roman REITER
Associate III

How can I use multiple events or multiple mixins in touchgfx. I've managed to use only one so far (like here). If I want to use several, I can't pass 2 callbacks to the view's constructor (in Screen1View.cpp).

Screen1View::Screen1View():boxMoveAnimationEndedCallback(this, &Screen1View::boxMoveAnimationEndedHandler), boxClickedCallback(this, &Screen1View::boxClickHandler)  { }

When i select an event in touchgfx the following structure can be see

(in Screen1ViewBase.hpp).

touchgfx::MoveAnimator< touchgfx::Box > box1;

If I use several, the structure is different

touchgfx::ClickListener< touchgfx::MoveAnimator< touchgfx::Box > > box1;

Does somebody has any idea? is it even possible to use multiple mixins?

1 REPLY 1
Osman SOYKURT
ST Employee

Hello RReit.1,

Yes it's possible to use multiple mixins. Let's say you have a TextureMapper (that we call myTextureMapper) with both ClickListener and MoveAnimaor mixins.

In your hpp file file you need to have something like this:

    //Declaration of needed Handlers
    virtual void textureMapperAnimationEndedHandler(const AnimationTextureMapper& src);
    virtual void textureMapperClickHandler(const touchgfx::MoveAnimator< touchgfx::AnimationTextureMapper >& b, const ClickEvent& e);
 
 
    //Callback for Texture mapper : triggered when animation ends
    Callback<FactoryView, const AnimationTextureMapper&> textureMapperAnimationEndedCallback;
 
    //Callback for Texture mapper : triggered when clicked
    Callback<FactoryView, const touchgfx::MoveAnimator< touchgfx::AnimationTextureMapper > &, const ClickEvent&> textureMapperClickedCallback;

Then in your cpp , you'll pass it to the constructor like this :

Screen1View::Screen1View() :
    textureMapperAnimationEndedCallback(this, &FactoryView::textureMapperAnimationEndedHandler),
    textureMapperClickedCallback(this, &FactoryView::textureMapperClickHandler)
{ }

And then you'll associate the widget to the callback in the setupScreen() function for example :

void Screen1View::setupScreen()
{
  myTextureMapper.setTextureMapperAnimationEndedAction(textureMapperAnimationEndedCallback);
    myTextureMapper.setClickAction(textureMapperClickedCallback); 
}

Hope that helps.

/Osman

Osman SOYKURT
ST Software Developer | TouchGFX