/** * Create message boxes to test their functionalities */ void lv_test_mbox_1(void) { /* Default object */ lv_obj_t *mbox1 = lv_mbox_create(lv_scr_act(), NULL); lv_obj_set_pos(mbox1, 10, 10); /*Add buttons and modify text*/ static const char * btns2[] = {"Ok", "Cancel", ""}; lv_obj_t *mbox2 = lv_mbox_create(lv_scr_act(), NULL); lv_mbox_add_btns(mbox2, btns2, NULL); lv_mbox_set_text(mbox2, "Message"); lv_obj_set_width(mbox2, LV_HOR_RES / 2); lv_obj_align(mbox2, mbox1, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); /*Add styles*/ static lv_style_t bg; static lv_style_t btn_bg; lv_style_copy(&bg, &lv_style_pretty); lv_style_copy(&btn_bg, &lv_style_pretty); bg.body.padding.hor = 20; bg.body.padding.ver = 20; bg.body.padding.inner = 20; bg.body.main_color = LV_COLOR_BLACK; bg.body.grad_color = LV_COLOR_MARRON; bg.text.color = LV_COLOR_WHITE; btn_bg.body.padding.hor = 10; btn_bg.body.padding.ver = 5; btn_bg.body.padding.inner = 40; btn_bg.body.empty = 1; btn_bg.body.border.color = LV_COLOR_WHITE; btn_bg.text.color = LV_COLOR_WHITE; static lv_style_t btn_rel; lv_style_copy(&btn_rel, &lv_style_btn_rel); btn_rel.body.empty = 1; btn_rel.body.border.color = LV_COLOR_WHITE; lv_obj_t *mbox3 = lv_mbox_create(lv_scr_act(), mbox2); lv_mbox_set_style(mbox3, LV_MBOX_STYLE_BTN_REL, &btn_rel); lv_mbox_set_style(mbox3, LV_MBOX_STYLE_BTN_BG, &btn_bg); lv_mbox_set_style(mbox3, LV_MBOX_STYLE_BG, &bg); lv_obj_align(mbox3, mbox1, LV_ALIGN_OUT_RIGHT_TOP, 10, 0); lv_mbox_set_action(mbox3, mbox_action); /*Copy with styles and set button width*/ lv_obj_t *mbox4 = lv_mbox_create(lv_scr_act(), mbox3); lv_mbox_set_text(mbox4, "A quite long message text which is\n" "manually broken into multiple lines"); static const char * btns3[] = {"Ok", "Cancel", "Third", ""}; lv_mbox_add_btns(mbox4, btns3, mbox_action); lv_obj_align(mbox4, mbox3, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 10); }
static void create_tab3(lv_theme_t * th, lv_obj_t *parent) { lv_obj_t *win = lv_win_create(parent, NULL); lv_win_add_btn(win, SYMBOL_CLOSE, lv_win_close_action); lv_win_add_btn(win, SYMBOL_DOWN, NULL); lv_obj_set_size(win, LV_HOR_RES / 2, LV_VER_RES / 2); lv_obj_set_pos(win, LV_DPI / 20, LV_DPI / 20); lv_obj_set_top(win, true); lv_obj_t *label = lv_label_create(win, NULL); lv_label_set_text(label, "Label in the window"); lv_obj_t *lmeter = lv_lmeter_create(win, NULL); lv_obj_align(lmeter, label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, LV_DPI / 2); lv_lmeter_set_value(lmeter, 70); lv_obj_t *led1 = lv_led_create(win, NULL); lv_obj_align(led1, lmeter, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0); lv_led_on(led1); lv_obj_t *led2 = lv_led_create(win, NULL); lv_obj_align(led2, led1, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 2, 0); lv_led_off(led2); lv_obj_t *page = lv_page_create(parent, NULL); lv_obj_set_size(page, LV_HOR_RES / 3, LV_VER_RES / 2); lv_obj_set_top(page, true); lv_obj_align(page, win, LV_ALIGN_IN_TOP_RIGHT, LV_DPI, LV_DPI); label = lv_label_create(page, NULL); lv_label_set_text(label, "Lorem ipsum dolor sit amet, repudiare voluptatibus pri cu.\n" "Ei mundi pertinax posidonium eum, cum tempor maiorum at,\n" "mea fuisset assentior ad. Usu cu suas civibus iudicabit.\n" "Eum eu congue tempor facilisi. Tale hinc unum te vim.\n" "Te cum populo animal eruditi, labitur inciderint at nec.\n\n" "Eius corpora et quo. Everti voluptaria instructior est id,\n" "vel in falli primis. Mea ei porro essent admodum,\n" "his ei malis quodsi, te quis aeterno his.\n" "Qui tritani recusabo reprehendunt ne,\n" "per duis explicari at. Simul mediocritatem mei et."); //lv_label_set_long_mode(label, LV_LABEL_LONG_BREAK); //lv_obj_set_width(label, lv_page_get_scrl_width(page)); lv_page_set_scrl_fit(page, true, true); static const char * mbox_btn_map[] = {"\211", "\222Got it!", "\211", ""}; lv_obj_t *mbox = lv_mbox_create(parent, NULL); lv_mbox_set_text(mbox, "Click on the window or the page to bring it to the foreground"); lv_mbox_add_btns(mbox, mbox_btn_map, NULL); lv_obj_set_top(mbox, true); }
static void list_create(lv_obj_t *parent) { lv_page_set_style(parent, LV_PAGE_STYLE_BG, &lv_style_transp_fit); lv_page_set_style(parent, LV_PAGE_STYLE_SCRL, &lv_style_transp_fit); lv_page_set_scrl_fit(parent, false, false); lv_page_set_scrl_height(parent, lv_obj_get_height(parent)); lv_page_set_sb_mode(parent, LV_SB_MODE_OFF); /*Create styles for the buttons*/ static lv_style_t style_btn_rel; static lv_style_t style_btn_pr; lv_style_copy(&style_btn_rel, &lv_style_btn_rel); style_btn_rel.body.main_color = LV_COLOR_HEX3(0x333); style_btn_rel.body.grad_color = LV_COLOR_BLACK; style_btn_rel.body.border.color = LV_COLOR_SILVER; style_btn_rel.body.border.width = 1; style_btn_rel.body.border.opa = LV_OPA_50; style_btn_rel.body.radius = 0; lv_style_copy(&style_btn_pr, &style_btn_rel); style_btn_pr.body.main_color = LV_COLOR_MAKE(0x55, 0x96, 0xd8); style_btn_pr.body.grad_color = LV_COLOR_MAKE(0x37, 0x62, 0x90); style_btn_pr.text.color = LV_COLOR_MAKE(0xbb, 0xd5, 0xf1); lv_obj_t *list = lv_list_create(parent, NULL); lv_obj_set_height(list, 2 * lv_obj_get_height(parent) / 3); lv_list_set_style(list, LV_LIST_STYLE_BG, &lv_style_transp_tight); lv_list_set_style(list, LV_LIST_STYLE_SCRL, &lv_style_transp_tight); lv_list_set_style(list, LV_LIST_STYLE_BTN_REL, &style_btn_rel); lv_list_set_style(list, LV_LIST_STYLE_BTN_PR, &style_btn_pr); lv_obj_align(list, NULL, LV_ALIGN_IN_TOP_MID, 0, LV_DPI / 4); lv_list_add(list, SYMBOL_FILE, "New", list_btn_action); lv_list_add(list, SYMBOL_DIRECTORY, "Open", list_btn_action); lv_list_add(list, SYMBOL_TRASH, "Delete", list_btn_action); lv_list_add(list, SYMBOL_EDIT, "Edit", list_btn_action); lv_list_add(list, SYMBOL_SAVE, "Save", list_btn_action); lv_list_add(list, SYMBOL_WIFI, "WiFi", list_btn_action); lv_list_add(list, SYMBOL_GPS, "GPS", list_btn_action); lv_obj_t *mbox= lv_mbox_create(parent, NULL); lv_mbox_set_text(mbox, "Click a button to copy its text to the Text area "); lv_obj_set_width(mbox, LV_HOR_RES - LV_DPI); static const char * mbox_btns[] = {"Got it", ""}; lv_mbox_add_btns(mbox, mbox_btns, NULL); /*The default action is close*/ lv_obj_align(mbox, parent, LV_ALIGN_IN_TOP_MID, 0, LV_DPI / 2); }