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线性循环渐隐

cpp 复制代码
#ifndef SCREENVIEW_HPP
#define SCREENVIEW_HPP

#include <gui_generated/screen_screen/screenViewBase.hpp>
#include <gui/screen_screen/screenPresenter.hpp>

class screenView : public screenViewBase
{
public:
    screenView();
    virtual ~screenView() {}
    virtual void setupScreen();
    virtual void tearDownScreen();
		void boxMoveAnimationEndedHandler(const touchgfx::MoveAnimator<Box>& comp);
		void boxClickHandler(const Box& b, const ClickEvent& e);
			
protected:
		Callback <screenView, const touchgfx::MoveAnimator<Box>&> boxMoveAnimationEndedCallback;
		Callback<screenView, const Box&, const ClickEvent&> boxClickedCallback;
private:
		uint8_t tag;
};

#endif // SCREENVIEW_HPP
cpp 复制代码
#include <gui/screen_screen/screenView.hpp>

screenView::screenView() : boxMoveAnimationEndedCallback(this, &screenView::boxMoveAnimationEndedHandler), boxClickedCallback(this, &screenView::boxClickHandler), tag(0)
{

}

void screenView::setupScreen()
{
    screenViewBase::setupScreen();
		box3.setClickAction(boxClickedCallback);
		box1.setMoveAnimationEndedAction(boxMoveAnimationEndedCallback);
}

void screenView::tearDownScreen()
{
    screenViewBase::tearDownScreen();
}

void screenView::boxClickHandler(const Box& b, const ClickEvent& evt)
{
    if (&b == &box3)
    {
			box1.startMoveAnimation(0, 0, 40, EasingEquations::linearEaseNone, EasingEquations::linearEaseNone);
			box2.startFadeAnimation(0, 40, EasingEquations::linearEaseNone);
    }
}

void screenView::boxMoveAnimationEndedHandler(const touchgfx::MoveAnimator<touchgfx::Box>& b)
{
    if (&b == &box1)
    {
			if(tag == 0)
			{
				tag = 1;
        box1.startMoveAnimation(200, 200, 40, EasingEquations::linearEaseNone, EasingEquations::linearEaseNone);
				box2.startFadeAnimation(255, 40, EasingEquations::linearEaseNone);
			}
			else
			{
				tag = 0;
				box1.startMoveAnimation(0, 0, 40, EasingEquations::linearEaseNone, EasingEquations::linearEaseNone);
				box2.startFadeAnimation(0, 40, EasingEquations::linearEaseNone);
			}
    }
}

运行模拟器

相关推荐
待什么青丝8 小时前
【TMS570LC4357】之相关驱动开发学习记录2
c语言·arm开发·驱动开发·单片机·学习
szxinmai主板定制专家10 小时前
【飞腾AI加固服务器】全国产化飞腾+昇腾310+PCIe Switch的AI大模型服务器解决方案
运维·服务器·arm开发·人工智能·fpga开发
小狗爱吃黄桃罐头15 小时前
正点原子[第三期]Arm(iMX6U)Linux移植学习笔记-12.1 Linux内核启动流程简介
linux·arm开发·学习
m0_6371469317 小时前
嵌入式全栈面试指南:TCP/IP、C 语言基础、STM32 外设与 RT‑Thread
arm开发
satadriver3 天前
Qemu arm操作系统开发环境
arm开发
待什么青丝4 天前
【TMS570LC4357】之相关驱动开发学习记录1
c语言·arm开发·驱动开发·学习
南玖yy5 天前
x86 汇编逻辑运算全解析:从【位操作】到实际应用(AND,OR,NOT,XOR,TEST)
开发语言·汇编·arm开发·后端·架构·策略模式
菜只因C6 天前
嵌入式系统:从技术原理到未来趋势(驱动程序篇)
arm开发
!chen8 天前
鲲鹏Arm+麒麟V10 K8s 离线部署教程
java·arm开发·kubernetes
ScilogyHunter8 天前
ARM P15协处理器指令详解:架构、编程与应用实践
arm开发·协处理器指令·cp15