参考TUI组件仓库
准备代码:
下面通过TUI基础控件,实现一个时钟表盘复杂组件的逻辑,TUI提供用户自定义组件,也可以在UIStudio上增加自己的创意组件。实现代码在这里
时钟组件代码调用
void tui_com_clock_test(void)
{
tui_obj_t * obj;
tui_com_clock_attri_t attri = { 0 };//注意先清空结构体,避免随机值
obj = tui_com_clock_create(tui_layer_top());
/* 通用属性 */
attri.obj.pt.x = 1024-382;
attri.obj.pt.y = 60;
attri.obj.size.width = 382;
attri.obj.size.height = 382;
attri.bg_img_path = "V:\\image\\clock_bg.png";
attri.bg_img_pt.x = 0;
attri.bg_img_pt.y = 0;
attri.point_h_img_path = "V:\\image\\point_h.png";
attri.point_h_img_pt.x = 186;
attri.point_h_img_pt.y = 108;
attri.point_h_img_rotate_pt.x = 6;
attri.point_h_img_rotate_pt.y = 78;
attri.point_m_img_path = "V:\\image\\point_m.png";
attri.point_m_img_pt.x = 185;
attri.point_m_img_pt.y = 66;
attri.point_m_img_rotate_pt.x = 7;
attri.point_m_img_rotate_pt.y = 120;
attri.point_s_img_path = "V:\\image\\point_s.png";
attri.point_s_img_pt.x = 185;
attri.point_s_img_pt.y = 71;
attri.point_s_img_rotate_pt.x = 7;
attri.point_s_img_rotate_pt.y = 115;
tui_com_clock_set_attri(obj, &attri);
}
运行效果:
注意
上面是时钟的组件,同样也可以应用于仪表盘等领域