TouchGFX 2 Screen
Screen 是TouchGFX的基础容器,界面资源管理的主要单元。
- Screen是显示时才会实例化,因此,不同Screen直接是不能互相访问的。
- Screen可以通过FrontendApplication实例来相互转跳。
创建
新建项目会自动创建一个默认screen,也可以通过箭头所指按钮添加新的Screen。
点击Generate Code生成代码,打开工程目录,进入simulator/msvc/通过visual studio,编辑代码。
如果VS版本较高,则需要重定向目标解决方案版本
生成代码
designer会生成一个基类,一个子类;一般在子类中添加自己的功能代码;
- 每个基类都会自动添加一个FrontendApplication实例,用以Screen切换等全局操作;
- 如果在designer中选择了canvas buffer, 也会在基类中生成相关代码;
主要函数:
- setupScreen() 主要用于界面的初始配置
/**
* Called by Application::switchScreen() when this screen is going to be displayed. Base
* version does nothing, but place any screen specific initialization code in an
* overridden version.
*
* @see Application::switchScreen
*/
virtual void setupScreen()
- afterTransition() 切换效果完成回调
/**
* Called by Application::handleTickEvent() when the transition to the screen is done. Base
* version does nothing, but override to do screen specific initialization code that has
* to be done after the transition to the screen.
*
* @see Application::handleTickEvent
*/
virtual void afterTransition()
- tearDownScreen() Screen退出时会被调用,可以做一