* make color classes editable

SVN revision: 36295
This commit is contained in:
Davide Andreoli 2008-09-28 18:44:19 +00:00
parent be3df7fcd1
commit 1e6847bb21
2 changed files with 229 additions and 6 deletions

View File

@ -262,6 +262,7 @@ edje_edit_data_value_set(
const char *value ///< The new value to set
);
/** Change the name of the given data object */
EAPI unsigned char ///@return TRUE on success
edje_edit_data_name_set(
Evas_Object *obj, ///< The edje object
@ -277,14 +278,80 @@ edje_edit_data_name_set(
* Functions to deal with Color Classes (see @ref edcref).
*/ //@{
/**Get the list of all the Color Classes in the given edje object.
* Use edje_edit_string_list_free() when you don't need it anymore.
/** Get the list of all the Color Classes in the given edje object.
* Use edje_edit_string_list_free() when you don't need it anymore.
*/
EAPI Evas_List * ///@return An Evas_List* of string (char *)containing all the classes names.
edje_edit_color_classes_list_get(
Evas_Object * obj ///< The edje object
);
/** Create a new color class object in the given edje
* If another class with the same name exists nothing is created and FALSE is returned.
*/
EAPI unsigned char ///@return TRUE on success
edje_edit_color_class_add(
Evas_Object *obj, ///< The edje object
const char *name ///< The name of the new color class
);
/** Delete the given class object from edje */
EAPI unsigned char ///@return TRUE on success
edje_edit_color_class_del(
Evas_Object *obj, ///< The edje object
const char *name ///< The name of the color class to delete
);
/** Get all the colors that compose the class.
* You can pass NULL to colors you are not intrested in
*/
EAPI unsigned char ///@return TRUE on success
edje_edit_color_class_colors_get(
Evas_Object *obj, ///< The edje object
const char *class_name, ///< The name of the color class
int *r, ///< Where to store the red component of the standard color
int *g, ///< Where to store the green component of the standard color
int *b, ///< Where to store the blue component of the standard color
int *a, ///< Where to store the alpha component of the standard color
int *r2, ///< Where to store the red component of the second color
int *g2, ///< Where to store the green component of the second color
int *b2, ///< Where to store the green component of the second color
int *a2, ///< Where to store the green component of the second color
int *r3, ///< Where to store the red component of the third color
int *g3, ///< Where to store the green component of the third color
int *b3, ///< Where to store the blue component of the third color
int *a3 ///< Where to store the alpha component of the third color
);
/** Set the colors for the given color class.
* If you set a color to -1 it will not be touched
*/
EAPI unsigned char ///@return TRUE on success
edje_edit_color_class_colors_set(
Evas_Object *obj, ///< The edje object
const char *class_name, ///< The name of the color class
int r, ///< The red component of the standard color
int g, ///< The green component of the standard color
int b, ///< The blue component of the standard color
int a, ///< The alpha component of the standard color
int r2, ///< The red component of the second color
int g2, ///< The green component of the second color
int b2, ///< The blue component of the second color
int a2, ///< The alpha component of the second color
int r3, ///< The red component of the third color
int g3, ///< The green component of the third color
int b3, ///< The blue component of the third color
int a3 ///< The alpha component of the third color
);
/** Change the name of a color class */
EAPI unsigned char ///@return TRUE on success
edje_edit_color_class_name_set(
Evas_Object *obj, ///< The edje object
const char *name, ///< The name of the color class
const char *newname ///< The new name to assign
);
//@}
/******************************************************************************/

View File

@ -1049,17 +1049,18 @@ edje_edit_data_name_set(Evas_Object *obj, const char *itemname, const char *new
EAPI Evas_List *
edje_edit_color_classes_list_get(Evas_Object * obj)
{
Edje_Color_Class *cc;
Evas_List *classes = NULL;
Evas_List *l;
GET_ED_OR_RETURN(NULL);
printf("GET CLASSES LIST\n");
if (!ed->file || !!ed->color_classes)
if (!ed->file || !ed->file->color_classes)
return NULL;
printf("GET CLASSES LIST %d\n", evas_list_count(ed->color_classes));
printf("GET CLASSES LIST %d %d\n", evas_list_count(ed->color_classes), evas_list_count(ed->file->color_classes));
for (l = ed->file->color_classes; l; l = l->next)
{
Edje_Color_Class *cc;
cc = l->data;
classes = evas_list_append(classes, evas_stringshare_add(cc->name));
}
@ -1067,6 +1068,161 @@ printf("GET CLASSES LIST %d\n", evas_list_count(ed->color_classes));
return classes;
}
EAPI unsigned char
edje_edit_color_class_colors_get(Evas_Object *obj, const char *class_name, int *r, int *g, int *b, int *a, int *r2, int *g2, int *b2, int *a2, int *r3, int *g3, int *b3, int *a3)
{
Evas_List *l;
GET_ED_OR_RETURN(0);
if (!ed->file || !ed->file->color_classes)
return 0;
for (l = ed->file->color_classes; l; l = l->next)
{
Edje_Color_Class *cc;
cc = l->data;
if (!strcmp(cc->name, class_name))
{
if (r) *r = cc->r;
if (g) *g = cc->g;
if (b) *b = cc->b;
if (a) *a = cc->a;
if (r2) *r2 = cc->r2;
if (g2) *g2 = cc->g2;
if (b2) *b2 = cc->b2;
if (a2) *a2 = cc->a2;
if (r3) *r3 = cc->r3;
if (g3) *g3 = cc->g3;
if (b3) *b3 = cc->b3;
if (a3) *a3 = cc->a3;
return 1;
}
}
return 0;
}
EAPI unsigned char
edje_edit_color_class_colors_set(Evas_Object *obj, const char *class_name, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3)
{
Evas_List *l;
GET_ED_OR_RETURN(0);
if (!ed->file || !ed->file->color_classes)
return 0;
for (l = ed->file->color_classes; l; l = l->next)
{
Edje_Color_Class *cc;
cc = l->data;
if (!strcmp(cc->name, class_name))
{
if (r > -1) cc->r = r;
if (g > -1) cc->g = g;
if (b > -1) cc->b = b;
if (a > -1) cc->a = a;
if (r2 > -1) cc->r2 = r2;
if (g2 > -1) cc->g2 = g2;
if (b2 > -1) cc->b2 = b2;
if (a2 > -1) cc->a2 = a2;
if (r3 > -1) cc->r3 = r3;
if (g3 > -1) cc->g3 = g3;
if (b3 > -1) cc->b3 = b3;
if (a3 > -1) cc->a3 = a3;
return 1;
}
}
return 0;
}
EAPI unsigned char
edje_edit_color_class_add(Evas_Object *obj, const char *name)
{
Evas_List *l;
Edje_Color_Class *c;
GET_ED_OR_RETURN(0);
if (!name || !ed->file)
return 0;
for (l = ed->file->color_classes; l; l = l->next)
{
Edje_Color_Class *cc = l->data;
if (strcmp(cc->name, name) == 0)
return 0;
}
c = mem_alloc(sizeof(Edje_Color_Class));
if (!c) return 0;
c->name = (char*)evas_stringshare_add(name);
c->r = c->g = c->b = c->a = 255;
c->r2 = c->g2 = c->b2 = c->a2 = 255;
c->r3 = c->g3 = c->b3 = c->a3 = 255;
ed->file->color_classes = evas_list_append(ed->file->color_classes, c);
return 1;
}
EAPI unsigned char
edje_edit_color_class_del(Evas_Object *obj, const char *name)
{
Evas_List *l;
GET_ED_OR_RETURN(0);
if (!name || !ed->file || !ed->file->color_classes)
return 0;
for (l = ed->file->color_classes; l; l = l->next)
{
Edje_Color_Class *cc = l->data;
if (strcmp(cc->name, name) == 0)
{
_edje_if_string_free(ed, cc->name);
ed->file->color_classes = evas_list_remove(ed->file->color_classes, cc);
free(cc);
return 1;
}
}
return 0;
}
EAPI unsigned char
edje_edit_color_class_name_set(Evas_Object *obj, const char *name, const char *newname)
{
Evas_List *l;
GET_ED_OR_RETURN(0);
if (!ed->file || !ed->file->color_classes)
return 0;
for (l = ed->file->color_classes; l; l = l->next)
{
Edje_Color_Class *cc;
cc = l->data;
if (!strcmp(cc->name, name))
{
_edje_if_string_free(ed, cc->name);
cc->name = (char*)evas_stringshare_add(newname);
return 1;
}
}
return 0;
}
/***************/
/* PARTS API */