summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2014-02-09 20:21:21 +0100
committerdavemds <dave@gurumeditation.it>2014-02-09 20:21:21 +0100
commit3ce61868e88fa95d507e01587bf4cbbec9b0d1a1 (patch)
treeee627c2ebb74f3b15b41941f3359b6d0752a06b6
parent0136122e1200ffc05985e8d97c39e75f5a6ca268 (diff)
Revert "label : Added the API to match the speed of label to different label"
As discussed I will try to implement the same functionality but with a different api. This reverts commit 56a2c96ea7a731d6066aa7cb0964a633c5bed35c.
-rw-r--r--src/bin/test_label.c47
-rw-r--r--src/lib/elm_label.c68
-rw-r--r--src/lib/elm_label_eo.h32
-rw-r--r--src/lib/elm_label_legacy.h32
-rw-r--r--src/lib/elm_widget_label.h5
5 files changed, 4 insertions, 180 deletions
diff --git a/src/bin/test_label.c b/src/bin/test_label.c
index d5e789876..7e6a73d68 100644
--- a/src/bin/test_label.c
+++ b/src/bin/test_label.c
@@ -113,8 +113,6 @@ void
113test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 113test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
114{ 114{
115 Evas_Object *win, *gd, *rect, *lb, *rd, *rdg, *sl; 115 Evas_Object *win, *gd, *rect, *lb, *rd, *rdg, *sl;
116 double duration;
117 Evas_Coord textlen;
118 116
119 win = elm_win_util_standard_add("label2", "Label 2"); 117 win = elm_win_util_standard_add("label2", "Label 2");
120 elm_win_autodel_set(win, EINA_TRUE); 118 elm_win_autodel_set(win, EINA_TRUE);
@@ -214,51 +212,6 @@ test_label2(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
214 elm_grid_pack(gd, sl, 5, 60, 90, 10); 212 elm_grid_pack(gd, sl, 5, 60, 90, 10);
215 evas_object_show(sl); 213 evas_object_show(sl);
216 214
217 /*Test label slide speed */
218 lb = elm_label_add(win);
219 elm_object_text_set(lb, "Test Label Slide Speed:");
220 elm_label_slide_mode_set(lb, ELM_LABEL_SLIDE_MODE_ALWAYS);
221 elm_label_slide_go(lb);
222 elm_grid_pack(gd, lb, 5, 70, 90, 10);
223 evas_object_show(lb);
224
225 rect = evas_object_rectangle_add(evas_object_evas_get(win));
226 elm_grid_pack(gd, rect, 5, 80, 90, 10);
227 evas_object_color_set(rect, 255, 125, 125, 255);
228 evas_object_show(rect);
229
230 lb = elm_label_add(win);
231 elm_object_style_set(lb, "slide_long");
232 elm_object_text_set(lb,
233 "This is a label set to slide and this will"
234 " test the speed of label with the below label."
235 " This label has few extra char to test");
236 elm_label_slide_duration_set(lb, 8.0);
237 elm_label_slide_mode_set(lb, ELM_LABEL_SLIDE_MODE_ALWAYS);
238 elm_label_slide_go(lb);
239 elm_grid_pack(gd, lb, 5, 80, 90, 10);
240 evas_object_show(lb);
241
242 //Get the required parameter of the previous label
243 duration = elm_label_slide_duration_get(lb);
244 textlen = elm_label_slide_text_length_get(lb);
245
246 rect = evas_object_rectangle_add(evas_object_evas_get(win));
247 elm_grid_pack(gd, rect, 5, 90, 90, 10);
248 evas_object_color_set(rect, 255, 125, 125, 255);
249 evas_object_show(rect);
250
251 lb = elm_label_add(win);
252 elm_object_style_set(lb, "slide_long");
253 elm_object_text_set(lb,
254 "This is a label set to slide and this will"
255 " match the speed of the upper label.");
256 elm_label_slide_mode_set(lb, ELM_LABEL_SLIDE_MODE_ALWAYS);
257 elm_label_slide_speed_match(lb, duration, textlen);
258 elm_label_slide_go(lb);
259 elm_grid_pack(gd, lb, 5, 90, 90, 10);
260 evas_object_show(lb);
261
262 evas_object_resize(win, 320, 320); 215 evas_object_resize(win, 320, 320);
263 evas_object_show(win); 216 evas_object_show(win);
264} 217}
diff --git a/src/lib/elm_label.c b/src/lib/elm_label.c
index a46badfff..976b18610 100644
--- a/src/lib/elm_label.c
+++ b/src/lib/elm_label.c
@@ -78,9 +78,7 @@ static void
78_label_slide_change(Evas_Object *obj) 78_label_slide_change(Evas_Object *obj)
79{ 79{
80 Evas_Object *tb; 80 Evas_Object *tb;
81 Evas_Coord lw;
82 char *plaintxt; 81 char *plaintxt;
83 double speed;
84 int plainlen = 0; 82 int plainlen = 0;
85 83
86 ELM_LABEL_DATA_GET(obj, sd); 84 ELM_LABEL_DATA_GET(obj, sd);
@@ -140,17 +138,6 @@ _label_slide_change(Evas_Object *obj)
140 Edje_Message_Float_Set *msg = 138 Edje_Message_Float_Set *msg =
141 alloca(sizeof(Edje_Message_Float_Set) + (sizeof(double))); 139 alloca(sizeof(Edje_Message_Float_Set) + (sizeof(double)));
142 140
143 evas_object_geometry_get(wd->resize_obj,
144 NULL, NULL, &lw, NULL);
145 if ((sd->slide_duration_recalc) &&
146 (lw > 0) &&
147 (sd->matchslide_duration > 0))
148 {
149 speed = (sd->matchslide_textlen + lw) / (sd->matchslide_duration);
150 sd->slide_duration = (sd->text_formatted_length + lw) / (speed);
151 sd->slide_duration_recalc = EINA_FALSE;
152 }
153
154 msg->count = 1; 141 msg->count = 1;
155 msg->val[0] = sd->slide_duration; 142 msg->val[0] = sd->slide_duration;
156 143
@@ -227,10 +214,9 @@ _on_label_resize(void *data,
227 Evas_Object *obj EINA_UNUSED, 214 Evas_Object *obj EINA_UNUSED,
228 void *event_info EINA_UNUSED) 215 void *event_info EINA_UNUSED)
229{ 216{
230 ELM_LABEL_DATA_GET(data, sd); 217 ELM_LABEL_DATA_GET(data, sd);
231 218
232 if (sd->slide_duration_recalc) _label_slide_change(data); 219 if (sd->linewrap) elm_layout_sizing_eval(data);
233 if (sd->linewrap) elm_layout_sizing_eval(data);
234} 220}
235 221
236static int 222static int
@@ -338,8 +324,6 @@ _stringshare_key_value_replace(const char **srcstring,
338static void 324static void
339_elm_label_smart_text_set(Eo *obj, void *_pd, va_list *list) 325_elm_label_smart_text_set(Eo *obj, void *_pd, va_list *list)
340{ 326{
341 Evas_Object *tb;
342
343 Elm_Label_Smart_Data *sd = _pd; 327 Elm_Label_Smart_Data *sd = _pd;
344 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 328 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
345 const char *part = va_arg(*list, const char *); 329 const char *part = va_arg(*list, const char *);
@@ -357,11 +341,6 @@ _elm_label_smart_text_set(Eo *obj, void *_pd, va_list *list)
357 sd->lastw = 0; 341 sd->lastw = 0;
358 eo_do(obj, elm_obj_layout_sizing_eval()); 342 eo_do(obj, elm_obj_layout_sizing_eval());
359 } 343 }
360
361 tb = (Evas_Object *)edje_object_part_object_get(wd->resize_obj,
362 "elm.text");
363 evas_object_textblock_size_formatted_get(tb, &sd->text_formatted_length, NULL);
364
365 if (ret) *ret = int_ret; 344 if (ret) *ret = int_ret;
366} 345}
367 346
@@ -695,41 +674,6 @@ elm_label_slide_duration_get(const Evas_Object *obj)
695} 674}
696 675
697EAPI void 676EAPI void
698elm_label_slide_speed_match(Evas_Object *obj, double duration, Evas_Coord textlen)
699{
700 ELM_LABEL_CHECK(obj);
701 eo_do(obj, elm_obj_label_slide_speed_match(duration, textlen));
702}
703
704static void
705_slide_speed_match(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
706{
707 double duration = va_arg(*list, double);
708 Evas_Coord textlen = va_arg(*list, Evas_Coord);
709 Elm_Label_Smart_Data *sd = _pd;
710 sd->matchslide_duration = duration;
711 sd->matchslide_textlen = textlen;
712 sd->slide_duration_recalc = EINA_TRUE;
713}
714
715EAPI Evas_Coord
716elm_label_slide_text_length_get(const Evas_Object *obj)
717{
718 ELM_LABEL_CHECK(obj) 0;
719 Evas_Coord ret = 0;
720 eo_do((Eo *) obj, elm_obj_label_slide_text_length_get(&ret));
721 return ret;
722}
723
724static void
725_slide_textlen_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
726{
727 Evas_Coord *ret = va_arg(*list, Evas_Coord *);
728 Elm_Label_Smart_Data *sd = _pd;
729 *ret = sd->text_formatted_length;
730}
731
732EAPI void
733elm_label_slide_go(Evas_Object *obj) 677elm_label_slide_go(Evas_Object *obj)
734{ 678{
735 ELM_LABEL_CHECK(obj); 679 ELM_LABEL_CHECK(obj);
@@ -799,8 +743,6 @@ _class_constructor(Eo_Class *klass)
799 EO_OP_FUNC(ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_SET), _slide_duration_set), 743 EO_OP_FUNC(ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_SET), _slide_duration_set),
800 EO_OP_FUNC(ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_GET), _slide_duration_get), 744 EO_OP_FUNC(ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_GET), _slide_duration_get),
801 EO_OP_FUNC(ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_SLIDE_GO), _slide_go), 745 EO_OP_FUNC(ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_SLIDE_GO), _slide_go),
802 EO_OP_FUNC(ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_SLIDE_SPEED_MATCH), _slide_speed_match),
803 EO_OP_FUNC(ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_TEXT_LENGTH_GET), _slide_textlen_get),
804 EO_OP_FUNC_SENTINEL 746 EO_OP_FUNC_SENTINEL
805 }; 747 };
806 eo_class_funcs_set(klass, func_desc); 748 eo_class_funcs_set(klass, func_desc);
@@ -816,11 +758,9 @@ static const Eo_Op_Description op_desc[] = {
816 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_ELLIPSIS_GET, "Get the ellipsis behavior of the label."), 758 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_ELLIPSIS_GET, "Get the ellipsis behavior of the label."),
817 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_MODE_SET, "Set slide effect mode of label widget."), 759 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_MODE_SET, "Set slide effect mode of label widget."),
818 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_MODE_GET, "Get current slide effect mode."), 760 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_MODE_GET, "Get current slide effect mode."),
819 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_SET, "Set the slide duration of the label."), 761 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_SET, "Set the slide duration (speed) of the label."),
820 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_GET, "Get the slide duration of the label."), 762 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_GET, "Get the slide duration(speed) of the label."),
821 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_GO, "Start slide effect."), 763 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_GO, "Start slide effect."),
822 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_SLIDE_SPEED_MATCH, "Set the required parameter to match slide speed."),
823 EO_OP_DESCRIPTION(ELM_OBJ_LABEL_SUB_ID_TEXT_LENGTH_GET, "Get the text length of the label."),
824 EO_OP_DESCRIPTION_SENTINEL 764 EO_OP_DESCRIPTION_SENTINEL
825}; 765};
826static const Eo_Class_Description class_desc = { 766static const Eo_Class_Description class_desc = {
diff --git a/src/lib/elm_label_eo.h b/src/lib/elm_label_eo.h
index efd401361..f79cb95f5 100644
--- a/src/lib/elm_label_eo.h
+++ b/src/lib/elm_label_eo.h
@@ -22,8 +22,6 @@ enum
22 ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_SET, 22 ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_SET,
23 ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_GET, 23 ELM_OBJ_LABEL_SUB_ID_SLIDE_DURATION_GET,
24 ELM_OBJ_LABEL_SUB_ID_SLIDE_GO, 24 ELM_OBJ_LABEL_SUB_ID_SLIDE_GO,
25 ELM_OBJ_LABEL_SUB_ID_SLIDE_SPEED_MATCH,
26 ELM_OBJ_LABEL_SUB_ID_TEXT_LENGTH_GET,
27 ELM_OBJ_LABEL_SUB_ID_LAST 25 ELM_OBJ_LABEL_SUB_ID_LAST
28}; 26};
29 27
@@ -181,36 +179,6 @@ enum
181 * @ingroup Label 179 * @ingroup Label
182 */ 180 */
183#define elm_obj_label_slide_go() ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_SLIDE_GO) 181#define elm_obj_label_slide_go() ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_SLIDE_GO)
184
185/**
186 * @def elm_obj_label_slide_speed_match
187 * @since 1.9
188 *
189 * @brief Set the required parameter to set the same speed of the label
190 *
191 * @param[in] duration
192 * @param[in] textlen
193 *
194 * @see elm_label_slide_duration_set
195 *
196 * @ingroup Label
197 */
198#define elm_obj_label_slide_speed_match(duration, textlen) ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_SLIDE_SPEED_MATCH), EO_TYPECHECK(double, duration), EO_TYPECHECK(Evas_Coord, textlen)
199
200/**
201 * @def elm_obj_label_slide_text_length_get
202 * @since 1.9
203 *
204 * @brief Get the text label length
205 *
206 * @param[out] ret
207 *
208 * @see elm_object_text_set
209 *
210 * @ingroup Label
211 */
212#define elm_obj_label_slide_text_length_get(ret) ELM_OBJ_LABEL_ID(ELM_OBJ_LABEL_SUB_ID_TEXT_LENGTH_GET), EO_TYPECHECK(Evas_Coord * , ret)
213
214/** 182/**
215 * @} 183 * @}
216 */ 184 */
diff --git a/src/lib/elm_label_legacy.h b/src/lib/elm_label_legacy.h
index 04cfc7e5d..b3222b800 100644
--- a/src/lib/elm_label_legacy.h
+++ b/src/lib/elm_label_legacy.h
@@ -162,35 +162,3 @@ EAPI double elm_label_slide_duration_get(const Evas_Object
162 * @ingroup Label 162 * @ingroup Label
163 */ 163 */
164EAPI void elm_label_slide_go(Evas_Object *obj); 164EAPI void elm_label_slide_go(Evas_Object *obj);
165
166/**
167 * @brief Set the required parameter to set the same speed of the label
168 *
169 * @param obj The label object
170 * @param duration The duration of the previous slide label
171 * @param duration The textlen of the previous slide label text
172 *
173 * @note If this API is called then it is not required to set the
174 * duration of the label. Internally it will calcuate the duration
175 * which will match the speed of the previous label. If the duration
176 * is explicitly set it will override these parameters.
177 *
178 * @see elm_label_slide_duration_set()
179 * @since 1.9
180 *
181 * @ingroup Label
182 */
183EAPI void elm_label_slide_speed_match(Evas_Object *obj, double duration, Evas_Coord textlen);
184
185/**
186 * @brief Get the text length of the label
187 *
188 * @param obj The label object
189 * @return The text length of the label
190 *
191 * @see elm_object_text_set()
192 * @since 1.9
193 *
194 * @ingroup Label
195 */
196EAPI Evas_Coord elm_label_slide_text_length_get(const Evas_Object *obj);
diff --git a/src/lib/elm_widget_label.h b/src/lib/elm_widget_label.h
index 4464e7607..4e2ac7254 100644
--- a/src/lib/elm_widget_label.h
+++ b/src/lib/elm_widget_label.h
@@ -13,18 +13,13 @@ struct _Elm_Label_Smart_Data
13{ 13{
14 const char *format; 14 const char *format;
15 double slide_duration; 15 double slide_duration;
16 double matchslide_duration;
17
18 Evas_Coord lastw; 16 Evas_Coord lastw;
19 Evas_Coord wrap_w; 17 Evas_Coord wrap_w;
20 Evas_Coord text_formatted_length;
21 Evas_Coord matchslide_textlen;
22 Elm_Wrap_Type linewrap; 18 Elm_Wrap_Type linewrap;
23 Elm_Label_Slide_Mode slide_mode; 19 Elm_Label_Slide_Mode slide_mode;
24 20
25 Eina_Bool ellipsis : 1; 21 Eina_Bool ellipsis : 1;
26 Eina_Bool slide_ellipsis : 1; 22 Eina_Bool slide_ellipsis : 1;
27 Eina_Bool slide_duration_recalc : 1;
28}; 23};
29 24
30#define ELM_LABEL_DATA_GET(o, sd) \ 25#define ELM_LABEL_DATA_GET(o, sd) \