Main Page | Data Structures | Directories | File List | Data Fields | Globals

e_mod_container_box.c

Go to the documentation of this file.
00001 #include "dEvian.h"
00002 
00003 static int _gadman_init(Container_Box *box);
00004 static void _gadman_shutdown(Container_Box *box);
00005 static void _gadman_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
00006 
00007 static void _cb_mouse_down(void *data, Evas* e, Evas_Object* obj,
00008          void* event_info);
00009 static void _cb_mouse_in(void *data, Evas* e, Evas_Object* obj,
00010        void* event_info);
00011 static void _cb_mouse_out(void *data, Evas* e, Evas_Object* obj,
00012         void* event_info);
00013 static void _cb_edje_part_change(void *data, Evas_Object *obj,
00014          const char *emission, const char *source);
00015 static void _cb_edje_part_change_start(void *data, Evas_Object *obj,
00016                const char *emission, const char *source);
00017 static void _cb_edje_part_change_stop(void *data, Evas_Object *obj,
00018               const char *emission, const char *source);
00019 static void _cb_edje_part_change_wanted(void *data, Evas_Object *obj,
00020                const char *emission, const char *source);
00021 static void _cb_edje_set_bg(void *data, Evas_Object *obj,
00022           const char *emission, const char *source);
00023 static int _cb_ecore_animator(void *data);
00024 static int _cb_timer_anim_ghost(void *data);
00025 static void _animation_stop(Container_Box *box);
00026 
00027 /*
00028   Put the devian in a box
00029   Return:
00030    - 0 on success
00031    - 1 on fail
00032 */
00033 int devian_container_box_add(dEvian *devian)
00034 {
00035   Container_Box *box;
00036   Evas_Object *source0, *source1;
00037 
00038   box = E_NEW(Container_Box, 1);
00039   
00040   box->devian = devian;
00041   box->gmc = NULL;
00042 
00043   DMAIN(("dEvian: init container box START"));
00044 
00045   box->layer = dEvianM->conf->boxs_stacking;
00046 
00047   /* Edje object */
00048   box->edje = edje_object_add(dEvianM->container->bg_evas);
00049   if ( devian_container_edje_load(box->edje, "devian/box") )
00050     {
00051       devian_container_box_del(box);
00052       return 1;
00053     }
00054   evas_object_layer_set(box->edje, box->layer);
00055   box->edje_part = 0;
00056   box->in_transition = 0;
00057 
00058   /* Init show name & number */
00059   devian_container_box_infos_display_set(box);
00060   devian_container_box_update_name_devian(box);
00061 
00062   /* Callbacks for mouse events */
00063   evas_object_event_callback_add(box->edje, EVAS_CALLBACK_MOUSE_DOWN,
00064          _cb_mouse_down, box);
00065   evas_object_event_callback_add(box->edje, EVAS_CALLBACK_MOUSE_IN,
00066          _cb_mouse_in, box);
00067   evas_object_event_callback_add(box->edje, EVAS_CALLBACK_MOUSE_OUT,
00068          _cb_mouse_out, box);
00069 
00070   /* Callbacks for controls on edje */
00071   edje_object_signal_callback_add(box->edje, "pause",
00072           "button_playpause",
00073           _cb_edje_part_change_stop, box);
00074   edje_object_signal_callback_add(box->edje, "play",
00075           "button_playpause",
00076           _cb_edje_part_change_start, box);
00077   edje_object_signal_callback_add(box->edje, "set_bg",
00078           "button_set_bg",
00079           _cb_edje_set_bg, box);
00080   edje_object_signal_callback_add(box->edje, "refresh",
00081           "button_refresh",
00082           _cb_edje_part_change_wanted, box);
00083 
00084   /* Source displays */
00085   if ( !devian_source_evas_object_get(devian, &source0, &source1) )
00086     {
00087       devian_container_box_del(box);
00088       return 1;
00089     }
00090   /* 0 */
00091   edje_object_part_swallow(box->edje, "source0", source0);
00092   /* 1 */
00093   edje_object_part_swallow(box->edje, "source1", source1);
00094 
00095   /* Clip object */
00096   /*
00097   box->clip = evas_object_rectangle_add(dEvianM->container->bg_evas);
00098   evas_object_color_set(box->clip, 120, 120, 120, 125);
00099   //evas_object_layer_set(box->clip, box->layer - 1);
00100   //evas_object_clip_set(source0, box->clip);
00101   //evas_object_clip_set(source1, box->clip);
00102   edje_object_part_swallow(box->edje, "evas_source_clip", box->clip);
00103   */
00104   
00105   /* Position & Size */
00106   box->x = devian->conf->box_x;
00107   box->y = devian->conf->box_y;
00108   box->w = 0;
00109   box->h = 0;
00110   box->go_w = devian->conf->box_max_size;
00111   box->go_h = devian->conf->box_max_size;
00112   evas_object_move(box->edje, box->x, box->y);
00113   devian_container_box_resize_auto(box);
00114   //evas_object_resize(box->edje, box->w, box->h);
00115 
00116   /* Show objects, edje and table */
00117   evas_object_show(source0);
00118   evas_object_show(source1);
00119   //evas_object_show(box->clip);
00120   evas_object_show(box->edje);
00121 
00122   /* Animation */
00123   box->anim = E_NEW(Container_Box_Anim, 1);
00124   devian_container_box_animation_start(box, box->devian->conf->box_anim);
00125 
00126   /* Gadman */
00127   _gadman_init(box);
00128 
00129   /* Attach the object to the devian */
00130   devian->conf->container_type = CONTAINER_BOX;
00131   devian->container = box;
00132 
00133   DCONTAINER(("dEvian: init container box OK"));
00134   
00135   return 0;
00136 }
00137 
00138 void devian_container_box_del(Container_Box *container)
00139 {
00140   Evas_Object *source0, *source1;
00141 
00142   container->devian->conf->container_type = CONTAINER_NO;
00143   container->devian->container = NULL;
00144 
00145   /* Gadman */
00146   _gadman_shutdown(container);
00147 
00148   /* Callbacks for mouse events */
00149   evas_object_event_callback_del(container->edje, EVAS_CALLBACK_MOUSE_DOWN,
00150          _cb_mouse_down);
00151   evas_object_event_callback_del(container->edje, EVAS_CALLBACK_MOUSE_IN,
00152          _cb_mouse_in);
00153   evas_object_event_callback_del(container->edje, EVAS_CALLBACK_MOUSE_OUT,
00154          _cb_mouse_out);
00155 
00156   /* Callbacks for controls */
00157   edje_object_signal_callback_del(container->edje, "pause",
00158           "button_playpause",
00159           _cb_edje_part_change_stop);
00160   edje_object_signal_callback_del(container->edje, "play",
00161           "button_playpause",
00162           _cb_edje_part_change_start);
00163   edje_object_signal_callback_del(container->edje, "set",
00164           "button_background",
00165           _cb_edje_set_bg);
00166   edje_object_signal_callback_del(container->edje, "refresh",
00167           "button_refresh",
00168           _cb_edje_part_change_wanted);
00169 
00170   /* Animation */
00171   if (container->animator)
00172     {
00173       if(container == ecore_animator_del(container->animator))
00174   {
00175     DCONTAINER(("Ecore animator deletion ok"));
00176     container->animator = NULL;
00177   }
00178     }
00179   devian_container_box_animation_start(container, CONTAINER_BOX_ANIM_NO);
00180   //_animation_stop(container);
00181   E_FREE(container->anim);
00182 
00183   /* Source */
00184   if ( devian_source_evas_object_get(container->devian, &source0, &source1) )
00185     {
00186       evas_object_hide(source0);
00187       evas_object_hide(source1);
00188     }
00189 
00190   /* Clip object */
00191   /*
00192   if (container->clip)
00193     {
00194       evas_object_hide(container->clip);
00195       evas_object_del(container->clip);
00196     }
00197   */
00198 
00199   /* Edje object */
00200   if (container->edje)
00201     {
00202       evas_object_hide(container->edje);
00203       evas_object_del(container->edje);
00204     }
00205   
00206   dEvianM->container_box_count--;
00207 
00208   E_FREE(container);
00209 }
00210 
00211 void devian_container_box_resize_auto(Container_Box *box)
00212 {
00213   int w, h;
00214   double w2, h2;
00215   int max_w, max_h;
00216   double thm_w, thm_h;
00217 
00218   /* Calc the size */
00219   if (!box->devian->dying)
00220     {
00221       max_w = box->devian->conf->box_max_size;
00222       max_h = box->devian->conf->box_max_size;
00223       thm_h = dEvianM->theme_box_border_source_h;
00224       thm_w = dEvianM->theme_box_border_source_w;
00225 
00226       if (box->devian->conf->box_auto_resize)
00227   {
00228     double ratio;
00229     if (!devian_source_original_size_get(box->devian, box->edje_part,
00230                  &w, &h))
00231       {
00232         printf("Cant get sources size !!!\n");
00233         return;
00234       }
00235     DCONTAINER((" - Auto resize - (im %dx%d) (max %dx%d) (r %f %f)", w, h, max_w, max_h, thm_w, thm_h));
00236 
00237     /* Box size limited to max box size, keeping ratio */
00238     /* Size of edje <-> size of the source
00239        What size the box should have to perfectly fit the source */
00240     /*
00241     //if (w > max_w)
00242     {
00243     ratio = (float)h / (float)w;
00244     w = max_w + thm_w;
00245     h = (int)((float)w * ratio);
00246     }
00247     if (h > max_h + thm_h)
00248     {
00249     ratio = (float)w / (float)h;
00250     h = max_h + thm_h;
00251     w = (int)((float)h * ratio);
00252     }
00253     */
00254     w2 = (double)w;
00255     h2 = (double)h;
00256       
00257     {
00258       ratio = h2 / w2;
00259       w2 = (double)max_w;
00260       h2 = w2 * ratio;
00261     }
00262     if ((int)h2 > max_h)
00263       {
00264         ratio = w2 / h2;
00265         h2 = (double)max_h;
00266         w2 = h2 * ratio;
00267       }
00268 
00269     w = (int)w2 + thm_w;
00270     h = (int)h2 + thm_h;
00271   }
00272       else
00273   {
00274     DCONTAINER((" - NO Auto resize -"));
00275     w = max_w;
00276     h = max_h;
00277   }
00278       DCONTAINER(("Box new size : %dx%d", w, h));
00279 
00280       if ((box->w == w) && (box->h == h))
00281   return;
00282 
00283       box->go_w = w;
00284       box->go_h = h;
00285     }
00286 
00287   /* Set the size */
00288   if (dEvianM->conf->boxs_nice_resize)
00289     {
00290       /* Nice resize */
00291       box->in_resize = 1;
00292       if (box->gmc)
00293   {
00294     e_gadman_client_aspect_set(box->gmc,
00295              ((float)box->go_w/(float)box->go_h),
00296              ((float)box->go_w/(float)box->go_h));
00297   }
00298       if (!box->animator)
00299   {
00300     box->animator = ecore_animator_add(_cb_ecore_animator, box);
00301   }
00302     }
00303   else
00304     {
00305       /* Quick resize */
00306       if(((box->go_w == 0) || (box->go_h == 0)) && box->devian->dying)
00307         {
00308     devian_devian_del(box->devian, 1);
00309     return;
00310         }
00311       if (box->gmc)
00312   {
00313     e_gadman_client_aspect_set(box->gmc,
00314              ((float)box->go_w/(float)box->go_h),
00315              ((float)box->go_w/(float)box->go_h));
00316     if(e_gadman_mode_get(box->gmc->gadman) != E_GADMAN_MODE_NORMAL)
00317       return;
00318   }
00319       box->w = box->go_w;
00320       box->h = box->go_h;
00321       if (box->gmc)
00322   {
00323     box->gmc->w = box->w;
00324     box->gmc->h = box->h;
00325   }
00326       evas_object_resize(box->edje, box->w, box->h);
00327     }
00328 
00329   return;
00330 }
00331 
00332 int devian_container_box_devian_dying(Container_Box *box)
00333 {
00334   box->go_w = 0;
00335   box->go_h = 0;
00336   devian_container_box_resize_auto(box);
00337   return 1;
00338 }
00339 
00340 int devian_container_box_edje_part_get(Container_Box *container)
00341 {
00342   return container->edje_part;
00343 }
00344 
00345 int devian_container_box_edje_part_change(Container_Box *container)
00346 {
00347   Evas_Object *source0, *source1;
00348   char *source_name;
00349 
00350   devian_source_evas_object_get(container->devian,
00351           &source0, &source1);
00352 
00353   if (!source0 || !source1)
00354     return 0;
00355 
00356   if (container->in_transition)
00357     return 0;
00358 
00359   /* Change the name displayed */
00360   source_name = NULL;
00361   source_name = devian_source_name_get(container->devian, !container->edje_part);
00362   if (source_name)
00363     {
00364             edje_object_part_text_set(container->edje, "name", source_name);
00365     }
00366   else
00367     {
00368             edje_object_part_text_set(container->edje, "name", "???");
00369     }
00370 
00371   /* Start transition */
00372   if(!container->edje_part)
00373     {
00374       container->edje_part = 1;
00375       edje_object_part_swallow(container->edje, "source1", source1);
00376       evas_object_show(source1);
00377       container->in_transition = 1;
00378       if (dEvianM->conf->boxs_nice_trans)
00379   {
00380     edje_object_signal_emit(container->edje, "source_transition_0-1_go", "");
00381     edje_object_signal_callback_add(container->edje, "source_transition_0-1_end",
00382             "th",
00383             _cb_edje_part_change, container);
00384   }
00385       else
00386   {
00387     edje_object_signal_emit(container->edje, "source_transition_q_0-1_go", "");
00388     edje_object_signal_callback_add(container->edje, "source_transition_q_0-1_end",
00389             "th",
00390             _cb_edje_part_change, container);
00391   }
00392     }
00393   else
00394     {
00395       container->edje_part = 0;
00396       edje_object_part_swallow(container->edje, "source0", source0);
00397       evas_object_show(source0);
00398       container->in_transition = 0;
00399       if (dEvianM->conf->boxs_nice_trans)
00400   {
00401     edje_object_signal_emit(container->edje, "source_transition_1-0_go", "");
00402     edje_object_signal_callback_add(container->edje, "source_transition_1-0_end",
00403             "th",
00404             _cb_edje_part_change, container);
00405   }
00406       else
00407   {
00408     edje_object_signal_emit(container->edje, "source_transition_q_1-0_go", "");
00409     edje_object_signal_callback_add(container->edje, "source_transition_q_1-0_end",
00410             "th",
00411             _cb_edje_part_change, container);
00412   }
00413     }
00414 
00415   DCONTAINER(("Begining of transition"));
00416   return 1;
00417 }
00418 
00419 void devian_container_box_edje_part_change_set(Container_Box *box, int action)
00420 {
00421   DCONTAINER(("Message part change set send (%d)", action));
00422   edje_object_message_send(box->edje, EDJE_MESSAGE_INT,
00423          DEVIAN_CONTAINER_BOX_EDJE_MSG_PART_CHANGE_SET, &action);
00424 }
00425 
00426 int devian_container_box_update_name_devian(Container_Box *box)
00427 {
00428   if (!box->devian->name)
00429     return 0;
00430 
00431   edje_object_part_text_set(box->edje, "number", box->devian->name);
00432 
00433   return 1;
00434 }
00435 
00436 void devian_container_box_infos_display_set(Container_Box *box)
00437 {
00438   if (dEvianM->conf->boxs_always_number)
00439     edje_object_signal_emit(box->edje, "number_always_activate", "");
00440   else
00441     edje_object_signal_emit(box->edje, "number_always_deactivate", "");
00442   if (dEvianM->conf->boxs_always_infos)
00443     edje_object_signal_emit(box->edje, "name_always_activate", "");
00444   else
00445     edje_object_signal_emit(box->edje, "name_always_deactivate", "");
00446 }
00447 
00448 /*
00449   Start a new animation of on a box
00450   Stop all other anim / restart current anim
00451   Args:
00452    - box
00453    - number of the anim
00454   Returns:
00455    - 1 if the animation has been set
00456    - 0 otherwise
00457 */
00458 int devian_container_box_animation_start(Container_Box *box, int anim_num)
00459 {
00460   _animation_stop(box);
00461 
00462   switch (anim_num)
00463     {
00464 
00465     case CONTAINER_BOX_ANIM_NO:
00466       {
00467   evas_object_color_set(box->edje, 255, 255, 255, 255);
00468   break;
00469       }
00470 
00471     case CONTAINER_BOX_ANIM_LINE:
00472       {
00473   evas_object_color_set(box->edje, 255, 255, 255, 255);
00474   break;
00475       }
00476 
00477     case CONTAINER_BOX_ANIM_GOULOUM:
00478       {
00479   evas_object_color_set(box->edje, 255, 255, 255, 255);
00480   box->anim->data[0] = 0;
00481   box->anim->data[1] = 1;
00482   box->anim->data[2] = 1;
00483   break;
00484       }
00485 
00486     case CONTAINER_BOX_ANIM_GHOST:
00487       {
00488   /* In fade */
00489   box->anim->data[1] = 0;
00490   /* 0: fade->trans, 1: fade->visible */
00491   box->anim->data[2] = 1;
00492   /* Alpha */
00493   evas_object_color_set(box->edje, 255, 255, 255, 255);
00494   box->anim->data[3] = 255;
00495   /* Timer */
00496   if (box->anim->timer)
00497     ecore_timer_del(box->anim->timer);
00498   box->anim->timer = ecore_timer_add(dEvianM->conf->boxs_anim_ghost_timer,
00499              _cb_timer_anim_ghost,
00500              box);
00501   break;
00502       }
00503 
00504     default:
00505       {
00506   return 0;
00507       }
00508 
00509     }
00510 
00511   DCONTAINER(("Start animation %d", anim_num));
00512 
00513   box->devian->conf->box_anim = anim_num;
00514   
00515   if (anim_num)
00516     {
00517       if (!box->animator &&
00518     (anim_num != CONTAINER_BOX_ANIM_GHOST))
00519   box->animator = ecore_animator_add(_cb_ecore_animator, box);
00520       if (anim_num != CONTAINER_BOX_ANIM_GHOST)
00521   {
00522     ecore_timer_del(box->anim->timer);
00523     box->anim->timer = NULL;
00524   }
00525     }
00526   else
00527     {
00528       if (box->anim->timer)
00529   {
00530     ecore_timer_del(box->anim->timer);
00531     box->anim->timer = NULL;
00532   }
00533     }
00534 
00535   return 1;
00536 }
00537 
00538 void devian_container_box_random_pos_get(int *x, int *y, int max_size)
00539 {
00540   *x = rand()%(dEvianM->canvas_w - (max_size + dEvianM->theme_box_border_source_w));
00541   *y = rand()%(dEvianM->canvas_h - (max_size + dEvianM->theme_box_border_source_h));
00542 }
00543 
00544 /* PRIVATE FUNCTIONS */
00545 
00546 static int _gadman_init(Container_Box *box)
00547 {
00548   box->gmc = e_gadman_client_new(dEvianM->container->gadman);
00549 
00550   box->gmc_init = 1;
00551 
00552   e_gadman_client_domain_set(box->gmc, "module.dEvian", dEvianM->container_box_count++);
00553   e_gadman_client_load(box->gmc); /* Only to avoid segfault when del the gmc */
00554 
00555   e_gadman_client_zone_set(box->gmc, e_zone_current_get(dEvianM->container));
00556   e_gadman_client_policy_set(box->gmc,
00557            E_GADMAN_POLICY_ANYWHERE |
00558            E_GADMAN_POLICY_HMOVE |
00559            E_GADMAN_POLICY_VMOVE |
00560            E_GADMAN_POLICY_HSIZE |
00561            E_GADMAN_POLICY_VSIZE);
00562   e_gadman_client_min_size_set(box->gmc, 100, 100);
00563   e_gadman_client_max_size_set(box->gmc, 500, 500);
00564   e_gadman_client_auto_size_set(box->gmc,
00565         (box->w),
00566         (box->h));
00567   //e_gadman_client_align_set(box->gmc,
00568   //        ((float)box->w/(float)box->h),
00569   //        ((float)box->w/(float)box->h));
00570   e_gadman_client_aspect_set(box->gmc,
00571            ((float)box->w/(float)box->h),
00572            ((float)box->w/(float)box->h));
00573   e_gadman_client_padding_set(box->gmc,
00574             10, 10,
00575             10, 10);
00576   e_gadman_client_resize(box->gmc, box->w, box->h);
00577   e_gadman_client_change_func_set(box->gmc, _gadman_change, box);
00578   box->gmc->x = box->x;
00579   box->gmc->y = box->y;
00580 
00581   //e_gadman_client_load(box->gmc);
00582 
00583   return 1;
00584 }
00585 
00586 static void _gadman_shutdown(Container_Box *box)
00587 {
00588   if (!box->gmc)
00589     return;
00590 
00591   while ( e_object_unref(E_OBJECT(box->gmc)) > 0 );
00592 }
00593 
00594 static void _gadman_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
00595 {
00596   Container_Box *box;
00597   Evas_Coord x, y, w, h;
00598 
00599   box = data;
00600  
00601   switch (change)
00602     {
00603 
00604     case E_GADMAN_CHANGE_MOVE_RESIZE:
00605       if (box->gmc_init)
00606   {
00607     box->gmc_init = 0;
00608     break;
00609   }
00610       
00611       e_gadman_client_geometry_get(box->gmc, &x, &y, &w, &h);
00612       box->x = x;
00613       box->y = y;
00614       box->w = w;
00615       box->h = h;
00616 
00617       box->go_w = box->w;
00618       box->go_h = box->h;
00619       if (w>h)
00620   box->devian->conf->box_max_size = box->w;
00621       else
00622   box->devian->conf->box_max_size = box->h;
00623       box->in_resize = 0;
00624 
00625       evas_object_move(box->edje, x, y);
00626       evas_object_resize(box->edje, w, h);
00627       break;
00628 
00629     case E_GADMAN_CHANGE_RAISE:
00630       evas_object_raise(box->edje);
00631       break;
00632 
00633     default:
00634       break;
00635 
00636     }
00637 
00638 }
00639 
00640 static void _cb_mouse_down(void *data, Evas* e, Evas_Object* obj,
00641          void* event_info)
00642 {
00643   Evas_Event_Mouse_Down* ev;
00644   Container_Box *box;
00645 
00646   box = data;
00647   ev = event_info;
00648   
00649   if (ev->button == 2)
00650     {
00651       box->layer = CONTAINER_BOX_STACKING_UNDER;
00652       evas_object_layer_set(box->edje, CONTAINER_BOX_STACKING_UNDER);
00653     }
00654   else
00655     {
00656       if (ev->button == 3)
00657   { 
00658     e_menu_activate_mouse(box->devian->menu,
00659         e_zone_current_get(dEvianM->container),
00660         ev->output.x, ev->output.y,
00661         1, 1, E_MENU_POP_DIRECTION_AUTO,
00662         ev->timestamp);
00663     e_util_container_fake_mouse_up_all_later(dEvianM->container);
00664   }
00665     }
00666 }
00667 
00668 static void _cb_mouse_in(void *data, Evas* e, Evas_Object* obj,
00669        void* event_info)
00670 {
00671   Container_Box *box;
00672 
00673   box = data;
00674   
00675   if (box->layer < CONTAINER_BOX_STACKING_UPPER)
00676     { 
00677       box->layer = CONTAINER_BOX_STACKING_UPPER;
00678       DCONTAINER(("dEvian: mouse in"));
00679       evas_object_layer_set(box->edje, CONTAINER_BOX_STACKING_UPPER);
00680     }
00681 }
00682 
00683 static void _cb_mouse_out(void *data, Evas* e, Evas_Object* obj,
00684        void* event_info)
00685 {
00686   Container_Box *box;
00687 
00688   box = data;
00689   
00690   if ((box->layer != CONTAINER_BOX_STACKING_NORMAL))
00691     { 
00692       box->layer = CONTAINER_BOX_STACKING_NORMAL;
00693       DCONTAINER(("dEvian: mouse out"));
00694       evas_object_layer_set(box->edje, CONTAINER_BOX_STACKING_NORMAL);
00695     }
00696 }
00697 
00698 static void _cb_edje_part_change(void *data, Evas_Object *obj,
00699          const char *emission, const char *source)
00700 {
00701   Container_Box *container;
00702   dEvian *devian;
00703   Evas_Object *source0, *source1;
00704 
00705   DCONTAINER(("End of transition has begin"));
00706 
00707   container = data;
00708   devian = container->devian;
00709 
00710   if (!container->edje || !obj)
00711     {
00712       DCONTAINER(("NO EDJE !!!"));
00713       container->in_transition = 0;
00714       return;
00715     }
00716 
00717   devian_source_evas_object_get(devian,
00718           &source0, &source1);
00719 
00720   if(!strcmp(emission, "source_transition_0-1_end"))
00721     {
00722       evas_object_hide(source0);
00723       edje_object_part_unswallow(container->edje, source0);
00724       edje_object_signal_callback_del(obj, "source_transition_0-1_end",
00725               "th",
00726               _cb_edje_part_change);
00727       container->in_transition = 0;
00728       devian_source_detach(devian, 0);
00729     }
00730   else
00731     {
00732       if(!strcmp(emission, "source_transition_q_0-1_end"))
00733   { 
00734     evas_object_hide(source0);
00735     edje_object_part_unswallow(container->edje, source0);
00736     edje_object_signal_callback_del(obj, "source_transition_q_0-1_end",
00737             "th",
00738             _cb_edje_part_change);
00739     container->in_transition = 0;
00740     devian_source_detach(devian, 0);
00741   }
00742       else
00743   {
00744     if(!strcmp(emission, "source_transition_1-0_end"))
00745       {
00746         evas_object_hide(source1);
00747         edje_object_part_unswallow(container->edje, source1);
00748         edje_object_signal_callback_del(obj, "source_transition_1-0_end",
00749                 "th",
00750                 _cb_edje_part_change);
00751         container->in_transition = 0;
00752         devian_source_detach(devian, 1);
00753       }
00754     else
00755       {
00756         if(!strcmp(emission, "source_transition_q_1-0_end"))
00757     {
00758       evas_object_hide(source1);
00759       edje_object_part_unswallow(container->edje, source1);
00760       edje_object_signal_callback_del(obj, "source_transition_q_1-0_end",
00761               "th",
00762               _cb_edje_part_change);
00763       container->in_transition = 0;
00764       devian_source_detach(devian, 1);
00765     }
00766         else
00767     printf("dEvian: Get unknow edje transition signal !\n");
00768       }
00769   }
00770     }
00771   
00772   DCONTAINER(("End of transition"));
00773 }
00774 
00775 static void _cb_edje_part_change_start(void *data, Evas_Object *obj,
00776                const char *emission, const char *source)
00777 {
00778   Container_Box *box;
00779   box = (Container_Box *)data;
00780 
00781   DCONTAINER(("Edje cb part_change_start"));
00782   devian_source_timer_change_set(box->devian, 1, 0);
00783 }
00784 
00785 static void _cb_edje_part_change_stop(void *data, Evas_Object *obj,
00786               const char *emission, const char *source)
00787 {
00788   Container_Box *box;
00789   box = (Container_Box *)data;
00790 
00791   DCONTAINER(("Edje cb part_change_stop"));
00792   devian_source_timer_change_set(box->devian, 0, 0);
00793 }
00794 
00795 static void _cb_edje_part_change_wanted(void *data, Evas_Object *obj,
00796                const char *emission, const char *source)
00797 {
00798   int i;
00799   Container_Box *box;
00800   box = (Container_Box *)data;
00801 
00802   DCONTAINER(("Edje cb part_change_wanted"));
00803   i = devian_source_refresh(box->devian);
00804   DCONTAINER(("Edje cb: transition returns %d", i));
00805 }
00806 
00807 static void _cb_edje_set_bg(void *data, Evas_Object *obj,
00808           const char *emission, const char *source)
00809 {
00810   Container_Box *box;
00811   box = (Container_Box *)data;
00812 
00813   DCONTAINER(("Edje cb set_bg"));
00814   devian_source_set_bg(box->devian);
00815 }
00816 
00817 /*
00818   The animator for one Container_Box
00819 */
00820 static int _cb_ecore_animator(void *data)
00821 {
00822   Container_Box *box;
00823   int spd;
00824 
00825   box = data;
00826   spd = box->devian->conf->box_speed;
00827 
00828   if(e_gadman_mode_get(box->gmc->gadman) == E_GADMAN_MODE_NORMAL)
00829     {
00830   /* Resize */
00831   if (box->in_resize)
00832     {
00833       int diff_w, diff_h;
00834       diff_w = box->w - box->go_w;
00835       diff_h = box->h - box->go_h;
00836       
00837       /* CHECK: End of resize ? */
00838       if((diff_w == 0) && (diff_h == 0))
00839   {
00840     DCONTAINER(("Resize finished"));
00841     box->in_resize = 0;
00842     if(box->devian->dying)
00843     {
00844       devian_devian_del(box->devian, 1);
00845       return 0;
00846     }
00847   }
00848       else
00849   {
00850     if(diff_w > 0)
00851       box->w = box->w - 1;
00852     else
00853       if(diff_w < 0)
00854         box->w = box->w + 1;
00855     if(diff_h > 0)
00856       box->h = box->h - 1;
00857     else
00858       if(diff_h < 0)
00859         box->h = box->h + 1;
00860 
00861     box->gmc->w = box->w;
00862     box->gmc->h = box->h;
00863     evas_object_resize(box->edje, box->w, box->h);
00864     
00865   }
00866     }
00867 
00868   /* Animation */
00869   switch (box->devian->conf->box_anim)
00870     {
00871     case CONTAINER_BOX_ANIM_NO:
00872       break;
00873     case CONTAINER_BOX_ANIM_LINE:
00874       {
00875   box->x = box->x + spd;
00876   if ( (box->x + box->w) > dEvianM->canvas_w )
00877     box->x = 0;
00878 
00879   box->gmc->x = box->x;
00880   box->gmc->y = box->y;
00881   evas_object_move(box->edje, box->x, box->y);
00882 
00883   break;
00884       }
00885     case CONTAINER_BOX_ANIM_GOULOUM:
00886       {
00887   box->x = box->x + box->anim->data[1]*spd;
00888   box->y = box->y + box->anim->data[2]*spd;
00889   if ( (box->x + box->w) > dEvianM->canvas_w )
00890     box->anim->data[1] = -1;
00891   if ( (box->x) < 0 )
00892     box->anim->data[1] = 1;
00893   if ( (box->y + box->h) > dEvianM->canvas_h )
00894     box->anim->data[2] = -1;
00895   if ( (box->y) < 0 )
00896     box->anim->data[2] = 1;
00897 
00898   box->gmc->x = box->x;
00899   box->gmc->y = box->y;
00900   evas_object_move(box->edje, box->x, box->y);
00901 
00902   break;
00903       }
00904     case CONTAINER_BOX_ANIM_GHOST:
00905       {
00906   if (box->anim->data[1])
00907     {
00908       if (!box->anim->data[2])
00909         {
00910     box->anim->data[3] = box->anim->data[3] - 10;
00911     if (box->anim->data[3] < 0)
00912       box->anim->data[3] = 0;
00913     evas_object_color_set(box->edje, 255, 255, 255,
00914               box->anim->data[3]);
00915     if (box->anim->data[3] == 0)
00916       {
00917         box->anim->data[2] = 1;
00918         devian_container_box_random_pos_get(&box->x, &box->y,
00919               box->devian->conf->box_max_size);
00920         box->gmc->x = box->x;
00921         box->gmc->y = box->y;
00922         evas_object_move(box->edje, box->x, box->y);
00923       }
00924         }
00925       else
00926         {
00927     box->anim->data[3] = box->anim->data[3] + 10;
00928     if (box->anim->data[3] > 255)
00929       box->anim->data[3] = 255;
00930     evas_object_color_set(box->edje, 255, 255, 255,
00931               box->anim->data[3]);
00932     if (box->anim->data[3] == 255)
00933       {
00934         box->anim->data[1] = 0;
00935       }
00936         }
00937     }
00938   break;
00939       }
00940     default: box->devian->conf->box_anim = CONTAINER_BOX_ANIM_NO;
00941     }
00942 
00943     }
00944   
00945   /* If there are no more animations for box , destroy ecore animator */
00946   if (!box->in_resize &&
00947       (!box->devian->conf->box_anim ||
00948        (box->devian->conf->box_anim==CONTAINER_BOX_ANIM_GHOST &&
00949   !box->anim->data[1])))
00950     {
00951       DCONTAINER(("> Stop anim callback <"));
00952       box->animator = NULL;
00953       return 0;
00954     }
00955   else
00956     return 1;
00957 }
00958 
00959 static int _cb_timer_anim_ghost(void *data)
00960 {
00961   Container_Box *box;
00962   box = (Container_Box *)data;
00963 
00964   if (!box->animator)
00965     box->animator = ecore_animator_add(_cb_ecore_animator, box);
00966 
00967   box->anim->data[1] = 1;
00968   box->anim->data[2] = !box->anim->data[2];
00969 
00970   return 1;
00971 }
00972 
00973 static void _animation_stop(Container_Box *box)
00974 {
00975   if (!box->anim)
00976     return;
00977   box->devian->conf->box_anim = CONTAINER_BOX_ANIM_NO;
00978 }

Generated on Fri Jan 6 02:26:26 2006 for dEvian by  doxygen 1.4.4