summaryrefslogtreecommitdiff
path: root/src/lib/edje
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2017-07-28 11:48:34 +0900
committerAmitesh Singh <amitesh.sh@samsung.com>2017-08-04 16:22:59 +0900
commit0e7a316a7a05b0c2733403285120a6a59a67d790 (patch)
tree408282a7dd2ce1eebbb4cb3db87ac1e3704a665e /src/lib/edje
parentf2082c0412a5e1df6b1a53e209125e7fe37dccf8 (diff)
edje: implement edje.player interface functions
fixes T5560
Diffstat (limited to 'src/lib/edje')
-rw-r--r--src/lib/edje/Edje_Legacy.h74
-rw-r--r--src/lib/edje/edje_legacy.c28
-rw-r--r--src/lib/edje/edje_object.eo49
-rw-r--r--src/lib/edje/edje_program.c61
-rw-r--r--src/lib/edje/edje_smart.c66
5 files changed, 174 insertions, 104 deletions
diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h
index d62c53ff97..a1e2ae4742 100644
--- a/src/lib/edje/Edje_Legacy.h
+++ b/src/lib/edje/Edje_Legacy.h
@@ -2157,6 +2157,80 @@ EAPI char *edje_object_part_text_unescaped_get(const Edje_Object *obj, const cha
2157EAPI void edje_object_part_text_insert(Edje_Object *obj, const char *part, const char *text); 2157EAPI void edje_object_part_text_insert(Edje_Object *obj, const char *part, const char *text);
2158 2158
2159/** 2159/**
2160 * @brief Whether this object is playing or not.
2161 *
2162 * This property indicates whether the object is running or not. If stopped (or
2163 * paused), all transitions are disabled and programs stop running, until
2164 * resumed.
2165 *
2166 * If play is disabled, the object will remain the same, and its parts will not
2167 * change state. Note that play can be disabled during a transition between
2168 * states, effectively freezing the object in flight. When paused, no events
2169 * will be processed or sent.
2170 *
2171 * Setting to @c true resumes playing from the current state.
2172 *
2173 * Start or stop playing programs in this object.
2174 *
2175 * @param[in] play The play state, @c true by default.
2176 *
2177 * @ingroup Edje_Object
2178 */
2179EAPI void edje_object_play_set(Evas_Object *obj, Eina_Bool play);
2180
2181/**
2182 * @brief Whether this object is playing or not.
2183 *
2184 * This property indicates whether the object is running or not. If stopped (or
2185 * paused), all transitions are disabled and programs stop running, until
2186 * resumed.
2187 *
2188 * If play is disabled, the object will remain the same, and its parts will not
2189 * change state. Note that play can be disabled during a transition between
2190 * states, effectively freezing the object in flight. When paused, no events
2191 * will be processed or sent.
2192 *
2193 * Setting to @c true resumes playing from the current state.
2194 *
2195 * Get the current state of play, @c true by default.
2196 *
2197 * @return The play state, @c true by default.
2198 *
2199 * @ingroup Edje_Object
2200 */
2201EAPI Eina_Bool edje_object_play_get(const Evas_Object *obj);
2202
2203/**
2204 * @brief Transition duration factor.
2205 *
2206 * This defines a multiplier for the duration of transitions as they are
2207 * defined in EDC. By default this factor is 1.0, which means animations play
2208 * at the same speed as described in EDC.
2209 *
2210 * Sets transition duration factor.
2211 *
2212 * @param[in] scale The transition duration factor.
2213 *
2214 * @ingroup Edje_Object
2215 */
2216EAPI void edje_object_transition_duration_factor_set(Evas_Object *obj, double scale);
2217
2218/**
2219 * @brief Transition duration factor.
2220 *
2221 * This defines a multiplier for the duration of transitions as they are
2222 * defined in EDC. By default this factor is 1.0, which means animations play
2223 * at the same speed as described in EDC.
2224 *
2225 * Gets transition duration factor.
2226 *
2227 * @return The transition duration factor.
2228 *
2229 * @ingroup Edje_Object
2230 */
2231EAPI double edje_object_transition_duration_factor_get(const Evas_Object *obj);
2232
2233/**
2160 * @} 2234 * @}
2161 */ 2235 */
2162#include "edje_object.eo.legacy.h" 2236#include "edje_object.eo.legacy.h"
diff --git a/src/lib/edje/edje_legacy.c b/src/lib/edje/edje_legacy.c
index a917903f32..fba9d6a55e 100644
--- a/src/lib/edje/edje_legacy.c
+++ b/src/lib/edje/edje_legacy.c
@@ -1121,3 +1121,31 @@ edje_object_calc_force(Edje_Object *obj)
1121{ 1121{
1122 efl_canvas_layout_calc_force(obj); 1122 efl_canvas_layout_calc_force(obj);
1123} 1123}
1124
1125EAPI void
1126edje_object_play_set(Evas_Object *obj, Eina_Bool play)
1127{
1128 efl_player_play_set(obj, play);
1129}
1130
1131EAPI Eina_Bool
1132edje_object_play_get(const Evas_Object *obj)
1133{
1134 return efl_player_play_get(obj);
1135}
1136
1137EAPI void
1138edje_object_transition_duration_factor_set(Evas_Object *obj, double scale)
1139{
1140 if (scale <= 0.0) return;
1141 efl_player_play_speed_set(obj, 1.0/scale);
1142}
1143
1144EAPI double
1145edje_object_transition_duration_factor_get(const Evas_Object *obj)
1146{
1147 double speed = efl_player_play_speed_get(obj);
1148
1149 if (speed <= 0.0) speed = 1.0;
1150 return 1.0/speed;
1151}
diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo
index 90e82ba7be..68033df08a 100644
--- a/src/lib/edje/edje_object.eo
+++ b/src/lib/edje/edje_object.eo
@@ -4,7 +4,8 @@ import edje_types;
4 4
5class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part, 5class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
6 Efl.Observer, Efl.Ui.Base, Efl.Canvas.Layout_Calc, 6 Efl.Observer, Efl.Ui.Base, Efl.Canvas.Layout_Calc,
7 Efl.Canvas.Layout_Signal, Efl.Canvas.Layout_Group) 7 Efl.Canvas.Layout_Signal, Efl.Canvas.Layout_Group,
8 Efl.Player)
8{ 9{
9 [[Edje object class]] 10 [[Edje object class]]
10 legacy_prefix: edje_object; 11 legacy_prefix: edje_object;
@@ -20,7 +21,7 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
20 21
21 If animations are disabled, transitions between states (as 22 If animations are disabled, transitions between states (as
22 defined in EDC) are then instantaneous. This is conceptually similar 23 defined in EDC) are then instantaneous. This is conceptually similar
23 to setting the @.transition_duration_factor to an infinitely high 24 to setting the @Efl.Player.play_speed to an infinitely high
24 value. 25 value.
25 ]] 26 ]]
26 get { 27 get {
@@ -33,30 +34,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
33 on: bool; [[The animation state, $true by default.]] 34 on: bool; [[The animation state, $true by default.]]
34 } 35 }
35 } 36 }
36 @property play {
37 [[Whether this object is playing or not.
38
39 This property indicates whether the object is running or not. If
40 stopped (or paused), all transitions are disabled and programs
41 stop running, until resumed.
42
43 If play is disabled, the object will remain the same, and its parts
44 will not change state. Note that play can be disabled during a
45 transition between states, effectively freezing the object in
46 flight. When paused, no events will be processed or sent.
47
48 Setting to $true resumes playing from the current state.
49 ]]
50 get {
51 [[Get the current state of play, $true by default.]]
52 }
53 set {
54 [[Start or stop playing programs in this object.]]
55 }
56 values {
57 play: bool; [[The play state, $true by default.]]
58 }
59 }
60 @property perspective { 37 @property perspective {
61 set { 38 set {
62 [[Sets the given perspective object on this Edje object. 39 [[Sets the given perspective object on this Edje object.
@@ -87,23 +64,6 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
87 } 64 }
88 } 65 }
89 } 66 }
90 @property transition_duration_factor {
91 [[Transition duration factor.
92
93 This defines a multiplier for the duration of transitions as they
94 are defined in EDC. By default this factor is 1.0, which means
95 animations play at the same speed as described in EDC.
96 ]]
97 set {
98 [[Sets transition duration factor.]]
99 }
100 get {
101 [[Gets transition duration factor.]]
102 }
103 values {
104 scale: double(1.0); [[The transition duration factor.]]
105 }
106 }
107 67
108 // TODO: Legacy only. EO may rely on futures. 68 // TODO: Legacy only. EO may rely on futures.
109 preload { 69 preload {
@@ -832,6 +792,9 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part,
832 Efl.Container.content_remove; 792 Efl.Container.content_remove;
833 Efl.Part.part; 793 Efl.Part.part;
834 Efl.Observer.update; 794 Efl.Observer.update;
795 Efl.Player.playable { get; }
796 Efl.Player.play { get; set; }
797 Efl.Player.play_speed { get; set; }
835 } 798 }
836 events { 799 events {
837 recalc; [[Edje re-calculated the object.]] 800 recalc; [[Edje re-calculated the object.]]
diff --git a/src/lib/edje/edje_program.c b/src/lib/edje/edje_program.c
index 8aeb63e9ab..6c90f46650 100644
--- a/src/lib/edje/edje_program.c
+++ b/src/lib/edje/edje_program.c
@@ -213,19 +213,6 @@ edje_transition_duration_factor_set(double scale)
213 _edje_transition_duration_scale = FROM_DOUBLE(scale); 213 _edje_transition_duration_scale = FROM_DOUBLE(scale);
214} 214}
215 215
216EOLIAN void
217_edje_object_transition_duration_factor_set(Eo *obj EINA_UNUSED,
218 Edje *pd, double scale)
219{
220 pd->duration_scale = scale;
221}
222
223EOLIAN double
224_edje_object_transition_duration_factor_get(Eo *obj EINA_UNUSED, Edje *pd)
225{
226 return pd->duration_scale;
227}
228
229static inline Eina_Bool 216static inline Eina_Bool
230_edje_object_signal_callback_add(Edje *ed, const char *emission, const char *source, Efl_Signal_Cb func, void *data) 217_edje_object_signal_callback_add(Edje *ed, const char *emission, const char *source, Efl_Signal_Cb func, void *data)
231{ 218{
@@ -299,54 +286,6 @@ _edje_object_efl_canvas_layout_signal_signal_emit(Eo *obj EINA_UNUSED, Edje *ed,
299 286
300/* FIXDOC: Verify/Expand */ 287/* FIXDOC: Verify/Expand */
301EOLIAN void 288EOLIAN void
302_edje_object_play_set(Eo *obj EINA_UNUSED, Edje *ed, Eina_Bool play)
303{
304 double t;
305 Eina_List *l;
306 Edje_Running_Program *runp;
307 unsigned short i;
308
309 if (!ed) return;
310 if (ed->delete_me) return;
311 if (play)
312 {
313 if (!ed->paused) return;
314 ed->paused = EINA_FALSE;
315 t = ecore_time_get() - ed->paused_at;
316 EINA_LIST_FOREACH(ed->actions, l, runp)
317 runp->start_time += t;
318 }
319 else
320 {
321 if (ed->paused) return;
322 ed->paused = EINA_TRUE;
323 ed->paused_at = ecore_time_get();
324 }
325
326 for (i = 0; i < ed->table_parts_size; i++)
327 {
328 Edje_Real_Part *rp;
329 rp = ed->table_parts[i];
330 if ((rp->part->type == EDJE_PART_TYPE_GROUP) &&
331 ((rp->type == EDJE_RP_TYPE_SWALLOW) &&
332 (rp->typedata.swallow)) &&
333 (rp->typedata.swallow->swallowed_object))
334 edje_object_play_set(rp->typedata.swallow->swallowed_object, play);
335 }
336}
337
338EOLIAN Eina_Bool
339_edje_object_play_get(Eo *obj EINA_UNUSED, Edje *ed)
340{
341 if (!ed) return EINA_FALSE;
342 if (ed->delete_me) return EINA_FALSE;
343 if (ed->paused) return EINA_FALSE;
344
345 return EINA_TRUE;
346}
347
348/* FIXDOC: Verify/Expand */
349EOLIAN void
350_edje_object_animation_set(Eo *obj, Edje *ed, Eina_Bool on) 289_edje_object_animation_set(Eo *obj, Edje *ed, Eina_Bool on)
351{ 290{
352 Eina_List *l; 291 Eina_List *l;
diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
index 20ebb0a050..72452fa943 100644
--- a/src/lib/edje/edje_smart.c
+++ b/src/lib/edje/edje_smart.c
@@ -554,6 +554,72 @@ _edje_object_efl_observer_update(Eo *obj EINA_UNUSED, Edje *ed, Efl_Object *obs,
554 } 554 }
555} 555}
556 556
557EOLIAN Eina_Bool
558_edje_object_efl_player_playable_get(Eo *obj EINA_UNUSED, Edje *pd EINA_UNUSED)
559{
560 return EINA_TRUE;
561}
562
563EOLIAN void
564_edje_object_efl_player_play_set(Eo *obj EINA_UNUSED, Edje *ed, Eina_Bool play)
565{
566 double t;
567 Eina_List *l;
568 Edje_Running_Program *runp;
569 unsigned short i;
570
571 if (!ed) return;
572 if (ed->delete_me) return;
573 if (play)
574 {
575 if (!ed->paused) return;
576 ed->paused = EINA_FALSE;
577 t = ecore_time_get() - ed->paused_at;
578 EINA_LIST_FOREACH(ed->actions, l, runp)
579 runp->start_time += t;
580 }
581 else
582 {
583 if (ed->paused) return;
584 ed->paused = EINA_TRUE;
585 ed->paused_at = ecore_time_get();
586 }
587
588 for (i = 0; i < ed->table_parts_size; i++)
589 {
590 Edje_Real_Part *rp;
591 rp = ed->table_parts[i];
592 if ((rp->part->type == EDJE_PART_TYPE_GROUP) &&
593 ((rp->type == EDJE_RP_TYPE_SWALLOW) &&
594 (rp->typedata.swallow)) &&
595 (rp->typedata.swallow->swallowed_object))
596 edje_object_play_set(rp->typedata.swallow->swallowed_object, play);
597 }
598}
599
600EOLIAN Eina_Bool
601_edje_object_efl_player_play_get(Eo *obj EINA_UNUSED, Edje *ed)
602{
603 if (!ed) return EINA_FALSE;
604 if (ed->delete_me) return EINA_FALSE;
605 if (ed->paused) return EINA_FALSE;
606
607 return EINA_TRUE;
608}
609
610EOLIAN void
611_edje_object_efl_player_play_speed_set(Eo *obj EINA_UNUSED, Edje *pd , double speed)
612{
613 if (speed <= 0.0) speed = 1.0;
614 pd->duration_scale = 1.0/speed;
615}
616
617EOLIAN double
618_edje_object_efl_player_play_speed_get(Eo *obj EINA_UNUSED, Edje *pd)
619{
620 return 1.0/pd->duration_scale;
621}
622
557/* Internal EO APIs and hidden overrides */ 623/* Internal EO APIs and hidden overrides */
558 624
559#define EDJE_OBJECT_EXTRA_OPS \ 625#define EDJE_OBJECT_EXTRA_OPS \