Add alpha to rgbs by default, leaving the old methods for completeness

SVN revision: 11064
This commit is contained in:
handyande 2004-07-27 21:27:25 +00:00 committed by handyande
parent 908b595357
commit 5ae281d5dd
4 changed files with 129 additions and 4 deletions

View File

@ -123,7 +123,10 @@ extern "C"
long ecore_config_int_get(const char *key); long ecore_config_int_get(const char *key);
int ecore_config_rgb_get(const char *key, int *r, int *g, int ecore_config_rgb_get(const char *key, int *r, int *g,
int *b); int *b);
int ecore_config_argb_get(const char *key, int *a, int *r,
int *g, int *b);
char *ecore_config_rgbstr_get(const char *key); char *ecore_config_rgbstr_get(const char *key);
char *ecore_config_argbstr_get(const char *key);
float ecore_config_float_get(const char *key); float ecore_config_float_get(const char *key);
char *ecore_config_theme_get(const char *key); char *ecore_config_theme_get(const char *key);
char *ecore_config_as_string_get(const char *key); char *ecore_config_as_string_get(const char *key);
@ -138,6 +141,7 @@ extern "C"
int ecore_config_string_set(const char *key, char *val); int ecore_config_string_set(const char *key, char *val);
int ecore_config_int_set(const char *key, int val); int ecore_config_int_set(const char *key, int val);
int ecore_config_rgb_set(const char *key, char *val); int ecore_config_rgb_set(const char *key, char *val);
int ecore_config_argb_set(const char *key, char *val);
int ecore_config_float_set(const char *key, float val); int ecore_config_float_set(const char *key, float val);
int ecore_config_theme_set(const char *key, char *val); int ecore_config_theme_set(const char *key, char *val);
int ecore_config_theme_preview_group_set(const char *key, int ecore_config_theme_preview_group_set(const char *key,
@ -157,6 +161,7 @@ extern "C"
float val, float lo, float val, float lo,
float hi, float step); float hi, float step);
int ecore_config_rgb_default(const char *key, char *val); int ecore_config_rgb_default(const char *key, char *val);
int ecore_config_argb_default(const char *keym, char *val);
int ecore_config_theme_default(const char *key, char *val); int ecore_config_theme_default(const char *key, char *val);
int ecore_config_listen(const char *name, const char *key, int ecore_config_listen(const char *name, const char *key,
@ -253,6 +258,9 @@ extern "C"
int ecore_config_rgb_create(const char *key, char *val, int ecore_config_rgb_create(const char *key, char *val,
char short_opt, char *long_opt, char short_opt, char *long_opt,
char *desc); char *desc);
int ecore_config_argb_create(const char *key, char *val,
char short_opt, char *long_opt,
char *desc);
int ecore_config_theme_create(const char *key, char *val, int ecore_config_theme_create(const char *key, char *val,
char short_opt, char *long_opt, char short_opt, char *long_opt,
char *desc); char *desc);

View File

@ -13,6 +13,7 @@
char *__ecore_config_app_description; char *__ecore_config_app_description;
extern int ecore_config_bound(Ecore_Config_Prop * e); extern int ecore_config_bound(Ecore_Config_Prop * e);
extern char *ecore_config_rgb_to_argb(char *rgb);
/* shorthand prop setup code to make client apps a little smaller ;) */ /* shorthand prop setup code to make client apps a little smaller ;) */
@ -225,10 +226,36 @@ ecore_config_float_create_bound(const char *key, float val, float low,
* @param desc String description of property. * @param desc String description of property.
* @return @c ECORE_CONFIG_ERR_SUCC on success. * @return @c ECORE_CONFIG_ERR_SUCC on success.
* @ingroup Ecore_Config_Create_Group * @ingroup Ecore_Config_Create_Group
* @deprecated
*/ */
int int
ecore_config_rgb_create(const char *key, char *val, char short_opt, ecore_config_rgb_create(const char *key, char *val, char short_opt,
char *long_opt, char *desc) char *long_opt, char *desc)
{
char *argb;
int ret;
argb = ecore_config_rgb_to_argb(val);
ret = ecore_config_argb_create(key, argb, short_opt, long_opt, desc);
free(argb);
return ret;
}
/**
* Creates a new color property, if it does not already exist, and sets its
* attributes to those given.
* @param key The property key.
* @param val Default color value of key, as a hexadecimal string.
* @param short_opt Short option used to set the property from command
* line.
* @param long_opt Long option used to set the property from command line.
* @param desc String description of property.
* @return @c ECORE_CONFIG_ERR_SUCC on success.
* @ingroup Ecore_Config_Create_Group
*/
int
ecore_config_argb_create(const char *key, char *val, char short_opt,
char *long_opt, char *desc)
{ {
return return
ecore_config_typed_create(key, (void *)val, PT_RGB, short_opt, long_opt, ecore_config_typed_create(key, (void *)val, PT_RGB, short_opt, long_opt,

View File

@ -201,9 +201,28 @@ ecore_config_float_get(const char *key)
* @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_FAIL * @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_FAIL
* otherwise. * otherwise.
* @ingroup Ecore_Config_Get_Group * @ingroup Ecore_Config_Get_Group
* @deprecated
*/ */
int int
ecore_config_rgb_get(const char *key, int *r, int *g, int *b) ecore_config_rgb_get(const char *key, int *r, int *g, int *b)
{
int alpha;
return ecore_config_argb_get(key, &alpha, r, g, b);
}
/**
* Finds the alpha, red, green and blue values of a color property.
* @param key The property key.
* @param a A pointer to an integer to store the alpha value into.
* @param r A pointer to an integer to store the red value into.
* @param g A pointer to an integer to store the green value into.
* @param b A pointer to an integer to store the blue value into.
* @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_FAIL
* otherwise.
* @ingroup Ecore_Config_Get_Group
*/
int
ecore_config_argb_get(const char *key, int *a, int *r, int *g, int *b)
{ {
Ecore_Config_Prop *e; Ecore_Config_Prop *e;
@ -211,6 +230,7 @@ ecore_config_rgb_get(const char *key, int *r, int *g, int *b)
if (e && ((e->type == PT_RGB))) if (e && ((e->type == PT_RGB)))
{ {
*a = (e->val >> 24) & 0xff;
*r = (e->val >> 16) & 0xff; *r = (e->val >> 16) & 0xff;
*g = (e->val >> 8) & 0xff; *g = (e->val >> 8) & 0xff;
*b = e->val & 0xff; *b = e->val & 0xff;
@ -224,14 +244,32 @@ ecore_config_rgb_get(const char *key, int *r, int *g, int *b)
* @param key The property key. * @param key The property key.
* @return A string of hexadecimal characters in the format #rrggbb. * @return A string of hexadecimal characters in the format #rrggbb.
* @ingroup Ecore_Config_Get_Group * @ingroup Ecore_Config_Get_Group
* @deprecated
*/ */
char * char *
ecore_config_rgbstr_get(const char *key) ecore_config_rgbstr_get(const char *key)
{
char *argb, *rgb;
argb = ecore_config_argbstr_get(key);
rgb = argb + 2;
*rgb = '#';
return rgb;
}
/**
* Returns a color property as a string of hexadecimal characters.
* @param key The property key.
* @return A string of hexadecimal characters in the format #aarrggbb.
* @ingroup Ecore_Config_Get_Group
*/
char *
ecore_config_argbstr_get(const char *key)
{ {
char *r; char *r;
r = NULL; r = NULL;
esprintf(&r, "#%06x", ecore_config_int_get(key)); esprintf(&r, "#%08x", ecore_config_int_get(key));
return r; return r;
} }
@ -287,7 +325,7 @@ ecore_config_as_string_get(const char *key)
ecore_config_string_get(key)); ecore_config_string_get(key));
break; break;
case PT_RGB: case PT_RGB:
esprintf(&r, "%s:%s=#%06x", key, type, ecore_config_int_get(key)); esprintf(&r, "%s:%s=#%08x", key, type, ecore_config_int_get(key));
break; break;
case PT_THM: case PT_THM:
esprintf(&r, "%s:%s=\"%s\"", key, type, esprintf(&r, "%s:%s=\"%s\"", key, type,
@ -697,15 +735,46 @@ ecore_config_float_set(const char *key, float val)
return ecore_config_typed_set(key, (void *)&val, PT_FLT); return ecore_config_typed_set(key, (void *)&val, PT_FLT);
} }
char *
ecore_config_rgb_to_argb(char *rgb)
{
char *argb;
argb = malloc(strlen(rgb) + 2);
strncpy(argb, "#ff", 3);
strncat(argb, rgb+1, strlen(rgb - 1));
return argb;
}
/** /**
* Sets the indicated property to a color value. * Sets the indicated property to a color value.
* @param key The property key * @param key The property key
* @param val Color value in RGB format. * @param val Color value in RGB format.
* @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully. * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
* @ingroup Ecore_Config_Set_Group * @ingroup Ecore_Config_Set_Group
* @deprecated
*/ */
int int
ecore_config_rgb_set(const char *key, char *val) ecore_config_rgb_set(const char *key, char *val)
{
char *argb;
int ret;
argb = ecore_config_rgb_to_argb(val);
ret = ecore_config_argb_set(key, argb);
free(argb);
return ret;
}
/**
* Sets the indicated property to a color value.
* @param key The property key
* @param val Color value in ARGB format.
* @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
* @ingroup Ecore_Config_Set_Group
*/
int
ecore_config_argb_set(const char *key, char *val)
{ {
return ecore_config_typed_set(key, (void *)val, PT_RGB); return ecore_config_typed_set(key, (void *)val, PT_RGB);
} }
@ -934,9 +1003,30 @@ ecore_config_float_default_bound(const char *key, float val, float low,
* @param val Color value in RGB format. * @param val Color value in RGB format.
* @return @c ECORE_CONFIG_ERR_SUCC if there are no problems. * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
* @ingroup Ecore_Config_Default_Group * @ingroup Ecore_Config_Default_Group
* @deprecated
*/ */
int int
ecore_config_rgb_default(const char *key, char *val) ecore_config_rgb_default(const char *key, char *val)
{
char *argb;
int ret;
argb = ecore_config_rgb_to_argb(val);
ret = ecore_config_argb_default(key, argb);
free(argb);
return ret;
}
/**
* Sets the indicated property to a color value if the property has not yet
* been set.
* @param key The property key.
* @param val Color value in ARGB format.
* @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
* @ingroup Ecore_Config_Default_Group
*/
int
ecore_config_argb_default(const char *key, char *val)
{ {
return ecore_config_typed_default(key, (void *)val, PT_RGB); return ecore_config_typed_default(key, (void *)val, PT_RGB);
} }

View File

@ -115,7 +115,7 @@ ecore_config_file_load(char *file)
switch (itmp) switch (itmp)
{ {
case PT_RGB: case PT_RGB:
ecore_config_rgb_set(keys[x], data); ecore_config_argb_set(keys[x], data);
break; break;
case PT_THM: case PT_THM:
ecore_config_theme_set(keys[x], data); ecore_config_theme_set(keys[x], data);
@ -214,7 +214,7 @@ ecore_config_file_save(char *file)
e_db_float_set(db, next->key, ecore_config_float_get(next->key)); e_db_float_set(db, next->key, ecore_config_float_get(next->key));
break; break;
case PT_RGB: case PT_RGB:
tmp = ecore_config_rgbstr_get(next->key); tmp = ecore_config_argbstr_get(next->key);
break; break;
case PT_STR: case PT_STR:
tmp = ecore_config_string_get(next->key); tmp = ecore_config_string_get(next->key);