forked from enlightenment/efl
Compare commits
2 Commits
master
...
devs/ami/c
Author | SHA1 | Date |
---|---|---|
Amitesh Singh | 62b3813ae4 | |
Amitesh Singh | d18de6b1b8 |
|
@ -139,6 +139,7 @@ lib/efl/interfaces/efl_io_queue.c \
|
|||
lib/efl/interfaces/efl_observer.c \
|
||||
lib/efl/interfaces/efl_file.c \
|
||||
lib/efl/interfaces/efl_ui_format.c \
|
||||
lib/efl/interfaces/efl_gfx_color_internal.c \
|
||||
lib/efl/interfaces/efl_gfx_color.c \
|
||||
lib/efl/interfaces/efl_text_markup_util.c \
|
||||
$(NULL)
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "../evas/canvas/evas_line.eo.h"
|
||||
#include "../evas/canvas/evas_text.eo.h"
|
||||
|
||||
#include "../efl/interfaces/efl_gfx_color_internal.h"
|
||||
|
||||
typedef struct _Edje_Box_Layout Edje_Box_Layout;
|
||||
struct _Edje_Box_Layout
|
||||
{
|
||||
|
@ -998,6 +1000,29 @@ _efl_canvas_layout_efl_gfx_color_class_color_class_clear(Eo *obj EINA_UNUSED, Ed
|
|||
}
|
||||
}
|
||||
|
||||
EOLIAN void
|
||||
_efl_canvas_layout_efl_gfx_color_class_color_class_code_set(Eo *obj, Edje *pd EINA_UNUSED, const char *color_class,
|
||||
Efl_Gfx_Color_Class_Layer layer, const char *colorcode)
|
||||
{
|
||||
int len;
|
||||
unsigned char r, g, b, a;
|
||||
|
||||
len = _gfx_color_format_clean_param(colorcode);
|
||||
|
||||
_gfx_color_format_color_parse(colorcode, len, &r, &g, &b, &a);
|
||||
efl_gfx_color_class_set(obj, color_class, layer, r, g, b, a);
|
||||
}
|
||||
|
||||
EOLIAN const char *
|
||||
_efl_canvas_layout_efl_gfx_color_class_color_class_code_get(Eo *obj, Edje *pd EINA_UNUSED, const char *color_class,
|
||||
Efl_Gfx_Color_Class_Layer layer)
|
||||
{
|
||||
int r, g, b, a;
|
||||
|
||||
efl_gfx_color_class_get(obj, color_class, layer, &r, &g, &b, &a);
|
||||
return eina_slstr_printf("#%02X%02X%02X%02X", r, g, b, a);
|
||||
}
|
||||
|
||||
typedef struct _Edje_File_Color_Class_Iterator Edje_File_Color_Class_Iterator;
|
||||
struct _Edje_File_Color_Class_Iterator
|
||||
{
|
||||
|
|
|
@ -102,6 +102,7 @@ class Efl.Canvas.Layout (Efl.Canvas.Group, Efl.File, Efl.Container, Efl.Part,
|
|||
Efl.Gfx.Color_Class.color_class_description { get; }
|
||||
Efl.Gfx.Color_Class.color_class_del;
|
||||
Efl.Gfx.Color_Class.color_class_clear;
|
||||
Efl.Gfx.Color_Class.color_class_code { get; set; }
|
||||
Efl.Gfx.Text_Class.text_class { get; set; }
|
||||
Efl.Gfx.Text_Class.text_class_del;
|
||||
Efl.Gfx.Size_Class.size_class { get; set; }
|
||||
|
|
|
@ -1,100 +1,6 @@
|
|||
#include "config.h"
|
||||
#include "Efl.h"
|
||||
|
||||
static int
|
||||
_format_clean_param(Eina_Tmpstr *s)
|
||||
{
|
||||
Eina_Tmpstr *ss;
|
||||
char *ds;
|
||||
int len = 0;
|
||||
|
||||
ds = (char*) s;
|
||||
for (ss = s; *ss; ss++, ds++, len++)
|
||||
{
|
||||
if ((*ss == '\\') && *(ss + 1)) ss++;
|
||||
if (ds != ss) *ds = *ss;
|
||||
}
|
||||
*ds = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
_hex_string_get(char ch, Eina_Bool *ok)
|
||||
{
|
||||
if ((ch >= '0') && (ch <= '9')) return (ch - '0');
|
||||
else if ((ch >= 'A') && (ch <= 'F')) return (ch - 'A' + 10);
|
||||
else if ((ch >= 'a') && (ch <= 'f')) return (ch - 'a' + 10);
|
||||
*ok = EINA_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Parses a string of one of the formas:
|
||||
* 1. "#RRGGBB"
|
||||
* 2. "#RRGGBBAA"
|
||||
* 3. "#RGB"
|
||||
* 4. "#RGBA"
|
||||
* To the rgba values.
|
||||
*
|
||||
* @param[in] str The string to parse - NOT NULL.
|
||||
* @param[out] r The Red value - NOT NULL.
|
||||
* @param[out] g The Green value - NOT NULL.
|
||||
* @param[out] b The Blue value - NOT NULL.
|
||||
* @param[out] a The Alpha value - NOT NULL.
|
||||
*/
|
||||
static Eina_Bool
|
||||
_format_color_parse(const char *str, int slen,
|
||||
unsigned char *r, unsigned char *g,
|
||||
unsigned char *b, unsigned char *a)
|
||||
{
|
||||
Eina_Bool v = EINA_TRUE;
|
||||
|
||||
*r = *g = *b = *a = 0;
|
||||
|
||||
if (slen == 7) /* #RRGGBB */
|
||||
{
|
||||
*r = (_hex_string_get(str[1], &v) << 4) | (_hex_string_get(str[2], &v));
|
||||
*g = (_hex_string_get(str[3], &v) << 4) | (_hex_string_get(str[4], &v));
|
||||
*b = (_hex_string_get(str[5], &v) << 4) | (_hex_string_get(str[6], &v));
|
||||
*a = 0xff;
|
||||
}
|
||||
else if (slen == 9) /* #RRGGBBAA */
|
||||
{
|
||||
*r = (_hex_string_get(str[1], &v) << 4) | (_hex_string_get(str[2], &v));
|
||||
*g = (_hex_string_get(str[3], &v) << 4) | (_hex_string_get(str[4], &v));
|
||||
*b = (_hex_string_get(str[5], &v) << 4) | (_hex_string_get(str[6], &v));
|
||||
*a = (_hex_string_get(str[7], &v) << 4) | (_hex_string_get(str[8], &v));
|
||||
}
|
||||
else if (slen == 4) /* #RGB */
|
||||
{
|
||||
*r = _hex_string_get(str[1], &v);
|
||||
*r = (*r << 4) | *r;
|
||||
*g = _hex_string_get(str[2], &v);
|
||||
*g = (*g << 4) | *g;
|
||||
*b = _hex_string_get(str[3], &v);
|
||||
*b = (*b << 4) | *b;
|
||||
*a = 0xff;
|
||||
}
|
||||
else if (slen == 5) /* #RGBA */
|
||||
{
|
||||
*r = _hex_string_get(str[1], &v);
|
||||
*r = (*r << 4) | *r;
|
||||
*g = _hex_string_get(str[2], &v);
|
||||
*g = (*g << 4) | *g;
|
||||
*b = _hex_string_get(str[3], &v);
|
||||
*b = (*b << 4) | *b;
|
||||
*a = _hex_string_get(str[4], &v);
|
||||
*a = (*a << 4) | *a;
|
||||
}
|
||||
else v = EINA_FALSE;
|
||||
|
||||
*r = (*r * *a) / 255;
|
||||
*g = (*g * *a) / 255;
|
||||
*b = (*b * *a) / 255;
|
||||
return v;
|
||||
}
|
||||
#include "efl_gfx_color_internal.h"
|
||||
|
||||
EOLIAN static void
|
||||
_efl_gfx_color_color_code_set(Eo *obj, void *_pd EINA_UNUSED, const char *colorcode)
|
||||
|
@ -102,9 +8,9 @@ _efl_gfx_color_color_code_set(Eo *obj, void *_pd EINA_UNUSED, const char *colorc
|
|||
int len;
|
||||
unsigned char r, g, b, a;
|
||||
|
||||
len = _format_clean_param(colorcode);
|
||||
len = _gfx_color_format_clean_param(colorcode);
|
||||
|
||||
_format_color_parse(colorcode, len, &r, &g, &b, &a);
|
||||
_gfx_color_format_color_parse(colorcode, len, &r, &g, &b, &a);
|
||||
efl_gfx_color_set(obj, r, g, b, a);
|
||||
}
|
||||
|
||||
|
@ -117,27 +23,4 @@ _efl_gfx_color_color_code_get(Eo *obj, void *_pd EINA_UNUSED)
|
|||
return eina_slstr_printf("#%02X%02X%02X%02X", r, g, b, a);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_gfx_color_color_class_code_set(Eo *obj, void *_pd EINA_UNUSED, const char *color_class,
|
||||
Efl_Gfx_Color_Class_Layer layer, const char *colorcode)
|
||||
{
|
||||
int len;
|
||||
unsigned char r, g, b, a;
|
||||
|
||||
len = _format_clean_param(colorcode);
|
||||
|
||||
_format_color_parse(colorcode, len, &r, &g, &b, &a);
|
||||
efl_gfx_color_class_set(obj, color_class, layer, r, g, b, a);
|
||||
}
|
||||
|
||||
EOLIAN static const char *
|
||||
_efl_gfx_color_color_class_code_get(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED,
|
||||
const char *color_class, Efl_Gfx_Color_Class_Layer layer)
|
||||
{
|
||||
int r, g, b, a;
|
||||
|
||||
efl_gfx_color_class_get(obj, color_class, layer, &r, &g, &b, &a);
|
||||
return eina_slstr_printf("#%02X%02X%02X%02X", r, g, b, a);
|
||||
}
|
||||
|
||||
#include "interfaces/efl_gfx_color.eo.c"
|
||||
|
|
|
@ -60,24 +60,5 @@ mixin Efl.Gfx.Color
|
|||
colorcode: string; [[the hex color code.]]
|
||||
}
|
||||
}
|
||||
@property color_class_code {
|
||||
set {
|
||||
[[Set the color class color of given Evas Object to the given hex color code(#RRGGBBAA).
|
||||
e.g. efl_gfx_color_class_code_set(obj, "color_class_name", layer, "#FFCCAACC");
|
||||
]]
|
||||
}
|
||||
get {
|
||||
[[Get hex color class code of given Evas Object.
|
||||
This returns a short lived hex color class code string.
|
||||
]]
|
||||
}
|
||||
keys {
|
||||
color_class: string; [[The name of color class]]
|
||||
layer: Efl.Gfx.Color_Class.Layer @optional; [[The layer to set the color]]
|
||||
}
|
||||
values {
|
||||
colorcode: string; [[the hex color code.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,5 +82,24 @@ interface Efl.Gfx.Color_Class
|
|||
|
||||
@since 1.17.0]]
|
||||
}
|
||||
@property color_class_code {
|
||||
set {
|
||||
[[Set the color class color of given Evas Object to the given hex color code(#RRGGBBAA).
|
||||
e.g. efl_gfx_color_class_code_set(obj, "color_class_name", layer, "#FFCCAACC");
|
||||
]]
|
||||
}
|
||||
get {
|
||||
[[Get hex color class code of given Evas Object.
|
||||
This returns a short lived hex color class code string.
|
||||
]]
|
||||
}
|
||||
keys {
|
||||
color_class: string; [[The name of color class]]
|
||||
layer: Efl.Gfx.Color_Class.Layer @optional; [[The layer to set the color]]
|
||||
}
|
||||
values {
|
||||
colorcode: string; [[the hex color code.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
#include "efl_gfx_color_internal.h"
|
||||
|
||||
EAPI int
|
||||
_gfx_color_format_clean_param(Eina_Tmpstr *s)
|
||||
{
|
||||
Eina_Tmpstr *ss;
|
||||
char *ds;
|
||||
int len = 0;
|
||||
|
||||
ds = (char*) s;
|
||||
for (ss = s; *ss; ss++, ds++, len++)
|
||||
{
|
||||
if ((*ss == '\\') && *(ss + 1)) ss++;
|
||||
if (ds != ss) *ds = *ss;
|
||||
}
|
||||
*ds = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
_hex_string_get(char ch, Eina_Bool *ok)
|
||||
{
|
||||
if ((ch >= '0') && (ch <= '9')) return (ch - '0');
|
||||
else if ((ch >= 'A') && (ch <= 'F')) return (ch - 'A' + 10);
|
||||
else if ((ch >= 'a') && (ch <= 'f')) return (ch - 'a' + 10);
|
||||
*ok = EINA_FALSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Parses a string of one of the formas:
|
||||
* 1. "#RRGGBB"
|
||||
* 2. "#RRGGBBAA"
|
||||
* 3. "#RGB"
|
||||
* 4. "#RGBA"
|
||||
* To the rgba values.
|
||||
*
|
||||
* @param[in] str The string to parse - NOT NULL.
|
||||
* @param[out] r The Red value - NOT NULL.
|
||||
* @param[out] g The Green value - NOT NULL.
|
||||
* @param[out] b The Blue value - NOT NULL.
|
||||
* @param[out] a The Alpha value - NOT NULL.
|
||||
*/
|
||||
EAPI Eina_Bool
|
||||
_gfx_color_format_color_parse(const char *str, int slen,
|
||||
unsigned char *r, unsigned char *g,
|
||||
unsigned char *b, unsigned char *a)
|
||||
{
|
||||
Eina_Bool v = EINA_TRUE;
|
||||
|
||||
*r = *g = *b = *a = 0;
|
||||
|
||||
if (slen == 7) /* #RRGGBB */
|
||||
{
|
||||
*r = (_hex_string_get(str[1], &v) << 4) | (_hex_string_get(str[2], &v));
|
||||
*g = (_hex_string_get(str[3], &v) << 4) | (_hex_string_get(str[4], &v));
|
||||
*b = (_hex_string_get(str[5], &v) << 4) | (_hex_string_get(str[6], &v));
|
||||
*a = 0xff;
|
||||
}
|
||||
else if (slen == 9) /* #RRGGBBAA */
|
||||
{
|
||||
*r = (_hex_string_get(str[1], &v) << 4) | (_hex_string_get(str[2], &v));
|
||||
*g = (_hex_string_get(str[3], &v) << 4) | (_hex_string_get(str[4], &v));
|
||||
*b = (_hex_string_get(str[5], &v) << 4) | (_hex_string_get(str[6], &v));
|
||||
*a = (_hex_string_get(str[7], &v) << 4) | (_hex_string_get(str[8], &v));
|
||||
}
|
||||
else if (slen == 4) /* #RGB */
|
||||
{
|
||||
*r = _hex_string_get(str[1], &v);
|
||||
*r = (*r << 4) | *r;
|
||||
*g = _hex_string_get(str[2], &v);
|
||||
*g = (*g << 4) | *g;
|
||||
*b = _hex_string_get(str[3], &v);
|
||||
*b = (*b << 4) | *b;
|
||||
*a = 0xff;
|
||||
}
|
||||
else if (slen == 5) /* #RGBA */
|
||||
{
|
||||
*r = _hex_string_get(str[1], &v);
|
||||
*r = (*r << 4) | *r;
|
||||
*g = _hex_string_get(str[2], &v);
|
||||
*g = (*g << 4) | *g;
|
||||
*b = _hex_string_get(str[3], &v);
|
||||
*b = (*b << 4) | *b;
|
||||
*a = _hex_string_get(str[4], &v);
|
||||
*a = (*a << 4) | *a;
|
||||
}
|
||||
else v = EINA_FALSE;
|
||||
|
||||
*r = (*r * *a) / 255;
|
||||
*g = (*g * *a) / 255;
|
||||
*b = (*b * *a) / 255;
|
||||
return v;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef _GFX_COLOR_UTIL_H
|
||||
#define _GFX_COLOR_UTIL_H
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
EAPI int _gfx_color_format_clean_param(Eina_Tmpstr *s);
|
||||
EAPI Eina_Bool _gfx_color_format_color_parse(const char *str, int slen, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue