杰理-侧边的滑动条显示
// struct slide_show_param{ //滑动条
// u16 timer; //定时器id
// u32 id; //需要显示控件的id
// u16 min; //top最顶上的值
// u16 max; //最顶上加最低下的值,绝对值
// u8 move_flag; //显示标志位,大于0显示
// };
struct slide_show_param slide;
void energy_slide(struct ui_grid *grid)
{
struct rect rect;
ui_core_get_element_abs_rect(&grid->item[0].elm , &rect);
// printf(" %d ",rect.top);
u16 cur = 0;
u8 percent = 0;
if(rect.top >= 0)
{
if(slide.min > rect.top)
cur = slide.min - rect.top;
else
cur = 0;
}
else
{
cur = abs(rect.top) + slide.min;
}
// printf("-------- %d ",cur);
if(cur != 0)
percent = (cur*100)/slide.max;
else
percent = 0;
if(percent >=97)
percent =97; //限制滑到最下面的时候最大为97,控件图片叠加颜色不一样
percent = 100 - percent; //反过来显示
// printf("------------------ %d ",percent);
if(slide.move_flag)
{
slide.move_flag -= 1;
show_id_layout(slide.id);
ui_vslider_set_persent_by_id(slide.id, percent);
}
else
{
hide_id_layout(slide.id);
}
}
void show_slide_move(struct ui_grid *grid,bool enable)
{
if(enable)
{
// key_ui_takeover(1); //编码器控制--暂时放下
if(slide.timer == 0)
{
slide.timer = sys_timer_add(grid,energy_slide,20);
}
}
else
{
// key_ui_takeover(0);
if(slide.timer)
{
sys_timer_del(slide.timer);
slide.timer = 0;
}
}
}