Hi everyone
Here are (my first!) two patches that add a function I use to access a
table's child using the coordinates it was inserted with.
evas_object_table_child_get(obj, col, row);
and its edje counterpart
edje_object_part_table_child_get(obj, part, col, row);
Hugo Camboulive
diff --git a/src/lib/Edje.h b/src/lib/Edje.h
index 90ebff2..efc2399 100644
--- a/src/lib/Edje.h
+++ b/src/lib/Edje.h
@@ -544,6 +544,7 @@ extern "C" {
EAPI Evas_Object *edje_object_part_box_remove (Evas_Object *obj, const char *part, Evas_Object *child);
EAPI Evas_Object *edje_object_part_box_remove_at (Evas_Object *obj, const char *part, unsigned int pos);
EAPI Eina_Bool edje_object_part_box_remove_all (Evas_Object *obj, const char *part, Eina_Bool clear);
+ EAPI Evas_Object *edje_object_part_table_child_get(Evas_Object *obj, const char *part, unsigned int col, unsigned int row);
EAPI Eina_Bool edje_object_part_table_pack (Evas_Object *obj, const char *part, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan);
EAPI Eina_Bool edje_object_part_table_unpack (Evas_Object *obj, const char *part, Evas_Object *child_obj);
EAPI Eina_Bool edje_object_part_table_col_row_size_get (const Evas_Object *obj, const char *part, int *cols, int *rows);
diff --git a/src/lib/edje_util.c b/src/lib/edje_util.c
index 1e5ea92..1a2b04a 100644
--- a/src/lib/edje_util.c
+++ b/src/lib/edje_util.c
@@ -3673,6 +3673,31 @@ _edje_table_child_remove(Edje_Real_Part *rp, Evas_Object *child)
}
/**
+ * @brief Retrieve a child from a table
+ *
+ * @param obj A valid Evas_Object handle
+ * @param part The part name
+ * @param col The column of the child to get
+ * @param row The row of the child to get
+ * @return The child Evas_Object
+ */
+EAPI Evas_Object *
+edje_object_part_table_child_get(Evas_Object *obj, const char *part, unsigned int col, unsigned int row)
+{
+ Edje *ed;
+ Edje_Real_Part *rp;
+
+ ed = _edje_fetch(obj);
+ if ((!ed) || (!part)) return NULL;
+
+ rp = _edje_real_part_recursive_get(ed, part);
+ if (!rp) return NULL;
+ if (rp->part->type != EDJE_PART_TYPE_TABLE) return NULL;
+
+ return evas_object_table_child_get(rp->object, col, row);
+}
+
+/**
* @brief Packs an object into the table.
*
* @param obj A valid Evas_Object handle
diff --git a/src/lib/Evas.h b/src/lib/Evas.h
index 8628b0e..827f325 100644
--- a/src/lib/Evas.h
+++ b/src/lib/Evas.h
@@ -2053,6 +2053,7 @@ struct _Evas_Smart_Cb_Description
EAPI Eina_Iterator *evas_object_table_iterator_new(const Evas_Object *o) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
EAPI Eina_Accessor *evas_object_table_accessor_new(const Evas_Object *o) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
EAPI Eina_List *evas_object_table_children_get(const Evas_Object *o) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
+ EAPI Evas_Object *evas_object_table_child_get(const Evas_Object *o, unsigned short col, unsigned short row) EINA_ARG_NONNULL(1);
/**
diff --git a/src/lib/canvas/evas_object_table.c b/src/lib/canvas/evas_object_table.c
index f713b05..90393f7 100644
--- a/src/lib/canvas/evas_object_table.c
+++ b/src/lib/canvas/evas_object_table.c
@@ -1358,3 +1358,22 @@ evas_object_table_children_get(const Evas_Object *o)
return new_list;
}
+
+/**
+ * Get a child from the table using its coordinates
+ *
+ * @note This does not take into account col/row spanning
+ */
+Evas_Object *
+evas_object_table_child_get(const Evas_Object *o, unsigned short col, unsigned short row)
+{
+ Eina_List *l;
+ Evas_Object_Table_Option *opt;
+
+ EVAS_OBJECT_TABLE_DATA_GET_OR_RETURN_VAL(o, priv, NULL);
+
+ EINA_LIST_FOREACH(priv->children, l, opt)
+ if (opt->col == col && opt->row == row)
+ return opt->obj;
+ return NULL;
+}
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel