diff options
author | Jaeun Choi <jaeun12.choi@samsung.com> | 2019-01-24 16:32:19 +0900 |
---|---|---|
committer | Jaeun Choi <jaeun12.choi@samsung.com> | 2019-01-25 13:47:37 +0900 |
commit | 4dc8712aba0e83f6ea22c8e11f99fe61c953fd5e (patch) | |
tree | 5e1a24bce075df60c6d33306a856261ff5c9fad9 /src/lib/elementary/efl_page_transition_scroll.c | |
parent | 0b63181113e105fd6f93005d1a69816d9670ce6e (diff) |
efl_page_transition_scroll: remove _content_show() function
_content_show() function was used in page_info_geometry_change() and
_efl_page_transition_scroll_loop_set() function since they need to
show/hide page info objects in common. but using a common function
made each function inefficient and buggy.
this patch removes _content_show() function.
Diffstat (limited to '')
-rw-r--r-- | src/lib/elementary/efl_page_transition_scroll.c | 173 |
1 files changed, 101 insertions, 72 deletions
diff --git a/src/lib/elementary/efl_page_transition_scroll.c b/src/lib/elementary/efl_page_transition_scroll.c index 165ebb5e2a..19c4acd82c 100644 --- a/src/lib/elementary/efl_page_transition_scroll.c +++ b/src/lib/elementary/efl_page_transition_scroll.c | |||
@@ -64,68 +64,14 @@ _page_info_allocate(Efl_Page_Transition_Scroll_Data *pd, | |||
64 | pd->tail->next = pd->head; | 64 | pd->tail->next = pd->head; |
65 | } | 65 | } |
66 | 66 | ||
67 | static void | ||
68 | _content_show(Efl_Page_Transition_Scroll_Data *pd, | ||
69 | Efl_Page_Transition_Data *spd) | ||
70 | { | ||
71 | Eina_List *list; | ||
72 | Page_Info *pi; | ||
73 | int tmp_id; | ||
74 | Eo *tmp; | ||
75 | int curr_page, cnt; | ||
76 | |||
77 | curr_page = efl_ui_pager_current_page_get(spd->pager.obj); | ||
78 | cnt = efl_content_count(spd->pager.obj); | ||
79 | |||
80 | // at this point, the number of visible pages might have been changed, | ||
81 | // so empty all boxes and refill them with the right contents. | ||
82 | // FIXME make logic efficient: don't have to empty all and fill all the time | ||
83 | EINA_LIST_FOREACH(pd->page_infos, list, pi) | ||
84 | { | ||
85 | if (pi->content) | ||
86 | { | ||
87 | efl_pack_unpack(pi->obj, pi->content); | ||
88 | efl_canvas_object_clip_set(pi->content, pd->backclip); | ||
89 | |||
90 | pi->content_num = -1; | ||
91 | pi->content = NULL; | ||
92 | pi->visible = EINA_FALSE; | ||
93 | } | ||
94 | efl_canvas_object_clip_set(pi->obj, pd->backclip); | ||
95 | } | ||
96 | |||
97 | EINA_LIST_FOREACH(pd->page_infos, list, pi) | ||
98 | { | ||
99 | if ((pi == pd->head) || (pi == pd->tail)) continue; | ||
100 | |||
101 | tmp_id = (curr_page + pi->pos + cnt) % cnt; | ||
102 | |||
103 | if ((spd->loop == EFL_UI_PAGER_LOOP_DISABLED) | ||
104 | && ((pi->pos) * (tmp_id - curr_page) < 0)) continue; | ||
105 | |||
106 | tmp = efl_pack_content_get(spd->pager.obj, tmp_id); | ||
107 | if (tmp) | ||
108 | { | ||
109 | efl_canvas_object_clip_set(pi->obj, pd->foreclip); | ||
110 | |||
111 | efl_pack(pi->obj, tmp); | ||
112 | efl_canvas_object_clip_set(tmp, pd->foreclip); | ||
113 | |||
114 | pi->content_num = tmp_id; | ||
115 | pi->content = tmp; | ||
116 | pi->visible = EINA_TRUE; | ||
117 | } | ||
118 | } | ||
119 | } | ||
120 | |||
121 | //FIXME use ecore_job | 67 | //FIXME use ecore_job |
122 | static void | 68 | static void |
123 | _page_info_geometry_change(Efl_Page_Transition_Scroll_Data *pd, | 69 | _page_info_geometry_change(Efl_Page_Transition_Scroll_Data *pd, |
124 | Efl_Page_Transition_Data *spd) | 70 | Efl_Page_Transition_Data *spd) |
125 | { | 71 | { |
126 | Eina_List *list; | 72 | Page_Info *curr; |
127 | Page_Info *pi; | 73 | Eo *tmp; |
128 | int content_w; | 74 | int content_w, tmp_id, curr_page, cnt; |
129 | 75 | ||
130 | content_w = (spd->page_spec.sz.w * (pd->side_page_num * 2 + 1)) | 76 | content_w = (spd->page_spec.sz.w * (pd->side_page_num * 2 + 1)) |
131 | + (spd->page_spec.padding * pd->side_page_num * 2); | 77 | + (spd->page_spec.padding * pd->side_page_num * 2); |
@@ -149,34 +95,76 @@ _page_info_geometry_change(Efl_Page_Transition_Scroll_Data *pd, | |||
149 | 95 | ||
150 | efl_gfx_entity_geometry_set(pd->foreclip, (Eina_Rect) pd->viewport); | 96 | efl_gfx_entity_geometry_set(pd->foreclip, (Eina_Rect) pd->viewport); |
151 | 97 | ||
152 | // this loop resets the geometry of each page based on the geometry of | 98 | curr_page = efl_ui_pager_current_page_get(spd->pager.obj); |
153 | // the pager object, the page size, and the padding size. | 99 | cnt = efl_content_count(spd->pager.obj); |
154 | EINA_LIST_FOREACH(pd->page_infos, list, pi) | 100 | |
101 | curr = pd->head; | ||
102 | do | ||
155 | { | 103 | { |
156 | EINA_RECTANGLE_SET(&pi->geometry, | 104 | EINA_RECTANGLE_SET(&curr->geometry, |
157 | spd->pager.x + (spd->pager.w / 2) | 105 | spd->pager.x + (spd->pager.w / 2) |
158 | + pi->pos * (spd->page_spec.sz.w + spd->page_spec.padding) | 106 | + curr->pos * (spd->page_spec.sz.w + spd->page_spec.padding) |
159 | - (spd->page_spec.sz.w / 2), | 107 | - (spd->page_spec.sz.w / 2), |
160 | spd->pager.y + (spd->pager.h / 2) - (spd->page_spec.sz.h / 2), | 108 | spd->pager.y + (spd->pager.h / 2) - (spd->page_spec.sz.h / 2), |
161 | spd->page_spec.sz.w, | 109 | spd->page_spec.sz.w, |
162 | spd->page_spec.sz.h); | 110 | spd->page_spec.sz.h); |
163 | 111 | ||
164 | if (eina_rectangles_intersect(&pi->geometry, &pd->viewport) && | 112 | efl_gfx_entity_geometry_set(curr->obj, (Eina_Rect) curr->geometry); |
165 | ((pi->id != 0) && (pi->id != (pd->page_info_num - 1)))) | 113 | |
114 | if (!eina_rectangles_intersect(&curr->geometry, &pd->viewport)) | ||
166 | { | 115 | { |
167 | pi->visible = EINA_TRUE; | 116 | if (curr->visible) |
168 | efl_canvas_object_clip_set(pi->obj, pd->foreclip); | 117 | { |
118 | efl_canvas_object_clip_set(curr->obj, pd->backclip); | ||
119 | |||
120 | efl_pack_unpack(curr->obj, curr->content); | ||
121 | efl_canvas_object_clip_set(curr->content, pd->backclip); | ||
122 | |||
123 | curr->content_num = -1; | ||
124 | curr->content = NULL; | ||
125 | curr->visible = EINA_FALSE; | ||
126 | } | ||
169 | } | 127 | } |
170 | else | 128 | else |
171 | { | 129 | { |
172 | pi->visible = EINA_FALSE; | 130 | tmp_id = curr_page + curr->pos; |
173 | efl_canvas_object_clip_set(pi->obj, pd->backclip); | 131 | if (spd->loop == EFL_UI_PAGER_LOOP_ENABLED) |
132 | tmp_id = (tmp_id + cnt) % cnt; | ||
133 | |||
134 | if ((abs(curr->pos) < cnt) && | ||
135 | (tmp_id >= 0) && | ||
136 | (tmp_id < cnt)) | ||
137 | { | ||
138 | if (curr->content_num != tmp_id) | ||
139 | { | ||
140 | tmp = efl_pack_content_get(spd->pager.obj, tmp_id); | ||
141 | |||
142 | efl_canvas_object_clip_set(curr->obj, pd->foreclip); | ||
143 | |||
144 | efl_pack(curr->obj, tmp); | ||
145 | efl_canvas_object_clip_set(tmp, pd->foreclip); | ||
146 | |||
147 | curr->content_num = tmp_id; | ||
148 | curr->content = tmp; | ||
149 | curr->visible = EINA_TRUE; | ||
150 | } | ||
151 | } | ||
152 | else if (curr->content) | ||
153 | { | ||
154 | efl_canvas_object_clip_set(curr->obj, pd->backclip); | ||
155 | |||
156 | efl_pack_unpack(curr->obj, curr->content); | ||
157 | efl_canvas_object_clip_set(curr->content, pd->backclip); | ||
158 | |||
159 | curr->content_num = -1; | ||
160 | curr->content = NULL; | ||
161 | curr->visible = EINA_FALSE; | ||
162 | } | ||
174 | } | 163 | } |
175 | 164 | ||
176 | efl_gfx_entity_geometry_set(pi->obj, (Eina_Rect) pi->geometry); | 165 | curr = curr->next; |
177 | } | ||
178 | 166 | ||
179 | if (efl_content_count(spd->pager.obj) > 0) _content_show(pd, spd); | 167 | } while (curr != pd->head); |
180 | } | 168 | } |
181 | 169 | ||
182 | static void | 170 | static void |
@@ -556,6 +544,9 @@ _efl_page_transition_scroll_loop_set(Eo *obj, | |||
556 | Efl_Ui_Pager_Loop loop) | 544 | Efl_Ui_Pager_Loop loop) |
557 | { | 545 | { |
558 | EFL_PAGE_TRANSITION_DATA_GET(obj, spd); | 546 | EFL_PAGE_TRANSITION_DATA_GET(obj, spd); |
547 | int tmp_id, curr_page, cnt; | ||
548 | Page_Info *curr; | ||
549 | Eo *tmp; | ||
559 | 550 | ||
560 | if (loop == efl_ui_pager_loop_mode_get(spd->pager.obj)) | 551 | if (loop == efl_ui_pager_loop_mode_get(spd->pager.obj)) |
561 | return EINA_TRUE; | 552 | return EINA_TRUE; |
@@ -566,7 +557,45 @@ _efl_page_transition_scroll_loop_set(Eo *obj, | |||
566 | 557 | ||
567 | efl_page_transition_loop_set(efl_super(obj, MY_CLASS), loop); | 558 | efl_page_transition_loop_set(efl_super(obj, MY_CLASS), loop); |
568 | 559 | ||
569 | _content_show(pd, spd); | 560 | curr_page = efl_ui_pager_current_page_get(spd->pager.obj); |
561 | cnt = efl_content_count(spd->pager.obj); | ||
562 | |||
563 | curr = pd->head->next; | ||
564 | do | ||
565 | { | ||
566 | tmp_id = curr_page + curr->pos; | ||
567 | if ((tmp_id < 0) || (tmp_id >= cnt)) | ||
568 | { | ||
569 | switch (loop) | ||
570 | { | ||
571 | case EFL_UI_PAGER_LOOP_ENABLED: | ||
572 | tmp_id = (tmp_id + cnt) % cnt; | ||
573 | tmp = efl_pack_content_get(spd->pager.obj, tmp_id); | ||
574 | |||
575 | efl_pack(curr->obj, tmp); | ||
576 | efl_canvas_object_clip_set(tmp, pd->foreclip); | ||
577 | |||
578 | curr->content_num = tmp_id; | ||
579 | curr->content = tmp; | ||
580 | curr->visible = EINA_TRUE; | ||
581 | |||
582 | break; | ||
583 | |||
584 | case EFL_UI_PAGER_LOOP_DISABLED: | ||
585 | efl_pack_unpack(curr->obj, curr->content); | ||
586 | efl_canvas_object_clip_set(curr->content, pd->backclip); | ||
587 | |||
588 | curr->content_num = -1; | ||
589 | curr->content = NULL; | ||
590 | curr->visible = EINA_FALSE; | ||
591 | |||
592 | break; | ||
593 | } | ||
594 | } | ||
595 | |||
596 | curr = curr->next; | ||
597 | |||
598 | } while (curr != pd->tail); | ||
570 | 599 | ||
571 | return EINA_TRUE; | 600 | return EINA_TRUE; |
572 | } | 601 | } |