Lines Matching refs:ext

97     lv_dropdown_ext_t * ext = lv_obj_allocate_ext_attr(ddlist, sizeof(lv_dropdown_ext_t));  in lv_dropdown_create()  local
98 LV_ASSERT_MEM(ext); in lv_dropdown_create()
99 if(ext == NULL) { in lv_dropdown_create()
105 ext->page = NULL; in lv_dropdown_create()
106 ext->options = NULL; in lv_dropdown_create()
107 ext->symbol = LV_SYMBOL_DOWN; in lv_dropdown_create()
108 ext->text = "Select"; in lv_dropdown_create()
109 ext->static_txt = 1; in lv_dropdown_create()
110 ext->show_selected = 1; in lv_dropdown_create()
111 ext->sel_opt_id = 0; in lv_dropdown_create()
112 ext->sel_opt_id_orig = 0; in lv_dropdown_create()
113 ext->pr_opt_id = LV_DROPDOWN_PR_NONE; in lv_dropdown_create()
114 ext->option_cnt = 0; in lv_dropdown_create()
115 ext->dir = LV_DROPDOWN_DIR_DOWN; in lv_dropdown_create()
116 ext->max_height = (3 * lv_disp_get_ver_res(NULL)) / 4; in lv_dropdown_create()
117 lv_style_list_init(&ext->style_page); in lv_dropdown_create()
118 lv_style_list_init(&ext->style_scrlbar); in lv_dropdown_create()
119 lv_style_list_init(&ext->style_selected); in lv_dropdown_create()
138 ext->option_cnt = copy_ext->option_cnt; in lv_dropdown_create()
139 ext->sel_opt_id = copy_ext->sel_opt_id; in lv_dropdown_create()
140 ext->sel_opt_id_orig = copy_ext->sel_opt_id; in lv_dropdown_create()
141 ext->symbol = copy_ext->symbol; in lv_dropdown_create()
142 ext->max_height = copy_ext->max_height; in lv_dropdown_create()
143 ext->text = copy_ext->text; in lv_dropdown_create()
144 ext->dir = copy_ext->dir; in lv_dropdown_create()
145 ext->show_selected = copy_ext->show_selected; in lv_dropdown_create()
146 lv_style_list_copy(&ext->style_page, &copy_ext->style_page); in lv_dropdown_create()
147 lv_style_list_copy(&ext->style_selected, &copy_ext->style_selected); in lv_dropdown_create()
148 lv_style_list_copy(&ext->style_scrlbar, &copy_ext->style_scrlbar); in lv_dropdown_create()
168 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_set_text() local
169 if(ext->text == txt) return; in lv_dropdown_set_text()
171 ext->text = txt; in lv_dropdown_set_text()
183 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_clear_options() local
184 if(ext->options == NULL) return; in lv_dropdown_clear_options()
186 if(ext->static_txt == 0) in lv_dropdown_clear_options()
187 lv_mem_free(ext->options); in lv_dropdown_clear_options()
189 ext->options = NULL; in lv_dropdown_clear_options()
190 ext->static_txt = 0; in lv_dropdown_clear_options()
191 ext->option_cnt = 0; in lv_dropdown_clear_options()
207 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_set_options() local
210 ext->option_cnt = 0; in lv_dropdown_set_options()
213 if(options[i] == '\n') ext->option_cnt++; in lv_dropdown_set_options()
215 ext->option_cnt++; /*Last option has no `\n`*/ in lv_dropdown_set_options()
216 ext->sel_opt_id = 0; in lv_dropdown_set_options()
217 ext->sel_opt_id_orig = 0; in lv_dropdown_set_options()
221 if(ext->options != NULL && ext->static_txt == 0) { in lv_dropdown_set_options()
222 lv_mem_free(ext->options); in lv_dropdown_set_options()
223 ext->options = NULL; in lv_dropdown_set_options()
226 ext->options = lv_mem_alloc(len); in lv_dropdown_set_options()
228 LV_ASSERT_MEM(ext->options); in lv_dropdown_set_options()
229 if(ext->options == NULL) return; in lv_dropdown_set_options()
231 strcpy(ext->options, options); in lv_dropdown_set_options()
234 ext->static_txt = 0; in lv_dropdown_set_options()
247 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_set_options_static() local
250 ext->option_cnt = 0; in lv_dropdown_set_options_static()
253 if(options[i] == '\n') ext->option_cnt++; in lv_dropdown_set_options_static()
255 ext->option_cnt++; /*Last option has no `\n`*/ in lv_dropdown_set_options_static()
256 ext->sel_opt_id = 0; in lv_dropdown_set_options_static()
257 ext->sel_opt_id_orig = 0; in lv_dropdown_set_options_static()
259 if(ext->static_txt == 0 && ext->options != NULL) { in lv_dropdown_set_options_static()
260 lv_mem_free(ext->options); in lv_dropdown_set_options_static()
261 ext->options = NULL; in lv_dropdown_set_options_static()
264 ext->static_txt = 1; in lv_dropdown_set_options_static()
265 ext->options = (char *)options; in lv_dropdown_set_options_static()
279 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_add_option() local
282 if(ext->static_txt != 0) { in lv_dropdown_add_option()
283 char * static_options = ext->options; in lv_dropdown_add_option()
286 ext->options = lv_mem_alloc(len); in lv_dropdown_add_option()
287 LV_ASSERT_MEM(ext->options); in lv_dropdown_add_option()
288 if(ext->options == NULL) return; in lv_dropdown_add_option()
290 strcpy(ext->options, static_options); in lv_dropdown_add_option()
291 ext->static_txt = 0; in lv_dropdown_add_option()
295 size_t old_len = (ext->options == NULL) ? 0 : strlen(ext->options); in lv_dropdown_add_option()
298 ext->options = lv_mem_realloc(ext->options, new_len + 1); in lv_dropdown_add_option()
299 LV_ASSERT_MEM(ext->options); in lv_dropdown_add_option()
300 if(ext->options == NULL) return; in lv_dropdown_add_option()
302 ext->options[old_len] = 0; in lv_dropdown_add_option()
308 for(insert_pos = 0; ext->options[insert_pos] != 0; insert_pos++) { in lv_dropdown_add_option()
311 if(ext->options[insert_pos] == '\n') in lv_dropdown_add_option()
317 if((insert_pos > 0) && (pos >= ext->option_cnt)) in lv_dropdown_add_option()
318 _lv_txt_ins(ext->options, _lv_txt_encoded_get_char_id(ext->options, insert_pos++), "\n"); in lv_dropdown_add_option()
325 if(pos < ext->option_cnt) in lv_dropdown_add_option()
327 _lv_txt_ins(ext->options, _lv_txt_encoded_get_char_id(ext->options, insert_pos), ins_buf); in lv_dropdown_add_option()
330 ext->option_cnt++; in lv_dropdown_add_option()
344 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_set_selected() local
345 if(ext->sel_opt_id == sel_opt) return; in lv_dropdown_set_selected()
347 ext->sel_opt_id = sel_opt < ext->option_cnt ? sel_opt : ext->option_cnt - 1; in lv_dropdown_set_selected()
348 ext->sel_opt_id_orig = ext->sel_opt_id; in lv_dropdown_set_selected()
350 if(ext->page != NULL) { in lv_dropdown_set_selected()
364 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_set_dir() local
365 if(ext->dir == dir) return; in lv_dropdown_set_dir()
367 ext->dir = dir; in lv_dropdown_set_dir()
381 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_set_max_height() local
382 if(ext->max_height == h) return; in lv_dropdown_set_max_height()
384 ext->max_height = h; in lv_dropdown_set_max_height()
386 if(ext->page) { in lv_dropdown_set_max_height()
388 lv_cont_set_fit(ext->page, LV_FIT_TIGHT); in lv_dropdown_set_max_height()
391 lv_cont_set_fit2(ext->page, LV_FIT_TIGHT, LV_FIT_NONE); in lv_dropdown_set_max_height()
392 lv_obj_set_height(ext->page, h); in lv_dropdown_set_max_height()
406 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_set_symbol() local
407 ext->symbol = symbol; in lv_dropdown_set_symbol()
420 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_set_show_selected() local
421 if(ext->show_selected == show) return; in lv_dropdown_set_show_selected()
423 ext->show_selected = show; in lv_dropdown_set_show_selected()
440 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_get_text() local
442 return ext->text; in lv_dropdown_get_text()
454 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_get_options() local
455 return ext->options; in lv_dropdown_get_options()
467 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_get_selected() local
469 return ext->sel_opt_id; in lv_dropdown_get_selected()
481 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_get_option_cnt() local
483 return ext->option_cnt; in lv_dropdown_get_option_cnt()
496 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_get_selected_str() local
500 size_t txt_len = strlen(ext->options); in lv_dropdown_get_selected_str()
502 for(i = 0; i < txt_len && line != ext->sel_opt_id_orig; i++) { in lv_dropdown_get_selected_str()
503 if(ext->options[i] == '\n') line++; in lv_dropdown_get_selected_str()
507 for(c = 0; i < txt_len && ext->options[i] != '\n'; c++, i++) { in lv_dropdown_get_selected_str()
512 buf[c] = ext->options[i]; in lv_dropdown_get_selected_str()
527 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_get_max_height() local
528 return ext->max_height; in lv_dropdown_get_max_height()
540 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_get_symbol() local
542 return ext->symbol; in lv_dropdown_get_symbol()
554 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_get_dir() local
556 return ext->dir; in lv_dropdown_get_dir()
568 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_get_show_selected() local
570 return ext->show_selected ? true : false; in lv_dropdown_get_show_selected()
584 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_open() local
585 if(ext->page) return; in lv_dropdown_open()
587 ext->page = lv_page_create(lv_obj_get_screen(ddlist), NULL); in lv_dropdown_open()
588 lv_obj_add_protect(ext->page, LV_PROTECT_POS | LV_PROTECT_CLICK_FOCUS); in lv_dropdown_open()
589 lv_obj_add_protect(lv_page_get_scrollable(ext->page), LV_PROTECT_CLICK_FOCUS); in lv_dropdown_open()
591 lv_obj_set_base_dir(ext->page, lv_obj_get_base_dir(ddlist)); in lv_dropdown_open()
593 if(ancestor_page_signal == NULL) ancestor_page_signal = lv_obj_get_signal_cb(ext->page); in lv_dropdown_open()
595ext->page)); in lv_dropdown_open()
596 if(ancestor_page_design == NULL) ancestor_page_design = lv_obj_get_design_cb(ext->page); in lv_dropdown_open()
598 …lv_dropdown_page_ext_t * page_ext = lv_obj_allocate_ext_attr(ext->page, sizeof(lv_dropdown_page_ex… in lv_dropdown_open()
601 lv_obj_del(ext->page); in lv_dropdown_open()
602 ext->page = NULL; in lv_dropdown_open()
607 lv_obj_set_design_cb(ext->page, lv_dropdown_page_design); in lv_dropdown_open()
608 lv_obj_set_signal_cb(ext->page, lv_dropdown_page_signal); in lv_dropdown_open()
609 lv_obj_set_signal_cb(lv_page_get_scrollable(ext->page), lv_dropdown_page_scrl_signal); in lv_dropdown_open()
611 lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_BG), &ext->style_page); in lv_dropdown_open()
612 … lv_style_list_copy(lv_obj_get_style_list(ext->page, LV_PAGE_PART_SCROLLBAR), &ext->style_scrlbar); in lv_dropdown_open()
613 lv_obj_clean_style_list(ext->page, LV_PAGE_PART_SCROLLABLE); in lv_dropdown_open()
614 lv_obj_refresh_style(ext->page, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); in lv_dropdown_open()
616 lv_obj_t * label = lv_label_create(ext->page, NULL); in lv_dropdown_open()
617 lv_label_set_text_static(label, ext->options); in lv_dropdown_open()
619 lv_cont_set_fit2(ext->page, LV_FIT_TIGHT, LV_FIT_NONE); in lv_dropdown_open()
621 if(lv_obj_get_width(ext->page) < lv_obj_get_width(ddlist) && in lv_dropdown_open()
622 (ext->dir == LV_DROPDOWN_DIR_UP || ext->dir == LV_DROPDOWN_DIR_DOWN)) { in lv_dropdown_open()
623 lv_cont_set_fit2(ext->page, LV_FIT_NONE, LV_FIT_NONE); in lv_dropdown_open()
624 lv_obj_set_width(ext->page, lv_obj_get_width(ddlist)); in lv_dropdown_open()
633 if(list_h > ext->max_height) list_h = ext->max_height; in lv_dropdown_open()
635 lv_dropdown_dir_t dir = ext->dir; in lv_dropdown_open()
637 if(ext->dir == LV_DROPDOWN_DIR_DOWN) { in lv_dropdown_open()
650 else if(ext->dir == LV_DROPDOWN_DIR_UP) { in lv_dropdown_open()
664 if(list_h > ext->max_height) list_h = ext->max_height; in lv_dropdown_open()
666 lv_obj_set_height(ext->page, list_h); in lv_dropdown_open()
670 …if(dir == LV_DROPDOWN_DIR_DOWN) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_BOTTOM_LEFT, 0, … in lv_dropdown_open()
671 … else if(dir == LV_DROPDOWN_DIR_UP) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_TOP_LEFT, 0, 0); in lv_dropdown_open()
672 … else if(dir == LV_DROPDOWN_DIR_LEFT) lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_LEFT_TOP, 0, 0); in lv_dropdown_open()
673 …else if(dir == LV_DROPDOWN_DIR_RIGHT)lv_obj_align(ext->page, ddlist, LV_ALIGN_OUT_RIGHT_TOP, 0, 0); in lv_dropdown_open()
675 if(ext->dir == LV_DROPDOWN_DIR_LEFT || ext->dir == LV_DROPDOWN_DIR_RIGHT) { in lv_dropdown_open()
676 if(ext->page->coords.y2 > LV_VER_RES) { in lv_dropdown_open()
677 lv_obj_set_y(ext->page, lv_obj_get_y(ext->page) - (ext->page->coords.y2 - LV_VER_RES)); in lv_dropdown_open()
682 lv_obj_set_x(label, lv_obj_get_width_fit(ext->page) - lv_obj_get_width(label)); in lv_dropdown_open()
692 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_close() local
693 if(ext->page == NULL) return; in lv_dropdown_close()
695 ext->pr_opt_id = LV_DROPDOWN_PR_NONE; in lv_dropdown_close()
696 lv_obj_del(ext->page); in lv_dropdown_close()
697 ext->page = NULL; in lv_dropdown_close()
724 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_design() local
737 const char * opt_txt = ext->text; in lv_dropdown_design()
738 if(ext->show_selected) { in lv_dropdown_design()
747 if(ext->dir == LV_DROPDOWN_DIR_LEFT) rev = true; in lv_dropdown_design()
750 txt = rev ? ext->symbol : opt_txt; in lv_dropdown_design()
759 if(ext->symbol == NULL && txt == opt_txt) { in lv_dropdown_design()
770 txt = rev ? opt_txt : ext->symbol; in lv_dropdown_design()
778 if(ext->symbol == NULL && txt == opt_txt) { in lv_dropdown_design()
790 if(ext->show_selected) { in lv_dropdown_design()
824 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_page_design() local
827 if(ext->page) { in lv_dropdown_page_design()
832 has_common = _lv_area_intersect(&clip_area_core, clip_area, &ext->page->coords); in lv_dropdown_page_design()
834 if(ext->pr_opt_id != LV_DROPDOWN_PR_NONE) { in lv_dropdown_page_design()
835 draw_box(ddlist, &clip_area_core, ext->pr_opt_id, LV_STATE_PRESSED); in lv_dropdown_page_design()
838 draw_box(ddlist, &clip_area_core, ext->sel_opt_id, LV_STATE_DEFAULT); in lv_dropdown_page_design()
850 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_page_design() local
853 if(ext->page) { in lv_dropdown_page_design()
858 has_common = _lv_area_intersect(&clip_area_core, clip_area, &ext->page->coords); in lv_dropdown_page_design()
860 if(ext->pr_opt_id != LV_DROPDOWN_PR_NONE) { in lv_dropdown_page_design()
861 draw_box_label(ddlist, &clip_area_core, ext->pr_opt_id, LV_STATE_PRESSED); in lv_dropdown_page_design()
864 draw_box_label(ddlist, &clip_area_core, ext->sel_opt_id, LV_STATE_DEFAULT); in lv_dropdown_page_design()
888 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_signal() local
901 info->result = lv_obj_get_state(ext->page, LV_PAGE_PART_BG); in lv_dropdown_signal()
906 if(ext->static_txt == 0) { in lv_dropdown_signal()
907 lv_mem_free(ext->options); in lv_dropdown_signal()
908 ext->options = NULL; in lv_dropdown_signal()
913 _lv_style_list_reset(&ext->style_page); in lv_dropdown_signal()
914 _lv_style_list_reset(&ext->style_scrlbar); in lv_dropdown_signal()
915 _lv_style_list_reset(&ext->style_selected); in lv_dropdown_signal()
940 if(ext->page) { in lv_dropdown_signal()
942 if(ext->sel_opt_id_orig != ext->sel_opt_id) { in lv_dropdown_signal()
943 ext->sel_opt_id_orig = ext->sel_opt_id; in lv_dropdown_signal()
944 uint32_t id = ext->sel_opt_id; /*Just to use uint32_t in event data*/ in lv_dropdown_signal()
961 ext->sel_opt_id = ext->sel_opt_id_orig; in lv_dropdown_signal()
966 if(ext->page) lv_dropdown_close(ddlist); in lv_dropdown_signal()
974 if(ext->page) lv_obj_refresh_style(ext->page, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); in lv_dropdown_signal()
980 if(ext->page == NULL) { in lv_dropdown_signal()
983 else if(ext->sel_opt_id + 1 < ext->option_cnt) { in lv_dropdown_signal()
984 ext->sel_opt_id++; in lv_dropdown_signal()
990 if(ext->page == NULL) { in lv_dropdown_signal()
993 else if(ext->sel_opt_id > 0) { in lv_dropdown_signal()
994 ext->sel_opt_id--; in lv_dropdown_signal()
999 ext->sel_opt_id = ext->sel_opt_id_orig; in lv_dropdown_signal()
1051 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_page_signal() local
1052 ext->page = NULL; /*The page is just being deleted*/ in lv_dropdown_page_signal()
1077 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_page_scrl_signal() local
1088 ext->pr_opt_id = LV_DROPDOWN_PR_NONE; in lv_dropdown_page_scrl_signal()
1114 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in lv_dropdown_get_style() local
1122 style_dsc_p = &ext->style_page; in lv_dropdown_get_style()
1125 style_dsc_p = &ext->style_scrlbar; in lv_dropdown_get_style()
1128 style_dsc_p = &ext->style_selected; in lv_dropdown_get_style()
1139 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in draw_box() local
1140 lv_obj_t * page = ext->page; in draw_box()
1161 rect_area.x1 = ext->page->coords.x1; in draw_box()
1162 rect_area.x2 = ext->page->coords.x2; in draw_box()
1177 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in draw_box_label() local
1178 lv_obj_t * page = ext->page; in draw_box_label()
1231 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in page_release_handler() local
1237 ext->sel_opt_id_orig = ext->sel_opt_id; in page_release_handler()
1249 ext->sel_opt_id = get_id_on_point(ddlist, p.x, p.y); in page_release_handler()
1250 ext->sel_opt_id_orig = ext->sel_opt_id; in page_release_handler()
1256 if(ext->show_selected) lv_obj_invalidate(ddlist); in page_release_handler()
1258 uint32_t id = ext->sel_opt_id; /*Just to use uint32_t in event data*/ in page_release_handler()
1261 if(ext->page == NULL) return LV_RES_INV; in page_release_handler()
1271 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in page_press_handler() local
1277 ext->pr_opt_id = get_id_on_point(ddlist, p.x, p.y); in page_press_handler()
1317 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in position_to_selected() local
1321 lv_obj_t * scrl = lv_page_get_scrollable(ext->page); in position_to_selected()
1325 lv_coord_t h = lv_obj_get_height(ext->page); in position_to_selected()
1328 … lv_coord_t line_y1 = ext->sel_opt_id * (font_h + line_space) + label->coords.y1 - scrl->coords.y1; in position_to_selected()
1331 lv_obj_invalidate(ext->page); in position_to_selected()
1338 lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(ddlist); in get_label() local
1339 if(ext->page == NULL) return NULL; in get_label()
1341 return lv_obj_get_child(lv_page_get_scrollable(ext->page), NULL); in get_label()