Hello all!

I patch edje to get working dragable objects like progressbars.

this done by event handling and passing to dragable (mouse_down, mouse_up, mouse_move).
you should add section like next one
===
dragable {
events: "progress_bar_drag";
}
===
into "part" section of object on that you make action.

example in 2nd attached file.
i hope this will be useful in eclair volume and progress bar (i tested both)

thanks for attention.

--
Sorry for bad English.
Boldin Pavel aka davinchi. mail-to: ldavinchi /at\ inbox _dot_ ru
   ZU - Zagovor Unixoidov. SSAU 303.


diff -NurpP -x compile -x '*-config' -x '*.Tpo' -x '.*' -x 'output.*' -x 
autom4te.cache -x '*.orig' -x '*.o' -x '*.so*' -x '*.a' -x missing -x 
install-sh -x depcomp -x core -x '*~' -x '*.m4' -x 'config.*' -x configure -x 
'*.sh' -x libtool -x 'Makefile*' -x 'stamp*' 
/home/davinchi/downloaded/e17/libs/edje/src/bin/edje_cc_handlers.c 
edje/src/bin/edje_cc_handlers.c
--- /home/davinchi/downloaded/e17/libs/edje/src/bin/edje_cc_handlers.c  
2005-03-31 22:26:30 +0500
+++ edje/src/bin/edje_cc_handlers.c     2005-06-18 20:41:43 +0500
@@ -30,6 +30,7 @@ static void st_collections_group_parts_p
 static void st_collections_group_parts_part_dragable_x(void);
 static void st_collections_group_parts_part_dragable_y(void);
 static void st_collections_group_parts_part_dragable_confine(void);
+static void st_collections_group_parts_part_dragable_events(void);
 
 static void ob_collections_group_parts_part_description(void);
 static void st_collections_group_parts_part_description_inherit(void);
@@ -118,6 +119,7 @@ New_Statement_Handler statement_handlers
      {"collections.group.parts.part.dragable.x", 
st_collections_group_parts_part_dragable_x},
      {"collections.group.parts.part.dragable.y", 
st_collections_group_parts_part_dragable_y},
      {"collections.group.parts.part.dragable.confine", 
st_collections_group_parts_part_dragable_confine},
+     {"collections.group.parts.part.dragable.events", 
st_collections_group_parts_part_dragable_events},
      {"collections.group.parts.part.image", st_images_image}, /* dup */
      {"collections.group.parts.part.images.image", st_images_image}, /* dup */
      {"collections.group.parts.part.font", st_fonts_font}, /* dup */
@@ -573,6 +575,7 @@ ob_collections_group_parts_part(void)
    ep->repeat_events = 0;
    ep->clip_to_id = -1;
    ep->dragable.confine_id = -1;
+   ep->dragable.events_id = -1;
 }
 
 static void
@@ -719,6 +722,25 @@ st_collections_group_parts_part_dragable
 }
 
 static void
+st_collections_group_parts_part_dragable_events(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Part *ep;
+
+   check_arg_count(1);
+
+   pc = evas_list_data(evas_list_last(edje_collections));
+   ep = evas_list_data(evas_list_last(pc->parts));
+     {
+       char *name;
+       
+       name = parse_str(0);
+       data_queue_part_lookup(pc, name, &(ep->dragable.events_id));
+       free(name);
+     }
+}
+
+static void
 ob_collections_group_parts_part_description(void)
 {
    Edje_Part_Collection *pc;
diff -NurpP -x compile -x '*-config' -x '*.Tpo' -x '.*' -x 'output.*' -x 
autom4te.cache -x '*.orig' -x '*.o' -x '*.so*' -x '*.a' -x missing -x 
install-sh -x depcomp -x core -x '*~' -x '*.m4' -x 'config.*' -x configure -x 
'*.sh' -x libtool -x 'Makefile*' -x 'stamp*' 
/home/davinchi/downloaded/e17/libs/edje/src/lib/edje_callbacks.c 
edje/src/lib/edje_callbacks.c
--- /home/davinchi/downloaded/e17/libs/edje/src/lib/edje_callbacks.c    
2004-12-14 07:24:32 +0400
+++ edje/src/lib/edje_callbacks.c       2005-06-19 01:29:33 +0500
@@ -1,3 +1,8 @@
+/*
+ * vim: ts=8
+ */
+
+
 #include "Edje.h"
 #include "edje_private.h"
 
@@ -54,14 +59,64 @@ _edje_mouse_down_cb(void *data, Evas * e
    _edje_ref(ed);
    _edje_freeze(ed);
    _edje_emit(ed, buf, rp->part->name);
+
+   if (rp->events_to)
+   {
+       int tmp_x;
+       Edje_Real_Part* events;
+       events = rp->events_to;
+
+       if ((events->part->dragable.x) || (events->part->dragable.y))
+       {
+              if (events->part->dragable.x)
+              {
+                  events->drag.tmp.x = ev->canvas.x - (events->x + 
events->w/2);
+                  events->drag.down.x = ev->canvas.x;
+                  events->x = ev->canvas.x;
+              }
+              if (rp->part->dragable.y)
+              {
+                  events->drag.tmp.y = ev->canvas.y - (events->y + 
events->h/2);
+                  events->drag.down.y = ev->canvas.y;
+                  events->y = ev->canvas.y;
+              }
+
+              snprintf(buf, sizeof(buf), "mouse,down,%i", ev->button);
+              _edje_emit(ed, buf, events->part->name);
+              ed->dirty = 1;
+       }
+       _edje_recalc(ed);
+       _edje_thaw(ed);
+       _edje_unref(ed);
+       _edje_ref(ed);
+       _edje_freeze(ed);
+
+       rp = events;
+       {
+          double dx, dy;
+          int dir;
+
+          dir = _edje_part_dragable_calc(ed, rp, &dx, &dy);
+          if ((dx != rp->drag.val.x) || (dy != rp->drag.val.y))
+          {
+              rp->drag.val.x = dx;
+              rp->drag.val.y = dy;
+              _edje_emit(ed, "drag", rp->part->name);
+              ed->dirty = 1;
+              rp->drag.need_reset = 1;
+              _edje_recalc(ed);
+          }
+       }
+   }
+
    if ((rp->part->dragable.x) || (rp->part->dragable.y))
      {
        if (rp->drag.down.count == 0)
          {
             if (rp->part->dragable.x)
-              rp->drag.down.x = ev->canvas.x;
+                rp->drag.down.x = ev->canvas.x;
             if (rp->part->dragable.y)
-              rp->drag.down.y = ev->canvas.y;
+                rp->drag.down.y = ev->canvas.y;
             _edje_emit(ed, "drag,start", rp->part->name);
          }
        rp->drag.down.count++;
@@ -90,9 +145,18 @@ _edje_mouse_up_cb(void *data, Evas * e, 
    ed = data;
    rp = evas_object_data_get(obj, "real_part");
    if (!rp) return;
+
    snprintf(buf, sizeof(buf), "mouse,up,%i", ev->button);
    _edje_ref(ed);
    _edje_emit(ed, buf, rp->part->name);
+
+   if(rp->events_to)
+   {
+       rp = rp->events_to;
+       snprintf(buf, sizeof(buf), "mouse,up,%i", ev->button);
+       _edje_emit(ed, buf, rp->part->name);
+   }
+
    if ((rp->part->dragable.x) || (rp->part->dragable.y))
      {
        if (rp->drag.down.count > 0)
@@ -132,6 +196,9 @@ _edje_mouse_move_cb(void *data, Evas * e
    ed = data;
    rp = evas_object_data_get(obj, "real_part");
    if (!rp) return;
+   if (rp->events_to)
+       rp = rp->events_to;
+
    if (rp->still_in)
      {
        Evas_Coord x, y, w, h;
diff -NurpP -x compile -x '*-config' -x '*.Tpo' -x '.*' -x 'output.*' -x 
autom4te.cache -x '*.orig' -x '*.o' -x '*.so*' -x '*.a' -x missing -x 
install-sh -x depcomp -x core -x '*~' -x '*.m4' -x 'config.*' -x configure -x 
'*.sh' -x libtool -x 'Makefile*' -x 'stamp*' 
/home/davinchi/downloaded/e17/libs/edje/src/lib/edje_data.c 
edje/src/lib/edje_data.c
--- /home/davinchi/downloaded/e17/libs/edje/src/lib/edje_data.c 2005-03-31 
22:26:31 +0500
+++ edje/src/lib/edje_data.c    2005-06-18 20:40:31 +0500
@@ -238,6 +238,7 @@ _edje_edd_setup(void)
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, 
"dragable.step_y", dragable.step_y, EET_T_INT);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, 
"dragable.count_y", dragable.count_y, EET_T_INT);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, 
"dragable.counfine_id", dragable.confine_id, EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, 
"dragable.events_id", dragable.events_id, EET_T_INT);
    
    _edje_edd_edje_part_collection  = 
      NEWD("Edje_Part_Collection", 
diff -NurpP -x compile -x '*-config' -x '*.Tpo' -x '.*' -x 'output.*' -x 
autom4te.cache -x '*.orig' -x '*.o' -x '*.so*' -x '*.a' -x missing -x 
install-sh -x depcomp -x core -x '*~' -x '*.m4' -x 'config.*' -x configure -x 
'*.sh' -x libtool -x 'Makefile*' -x 'stamp*' 
/home/davinchi/downloaded/e17/libs/edje/src/lib/edje_load.c 
edje/src/lib/edje_load.c
--- /home/davinchi/downloaded/e17/libs/edje/src/lib/edje_load.c 2005-05-27 
20:27:30 +0500
+++ edje/src/lib/edje_load.c    2005-06-18 20:39:36 +0500
@@ -85,6 +85,7 @@ edje_object_file_set(Evas_Object *obj, c
                  desc = hist->data;
                  if (desc->color_class) _edje_color_class_member_add(ed, 
desc->color_class);
               }
+            hist = NULL;
             hist = evas_list_append(hist, ep);
             while (ep->dragable.confine_id >= 0)
               {
@@ -101,6 +102,21 @@ edje_object_file_set(Evas_Object *obj, c
             evas_list_free(hist);
             hist = NULL;
             hist = evas_list_append(hist, ep);
+            while (ep->dragable.events_id >= 0)
+              {
+                 ep = evas_list_nth(ed->collection->parts,
+                                    ep->dragable.events_id);
+                 if (evas_list_find(hist, ep))
+                   {
+                      printf("EDJE ERROR: events_to loops. invalidating 
loop.\n");
+                      ep->dragable.events_id = -1;
+                      break;
+                   }
+                 hist = evas_list_append(hist, ep);
+              }
+            evas_list_free(hist);
+            hist = NULL;
+            hist = evas_list_append(hist, ep);
             while (ep->clip_to_id >= 0)
               {
                  ep = evas_list_nth(ed->collection->parts,
@@ -232,6 +248,10 @@ edje_object_file_set(Evas_Object *obj, c
                  if (rp->part->dragable.confine_id >= 0)
                    rp->confine_to = evas_list_nth(ed->parts, 
rp->part->dragable.confine_id);
                  
+                 /* replay events for dragable */
+                 if (rp->part->dragable.events_id >= 0)
+                   rp->events_to = evas_list_nth(ed->parts, 
rp->part->dragable.events_id);
+
                  rp->swallow_params.min.w = 0;
                  rp->swallow_params.min.w = 0;
                  rp->swallow_params.max.w = -1;
diff -NurpP -x compile -x '*-config' -x '*.Tpo' -x '.*' -x 'output.*' -x 
autom4te.cache -x '*.orig' -x '*.o' -x '*.so*' -x '*.a' -x missing -x 
install-sh -x depcomp -x core -x '*~' -x '*.m4' -x 'config.*' -x configure -x 
'*.sh' -x libtool -x 'Makefile*' -x 'stamp*' 
/home/davinchi/downloaded/e17/libs/edje/src/lib/edje_private.h 
edje/src/lib/edje_private.h
--- /home/davinchi/downloaded/e17/libs/edje/src/lib/edje_private.h      
2005-04-03 16:43:00 +0500
+++ edje/src/lib/edje_private.h 2005-06-18 20:37:16 +0500
@@ -182,7 +182,7 @@ struct _Edje_Font_Directory_Entry
    char *entry; /* the name of the font */
 };
 
-
+       
 /*----------*/
 
 struct _Edje_Image_Directory
@@ -305,6 +305,9 @@ struct _Edje_Part
       int                 count_y; /* drag area divided by n (0 = no limit) */
       
       int                 confine_id; /* dragging within this bit, -1 = no */
+
+      /* davinchi */
+      int                                events_id;    /* If it is used as 
scrollbar */
    } dragable;
 };
 
@@ -539,6 +542,7 @@ struct _Edje_Real_Part
    } param1, param2, custom;
 
    Edje_Real_Part           *confine_to;
+   Edje_Real_Part           *events_to;
    Edje_Real_Part           *clip_to;
    
    Edje_Running_Program     *program;
      part {
         name: "volume_bar";
         dragable {
            events: "volume_bar_drag";
         }

         description {
            state: "default" 0.0;
            visible: 1;
            //align: 0 0;
            rel1 {
               relative: 0 0;
               offset: 123 0;
               to: "entry_rect";
            }
            rel2 {
               relative: 0 0;
               offset: 200 22;
               to: "entry_rect";
            }
            image {
               normal: "volume_bar.png";
            }
         }
      }

Reply via email to