forked from enlightenment/efl
edje_cc: Clean up repeated code in color setter
Summary: Remove duplicated code Reviewers: jpeg, cedric Reviewed By: jpeg Subscribers: bu5hm4n Differential Revision: https://phab.enlightenment.org/D4769
This commit is contained in:
parent
10f1fedfec
commit
e8711baec3
|
@ -3086,6 +3086,36 @@ st_color_class_name(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
parse_color(void *base)
|
||||
{
|
||||
Edje_Color *color = (Edje_Color *)base;
|
||||
int r, g, b, a;
|
||||
char *str;
|
||||
|
||||
switch (get_arg_count())
|
||||
{
|
||||
case 1:
|
||||
str = parse_str(0);
|
||||
convert_color_code(str, &r, &g, &b, &a);
|
||||
color->r = r;
|
||||
color->g = g;
|
||||
color->b = b;
|
||||
color->a = a;
|
||||
break;
|
||||
case 4:
|
||||
color->r = parse_int_range(0, 0, 255);
|
||||
color->g = parse_int_range(1, 0, 255);
|
||||
color->b = parse_int_range(2, 0, 255);
|
||||
color->a = parse_int_range(3, 0, 255);
|
||||
break;
|
||||
default:
|
||||
ERR("%s:%i. color code should be a string or a set of 4 integers.",
|
||||
file_in, line - 1);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@page edcref
|
||||
@property
|
||||
|
@ -3100,34 +3130,10 @@ static void
|
|||
st_color_class_color(void)
|
||||
{
|
||||
Edje_Color_Class *cc;
|
||||
int nargs = get_arg_count();
|
||||
|
||||
cc = eina_list_data_get(eina_list_last(edje_file->color_classes));
|
||||
|
||||
if (nargs == 1)
|
||||
{
|
||||
int r, g, b, a;
|
||||
char *str = parse_str(0);
|
||||
|
||||
convert_color_code(str, &r, &g, &b, &a);
|
||||
cc->r = r;
|
||||
cc->g = g;
|
||||
cc->b = b;
|
||||
cc->a = a;
|
||||
}
|
||||
else if (nargs == 4)
|
||||
{
|
||||
cc->r = parse_int_range(0, 0, 255);
|
||||
cc->g = parse_int_range(1, 0, 255);
|
||||
cc->b = parse_int_range(2, 0, 255);
|
||||
cc->a = parse_int_range(3, 0, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("%s:%i. color code should be a string or a set of 4 integers.",
|
||||
file_in, line - 1);
|
||||
exit(-1);
|
||||
}
|
||||
parse_color(&(cc->r));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3144,34 +3150,10 @@ static void
|
|||
st_color_class_color2(void)
|
||||
{
|
||||
Edje_Color_Class *cc;
|
||||
int nargs = get_arg_count();
|
||||
|
||||
cc = eina_list_data_get(eina_list_last(edje_file->color_classes));
|
||||
|
||||
if (nargs == 1)
|
||||
{
|
||||
int r, g, b, a;
|
||||
char *str = parse_str(0);
|
||||
|
||||
convert_color_code(str, &r, &g, &b, &a);
|
||||
cc->r2 = r;
|
||||
cc->g2 = g;
|
||||
cc->b2 = b;
|
||||
cc->a2 = a;
|
||||
}
|
||||
else if (nargs == 4)
|
||||
{
|
||||
cc->r2 = parse_int_range(0, 0, 255);
|
||||
cc->g2 = parse_int_range(1, 0, 255);
|
||||
cc->b2 = parse_int_range(2, 0, 255);
|
||||
cc->a2 = parse_int_range(3, 0, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("%s:%i. color code should be a string or a set of 4 integers.",
|
||||
file_in, line - 1);
|
||||
exit(-1);
|
||||
}
|
||||
parse_color(&(cc->r2));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3188,34 +3170,10 @@ static void
|
|||
st_color_class_color3(void)
|
||||
{
|
||||
Edje_Color_Class *cc;
|
||||
int nargs = get_arg_count();
|
||||
|
||||
cc = eina_list_data_get(eina_list_last(edje_file->color_classes));
|
||||
|
||||
if (nargs == 1)
|
||||
{
|
||||
int r, g, b, a;
|
||||
char *str = parse_str(0);
|
||||
|
||||
convert_color_code(str, &r, &g, &b, &a);
|
||||
cc->r3 = r;
|
||||
cc->g3 = g;
|
||||
cc->b3 = b;
|
||||
cc->a3 = a;
|
||||
}
|
||||
else if (nargs == 4)
|
||||
{
|
||||
cc->r3 = parse_int_range(0, 0, 255);
|
||||
cc->g3 = parse_int_range(1, 0, 255);
|
||||
cc->b3 = parse_int_range(2, 0, 255);
|
||||
cc->a3 = parse_int_range(3, 0, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("%s:%i. color code should be a string or a set of 4 integers.",
|
||||
file_in, line - 1);
|
||||
exit(-1);
|
||||
}
|
||||
parse_color(&(cc->r3));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9045,8 +9003,6 @@ st_collections_group_parts_part_description_color_class(void)
|
|||
static void
|
||||
st_collections_group_parts_part_description_color(void)
|
||||
{
|
||||
int nargs = get_arg_count();
|
||||
|
||||
if (current_part->type == EDJE_PART_TYPE_SPACER)
|
||||
{
|
||||
ERR("parse error %s:%i. SPACER part can't have a color defined",
|
||||
|
@ -9054,30 +9010,7 @@ st_collections_group_parts_part_description_color(void)
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
if (nargs == 1)
|
||||
{
|
||||
int r, g, b, a;
|
||||
char *str = parse_str(0);
|
||||
|
||||
convert_color_code(str, &r, &g, &b, &a);
|
||||
current_desc->color.r = r;
|
||||
current_desc->color.g = g;
|
||||
current_desc->color.b = b;
|
||||
current_desc->color.a = a;
|
||||
}
|
||||
else if (nargs == 4)
|
||||
{
|
||||
current_desc->color.r = parse_int_range(0, 0, 255);
|
||||
current_desc->color.g = parse_int_range(1, 0, 255);
|
||||
current_desc->color.b = parse_int_range(2, 0, 255);
|
||||
current_desc->color.a = parse_int_range(3, 0, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("%s:%i. color code should be a string or a set of 4 integers.",
|
||||
file_in, line - 1);
|
||||
exit(-1);
|
||||
}
|
||||
parse_color(&(current_desc->color.r));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9093,8 +9026,6 @@ st_collections_group_parts_part_description_color(void)
|
|||
static void
|
||||
st_collections_group_parts_part_description_color2(void)
|
||||
{
|
||||
int nargs = get_arg_count();
|
||||
|
||||
if (current_part->type == EDJE_PART_TYPE_SPACER)
|
||||
{
|
||||
ERR("parse error %s:%i. SPACER part can't have a color defined",
|
||||
|
@ -9102,30 +9033,7 @@ st_collections_group_parts_part_description_color2(void)
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
if (nargs == 1)
|
||||
{
|
||||
int r, g, b, a;
|
||||
char *str = parse_str(0);
|
||||
|
||||
convert_color_code(str, &r, &g, &b, &a);
|
||||
current_desc->color2.r = r;
|
||||
current_desc->color2.g = g;
|
||||
current_desc->color2.b = b;
|
||||
current_desc->color2.a = a;
|
||||
}
|
||||
else if (nargs == 4)
|
||||
{
|
||||
current_desc->color2.r = parse_int_range(0, 0, 255);
|
||||
current_desc->color2.g = parse_int_range(1, 0, 255);
|
||||
current_desc->color2.b = parse_int_range(2, 0, 255);
|
||||
current_desc->color2.a = parse_int_range(3, 0, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("%s:%i. color code should be a string or a set of 4 integers.",
|
||||
file_in, line - 1);
|
||||
exit(-1);
|
||||
}
|
||||
parse_color(&(current_desc->color2.r));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9143,7 +9051,6 @@ st_collections_group_parts_part_description_color3(void)
|
|||
{
|
||||
Edje_Part_Collection *pc;
|
||||
Edje_Part_Description_Text *ed;
|
||||
int nargs = get_arg_count();
|
||||
|
||||
pc = eina_list_data_get(eina_list_last(edje_collections));
|
||||
|
||||
|
@ -9157,30 +9064,7 @@ st_collections_group_parts_part_description_color3(void)
|
|||
|
||||
ed = (Edje_Part_Description_Text*)current_desc;
|
||||
|
||||
if (nargs == 1)
|
||||
{
|
||||
int r, g, b, a;
|
||||
char *str = parse_str(0);
|
||||
|
||||
convert_color_code(str, &r, &g, &b, &a);
|
||||
ed->text.color3.r = r;
|
||||
ed->text.color3.g = g;
|
||||
ed->text.color3.b = b;
|
||||
ed->text.color3.a = a;
|
||||
}
|
||||
else if (nargs == 4)
|
||||
{
|
||||
ed->text.color3.r = parse_int_range(0, 0, 255);
|
||||
ed->text.color3.g = parse_int_range(1, 0, 255);
|
||||
ed->text.color3.b = parse_int_range(2, 0, 255);
|
||||
ed->text.color3.a = parse_int_range(3, 0, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERR("%s:%i. color code should be a string or a set of 4 integers.",
|
||||
file_in, line - 1);
|
||||
exit(-1);
|
||||
}
|
||||
parse_color(&(ed->text.color3.r));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue