Add CURRENT option which edje object moves from current position.
authorjaehwan <jaehwan>
Thu, 3 Nov 2011 04:43:00 +0000 (04:43 +0000)
committerjaehwan <jaehwan@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 3 Nov 2011 04:43:00 +0000 (04:43 +0000)
Currently, when the part in edc move by transition, it moves from the
one of the states to another of the states even if it is ainimating.
We need it to move from current position, because the animation is not
natural and smooth. So I made the "CURRENT" option.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@64675 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/edje_cc_handlers.c
src/lib/Edje.h
src/lib/edje_calc.c
src/lib/edje_private.h
src/lib/edje_program.c

index a2c18b9..e0f4320 100644 (file)
@@ -7121,7 +7121,7 @@ st_collections_group_programs_program_action(void)
     @property
         transition
     @parameters
-        [type] [length] [[interp val 1]] [[interp val 2]]
+        [type] [length] [[interp val 1]] [[interp val 2]] [[option]]
     @effect
         Defines how transitions occur using STATE_SET action.\n
         Where 'type' is the style of the transition and 'length' is a double
@@ -7157,6 +7157,11 @@ st_collections_group_programs_program_action(void)
         spring "swings" and val 1 specifies the decay, but it can exceed 1.0
         on the outer swings.
 
+        Valid option is CURRENT.
+
+        CURRENT is the option which the edje object moves from current position.
+        It can be used as the last parameter of the every type.
+
     @endproperty
 */
 static void
@@ -7190,15 +7195,30 @@ st_collections_group_programs_program_transition(void)
                                            "SPRING", EDJE_TWEEN_MODE_SPRING,
                                            NULL);
    current_program->tween.time = FROM_DOUBLE(parse_float_range(1, 0.0, 999999999.0));
+   if ((current_program->tween.mode >= EDJE_TWEEN_MODE_LINEAR) &&
+       (current_program->tween.mode <= EDJE_TWEEN_MODE_DECELERATE))
+     {
+        if ((get_arg_count() == 3) && (!strcmp(parse_str(2), "CURRENT")))
+          current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
+        else if (get_arg_count() != 2)
+          {
+             ERR("%s: Error. parse error %s:%i. "
+                 "Need 2rd parameter to set time",
+                 progname, file_in, line - 1);
+             exit(-1);
+          }
+     }
    // the following need v1
    // EDJE_TWEEN_MODE_ACCELERATE_FACTOR
    // EDJE_TWEEN_MODE_DECELERATE_FACTOR
    // EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR
    // current_program->tween.v1
-   if ((current_program->tween.mode >= EDJE_TWEEN_MODE_ACCELERATE_FACTOR) &&
+   else if ((current_program->tween.mode >= EDJE_TWEEN_MODE_ACCELERATE_FACTOR) &&
        (current_program->tween.mode <= EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR))
      {
-        if (get_arg_count() != 3)
+        if ((get_arg_count() == 4) && (!strcmp(parse_str(3), "CURRENT")))
+          current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
+        else if (get_arg_count() != 3)
           {
             ERR("%s: Error. parse error %s:%i. "
                 "Need 3rd parameter to set factor",
@@ -7215,7 +7235,9 @@ st_collections_group_programs_program_transition(void)
    else if ((current_program->tween.mode >= EDJE_TWEEN_MODE_DIVISOR_INTERP) &&
             (current_program->tween.mode <= EDJE_TWEEN_MODE_SPRING))
      {
-        if (get_arg_count() != 4)
+        if ((get_arg_count() == 5) && (!strcmp(parse_str(4), "CURRENT")))
+          current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT;
+        else if (get_arg_count() != 4)
           {
             ERR("%s: Error. parse error %s:%i. "
                 "Need 3rd and 4th parameters to set factor and counts",
index 030615b..ba6706d 100644 (file)
@@ -631,7 +631,9 @@ typedef enum _Edje_Tween_Mode
    EDJE_TWEEN_MODE_DIVISOR_INTERP    = 8,
    EDJE_TWEEN_MODE_BOUNCE            = 9,
    EDJE_TWEEN_MODE_SPRING            = 10,
-   EDJE_TWEEN_MODE_LAST              = 11
+   EDJE_TWEEN_MODE_LAST              = 11,
+   EDJE_TWEEN_MODE_MASK              = 0xff,
+   EDJE_TWEEN_MODE_OPT_FROM_CURRENT  = (1 << 31)
 } Edje_Tween_Mode;
 
 typedef enum _Edje_Cursor
index 2ee6180..b8fac21 100644 (file)
@@ -56,7 +56,7 @@ _edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T
          break;
      }
 #else
-   switch (mode)
+   switch (mode & EDJE_TWEEN_MODE_MASK)
      {
       case EDJE_TWEEN_MODE_SINUSOIDAL:
         npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
@@ -2212,11 +2212,32 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags)
 #endif
          }
      }
-   if (ep->param2 && ep->description_pos != ZERO)
+   if (ep->param2)
      {
        int beginning_pos, part_type;
        Edje_Calc_Params *p2, *p3;
 
+        if (ep->current)
+          {
+             p1->x = ep->current->x - ed->x;
+             p1->y = ep->current->y - ed->y;
+             p1->w = ep->current->w;
+             p1->h = ep->current->h;
+             p1->color.r = ep->current->color.r;
+             p1->color.g = ep->current->color.g;
+             p1->color.b = ep->current->color.b;
+             p1->color.a = ep->current->color.a;
+             p1->type.text.size = ep->current->type.text.size;
+             p1->type.text.color2.r = ep->current->type.text.color2.r;
+             p1->type.text.color2.g = ep->current->type.text.color2.g;
+             p1->type.text.color2.b = ep->current->type.text.color2.b;
+             p1->type.text.color2.a = ep->current->type.text.color2.a;
+             p1->type.text.color3.r = ep->current->type.text.color3.r;
+             p1->type.text.color3.g = ep->current->type.text.color3.g;
+             p1->type.text.color3.b = ep->current->type.text.color3.b;
+             p1->type.text.color3.a = ep->current->type.text.color3.a;
+          }
+
        p3 = &lp3;
 
 #ifndef EDJE_CALC_CACHE
index e044e66..ead0382 100644 (file)
@@ -1212,6 +1212,7 @@ struct _Edje_Real_Part
    Edje_Real_Part_State      param1; // 20
    // WITH EDJE_CALC_CACHE: 140
    Edje_Real_Part_State     *param2, *custom; // 8
+   Edje_Calc_Params         *current; // 4
 
 #ifdef EDJE_CALC_CACHE
    int                       state; // 4
@@ -1230,8 +1231,8 @@ struct _Edje_Real_Part
 #ifdef EDJE_CALC_CACHE
    unsigned char             invalidate : 1; // 0
 #endif
-}; //  260
-// WITH EDJE_CALC_CACHE: 400
+}; //  264
+// WITH EDJE_CALC_CACHE: 404
 
 struct _Edje_Running_Program
 {
index 26160c8..48ff6ef 100644 (file)
@@ -478,6 +478,35 @@ _edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig,
                       rp = ed->table_parts[pt->id % ed->table_parts_size];
                       if (rp)
                         {
+                            if ((rp->object) && (pr->tween.mode & EDJE_TWEEN_MODE_OPT_FROM_CURRENT))
+                              {
+                                 rp->current = calloc(1, sizeof(Edje_Calc_Params));
+                                 evas_object_geometry_get(rp->object, &(rp->current->x),
+                                                          &(rp->current->y),
+                                                          &(rp->current->w),
+                                                          &(rp->current->h));
+                                 evas_object_color_get(rp->object, (int *)&(rp->current->color.r),
+                                                       (int *)&(rp->current->color.g),
+                                                       (int *)&(rp->current->color.b),
+                                                       (int *)&(rp->current->color.a));
+                                 evas_object_text_font_get(rp->object, NULL, &(rp->current->type.text.size));
+                                 evas_object_text_outline_color_get(rp->object,
+                                                       (int *)&(rp->current->type.text.color2.r),
+                                                       (int *)&(rp->current->type.text.color2.g),
+                                                       (int *)&(rp->current->type.text.color2.b),
+                                                       (int *)&(rp->current->type.text.color2.a));
+                                 evas_object_text_shadow_color_get(rp->object,
+                                                       (int *)&(rp->current->type.text.color3.r),
+                                                       (int *)&(rp->current->type.text.color3.g),
+                                                       (int *)&(rp->current->type.text.color3.b),
+                                                       (int *)&(rp->current->type.text.color3.a));
+                              }
+                            else
+                              {
+                                 if (rp->current) free(rp->current);
+                                 rp->current = NULL;
+                              }
+
                            if (rp->program)
                              _edje_program_end(ed, rp->program);
                            _edje_part_description_apply(ed, rp,