clouseau: second step towards splitting ui and lib.

SVN revision: 62825
This commit is contained in:
Tom Hacohen 2011-08-25 14:54:27 +00:00
parent 68e03ea526
commit 4f8c6c3668
3 changed files with 239 additions and 69 deletions

2
TODO
View File

@ -11,3 +11,5 @@
* Things to show per-object
* clipping info.
* callback list?
* EET uses malloc, not stringshare, change stringshare -> strdup

View File

@ -8,6 +8,7 @@ struct _Inf_Tree_Item
const char *string;
};
static Eina_List *information_tree = NULL;
static Evas_Object *prop_list = NULL;
static Elm_Genlist_Item_Class itc;
@ -119,6 +120,132 @@ _item_tree_free(void)
}
}
static void
_obj_information_free(Obj_Information *oinfo)
{
eina_stringshare_del(oinfo->evas_props.name);
if (oinfo->obj_type == CLOUSEAU_OBJ_TYPE_ELM)
{
eina_stringshare_del(oinfo->extra_props.elm.type);
eina_stringshare_del(oinfo->extra_props.elm.style);
}
else if (oinfo->obj_type == CLOUSEAU_OBJ_TYPE_TEXT)
{
eina_stringshare_del(oinfo->extra_props.text.font);
eina_stringshare_del(oinfo->extra_props.text.source);
}
else if (oinfo->obj_type == CLOUSEAU_OBJ_TYPE_IMAGE)
{
eina_stringshare_del(oinfo->extra_props.image.file);
eina_stringshare_del(oinfo->extra_props.image.key);
eina_stringshare_del(oinfo->extra_props.image.load_err);
}
else if (oinfo->obj_type == CLOUSEAU_OBJ_TYPE_EDJE)
{
eina_stringshare_del(oinfo->extra_props.edje.file);
eina_stringshare_del(oinfo->extra_props.edje.group);
eina_stringshare_del(oinfo->extra_props.edje.load_err);
}
free(oinfo);
}
static Obj_Information *
_obj_information_get(Tree_Item *treeit)
{
Obj_Information *oinfo;
Evas_Object *obj = treeit->ptr;
oinfo = calloc(1, sizeof(*oinfo));
oinfo->evas_props.is_visible = evas_object_visible_get(obj);
oinfo->evas_props.name = eina_stringshare_add(evas_object_name_get(obj));
oinfo->evas_props.layer = evas_object_layer_get(obj);
evas_object_geometry_get(obj, &oinfo->evas_props.w, &oinfo->evas_props.y,
&oinfo->evas_props.w, &oinfo->evas_props.h);
oinfo->evas_props.scale = evas_object_scale_get(obj);
evas_object_size_hint_min_get(obj, &oinfo->evas_props.min_w,
&oinfo->evas_props.min_h);
evas_object_size_hint_max_get(obj, &oinfo->evas_props.max_w,
&oinfo->evas_props.max_h);
evas_object_size_hint_request_get(obj, &oinfo->evas_props.req_w,
&oinfo->evas_props.req_h);
evas_object_size_hint_align_get(obj, &oinfo->evas_props.align_x,
&oinfo->evas_props.align_y);
evas_object_size_hint_weight_get(obj, &oinfo->evas_props.weight_x,
&oinfo->evas_props.weight_y);
evas_object_color_get(obj, &oinfo->evas_props.r, &oinfo->evas_props.g,
&oinfo->evas_props.b, &oinfo->evas_props.a);
oinfo->evas_props.is_clipper = !!evas_object_clipees_get(obj);
if (!strcmp("elm_widget", evas_object_type_get(obj)))
{
oinfo->obj_type = CLOUSEAU_OBJ_TYPE_ELM;
oinfo->extra_props.elm.type =
eina_stringshare_add(elm_widget_type_get(obj));
oinfo->extra_props.elm.style =
eina_stringshare_add(elm_widget_style_get(obj));
oinfo->extra_props.elm.scale = elm_widget_scale_get(obj);
oinfo->extra_props.elm.is_disabled = elm_widget_disabled_get(obj);
oinfo->extra_props.elm.is_mirrored = elm_widget_mirrored_get(obj);
oinfo->extra_props.elm.is_mirrored_automatic =
elm_widget_mirrored_automatic_get(obj);
}
else if (!strcmp("text", evas_object_type_get(obj)))
{
const char *font;
int size;
oinfo->obj_type = CLOUSEAU_OBJ_TYPE_TEXT;
evas_object_text_font_get(obj, &font, &size);
oinfo->extra_props.text.font = eina_stringshare_add(font);
oinfo->extra_props.text.size = size;
oinfo->extra_props.text.source =
eina_stringshare_add(evas_object_text_font_source_get(obj));
}
else if (!strcmp("image", evas_object_type_get(obj)))
{
const char *file, *key;
oinfo->obj_type = CLOUSEAU_OBJ_TYPE_IMAGE;
evas_object_image_file_get(obj, &file, &key);
oinfo->extra_props.image.file = eina_stringshare_add(file);
oinfo->extra_props.image.key = eina_stringshare_add(key);
oinfo->extra_props.image.source = evas_object_image_source_get(obj);
if (evas_object_image_load_error_get(obj) != EVAS_LOAD_ERROR_NONE)
{
oinfo->extra_props.image.load_err = eina_stringshare_add(
evas_load_error_str(evas_object_image_load_error_get(obj)));
}
}
else if (!strcmp("edje", evas_object_type_get(obj)))
{
const char *file, *group;
oinfo->obj_type = CLOUSEAU_OBJ_TYPE_EDJE;
edje_object_file_get(obj, &file, &group);
oinfo->extra_props.edje.file = eina_stringshare_add(file);
oinfo->extra_props.edje.group = eina_stringshare_add(group);
if (edje_object_load_error_get(obj) != EDJE_LOAD_ERROR_NONE)
{
oinfo->extra_props.edje.load_err = eina_stringshare_add(
edje_load_error_str(edje_object_load_error_get(obj)));
}
}
else
{
oinfo->obj_type = CLOUSEAU_OBJ_TYPE_OTHER;
}
return oinfo;
}
void
clouseau_obj_information_list_populate(Tree_Item *treeit)
@ -128,8 +255,8 @@ clouseau_obj_information_list_populate(Tree_Item *treeit)
if (!treeit->parent)
return;
Evas_Object *obj = treeit->ptr;
Inf_Tree_Item *main_tit;
Obj_Information *oinfo = _obj_information_get(treeit);
/* Populate evas properties list */
main_tit = calloc(1, sizeof(*main_tit));
@ -139,43 +266,38 @@ clouseau_obj_information_list_populate(Tree_Item *treeit)
{
Inf_Tree_Item *tit;
char buf[1024];
Eina_Bool visibility;
Evas_Coord x, y, w, h;
double dx, dy;
visibility = evas_object_visible_get(obj);
snprintf(buf, sizeof(buf), "Visibility: %d", (int) visibility);
snprintf(buf, sizeof(buf), "Visibility: %d",
(int) oinfo->evas_props.is_visible);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
if (evas_object_name_get(obj))
if (oinfo->evas_props.name)
{
snprintf(buf, sizeof(buf), "Name: %s",
evas_object_name_get(obj));
snprintf(buf, sizeof(buf), "Name: %s", oinfo->evas_props.name);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
}
snprintf(buf, sizeof(buf), "Layer: %hd",
evas_object_layer_get(obj));
snprintf(buf, sizeof(buf), "Layer: %hd", oinfo->evas_props.layer);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
evas_object_geometry_get(obj, &x, &y, &w, &h);
snprintf(buf, sizeof(buf), "Position: %d %d", x, y);
snprintf(buf, sizeof(buf), "Position: %d %d", oinfo->evas_props.x,
oinfo->evas_props.y);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
snprintf(buf, sizeof(buf), "Size: %d %d", w, h);
snprintf(buf, sizeof(buf), "Size: %d %d", oinfo->evas_props.w,
oinfo->evas_props.h);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
snprintf(buf, sizeof(buf), "Scale: %.6lg",
evas_object_scale_get(obj));
snprintf(buf, sizeof(buf), "Scale: %.6lg", oinfo->evas_props.scale);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
@ -197,53 +319,52 @@ clouseau_obj_information_list_populate(Tree_Item *treeit)
}
#endif
evas_object_size_hint_min_get(obj, &w, &h);
snprintf(buf, sizeof(buf), "Min size: %d %d", w, h);
snprintf(buf, sizeof(buf), "Min size: %d %d", oinfo->evas_props.min_w,
oinfo->evas_props.min_h);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
evas_object_size_hint_max_get(obj, &w, &h);
snprintf(buf, sizeof(buf), "Max size: %d %d", w, h);
snprintf(buf, sizeof(buf), "Max size: %d %d", oinfo->evas_props.max_w,
oinfo->evas_props.max_h);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
evas_object_size_hint_request_get(obj, &w, &h);
snprintf(buf, sizeof(buf), "Request size: %d %d", w, h);
snprintf(buf, sizeof(buf), "Request size: %d %d",
oinfo->evas_props.req_w, oinfo->evas_props.req_h);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
evas_object_size_hint_align_get(obj, &dx, &dy);
snprintf(buf, sizeof(buf), "Align: %.6lg %.6lg", dx, dy);
snprintf(buf, sizeof(buf), "Align: %.6lg %.6lg",
oinfo->evas_props.align_x, oinfo->evas_props.align_y);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
evas_object_size_hint_weight_get(obj, &dx, &dy);
snprintf(buf, sizeof(buf), "Weight: %.6lg %.6lg", dx, dy);
snprintf(buf, sizeof(buf), "Weight: %.6lg %.6lg",
oinfo->evas_props.weight_x, oinfo->evas_props.weight_y);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
evas_object_size_hint_request_get(obj, &w, &h);
#if 0
evas_object_size_hint_aspect_get(obj, &w, &h);
snprintf(buf, sizeof(buf), "Aspect: %d %d", w, h);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
#endif
/* Handle color */
{
int r, g, b, a;
evas_object_color_get(obj, &r, &g, &b, &a);
snprintf(buf, sizeof(buf), "Color: %d %d %d %d", r, g, b, a);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
}
snprintf(buf, sizeof(buf), "Color: %d %d %d %d",
oinfo->evas_props.r, oinfo->evas_props.g, oinfo->evas_props.b,
oinfo->evas_props.a);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
if (evas_object_clipees_get(obj))
if (oinfo->evas_props.is_clipper)
{
snprintf(buf, sizeof(buf), "Has clipees");
tit = calloc(1, sizeof(*tit));
@ -252,7 +373,7 @@ clouseau_obj_information_list_populate(Tree_Item *treeit)
}
}
if (!strcmp("elm_widget", evas_object_type_get(obj)))
if (oinfo->obj_type == CLOUSEAU_OBJ_TYPE_ELM)
{
Inf_Tree_Item *tit;
char buf[1024];
@ -261,7 +382,7 @@ clouseau_obj_information_list_populate(Tree_Item *treeit)
main_tit->string = eina_stringshare_add("Elementary");
information_tree = eina_list_append(information_tree, main_tit);
snprintf(buf, sizeof(buf), "Wid-Type: %s", elm_widget_type_get(obj));
snprintf(buf, sizeof(buf), "Wid-Type: %s", oinfo->extra_props.elm.type);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
@ -274,58 +395,57 @@ clouseau_obj_information_list_populate(Tree_Item *treeit)
main_tit->children = eina_list_append(main_tit->children, tit);
#endif
snprintf(buf, sizeof(buf), "Style: %s", elm_widget_style_get(obj));
snprintf(buf, sizeof(buf), "Style: %s",
oinfo->extra_props.elm.style);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
snprintf(buf, sizeof(buf), "Scale: %.6lg",
elm_widget_scale_get(obj));
oinfo->extra_props.elm.scale);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
snprintf(buf, sizeof(buf), "Disabled: %d",
elm_widget_disabled_get(obj));
oinfo->extra_props.elm.is_disabled);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
snprintf(buf, sizeof(buf), "Mirrored: %d",
elm_widget_mirrored_get(obj));
oinfo->extra_props.elm.is_mirrored);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
snprintf(buf, sizeof(buf), "Automatic mirroring: %d",
elm_widget_mirrored_automatic_get(obj));
oinfo->extra_props.elm.is_mirrored_automatic);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
}
else if (!strcmp("text", evas_object_type_get(obj)))
else if (oinfo->obj_type == CLOUSEAU_OBJ_TYPE_TEXT)
{
Inf_Tree_Item *tit;
char buf[1024];
const char *font;
int size;
main_tit = calloc(1, sizeof(*main_tit));
main_tit->string = eina_stringshare_add("Text");
information_tree = eina_list_append(information_tree, main_tit);
evas_object_text_font_get(obj, &font, &size);
snprintf(buf, sizeof(buf), "Font: %s", font);
snprintf(buf, sizeof(buf), "Font: %s", oinfo->extra_props.text.font);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
snprintf(buf, sizeof(buf), "Size: %d", size);
snprintf(buf, sizeof(buf), "Size: %d", oinfo->extra_props.text.size);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
font = evas_object_text_font_source_get(obj);
font = oinfo->extra_props.text.source;
if (font)
{
snprintf(buf, sizeof(buf), "Source: %s", font);
@ -334,75 +454,71 @@ clouseau_obj_information_list_populate(Tree_Item *treeit)
main_tit->children = eina_list_append(main_tit->children, tit);
}
}
else if (!strcmp("image", evas_object_type_get(obj)))
else if (oinfo->obj_type == CLOUSEAU_OBJ_TYPE_IMAGE)
{
Inf_Tree_Item *tit;
char buf[1024];
const char *file, *key;
main_tit = calloc(1, sizeof(*main_tit));
main_tit->string = eina_stringshare_add("Image");
information_tree = eina_list_append(information_tree, main_tit);
evas_object_image_file_get(obj, &file, &key);
snprintf(buf, sizeof(buf), "File name: %s", file);
snprintf(buf, sizeof(buf), "File name: %s",
oinfo->extra_props.image.file);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
if (key)
if (oinfo->extra_props.image.key)
{
snprintf(buf, sizeof(buf), "File key: %s", key);
snprintf(buf, sizeof(buf), "File key: %s",
oinfo->extra_props.image.key);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
}
if (evas_object_image_source_get(obj))
if (oinfo->extra_props.image.source)
{
snprintf(buf, sizeof(buf), "Source: %p",
evas_object_image_source_get(obj));
oinfo->extra_props.image.source);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
}
if (evas_object_image_load_error_get(obj) != EVAS_LOAD_ERROR_NONE)
if (oinfo->extra_props.image.load_err)
{
snprintf(buf, sizeof(buf), "Load error: %s",
evas_load_error_str(evas_object_image_load_error_get(obj)));
oinfo->extra_props.image.load_err);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
}
}
else if (!strcmp("edje", evas_object_type_get(obj)))
else if (oinfo->obj_type == CLOUSEAU_OBJ_TYPE_EDJE)
{
Inf_Tree_Item *tit;
char buf[1024];
const char *file, *group;
main_tit = calloc(1, sizeof(*main_tit));
main_tit->string = eina_stringshare_add("Edje");
information_tree = eina_list_append(information_tree, main_tit);
edje_object_file_get(obj, &file, &group);
snprintf(buf, sizeof(buf), "File: %s", file);
snprintf(buf, sizeof(buf), "File: %s", oinfo->extra_props.edje.file);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
snprintf(buf, sizeof(buf), "Group: %s", group);
snprintf(buf, sizeof(buf), "Group: %s", oinfo->extra_props.edje.group);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
if (edje_object_load_error_get(obj) != EDJE_LOAD_ERROR_NONE)
if (oinfo->extra_props.edje.load_err)
{
snprintf(buf, sizeof(buf), "Load error: %s",
edje_load_error_str(edje_object_load_error_get(obj)));
oinfo->extra_props.edje.load_err);
tit = calloc(1, sizeof(*tit));
tit->string = eina_stringshare_add(buf);
main_tit->children = eina_list_append(main_tit->children, tit);
@ -423,6 +539,8 @@ clouseau_obj_information_list_populate(Tree_Item *treeit)
elm_genlist_item_expanded_set(git, EINA_TRUE);
}
}
_obj_information_free(oinfo);
}
void

View File

@ -3,6 +3,56 @@
#include "libclouseau.h"
typedef struct _Obj_Information Obj_Information;
struct _Obj_Information
{
struct {
const char *name;
short layer;
Evas_Coord x, y, w, h;
double scale;
Evas_Coord min_w, min_h, max_w, max_h, req_w, req_h;
double align_x, align_y;
double weight_x, weight_y;
int r, g, b, a;
Eina_Bool is_clipper : 1;
Eina_Bool is_visible : 1;
} evas_props;
enum {
CLOUSEAU_OBJ_TYPE_OTHER,
CLOUSEAU_OBJ_TYPE_ELM,
CLOUSEAU_OBJ_TYPE_TEXT,
CLOUSEAU_OBJ_TYPE_IMAGE,
CLOUSEAU_OBJ_TYPE_EDJE,
} obj_type;
union {
struct {
const char *type;
const char *style;
double scale;
Eina_Bool is_disabled : 1;
Eina_Bool is_mirrored : 1;
Eina_Bool is_mirrored_automatic : 1;
} elm;
struct {
const char *font;
int size;
const char *source;
} text;
struct {
const char *file, *key;
void *source;
const char *load_err;
} image;
struct {
const char *file, *group;
const char *load_err;
} edje;
} extra_props;
};
Evas_Object *clouseau_obj_information_list_add(Evas_Object *parent);
void clouseau_obj_information_list_populate(Tree_Item *treeit);
void clouseau_obj_information_list_clear();