• TouchGFX之Mixins


    Mixin类扩展控件的功能,例如使之能够将移动或透明度值变化制作成动画。 在Move Animator和Fade Animator Mixin的基础上,TouchGFX Designer交互能够生成将移动或透明度值变化制作成动画的代码。 这些Mixin可通过TouchGFX Designer或在用户代码中手动添加到控件。

    Move Animator Mixin使控件能够将从当前位置到指定结束位置的移动制作成动画。

    Fade Animator Mixin使控件能够将其从当前透明度值至指定结束透明度值的渐隐过程制作成动画。 

    Click Listener Mixin用回调扩展控件,使控件能够响应触控输入。

    Draggable mixin使控件能够通过触控输入被四处拖拽。

    下面创建四个box,分别勾选Mixin的四种扩展功能来做这个实验

    代码实现点击box3之后,box1线性循环移动,box2线性循环渐隐

    1. #ifndef SCREENVIEW_HPP
    2. #define SCREENVIEW_HPP
    3. #include
    4. #include
    5. class screenView : public screenViewBase
    6. {
    7. public:
    8. screenView();
    9. virtual ~screenView() {}
    10. virtual void setupScreen();
    11. virtual void tearDownScreen();
    12. void boxMoveAnimationEndedHandler(const touchgfx::MoveAnimator& comp);
    13. void boxClickHandler(const Box& b, const ClickEvent& e);
    14. protected:
    15. Callback const touchgfx::MoveAnimator&> boxMoveAnimationEndedCallback;
    16. Callbackconst Box&, const ClickEvent&> boxClickedCallback;
    17. private:
    18. uint8_t tag;
    19. };
    20. #endif // SCREENVIEW_HPP
    1. #include
    2. screenView::screenView() : boxMoveAnimationEndedCallback(this, &screenView::boxMoveAnimationEndedHandler), boxClickedCallback(this, &screenView::boxClickHandler), tag(0)
    3. {
    4. }
    5. void screenView::setupScreen()
    6. {
    7. screenViewBase::setupScreen();
    8. box3.setClickAction(boxClickedCallback);
    9. box1.setMoveAnimationEndedAction(boxMoveAnimationEndedCallback);
    10. }
    11. void screenView::tearDownScreen()
    12. {
    13. screenViewBase::tearDownScreen();
    14. }
    15. void screenView::boxClickHandler(const Box& b, const ClickEvent& evt)
    16. {
    17. if (&b == &box3)
    18. {
    19. box1.startMoveAnimation(0, 0, 40, EasingEquations::linearEaseNone, EasingEquations::linearEaseNone);
    20. box2.startFadeAnimation(0, 40, EasingEquations::linearEaseNone);
    21. }
    22. }
    23. void screenView::boxMoveAnimationEndedHandler(const touchgfx::MoveAnimator& b)
    24. {
    25. if (&b == &box1)
    26. {
    27. if(tag == 0)
    28. {
    29. tag = 1;
    30. box1.startMoveAnimation(200, 200, 40, EasingEquations::linearEaseNone, EasingEquations::linearEaseNone);
    31. box2.startFadeAnimation(255, 40, EasingEquations::linearEaseNone);
    32. }
    33. else
    34. {
    35. tag = 0;
    36. box1.startMoveAnimation(0, 0, 40, EasingEquations::linearEaseNone, EasingEquations::linearEaseNone);
    37. box2.startFadeAnimation(0, 40, EasingEquations::linearEaseNone);
    38. }
    39. }
    40. }

    运行模拟器

  • 相关阅读:
    Vite2.0+Vue3.0+Element-Plus+TypeScript 项目配置及初始化
    vue Element Plus组件自动引入
    软件项目管理第一章---项目管理概念
    hypermesh 圆周阵列-插件
    MediaCodec 同步方式完成AAC硬解成PCM
    Flutter混编之路IOS插件0基础开发(mac环境)
    基于信息融合的风电机组关键部件状态识别
    【网络层】DHCP协议(应用层)、ICMP、IPv6详解
    HTML 标签简写及全称
    【Echarts】曲线图上方显示数字以及自定义值,标题和副标题居中,鼠标上显示信息以及自定义信息
  • 原文地址:https://blog.csdn.net/lushoumin/article/details/133552538