static void player_entry(void* parameter) { rt_mq_t mq; rtgui_rect_t rect; mq = rt_mq_create("ply_ui", 256, 4, RT_IPC_FLAG_FIFO); rtgui_thread_register(rt_thread_self(), mq); /* create information timer */ info_timer = rtgui_timer_create(RT_TICK_PER_SECOND, RT_TIMER_FLAG_PERIODIC, info_timer_timeout, RT_NULL); workbench = rtgui_workbench_create("main", "workbench"); if (workbench == RT_NULL) return; rtgui_widget_set_event_handler(RTGUI_WIDGET(workbench), player_workbench_event_handler); /* add home view */ home_view = rtgui_view_create("Home"); rtgui_widget_set_event_handler(RTGUI_WIDGET(home_view), home_view_event_handler); rtgui_workbench_add_view(workbench, home_view); /* this view can be focused */ RTGUI_WIDGET(home_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; /* set widget focus */ rtgui_widget_focus(RTGUI_WIDGET(home_view)); rtgui_widget_get_rect(RTGUI_WIDGET(home_view), &rect); rect.x1 += 6; rect.y1 += 150 + 25; rect.x2 = rect.x1 + 228; rect.y2 = rect.y1 + 145; music_listbox = rtgui_listbox_create(RT_NULL, 0, &rect); /* none focusable widget */ RTGUI_WIDGET(music_listbox)->flag &= ~RTGUI_WIDGET_FLAG_FOCUSABLE; RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(music_listbox)) = black; RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(music_listbox)) = white; rtgui_container_add_child(RTGUI_CONTAINER(home_view), RTGUI_WIDGET(music_listbox)); rtgui_listbox_set_onitem(music_listbox, player_play_list_onitem); rtgui_view_show(home_view, RT_FALSE); /* add function view */ rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect); function_view = rtgui_list_view_create(function_list, sizeof(function_list)/sizeof(struct rtgui_list_item), &rect, RTGUI_LIST_VIEW_LIST); rtgui_workbench_add_view(workbench, RTGUI_VIEW(function_view)); rtgui_workbench_event_loop(workbench); rtgui_thread_deregister(rt_thread_self()); rt_mq_delete(mq); }
static void info_entry(void* parameter) { rt_mq_t mq; struct rtgui_view* view; struct rtgui_workbench* workbench; mq = rt_mq_create("qInfo", 256, 4, RT_IPC_FLAG_FIFO); rtgui_thread_register(rt_thread_self(), mq); workbench = rtgui_workbench_create("info", "workbench"); if(workbench == RT_NULL) return; view = rtgui_view_create("view"); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white; RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(view)) = black; rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler); rtgui_workbench_add_view(workbench, view); /* this view can be focused */ RTGUI_WIDGET(view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; /* set widget focus */ rtgui_widget_focus(RTGUI_WIDGET(view)); rtgui_view_show(view, RT_FALSE); rtgui_workbench_event_loop(workbench); rtgui_thread_deregister(rt_thread_self()); rt_mq_delete(mq); }
static void info_entry(void* parameter) { rt_mq_t mq; struct rtgui_view* view; struct rtgui_workbench* workbench; mq = rt_mq_create("qInfo", 256, 4, RT_IPC_FLAG_FIFO); rtgui_thread_register(rt_thread_self(), mq); network_image = rtgui_image_create_from_mem("xpm", (rt_uint8_t*)network_xpm, sizeof(network_xpm), RT_TRUE); workbench = rtgui_workbench_create("info", "workbench"); if (workbench == RT_NULL) return; view = rtgui_view_create("view"); RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white; rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler); rtgui_workbench_add_view(workbench, view); rtgui_view_show(view, RT_FALSE); rtgui_workbench_event_loop(workbench); rtgui_thread_deregister(rt_thread_self()); rt_mq_delete(mq); }
static void today_entry(void* parameter) { rt_mq_t mq; struct rtgui_view* view; struct rtgui_workbench* workbench; mq = rt_mq_create("qToday", 256, 4, RT_IPC_FLAG_FIFO); rtgui_thread_register(rt_thread_self(), mq); /* create background image */ background = rtgui_image_create_from_file("png", "/bg.png", RT_FALSE); workbench = rtgui_workbench_create("main", "workbench"); if (workbench == RT_NULL) return; view = rtgui_view_create("Today"); rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler); rtgui_workbench_add_view(workbench, view); rtgui_view_show(view); rtgui_workbench_event_loop(workbench); rtgui_thread_deregister(rt_thread_self()); rt_mq_delete(mq); }
/* select a station from list */ struct station_item* station_list_select(struct station_list* list, struct rtgui_workbench* workbench) { rt_size_t index; rtgui_rect_t rect; rtgui_list_view_t *view; struct rtgui_list_item* items; struct station_item* station; char exit_str[] = "их╗п.."; RT_ASSERT(list != RT_NULL); RT_ASSERT(workbench != RT_NULL); station = RT_NULL; items = (struct rtgui_list_item*) rt_malloc (sizeof(struct rtgui_list_item) * (list->count + 1)); if (items == RT_NULL) return RT_NULL; /* no memory */ /* create view */ rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect); view = rtgui_list_view_create(items, list->count + 1, &rect, RTGUI_LIST_VIEW_LIST); items[0].image = RT_NULL; items[0].action = station_list_selected; items[0].name = exit_str; items[0].parameter = view; for (index = 1; index < list->count + 1; index ++) { items[index].image = RT_NULL; items[index].action = station_list_selected; items[index].name = list->items[index - 1].title; items[index].parameter = view; } /* add view to workbench */ rtgui_workbench_add_view(workbench, RTGUI_VIEW(view)); /* show view as modal */ if (rtgui_view_show(RTGUI_VIEW(view), RT_TRUE) == RTGUI_MODAL_OK) { station = &list->items[view->current_item - 1]; } /* destroy view */ rtgui_list_view_destroy(view); /* release items */ rt_free(items); return station; }
void setting_ui(rtgui_workbench_t* workbench) { rtgui_rect_t rect; father_workbench = workbench; /* add function view */ rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect); function_view = rtgui_list_view_create(function_list, sizeof(function_list) / sizeof(struct rtgui_list_item), &rect, RTGUI_LIST_VIEW_LIST); rtgui_workbench_add_view(workbench, RTGUI_VIEW(function_view)); rtgui_view_show(RTGUI_VIEW(function_view), RT_FALSE); }
void workbench_panel1(void* parameter) { rt_mq_t mq; rtgui_view_t* view; rtgui_label_t* label; struct rtgui_workbench* workbench; rtgui_rect_t rect; mq = rt_mq_create("wmq", 256, 8, RT_IPC_FLAG_FIFO); /* 注册当前线程为GUI线程 */ rtgui_thread_register(rt_thread_self(), mq); /* 创建一个工作台 */ workbench = rtgui_workbench_create("main", "workbench #1"); if (workbench == RT_NULL) return; view = rtgui_view_create("view"); if (view == RT_NULL) return; /* 指定视图的背景色 */ RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white; /* 添加一个label */ label = rtgui_label_create("hello RT-Thread!"); rect.x1 = 10; rect.y1 = 10; rect.x2 = 210; rect.y2 = 30; /* 设置label的位置 */ rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); /* 添加到父workbench中 */ rtgui_workbench_add_view(workbench, view); /* 创建图片视图 */ view = picture_view_create(workbench); /* 非模式方式显示视图 */ rtgui_view_show(view, RT_FALSE); /* 执行工作台事件循环 */ rtgui_workbench_event_loop(workbench); /* 去注册GUI线程 */ rtgui_thread_deregister(rt_thread_self()); /* delete message queue */ rt_mq_delete(mq); }
rtgui_view_t *picture_view_create_view_file(struct rtgui_workbench* workbench, const char* filename) { strcpy(current_fn, filename); /* create picture view */ picture_view = rtgui_view_create("Picture Presentation"); rtgui_widget_set_event_handler(RTGUI_WIDGET(picture_view), picture_view_event_handler); rtgui_workbench_add_view(workbench, picture_view); /* this view can be focused */ RTGUI_WIDGET(picture_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; view_mode = VIEW_SINGLE_MODE; return picture_view; }
rtgui_view_t *picture_view_create(struct rtgui_workbench* workbench) { /* create picture view */ picture_view = rtgui_view_create("Picture Presentation"); rtgui_widget_set_event_handler(RTGUI_WIDGET(picture_view), picture_view_event_handler); rtgui_workbench_add_view(workbench, picture_view); /* this view can be focused */ RTGUI_WIDGET(picture_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; /* show next picture */ picture_show_next(); view_mode = VIEW_DIR_MODE; return picture_view; }
/* 打开列表视图用的按钮触发函数 */ static void open_btn_onbutton(rtgui_widget_t* widget, struct rtgui_event* event) { rtgui_rect_t rect; rt_uint32_t index; /* 获得顶层的workbench */ workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget)); rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect); /* 初始化图标列表 */ if (items == RT_NULL) { char item_name[32]; items = (struct rtgui_list_item *) rtgui_malloc((ITEM_MAX + 1) * sizeof(struct rtgui_list_item)); for (index = 0; index < ITEM_MAX; index ++) { rt_snprintf(item_name, sizeof(item_name), "图标%d", index); items[index].action = listitem_action; items[index].image = item_icon; items[index].name = rt_strdup(item_name); items[index].parameter = (void*) index; } items[ITEM_MAX].action = return_action; items[ITEM_MAX].image = exit_icon; items[ITEM_MAX].name = "退出"; items[ITEM_MAX].parameter = RT_NULL; } /* 创建一个列表视图, 项指定为items */ _view = rtgui_list_view_create(items, ITEM_MAX + 1, &rect, RTGUI_LIST_VIEW_ICON); /* 在workbench中添加相应的视图 */ rtgui_workbench_add_view(workbench, RTGUI_VIEW(_view)); /* 模式显示视图 */ rtgui_view_show(RTGUI_VIEW(_view), RT_TRUE); rtgui_view_destroy(RTGUI_VIEW(_view)); _view = RT_NULL; }
rtgui_view_t *device_view_create(rtgui_workbench_t* workbench) { if (device_view != RT_NULL) { rtgui_view_show(device_view, RT_FALSE); } else { /* create a view */ device_view = rtgui_view_create("Device Info"); /* set view event handler */ rtgui_widget_set_event_handler(RTGUI_WIDGET(device_view), view_event_handler); /* this view can be focused */ RTGUI_WIDGET(device_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; /* add view to workbench */ rtgui_workbench_add_view(workbench, device_view); } return device_view; }
rtgui_view_t *update_radio_list_view_create(rtgui_workbench_t* workbench) { if (update_radio_list_view != RT_NULL) { rtgui_view_show(update_radio_list_view, RT_FALSE); } else { /* create a view */ update_radio_list_view = rtgui_view_create("update radio list Info"); /* set view event handler */ rtgui_widget_set_event_handler(RTGUI_WIDGET(update_radio_list_view), update_radio_list_view_event_handler); /* this view can be focused */ RTGUI_WIDGET(update_radio_list_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; /* add view to workbench */ rtgui_workbench_add_view(workbench, update_radio_list_view); } return update_radio_list_view; }
rtgui_view_t *picture_view_create_view_list(struct rtgui_workbench* workbench, const char* list[], rt_uint8_t size) { picture_fn_list = list; picture_fn_list_size = size; picture_fn_list_current = 0; strcpy(current_fn, picture_fn_list[picture_fn_list_current]); /* create picture view */ picture_view = rtgui_view_create("Picture Presentation"); rtgui_widget_set_event_handler(RTGUI_WIDGET(picture_view), picture_view_event_handler); rtgui_workbench_add_view(workbench, picture_view); /* this view can be focused */ RTGUI_WIDGET(picture_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE; view_mode = VIEW_FN_LIST_MODE; return picture_view; }
/* 创建一个演示视图,需提供父workbench和演示用的标题 */ rtgui_view_t* demo_view(rtgui_workbench_t* workbench, const char* title) { struct rtgui_view* view; /* 设置视图的名称 */ view = rtgui_view_create(title); if (view == RT_NULL) return RT_NULL; /* 创建成功后,添加到数组中 */ demo_view_list[demo_view_number] = view; demo_view_number ++; /* 添加到父workbench中 */ rtgui_workbench_add_view(workbench, view); /* 添加下一个视图和前一个视图按钮 */ { struct rtgui_rect rect; struct rtgui_button *next_btn, *prev_btn; struct rtgui_label *label; struct rtgui_staticline *line; /* 获得视图的位置信息(在加入到workbench中时,workbench会自动调整视图的大小) */ rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect); rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect); rect.x1 += 5; rect.y1 += 5; rect.x2 -= 5; rect.y2 = rect.y1 + 20; /* 创建标题用的标签 */ label = rtgui_label_create(title); /* 设置标签位置信息 */ rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); /* 添加标签到视图中 */ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); rect.y1 += 20; rect.y2 += 20; /* 创建一个水平的staticline线 */ line = rtgui_staticline_create(RTGUI_HORIZONTAL); /* 设置静态线的位置信息 */ rtgui_widget_set_rect(RTGUI_WIDGET(line), &rect); /* 添加静态线到视图中 */ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(line)); /* 获得视图的位置信息 */ rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect); rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect); rect.x2 -= 5; rect.y2 -= 5; rect.x1 = rect.x2 - 100; rect.y1 = rect.y2 - 25; /* 创建"下一个"按钮 */ next_btn = rtgui_button_create("下一个"); /* 设置onbutton动作到demo_view_next函数 */ rtgui_button_set_onbutton(next_btn, demo_view_next); /* 设置按钮的位置信息 */ rtgui_widget_set_rect(RTGUI_WIDGET(next_btn), &rect); /* 添加按钮到视图中 */ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(next_btn)); /* 获得视图的位置信息 */ rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect); rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect); rect.x1 += 5; rect.y2 -= 5; rect.x2 = rect.x1 + 100; rect.y1 = rect.y2 - 25; /* 创建"上一个"按钮 */ prev_btn = rtgui_button_create("上一个"); /* 设置onbutton动作到demo_view_prev函数 */ rtgui_button_set_onbutton(prev_btn, demo_view_prev); /* 设置按钮的位置信息 */ rtgui_widget_set_rect(RTGUI_WIDGET(prev_btn), &rect); /* 添加按钮到视图中 */ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(prev_btn)); } /* 返回创建的视图 */ return view; }
static void function_action_setup(struct rtgui_widget* widget, void* paramter) { rtgui_view_t* view; rtgui_rect_t rect; rtgui_label_t* label; struct rtgui_button* cancel_button, *apply_button, *save_button; rtgui_workbench_t* workbench = father_workbench; /* create a demo view */ view = rtgui_view_create("Slider View"); /* 添加到父workbench中 */ rtgui_workbench_add_view(workbench, view); //设置服务函数 rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler); /* get demo view rect */ rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect); rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect); label = rtgui_label_create("默认音量:"); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); rect.x1 += 5; rect.x2 -= 5; rect.y1 += 5; rect.y2 = rect.y1 + 18; rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); rect.y1 += 20; rect.y2 = rect.y1 + 18; slider_volume = rtgui_slider_create(0, 100, RTGUI_HORIZONTAL); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(slider_volume)); rtgui_widget_set_rect(RTGUI_WIDGET(slider_volume), &rect); rtgui_slider_set_value(slider_volume, radio_setup.default_volume); /* get demo view rect */ rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect); rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect); label = rtgui_label_create("LCD背光亮度:"); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); rect.x1 += 5; rect.x2 -= 5; rect.y1 += 50; rect.y2 = rect.y1 + 18; rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); rect.y1 += 20; rect.y2 = rect.y1 + 18; slider_brightness = rtgui_slider_create(0, 100, RTGUI_HORIZONTAL); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(slider_brightness)); rtgui_widget_set_rect(RTGUI_WIDGET(slider_brightness), &rect); rtgui_slider_set_value(slider_brightness, radio_setup.lcd_brightness); //得到 "取消" 按键的位置 rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect); rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect); rect.x1 += 20; rect.x2 = rect.x1 + 60; rect.y2 -= 20; rect.y1 = rect.y2 - 20; //创建 "取消" 按钮(兼返回) cancel_button = rtgui_button_create("取消"); /* 设置onbutton动作到demo_view_next函数 */ rtgui_button_set_onbutton(cancel_button, cancel_handler); /* 设置按钮的位置信息 */ rtgui_widget_set_rect(RTGUI_WIDGET(cancel_button), &rect); /* 添加按钮到视图中 */ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(cancel_button)); rect.x1 = rect.x2 + 10; rect.x2 = rect.x1 + 60; apply_button = rtgui_button_create("应用"); /* 设置onbutton动作到demo_view_next函数 */ rtgui_button_set_onbutton(apply_button, apply_handler); /* 设置按钮的位置信息 */ rtgui_widget_set_rect(RTGUI_WIDGET(apply_button), &rect); /* 添加按钮到视图中 */ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(apply_button)); //得到 "保存" 按键的位置 rtgui_widget_get_rect(RTGUI_WIDGET(view), &rect); rtgui_widget_rect_to_device(RTGUI_WIDGET(view), &rect); rect.x2 -= 20; rect.x1 = rect.x2 - 60; rect.y2 -= 20; rect.y1 = rect.y2 - 20; /* 创建 "保存" 按钮 */ save_button = rtgui_button_create("保存"); /* 设置onbutton动作到demo_view_prev函数 */ rtgui_button_set_onbutton(save_button, save_handler); /* 设置按钮的位置信息 */ rtgui_widget_set_rect(RTGUI_WIDGET(save_button), &rect); /* 添加按钮到视图中 */ rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(save_button)); rtgui_view_show(view, RT_FALSE); }
static rt_bool_t home_view_event_handler(struct rtgui_widget* widget, struct rtgui_event* event) { if (event->type == RTGUI_EVENT_PAINT) { struct rtgui_dc* dc; struct rtgui_rect rect; rtgui_image_t *background; /* draw child */ rtgui_view_event_handler(widget, event); dc = rtgui_dc_begin_drawing(widget); if (dc == RT_NULL) return RT_FALSE; rtgui_widget_get_rect(widget, &rect); /* draw background */ background = rtgui_image_create_from_file("hdc", "/resource/bg.hdc", RT_FALSE); if (background != RT_NULL) { rtgui_image_blit(background, dc, &rect); rtgui_image_destroy(background); } else { rtgui_dc_fill_rect(dc, &rect); } /* draw playing information */ player_update_tag_info(); rtgui_dc_end_drawing(dc); return RT_FALSE; } else if (event->type == RTGUI_EVENT_KBD) { struct rtgui_event_kbd* ekbd = (struct rtgui_event_kbd*)event; if (ekbd->type == RTGUI_KEYDOWN) { if ((ekbd->key == RTGUIK_LEFT) || (ekbd->key == RTGUIK_RIGHT)) { if (player_mode == PLAYER_STOP) { rtgui_view_show(RTGUI_VIEW(function_view), RT_FALSE); } else { rt_device_t dev = rt_device_find("snd"); if (ekbd->key == RTGUIK_LEFT && radio_setup.default_volume > 0) { radio_setup.default_volume--; rt_device_control(dev, CODEC_CMD_VOLUME, &radio_setup.default_volume); } else if (ekbd->key == RTGUIK_RIGHT && radio_setup.default_volume < CODEC_VOLUME_MAX) { radio_setup.default_volume++; rt_device_control(dev, CODEC_CMD_VOLUME, &radio_setup.default_volume); } } } else { return RTGUI_WIDGET(music_listbox)->event_handler(RTGUI_WIDGET(music_listbox), event); } } return RT_FALSE; } else if (event->type == RTGUI_EVENT_MOUSE_BUTTON) { struct rtgui_event_mouse* emouse; emouse = (struct rtgui_event_mouse*)event; if (emouse->button & RTGUI_MOUSE_BUTTON_UP) { if (rtgui_rect_contains_point(&next_btn_rect, emouse->x, emouse->y) == RT_EOK) player_onbutton(NEXT_BUTTON); else if (rtgui_rect_contains_point(&prev_btn_rect, emouse->x, emouse->y) == RT_EOK) player_onbutton(PREV_BUTTON); else if (rtgui_rect_contains_point(&playing_btn_rect, emouse->x, emouse->y) == RT_EOK) player_onbutton(PLAYING_BUTTON); } } else if (event->type == RTGUI_EVENT_COMMAND) { struct rtgui_event_command* ecmd = (struct rtgui_event_command*)event; switch (ecmd->command_id) { case PLAYER_REQUEST_PLAY_SINGLE_FILE: case PLAYER_REQUEST_PLAY_LIST: rtgui_timer_start(info_timer); return RT_TRUE; case PLAYER_REQUEST_STOP: { struct play_item *item = RT_NULL; /* if it's radio mode, set next mode to stop */ if (player_mode == PLAYER_PLAY_RADIO) next_step = PLAYER_STEP_STOP; /* set player mode */ player_mode = PLAYER_STOP; switch (next_step) { case PLAYER_STEP_NEXT: /* play next */ item = play_list_next(play_list_get_mode()); break; case PLAYER_STEP_PREV: /* play prev */ item = play_list_prev(play_list_get_mode()); break; case PLAYER_STEP_SEEK: /* play current item */ item = play_list_current(); } if (item != RT_NULL) player_play_item(item); else { player_mode = PLAYER_STOP; rtgui_timer_stop(info_timer); } /* update tag information */ player_update_tag_info(); } return RT_TRUE; case PLAYER_REQUEST_FREEZE: { /* stop play */ if (player_is_playing() == RT_TRUE) { player_stop(); } /* delay some tick */ rt_thread_delay(50); /* show a modal view */ { rtgui_view_t *view; rtgui_label_t *label; rtgui_rect_t rect = {0, 0, 150, 150}, container_rect; rtgui_graphic_driver_get_default_rect(&container_rect); /* set centre */ rtgui_rect_moveto_align(&container_rect, &rect, RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL); view = rtgui_view_create("USB"); rtgui_workbench_add_view(workbench, view); /* set container to window rect */ container_rect = rect; rect.x1 = 0; rect.y1 = 0; rect.x2 = 120; rect.y2 = 20; label = rtgui_label_create("USB 联机中..."); rtgui_rect_moveto_align(&container_rect, &rect, RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL); rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect); rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label)); rtgui_view_show(view, RT_TRUE); /* never reach hear */ } } case PLAYER_REQUEST_UPDATE_INFO: /* update status information */ player_update_tag_info(); return RT_TRUE; default: break; } return RT_FALSE; } return rtgui_view_event_handler(widget, event); }