• TD 加载界面实现


    一)编写ini文件,用button实现加载界面

    cl_animationWin={
      type="window"
      x=0
      y=0
      w=1024
      h=600
      style="cl_normalwin"
      flags={
        window_splash
      }
    
    ...
    
      cl_picLoadingButton={
        type="button"
        x=425
        y=180
        w=174
        h=174
        style="comWaitBtn"
        flags={
          no_focus
          button_no_offset
          no_event
        }
      }
    ...
    }

    二)代码中实现此功能

    static void initCarLifeAnimation()
    {
        TWidget *loading,*aniLogo;
    
        loading = TObjectGetFromName("cl_picLoadingButton");
        aniLogo = TObjectGetFromName("cl_picLoadingLogo");
    
        TTable *tableLoading = TTableCreate();
        TTable *tableLogo = TTableCreate();
    
        int i = 0;
        char picPath[ANI_PICPATH_CHARMAX]= {0};
        for(i=0; i<ANI_LOADING_PIC_MAX; i++)
        {
            sprintf(picPath,"../style/carlife/car_ic_loading_%02d.png",i+1);
    
            CL_D("----add %d%s 
    ",i,picPath);
            TTableAddString(tableLoading,(Tint)NULL,picPath,-1);
            memset(picPath,0,ANI_PICPATH_CHARMAX);
        }
    
        for(i = 0; i<ANI_LOGO_PIC_MAX; i++)
        {
            sprintf(picPath,"../style/carlife/car_ic_loading_logo%02d.png",i+1);
            CL_D("----add %d %s 
    ",i,picPath);
            TTableAddString(tableLogo,(Tint)NULL,picPath,-1);
            memset(picPath,0,ANI_PICPATH_CHARMAX);
        }
    
        if(clViewInfo&&clViewInfo->animationInfo)
        {
            if(clViewInfo->animationInfo->btnAniLogo==NULL)
            {
                clViewInfo->animationInfo->btnAniLogo = createBtnAnimation(aniLogo,tableLogo,ANI_TIME_INT,1);
                registerAniBtnFinishCBK(clViewInfo->animationInfo->btnAniLogo,animationLogoFinished,animationShowLogo);
            }
            else
            {
                CL_E("[error] last logo animtion hasn't destory.plz check.
    ");
            }
    
            if(clViewInfo->animationInfo->btnAni==NULL)
            {
                clViewInfo->animationInfo->btnAni = createBtnAnimation(loading,tableLoading,ANI_TIME_INT,-1);
                registerAniBtnFinishCBK(clViewInfo->animationInfo->btnAni,animationLogoFinished,NULL);
                startBtnAnimation(clViewInfo->animationInfo->btnAni);
            }
            else
            {
                CL_E("[error] last loading animtion hasn't destory.plz check.
    ");
            }
    
        }
    
        TTableDestroy(tableLoading);
        TTableDestroy(tableLogo);
    
    }

    三)开始加载界面  startBtnAnimation

    四)暂停加载界面 stopBtnAnimation

    五)实现回调函数

    animationShowLogo

    static void animationShowLogo(TWidget *widget)
    {
        TWidget *btn = TObjectGetFromName("cl_picBaiduLabel");
        TwShow(btn);
    }

    animationLogoFinished

    static void animationLogoFinished(TWidget *widget)
    {
        CHECK_POINTER(clViewInfo);
    
        TWidget *loading = TObjectGetFromName("cl_picLoadingButton");
    
        CL_D("%s %d widget %x:laoding %x
    ",__FUNCTION__,__LINE__,(Tuint32)widget,(Tuint32)loading);
    
        if(loading == widget)
        {
            CL_I();
    
            TWidget *btn = TObjectGetFromName("cl_picLoadLogo");
            TwHide(btn);
            btn = TObjectGetFromName("cl_picLoadingButton");
            TwHide(btn);
            btn = TObjectGetFromName("cl_picLoadingLabel");
            TwHide(btn);
    
            btn = TObjectGetFromName("cl_picLoadingLogo");
            TwShow(btn);
    
            if(clViewInfo->animationInfo->btnAniLogo)
            {
                startBtnAnimation(clViewInfo->animationInfo->btnAniLogo);
            }
        }
        else
        {
            if(clViewInfo->isProjected == TRUE)
            {
                clViewInfo->isProjected = FALSE;
                changeView(CL_PROJECTED);
            }
            else
            {
                changeView(CL_Failed);
            }
        }
    }
  • 相关阅读:
    学习笔记
    博客园css
    linux命令随时添加
    spring注解
    springboot常用注解
    Ubuntu(16.04)安装Redis
    Mac OS 10.15 虚拟机安装(提供镜像,安装VMware tools,更改分辨率)
    SSM-员工管理项目实战-CRUD-增删改查
    蓝桥杯 2014届真题 地宫取宝 动态规划解法
    设计模式-工厂方法模式 实战演习 代码实现
  • 原文地址:https://www.cnblogs.com/senior-engineer/p/14026174.html
Copyright © 2020-2023  润新知