Added version and insert_after to box api
authorsachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 2 Oct 2009 19:06:12 +0000 (19:06 +0000)
committersachiel <sachiel@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 2 Oct 2009 19:06:12 +0000 (19:06 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@42862 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/Evas.h
src/lib/canvas/evas_object_box.c

index 47313fa..853a112 100644 (file)
@@ -1107,12 +1107,15 @@ extern "C" {
    typedef struct _Evas_Object_Box_Option     Evas_Object_Box_Option;
    typedef void (*Evas_Object_Box_Layout)(Evas_Object *o, Evas_Object_Box_Data *priv, void *user_data);
 
+#define EVAS_OBJECT_BOX_API_VERSION 1
    struct _Evas_Object_Box_Api
    {
       Evas_Smart_Class base;
+      int version;
       Evas_Object_Box_Option *(*append)(Evas_Object *o, Evas_Object_Box_Data *priv, Evas_Object *child);
       Evas_Object_Box_Option *(*prepend)(Evas_Object *o, Evas_Object_Box_Data *priv, Evas_Object *child);
       Evas_Object_Box_Option *(*insert_before)(Evas_Object *o, Evas_Object_Box_Data *priv, Evas_Object *child, const Evas_Object *reference);
+      Evas_Object_Box_Option *(*insert_after)(Evas_Object *o, Evas_Object_Box_Data *priv, Evas_Object *child, const Evas_Object *reference);
       Evas_Object_Box_Option *(*insert_at)(Evas_Object *o, Evas_Object_Box_Data *priv, Evas_Object *child, unsigned int pos);
       Evas_Object            *(*remove)(Evas_Object *o, Evas_Object_Box_Data *priv, Evas_Object *child);
       Evas_Object            *(*remove_at)(Evas_Object *o, Evas_Object_Box_Data *priv, unsigned int pos);
@@ -1137,7 +1140,7 @@ extern "C" {
  * @see EVAS_OBJECT_BOX_API_INIT_VERSION
  * @see EVAS_OBJECT_BOX_API_INIT_NAME_VERSION
  */
-#define EVAS_OBJECT_BOX_API_INIT(smart_class_init) {smart_class_init, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
+#define EVAS_OBJECT_BOX_API_INIT(smart_class_init) {smart_class_init, EVAS_OBJECT_BOX_API_VERSION, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
 
 /**
  * Initializer to zero a whole Evas_Object_Box_Api structure.
@@ -1225,6 +1228,7 @@ extern "C" {
    EAPI Evas_Object_Box_Option *evas_object_box_append(Evas_Object *o, Evas_Object *child) EINA_ARG_NONNULL(1, 2);
    EAPI Evas_Object_Box_Option *evas_object_box_prepend(Evas_Object *o, Evas_Object *child) EINA_ARG_NONNULL(1, 2);
    EAPI Evas_Object_Box_Option *evas_object_box_insert_before(Evas_Object *o, Evas_Object *child, const Evas_Object *reference) EINA_ARG_NONNULL(1, 2, 3);
+   EAPI Evas_Object_Box_Option *evas_object_box_insert_after(Evas_Object *o, Evas_Object *child, const Evas_Object *referente) EINA_ARG_NONNULL(1, 2, 3);
    EAPI Evas_Object_Box_Option *evas_object_box_insert_at(Evas_Object *o, Evas_Object *child, unsigned int pos) EINA_ARG_NONNULL(1, 2);
    EAPI Eina_Bool               evas_object_box_remove(Evas_Object *o, Evas_Object *child) EINA_ARG_NONNULL(1, 2);
    EAPI Eina_Bool               evas_object_box_remove_at(Evas_Object *o, unsigned int pos) EINA_ARG_NONNULL(1);
index de4489b..8bf66a9 100644 (file)
@@ -267,6 +267,31 @@ _evas_object_box_insert_before_default(Evas_Object *o, Evas_Object_Box_Data *pri
 }
 
 static Evas_Object_Box_Option *
+_evas_object_box_insert_after_default(Evas_Object *o, Evas_Object_Box_Data *priv, Evas_Object *child, const Evas_Object *reference)
+{
+   Eina_List *l;
+   Evas_Object_Box_Option *opt;
+
+   EINA_LIST_FOREACH(priv->children, l, opt)
+     {
+       if (opt->obj == reference)
+         {
+            Evas_Object_Box_Option *new_opt;
+
+            new_opt = _evas_object_box_option_new(o, priv, child);
+            if (!new_opt)
+              return NULL;
+
+            priv->children = eina_list_append_relative
+               (priv->children, new_opt, opt);
+            return new_opt;
+         }
+     }
+
+   return NULL;
+}
+
+static Evas_Object_Box_Option *
 _evas_object_box_insert_at_default(Evas_Object *o, Evas_Object_Box_Data *priv, Evas_Object *child, unsigned int pos)
 {
    Eina_List *l;
@@ -534,6 +559,7 @@ evas_object_box_smart_set(Evas_Object_Box_Api *api)
    api->append = _evas_object_box_append_default;
    api->prepend = _evas_object_box_prepend_default;
    api->insert_before = _evas_object_box_insert_before_default;
+   api->insert_after = _evas_object_box_insert_after_default;
    api->insert_at = _evas_object_box_insert_at_default;
    api->remove = _evas_object_box_remove_default;
    api->remove_at = _evas_object_box_remove_at_default;
@@ -2023,6 +2049,37 @@ evas_object_box_insert_before(Evas_Object *o, Evas_Object *child, const Evas_Obj
 }
 
 /**
+ * Append a new object @a child to the box @c o relative to element @a
+ * reference. If @a reference is not contained in the box or any other
+ * error occurs, @c NULL is returend.
+ */
+Evas_Object_Box_Option *
+evas_object_box_insert_after(Evas_Object *o, Evas_Object *child, const Evas_Object *reference)
+{
+   Evas_Object_Box_Option *opt;
+   const Evas_Object_Box_Api *api;
+
+   EVAS_OBJECT_BOX_DATA_GET_OR_RETURN_VAL(o, priv, NULL);
+   if (!child)
+     return NULL;
+
+   api = priv->api;
+   if ((!api) || (!api->insert_after))
+     return NULL;
+
+   opt = api->insert_after(o, priv, child, reference);
+
+   if (opt)
+     {
+       evas_object_smart_member_add(child, o);
+       evas_object_smart_changed(o);
+       return _evas_object_box_option_callbacks_register(o, priv, opt);
+     }
+
+   return NULL;
+}
+
+/**
  * Insert a new object @a child to the box @a o at position @a pos. On
  * error, @c NULL is returned.
  */