edje: add collection.group.limits.vertical and collection.group.limits.horizontal.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 22 Aug 2011 21:44:49 +0000 (21:44 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 22 Aug 2011 21:44:49 +0000 (21:44 +0000)
The goal is to provide an easy way to do the kind of effect you see in that video
around 00:36 : http://www.youtube.com/watch?v=KVoVLHh8CHc.
  At that time it was really difficult to do such thing and required a lot of
embryo code, we designed limit with Billiob to be able to do such kind of things
much more easily.

NOTE: so Billiob, now nothing stop you from releasing amsn2 ! ;-)

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@62701 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
src/bin/edje_cc_handlers.c
src/lib/edje_data.c
src/lib/edje_private.h
src/lib/edje_smart.c

index 2e71461..a76cf99 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
         * Add entry,selection,all,request for signalling ctrl+a in an entry
         * Add entry,selection,none,request for signalling ctrl+shift+a in an entry
         * Fix entry,paste,request* to be emitted after cursor,changed (fixes middle mouse paste location)
-        
+
 2011-05-27  Carsten Haitzler (The Rasterman)
 
        * Fix edje_shutdown() being called before all evas objects created
 
        * Entry: Added changed,user signal. This signal indicates the entry
        has changed because of user interaction, i.e not by code.
+
+2011-08-22  Cedric Bail
+
+       * Add collection.group.limits {
+                 vertical: "name" value;
+                 horizontal: "name" value;
+             }.
index 09b88dd..f12ff37 100644 (file)
@@ -104,6 +104,9 @@ static void st_collections_group_max(void);
 static void st_collections_group_data_item(void);
 static void st_collections_group_orientation(void);
 
+static void st_collections_group_limits_vertical(void);
+static void st_collections_group_limits_horizontal(void);
+
 static void ob_collections_group_script(void);
 static void ob_collections_group_lua_script(void);
 
@@ -296,6 +299,8 @@ New_Statement_Handler statement_handlers[] =
      {"collections.group.max", st_collections_group_max},
      {"collections.group.orientation", st_collections_group_orientation},
      {"collections.group.data.item", st_collections_group_data_item},
+     {"collections.group.limits.horizontal", st_collections_group_limits_horizontal},
+     {"collections.group.limits.vertical", st_collections_group_limits_vertical},
      {"collections.group.externals.external", st_externals_external}, /* dup */
      {"collections.group.image", st_images_image}, /* dup */
      {"collections.group.set.name", st_images_set_name},
@@ -2062,6 +2067,92 @@ st_collections_group_orientation(void)
 
 /**
     @page edcref
+    @property
+       group {
+            limits {
+               vertical: "limit_name" height_barrier;
+               ..
+           }
+       }
+    @parameters
+       [name] [height barrier]
+    @effect
+        This defines when to trigger some even when the Edje object is resized.
+       It will send a signal: "limit,name,over" when the object is resized and pass
+       the limit by growing over it. And it will send: "limit,name,below" when
+       it pass below that limit.
+    @endproperty
+*/
+static void
+st_collections_group_limits_vertical(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Limit *el;
+
+   check_arg_count(2);
+
+   el = mem_alloc(SZ(Edje_Limit));
+
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   pc->limits.vertical_count++;
+   pc->limits.vertical = realloc(pc->limits.vertical, pc->limits.vertical_count * sizeof (Edje_Limit *));
+   if (!pc->limits.vertical || el)
+     {
+        ERR("%s: Error. Not enough memory.", progname);
+        exit(-1);
+     }
+
+   pc->limits.vertical[pc->limits.vertical_count - 1] = el;
+
+   el->name = parse_str(0);
+   el->value = parse_int_range(1, 1, 0xffff);
+}
+
+/**
+    @page edcref
+    @property
+       group {
+            limits {
+               horizontal: "limit_name" width_barrier;
+               ..
+           }
+       }
+    @parameters
+       [name] [width barrier]
+    @effect
+        This defines when to trigger some signal when the Edje object is resized.
+       It will send a signal: "limit,name,over" when the object is resized and pass
+       the limit by growing over it. And it will send: "limit,name,below" when
+       it pass below that limit.
+    @endproperty
+*/
+static void
+st_collections_group_limits_horizontal(void)
+{
+   Edje_Part_Collection *pc;
+   Edje_Limit *el;
+
+   check_arg_count(2);
+
+   el = mem_alloc(SZ(Edje_Limit));
+
+   pc = eina_list_data_get(eina_list_last(edje_collections));
+   pc->limits.horizontal_count++;
+   pc->limits.horizontal = realloc(pc->limits.horizontal, pc->limits.horizontal_count * sizeof (Edje_Limit *));
+   if (!pc->limits.horizontal || el)
+     {
+        ERR("%s: Error. Not enough memory.", progname);
+        exit(-1);
+     }
+
+   pc->limits.horizontal[pc->limits.horizontal_count - 1] = el;
+
+   el->name = parse_str(0);
+   el->value = parse_int_range(1, 1, 0xffff);
+}
+
+/**
+    @page edcref
     @block
         parts
     @context
index 48559ba..12130f7 100644 (file)
@@ -14,6 +14,8 @@ Eet_Data_Descriptor *_edje_edd_edje_image_directory = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_image_directory_entry = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_image_directory_set = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_image_directory_set_entry = NULL;
+Eet_Data_Descriptor *_edje_edd_edje_limit = NULL;
+Eet_Data_Descriptor *_edje_edd_edje_limit_pointer = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_program = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_program_pointer = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_program_target = NULL;
@@ -165,6 +167,8 @@ _edje_edd_shutdown(void)
    FREED(_edje_edd_edje_font_directory_entry);
    FREED(_edje_edd_edje_image_directory);
    FREED(_edje_edd_edje_image_directory_entry);
+   FREED(_edje_edd_edje_limit);
+   FREED(_edje_edd_edje_limit_pointer);
    FREED(_edje_edd_edje_program);
    FREED(_edje_edd_edje_program_pointer);
    FREED(_edje_edd_edje_program_target);
@@ -343,7 +347,12 @@ _edje_edd_init(void)
    EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "fonts", fonts, _edje_edd_edje_font_directory_entry);
    EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "collection", collection, _edje_edd_edje_part_collection_directory_entry);
 
-   /* parts & programs - loaded induvidually */
+   /* parts & limit & programs - loaded induvidually */
+   EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Limit);
+   _edje_edd_edje_limit = eet_data_descriptor_file_new(&eddc);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_limit, Edje_Limit, "name", name, EET_T_STRING);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_limit, Edje_Limit, "value", value, EET_T_INT);
+
    EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program_Target);
    _edje_edd_edje_program_target =
      eet_data_descriptor_file_new(&eddc);
@@ -813,6 +822,10 @@ _edje_edd_init(void)
    EDJE_DEFINE_POINTER_TYPE(Part, part);
    EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "parts", parts, _edje_edd_edje_part_pointer);
 
+   EDJE_DEFINE_POINTER_TYPE(Limit, limit);
+   EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "limits.vertical", limits.vertical, _edje_edd_edje_limit_pointer);
+   EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "limits.horizontal", limits.horizontal, _edje_edd_edje_limit_pointer);
+
    EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_part_collection, Edje_Part_Collection, "data", data, _edje_edd_edje_string);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "id", id, EET_T_INT);
    EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "alias", alias);
index 07a901e..e362904 100644 (file)
@@ -267,6 +267,7 @@ typedef struct _Edje_Image_Directory                 Edje_Image_Directory;
 typedef struct _Edje_Image_Directory_Entry           Edje_Image_Directory_Entry;
 typedef struct _Edje_Image_Directory_Set             Edje_Image_Directory_Set;
 typedef struct _Edje_Image_Directory_Set_Entry       Edje_Image_Directory_Set_Entry;
+typedef struct _Edje_Limit                           Edje_Limit;
 typedef struct _Edje_Program                         Edje_Program;
 typedef struct _Edje_Program_Target                  Edje_Program_Target;
 typedef struct _Edje_Program_After                   Edje_Program_After;
@@ -576,6 +577,13 @@ struct _Edje_Program_After /* the action to run after another action */
 };
 
 /*----------*/
+struct _Edje_Limit
+{
+   const char *name;
+   int value;
+};
+
+/*----------*/
 #define PART_TYPE_FIELDS(TYPE)    \
       TYPE      RECTANGLE;        \
       TYPE      TEXT;             \
@@ -657,6 +665,14 @@ struct _Edje_Part_Collection
       unsigned int nocmp_count;
    } programs;
 
+   struct { /* list of limit that need to be monitored */
+      Edje_Limit **vertical;
+      unsigned int vertical_count;
+
+      Edje_Limit **horizontal;
+      unsigned int horizontal_count;
+   } limits;
+
    Edje_Part **parts; /* an array of Edje_Part */
    unsigned int parts_count;
 
@@ -1005,6 +1021,7 @@ struct _Edje
    Eina_List            *subobjs;
    Eina_List            *text_insert_filter_callbacks;
    void                 *script_only_data;
+
    int                   table_programs_size;
    unsigned int          table_parts_size;
 
@@ -1037,12 +1054,21 @@ struct _Edje
       void                    *data;
       int                      num;
    } message;
-   int                      processing_messages;
+   int                   processing_messages;
 
    int                   state;
 
    int                  preload_count;
 
+   lua_State            *L;
+   Eina_Inlist          *lua_objs;
+   int                   lua_ref;
+
+   struct {
+      Edje_Item_Provider_Cb  func;
+      void                  *data;
+   } item_provider;
+
    unsigned int          dirty : 1;
    unsigned int          recalc : 1;
    unsigned int          walking_callbacks : 1;
@@ -1064,15 +1090,6 @@ struct _Edje
    unsigned int          all_part_change : 1;
 #endif
    unsigned int          have_mapped_part : 1;
-
-   lua_State            *L;
-   Eina_Inlist          *lua_objs;
-   int                   lua_ref;
-   
-   struct {
-      Edje_Item_Provider_Cb  func;
-      void                  *data;
-   } item_provider;
 };
 
 struct _Edje_Calc_Params
index 5d1440d..59ccc46 100644 (file)
@@ -208,6 +208,40 @@ _edje_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y)
 }
 
 static void
+_edje_limit_emit(Edje *ed, const char *limit_name, Eina_Bool over)
+{
+   char *buffer;
+   unsigned int length;
+
+   if (!limit_name) return ;
+
+   length = strlen(limit_name) + 13;
+   buffer = alloca(length);
+   snprintf(buffer, length, "limit,%s,%s", limit_name, over ? "over" : "below");
+   _edje_emit(ed, buffer, NULL);
+}
+
+static void
+_edje_limit_get(Edje *ed, Edje_Limit **limits, unsigned int length, Evas_Coord size_current, Evas_Coord size_next)
+{
+   unsigned int i;
+
+   if (size_next == size_current) return ;
+
+   for (i = 0; i < length; ++i)
+     {
+        if ((size_current <= limits[i]->value) && (limits[i]->value < size_next))
+          {
+             _edje_limit_emit(ed, limits[i]->name, EINA_TRUE);
+          }
+        else if ((size_next <= limits[i]->value) && (limits[i]->value < size_current))
+          {
+             _edje_limit_emit(ed, limits[i]->name, EINA_FALSE);
+          }
+     }
+}
+
+static void
 _edje_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h)
 {
    Edje *ed;
@@ -215,6 +249,11 @@ _edje_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h)
    ed = evas_object_smart_data_get(obj);
    if (!ed) return;
    if ((w == ed->w) && (h == ed->h)) return;
+   if (ed->collection)
+     {
+        _edje_limit_get(ed, ed->collection->limits.horizontal, ed->collection->limits.horizontal_count, ed->w, w);
+        _edje_limit_get(ed, ed->collection->limits.vertical, ed->collection->limits.vertical_count, ed->h, h);
+     }
    ed->w = w;
    ed->h = h;
 #ifdef EDJE_CALC_CACHE