forked from enlightenment/efl
efl_gfx_color_class: make this a mixin and move color_class_code here
Summary: color_class_code seems to only have been added to efl_gfx_color in order to share the hex conversion code, but this is trivial to do when it's in another class and makes the api more sensible ref T7559 Reviewers: segfaultxavi, bu5hm4n, cedric Reviewed By: segfaultxavi Subscribers: #reviewers, #committers Tags: #efl_api Maniphest Tasks: T7559 Differential Revision: https://phab.enlightenment.org/D7898
This commit is contained in:
parent
b805f11c89
commit
1b568327c4
|
@ -84,7 +84,7 @@ edje_init(void)
|
|||
_edje_scale = FROM_DOUBLE(1.0);
|
||||
_edje_global_obj = efl_add(EDJE_GLOBAL_CLASS, efl_main_loop_get());
|
||||
EINA_SAFETY_ON_TRUE_GOTO(!_edje_global_obj, shutdown_efreet);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(!efl_loop_register(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj), shutdown_efreet);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(!efl_loop_register(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_MIXIN, _edje_global_obj), shutdown_efreet);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(!efl_loop_register(efl_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj), shutdown_efreet);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(!efl_loop_register(efl_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj), shutdown_efreet);
|
||||
|
||||
|
@ -154,7 +154,7 @@ shutdown_all:
|
|||
_edje_edd_shutdown();
|
||||
if (_edje_global_obj)
|
||||
{
|
||||
efl_loop_unregister(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj);
|
||||
efl_loop_unregister(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_MIXIN, _edje_global_obj);
|
||||
efl_loop_unregister(efl_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj);
|
||||
efl_loop_unregister(efl_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj);
|
||||
efl_del(_edje_global_obj);
|
||||
|
@ -213,7 +213,7 @@ _edje_shutdown_core(void)
|
|||
_edje_text_class_hash_free();
|
||||
_edje_size_class_hash_free();
|
||||
_edje_edd_shutdown();
|
||||
efl_loop_unregister(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj);
|
||||
efl_loop_unregister(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_MIXIN, _edje_global_obj);
|
||||
efl_loop_unregister(efl_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj);
|
||||
efl_loop_unregister(efl_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj);
|
||||
efl_del(_edje_global_obj);
|
||||
|
|
|
@ -2486,7 +2486,7 @@ static inline Edje_Global *
|
|||
_edje_global(void)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
return efl_provider_find(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE);
|
||||
return efl_provider_find(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_MIXIN);
|
||||
#else
|
||||
extern Edje_Global *_edje_global_obj;
|
||||
return _edje_global_obj;
|
||||
|
|
|
@ -117,8 +117,8 @@ _efl_gfx_color_color_code_get(const 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,
|
||||
EOLIAN static Eina_Bool
|
||||
_efl_gfx_color_class_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;
|
||||
|
@ -127,17 +127,19 @@ _efl_gfx_color_color_class_code_set(Eo *obj, void *_pd EINA_UNUSED, const char *
|
|||
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);
|
||||
return efl_gfx_color_class_set(obj, color_class, layer, r, g, b, a);
|
||||
}
|
||||
|
||||
EOLIAN static const char *
|
||||
_efl_gfx_color_color_class_code_get(const Eo *obj EINA_UNUSED, void *pd EINA_UNUSED,
|
||||
_efl_gfx_color_class_color_class_code_get(const 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);
|
||||
if (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);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#include "interfaces/efl_gfx_color.eo.c"
|
||||
#include "interfaces/efl_gfx_color_class.eo.c"
|
||||
|
|
|
@ -58,24 +58,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.]]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import efl_gfx_types;
|
||||
|
||||
interface Efl.Gfx.Color_Class
|
||||
mixin Efl.Gfx.Color_Class
|
||||
{
|
||||
[[Efl Gfx Color Class interface]]
|
||||
[[Efl Gfx Color Class mixin class]]
|
||||
data: null;
|
||||
methods {
|
||||
@property color_class {
|
||||
@property color_class @pure_virtual {
|
||||
set {
|
||||
[[Set the color of color class.
|
||||
|
||||
|
@ -46,7 +47,47 @@ interface Efl.Gfx.Color_Class
|
|||
a: int; [[The alpha value]]
|
||||
}
|
||||
}
|
||||
@property color_class_description {
|
||||
@property color_class_code {
|
||||
set {
|
||||
[[Set the hex color string of color class.
|
||||
|
||||
This function sets the color values for a color class. This will
|
||||
cause all edje parts in the specified object that have the specified
|
||||
color class to have their colors multiplied by these values.
|
||||
|
||||
The first color is the object, the second is the text outline, and
|
||||
the third is the text shadow. (Note that the second two only apply
|
||||
to text parts).
|
||||
|
||||
Setting color emits a signal "color_class,set" with source being
|
||||
the given color.
|
||||
|
||||
Note: These color values are expected to be premultiplied by the alpha.]]
|
||||
return: bool; [[$true if setting the color succeeded, $false otherwise]]
|
||||
}
|
||||
get {
|
||||
[[Get the hex color string of color class.
|
||||
|
||||
This function gets the color values for a color class. If no explicit
|
||||
object color is set, then global values will be used.
|
||||
|
||||
The first color is the object, the second is the text outline, and
|
||||
the third is the text shadow. (Note that the second two only apply
|
||||
to text parts).
|
||||
|
||||
Returns NULL if the color class cannot be fetched.
|
||||
|
||||
Note: These color values are expected to be premultiplied by $a.]]
|
||||
}
|
||||
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.]]
|
||||
}
|
||||
}
|
||||
@property color_class_description @pure_virtual {
|
||||
get {
|
||||
[[Get the description of a color class.
|
||||
|
||||
|
@ -59,7 +100,7 @@ interface Efl.Gfx.Color_Class
|
|||
description: string; [[The description of the target color class or $null if not found]]
|
||||
}
|
||||
}
|
||||
color_class_del {
|
||||
color_class_del @pure_virtual {
|
||||
[[Delete the color class.
|
||||
|
||||
This function deletes any values for the specified color class.
|
||||
|
@ -73,7 +114,7 @@ interface Efl.Gfx.Color_Class
|
|||
@in color_class: string; [[The name of color_class]]
|
||||
}
|
||||
}
|
||||
color_class_clear {
|
||||
color_class_clear @pure_virtual {
|
||||
[[Delete all color classes defined in object level.
|
||||
|
||||
This function deletes any color classes defined in object level.
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "interfaces/efl_gfx_fill.eo.c"
|
||||
#include "interfaces/efl_gfx_view.eo.c"
|
||||
|
||||
#include "interfaces/efl_gfx_color_class.eo.c"
|
||||
#include "interfaces/efl_gfx_text_class.eo.c"
|
||||
#include "interfaces/efl_gfx_size_class.eo.c"
|
||||
|
||||
|
|
Loading…
Reference in New Issue