Lines Matching +full:- +full:- +full:include
9 #include "lv_roller_private.h"
10 #include "../label/lv_label_private.h"
11 #include "../../misc/lv_area_private.h"
12 #include "../../misc/lv_anim_private.h"
13 #include "../../core/lv_obj_private.h"
14 #include "../../core/lv_obj_class_private.h"
17 #include "../../misc/lv_assert.h"
18 #include "../../misc/lv_text_private.h"
19 #include "../../draw/lv_draw_private.h"
20 #include "../../core/lv_group.h"
21 #include "../../indev/lv_indev.h"
22 #include "../../indev/lv_indev_scroll.h"
23 #include "../../indev/lv_indev_private.h"
24 #include "../../stdlib/lv_string.h"
105 .name = "roller-label",
136 roller->sel_opt_id = 0; in lv_roller_set_options()
137 roller->sel_opt_id_ori = 0; in lv_roller_set_options()
139 /*Count the '\n'-s to determine the number of options*/ in lv_roller_set_options()
140 roller->option_cnt = 0; in lv_roller_set_options()
143 if(options[cnt] == '\n') roller->option_cnt++; in lv_roller_set_options()
145 roller->option_cnt++; /*Last option has no `\n`*/ in lv_roller_set_options()
148 roller->mode = LV_ROLLER_MODE_NORMAL; in lv_roller_set_options()
152 roller->mode = LV_ROLLER_MODE_INFINITE; in lv_roller_set_options()
155 …int32_t normal_h = roller->option_cnt * (lv_font_get_line_height(font) + lv_obj_get_style_text_let… in lv_roller_set_options()
156 roller->inf_page_cnt = LV_CLAMP(3, EXTRA_INF_SIZE / normal_h, 15); in lv_roller_set_options()
157 if(!(roller->inf_page_cnt & 1)) roller->inf_page_cnt++; /*Make it odd*/ in lv_roller_set_options()
158 … LV_LOG_INFO("Using %" LV_PRIu32 " pages to make the roller look infinite", roller->inf_page_cnt); in lv_roller_set_options()
161 size_t opt_extra_len = opt_len * roller->inf_page_cnt; in lv_roller_set_options()
169 for(i = 0; i < roller->inf_page_cnt; i++) { in lv_roller_set_options()
171 opt_extra[opt_len * (i + 1) - 1] = '\n'; in lv_roller_set_options()
173 opt_extra[opt_extra_len - 1] = '\0'; in lv_roller_set_options()
177 roller->sel_opt_id = ((roller->inf_page_cnt / 2) + 0) * roller->option_cnt; in lv_roller_set_options()
179 roller->option_cnt = roller->option_cnt * roller->inf_page_cnt; in lv_roller_set_options()
183 roller->sel_opt_id_ori = roller->sel_opt_id; in lv_roller_set_options()
200 if(roller->mode == LV_ROLLER_MODE_INFINITE) { in lv_roller_set_selected()
201 uint32_t real_option_cnt = roller->option_cnt / roller->inf_page_cnt; in lv_roller_set_selected()
202 uint32_t current_page = roller->sel_opt_id / real_option_cnt; in lv_roller_set_selected()
206 uint32_t act_opt = roller->sel_opt_id - current_page * real_option_cnt; in lv_roller_set_selected()
209 if((uint32_t)LV_ABS((int16_t)(act_opt - sel_opt)) > real_option_cnt / 2) { in lv_roller_set_selected()
211 else sel_opt_signed -= real_option_cnt; in lv_roller_set_selected()
217 roller->sel_opt_id = sel_opt < roller->option_cnt ? sel_opt : roller->option_cnt - 1; in lv_roller_set_selected()
218 roller->sel_opt_id_ori = roller->sel_opt_id; in lv_roller_set_selected()
236 if(lv_strncmp(&options[line_start], sel_opt, i - line_start) == 0) { in lv_roller_set_selected_str()
269 if(roller->mode == LV_ROLLER_MODE_INFINITE) { in lv_roller_get_selected()
270 uint32_t real_id_cnt = roller->option_cnt / roller->inf_page_cnt; in lv_roller_get_selected()
271 return roller->sel_opt_id % real_id_cnt; in lv_roller_get_selected()
274 return roller->sel_opt_id; in lv_roller_get_selected()
289 for(i = 0; i < txt_len && line != roller->sel_opt_id; i++) { in lv_roller_get_selected_str()
295 if(buf_size && c >= buf_size - 1) { in lv_roller_get_selected_str()
308 * @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
322 if(roller->mode == LV_ROLLER_MODE_INFINITE) { in lv_roller_get_option_count()
323 return roller->option_cnt / roller->inf_page_cnt; in lv_roller_get_option_count()
326 return roller->option_cnt; in lv_roller_get_option_count()
339 roller->mode = LV_ROLLER_MODE_NORMAL; in lv_roller_constructor()
340 roller->option_cnt = 0; in lv_roller_constructor()
341 roller->sel_opt_id = 0; in lv_roller_constructor()
342 roller->sel_opt_id_ori = 0; in lv_roller_constructor()
372 p->x = get_selected_label_width(obj); in lv_roller_event()
385 if(roller->option_cnt <= 1) return; in lv_roller_event()
387 roller->moved = 0; in lv_roller_event()
391 if(roller->option_cnt <= 1) return; in lv_roller_event()
400 roller->moved = 1; in lv_roller_event()
404 if(roller->option_cnt <= 1) return; in lv_roller_event()
418 roller->sel_opt_id_ori = roller->sel_opt_id; in lv_roller_event()
421 if(roller->sel_opt_id != roller->sel_opt_id_ori) { in lv_roller_event()
422 roller->sel_opt_id = roller->sel_opt_id_ori; in lv_roller_event()
430 roller->sel_opt_id_ori = roller->sel_opt_id; in lv_roller_event()
435 if(roller->sel_opt_id != roller->sel_opt_id_ori) { in lv_roller_event()
436 roller->sel_opt_id = roller->sel_opt_id_ori; in lv_roller_event()
441 if(roller->option_cnt <= 1) return; in lv_roller_event()
445 if(roller->sel_opt_id + 1 < roller->option_cnt) { in lv_roller_event()
446 … uint32_t ori_id = roller->sel_opt_id_ori; /*lv_roller_set_selected will overwrite this*/ in lv_roller_event()
447 lv_roller_set_selected(obj, roller->sel_opt_id + 1, LV_ANIM_ON); in lv_roller_event()
448 roller->sel_opt_id_ori = ori_id; in lv_roller_event()
452 if(roller->sel_opt_id > 0) { in lv_roller_event()
453 … uint32_t ori_id = roller->sel_opt_id_ori; /*lv_roller_set_selected will overwrite this*/ in lv_roller_event()
454 lv_roller_set_selected(obj, roller->sel_opt_id - 1, LV_ANIM_ON); in lv_roller_event()
455 roller->sel_opt_id_ori = ori_id; in lv_roller_event()
460 if(roller->option_cnt <= 1) return; in lv_roller_event()
463 int32_t new_id = roller->sel_opt_id + r; in lv_roller_event()
464 new_id = LV_CLAMP(0, new_id, (int32_t)roller->option_cnt - 1); in lv_roller_event()
465 if((int32_t)roller->sel_opt_id != new_id) { in lv_roller_event()
466 uint32_t ori_id = roller->sel_opt_id_ori; /*lv_roller_set_selected will overwrite this*/ in lv_roller_event()
468 roller->sel_opt_id_ori = ori_id; in lv_roller_event()
501 *s = LV_MAX(*s, sel_w - label_w); in lv_roller_label_event()
540 area_ok = lv_area_intersect(&mask_sel, &layer->_clip_area, &sel_area); in draw_main()
554 …int32_t label_y_prop = (label->coords.y1 + normal_label_font->line_height / 2) - (roller_h / 2 + o… in draw_main()
558 int32_t remain_h = lv_obj_get_height(label) - normal_label_font->line_height; in draw_main()
565 int32_t corr = label_dsc.font->line_height; in draw_main()
568 int32_t label_sel_y = roller_h / 2 + obj->coords.y1; in draw_main()
569 label_sel_y += ((label_sel_size.y - corr) * label_y_prop) >> 14; in draw_main()
570 label_sel_y -= corr / 2; in draw_main()
578 label_sel_area.x1 = obj->coords.x1 + pleft + bwidth; in draw_main()
580 label_sel_area.x2 = obj->coords.x2 - pright - bwidth; in draw_main()
584 const lv_area_t clip_area_ori = layer->_clip_area; in draw_main()
585 layer->_clip_area = mask_sel; in draw_main()
588 layer->_clip_area = clip_area_ori; in draw_main()
609 const lv_area_t clip_area_ori = layer->_clip_area; in draw_label()
611 if(!lv_area_intersect(&roller_clip_area, &layer->_clip_area, &roller->coords)) return; in draw_label()
612 layer->_clip_area = roller_clip_area; in draw_label()
618 clip2.x1 = label_obj->coords.x1; in draw_label()
619 clip2.y1 = label_obj->coords.y1; in draw_label()
620 clip2.x2 = label_obj->coords.x2; in draw_label()
622 if(lv_area_intersect(&clip2, &layer->_clip_area, &clip2)) { in draw_label()
623 const lv_area_t clip_area_ori2 = layer->_clip_area; in draw_label()
624 layer->_clip_area = clip2; in draw_label()
626 lv_draw_label(layer, &label_draw_dsc, &label_obj->coords); in draw_label()
627 layer->_clip_area = clip_area_ori2; in draw_label()
630 clip2.x1 = label_obj->coords.x1; in draw_label()
632 clip2.x2 = label_obj->coords.x2; in draw_label()
633 clip2.y2 = label_obj->coords.y2; in draw_label()
634 if(lv_area_intersect(&clip2, &layer->_clip_area, &clip2)) { in draw_label()
635 const lv_area_t clip_area_ori2 = layer->_clip_area; in draw_label()
636 layer->_clip_area = clip2; in draw_label()
638 lv_draw_label(layer, &label_draw_dsc, &label_obj->coords); in draw_label()
639 layer->_clip_area = clip_area_ori2; in draw_label()
642 layer->_clip_area = clip_area_ori; in draw_label()
654 sel_area->y1 = obj->coords.y1 + lv_obj_get_height(obj) / 2 - d / 2; in get_sel_area()
655 sel_area->y2 = sel_area->y1 + d; in get_sel_area()
659 sel_area->x1 = roller_coords.x1; in get_sel_area()
660 sel_area->x2 = roller_coords.x2; in get_sel_area()
665 * Refresh the position of the roller. It uses the id stored in: roller->ddlist.selected_option_id
679 x = (lv_obj_get_content_width(obj) - lv_obj_get_width(label)) / 2; in refr_position()
682 x = lv_obj_get_content_width(obj) - lv_obj_get_width(label); in refr_position()
707 int32_t id = roller->sel_opt_id; in refr_position()
709 const int32_t mid_y1 = h / 2 - font_h / 2; in refr_position()
710 const int32_t new_y = mid_y1 - sel_y1; in refr_position()
740 roller->sel_opt_id_ori = roller->sel_opt_id; in release_handler()
752 int16_t new_opt = -1; in release_handler()
753 if(roller->moved == 0) { in release_handler()
757 p.y -= label->coords.y1; in release_handler()
758 p.x -= label->coords.x1; in release_handler()
782 int32_t mid = obj->coords.y1 + (obj->coords.y2 - obj->coords.y1) / 2; in release_handler()
784 lv_point_t p = indev->pointer.scroll_throw_vect_ori; in release_handler()
787 int32_t scroll_throw = indev->scroll_throw; in release_handler()
792 v = v * (100 - scroll_throw) / 100; in release_handler()
795 int32_t label_y1 = label->coords.y1 + sum; in release_handler()
796 int32_t id = (mid - label_y1) / label_unit; in release_handler()
799 if(id >= (int32_t)roller->option_cnt) id = roller->option_cnt - 1; in release_handler()
809 uint32_t id = roller->sel_opt_id; /*Just to use uint32_t in event data*/ in release_handler()
822 if(roller->mode == LV_ROLLER_MODE_INFINITE) { in inf_normalize()
823 uint32_t real_id_cnt = roller->option_cnt / roller->inf_page_cnt; in inf_normalize()
824 roller->sel_opt_id = roller->sel_opt_id % real_id_cnt; in inf_normalize()
825 roller->sel_opt_id += (roller->inf_page_cnt / 2) * real_id_cnt; /*Select the middle page*/ in inf_normalize()
827 roller->sel_opt_id_ori = roller->sel_opt_id % real_id_cnt; in inf_normalize()
828 … roller->sel_opt_id_ori += (roller->inf_page_cnt / 2) * real_id_cnt; /*Select the middle page*/ in inf_normalize()
838 int32_t sel_y1 = roller->sel_opt_id * (font_h + line_space); in inf_normalize()
839 int32_t mid_y1 = h / 2 - font_h / 2; in inf_normalize()
840 int32_t new_y = mid_y1 - sel_y1; in inf_normalize()
865 lv_obj_t * obj = lv_obj_get_parent(a->var); /*The label is animated*/ in scroll_anim_completed_cb()
900 lv_point_transform(vect, -angle, scale_x, scale_y, &pivot, false); in transform_vect_recursive()