summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-02-11 12:11:39 +0100
committerXavi Artigas <xavierartigas@yahoo.es>2019-02-11 12:34:12 +0100
commit1b568327c4feca6ac79863551abf1507bb090c55 (patch)
tree76d2ed617f688e12a956c55d511d874296dab014
parentb805f11c89ae5a43b6e74bfe2856beb35483a182 (diff)
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
-rw-r--r--src/lib/edje/edje_main.c6
-rw-r--r--src/lib/edje/edje_private.h2
-rw-r--r--src/lib/efl/interfaces/efl_gfx_color.c14
-rw-r--r--src/lib/efl/interfaces/efl_gfx_color.eo19
-rw-r--r--src/lib/efl/interfaces/efl_gfx_color_class.eo53
-rw-r--r--src/lib/efl/interfaces/efl_interfaces_main.c1
6 files changed, 59 insertions, 36 deletions
diff --git a/src/lib/edje/edje_main.c b/src/lib/edje/edje_main.c
index 1417309250..dc2c35cba5 100644
--- a/src/lib/edje/edje_main.c
+++ b/src/lib/edje/edje_main.c
@@ -84,7 +84,7 @@ edje_init(void)
84 _edje_scale = FROM_DOUBLE(1.0); 84 _edje_scale = FROM_DOUBLE(1.0);
85 _edje_global_obj = efl_add(EDJE_GLOBAL_CLASS, efl_main_loop_get()); 85 _edje_global_obj = efl_add(EDJE_GLOBAL_CLASS, efl_main_loop_get());
86 EINA_SAFETY_ON_TRUE_GOTO(!_edje_global_obj, shutdown_efreet); 86 EINA_SAFETY_ON_TRUE_GOTO(!_edje_global_obj, shutdown_efreet);
87 EINA_SAFETY_ON_TRUE_GOTO(!efl_loop_register(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj), shutdown_efreet); 87 EINA_SAFETY_ON_TRUE_GOTO(!efl_loop_register(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_MIXIN, _edje_global_obj), shutdown_efreet);
88 EINA_SAFETY_ON_TRUE_GOTO(!efl_loop_register(efl_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj), shutdown_efreet); 88 EINA_SAFETY_ON_TRUE_GOTO(!efl_loop_register(efl_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj), shutdown_efreet);
89 EINA_SAFETY_ON_TRUE_GOTO(!efl_loop_register(efl_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj), shutdown_efreet); 89 EINA_SAFETY_ON_TRUE_GOTO(!efl_loop_register(efl_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj), shutdown_efreet);
90 90
@@ -154,7 +154,7 @@ shutdown_all:
154 _edje_edd_shutdown(); 154 _edje_edd_shutdown();
155 if (_edje_global_obj) 155 if (_edje_global_obj)
156 { 156 {
157 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj); 157 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_MIXIN, _edje_global_obj);
158 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj); 158 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj);
159 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj); 159 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj);
160 efl_del(_edje_global_obj); 160 efl_del(_edje_global_obj);
@@ -213,7 +213,7 @@ _edje_shutdown_core(void)
213 _edje_text_class_hash_free(); 213 _edje_text_class_hash_free();
214 _edje_size_class_hash_free(); 214 _edje_size_class_hash_free();
215 _edje_edd_shutdown(); 215 _edje_edd_shutdown();
216 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE, _edje_global_obj); 216 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_MIXIN, _edje_global_obj);
217 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj); 217 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_TEXT_CLASS_INTERFACE, _edje_global_obj);
218 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj); 218 efl_loop_unregister(efl_main_loop_get(), EFL_GFX_SIZE_CLASS_INTERFACE, _edje_global_obj);
219 efl_del(_edje_global_obj); 219 efl_del(_edje_global_obj);
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 6b7cf50ffc..3721d28bdf 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -2486,7 +2486,7 @@ static inline Edje_Global *
2486_edje_global(void) 2486_edje_global(void)
2487{ 2487{
2488#ifndef NDEBUG 2488#ifndef NDEBUG
2489 return efl_provider_find(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_INTERFACE); 2489 return efl_provider_find(efl_main_loop_get(), EFL_GFX_COLOR_CLASS_MIXIN);
2490#else 2490#else
2491 extern Edje_Global *_edje_global_obj; 2491 extern Edje_Global *_edje_global_obj;
2492 return _edje_global_obj; 2492 return _edje_global_obj;
diff --git a/src/lib/efl/interfaces/efl_gfx_color.c b/src/lib/efl/interfaces/efl_gfx_color.c
index 54c4df868f..92c1f07483 100644
--- a/src/lib/efl/interfaces/efl_gfx_color.c
+++ b/src/lib/efl/interfaces/efl_gfx_color.c
@@ -117,8 +117,8 @@ _efl_gfx_color_color_code_get(const Eo *obj, void *_pd EINA_UNUSED)
117 return eina_slstr_printf("#%02X%02X%02X%02X", r, g, b, a); 117 return eina_slstr_printf("#%02X%02X%02X%02X", r, g, b, a);
118} 118}
119 119
120EOLIAN static void 120EOLIAN static Eina_Bool
121_efl_gfx_color_color_class_code_set(Eo *obj, void *_pd EINA_UNUSED, const char *color_class, 121_efl_gfx_color_class_color_class_code_set(Eo *obj, void *_pd EINA_UNUSED, const char *color_class,
122 Efl_Gfx_Color_Class_Layer layer, const char *colorcode) 122 Efl_Gfx_Color_Class_Layer layer, const char *colorcode)
123{ 123{
124 int len; 124 int len;
@@ -127,17 +127,19 @@ _efl_gfx_color_color_class_code_set(Eo *obj, void *_pd EINA_UNUSED, const char *
127 len = _format_clean_param(colorcode); 127 len = _format_clean_param(colorcode);
128 128
129 _format_color_parse(colorcode, len, &r, &g, &b, &a); 129 _format_color_parse(colorcode, len, &r, &g, &b, &a);
130 efl_gfx_color_class_set(obj, color_class, layer, r, g, b, a); 130 return efl_gfx_color_class_set(obj, color_class, layer, r, g, b, a);
131} 131}
132 132
133EOLIAN static const char * 133EOLIAN static const char *
134_efl_gfx_color_color_class_code_get(const Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, 134_efl_gfx_color_class_color_class_code_get(const Eo *obj EINA_UNUSED, void *pd EINA_UNUSED,
135 const char *color_class, Efl_Gfx_Color_Class_Layer layer) 135 const char *color_class, Efl_Gfx_Color_Class_Layer layer)
136{ 136{
137 int r, g, b, a; 137 int r, g, b, a;
138 138
139 efl_gfx_color_class_get(obj, color_class, layer, &r, &g, &b, &a); 139 if (efl_gfx_color_class_get(obj, color_class, layer, &r, &g, &b, &a))
140 return eina_slstr_printf("#%02X%02X%02X%02X", r, g, b, a); 140 return eina_slstr_printf("#%02X%02X%02X%02X", r, g, b, a);
141 return NULL;
141} 142}
142 143
143#include "interfaces/efl_gfx_color.eo.c" 144#include "interfaces/efl_gfx_color.eo.c"
145#include "interfaces/efl_gfx_color_class.eo.c"
diff --git a/src/lib/efl/interfaces/efl_gfx_color.eo b/src/lib/efl/interfaces/efl_gfx_color.eo
index 6e1aa2b260..d3c41e1e31 100644
--- a/src/lib/efl/interfaces/efl_gfx_color.eo
+++ b/src/lib/efl/interfaces/efl_gfx_color.eo
@@ -58,24 +58,5 @@ mixin Efl.Gfx.Color
58 colorcode: string; [[the hex color code.]] 58 colorcode: string; [[the hex color code.]]
59 } 59 }
60 } 60 }
61 @property color_class_code {
62 set {
63 [[Set the color class color of given Evas Object to the given hex color code(#RRGGBBAA).
64 e.g. efl_gfx_color_class_code_set(obj, "color_class_name", layer, "#FFCCAACC");
65 ]]
66 }
67 get {
68 [[Get hex color class code of given Evas Object.
69 This returns a short lived hex color class code string.
70 ]]
71 }
72 keys {
73 color_class: string; [[The name of color class]]
74 layer: Efl.Gfx.Color_Class_Layer @optional; [[The layer to set the color]]
75 }
76 values {
77 colorcode: string; [[the hex color code.]]
78 }
79 }
80 } 61 }
81} 62}
diff --git a/src/lib/efl/interfaces/efl_gfx_color_class.eo b/src/lib/efl/interfaces/efl_gfx_color_class.eo
index f0d4dcb866..990835dfce 100644
--- a/src/lib/efl/interfaces/efl_gfx_color_class.eo
+++ b/src/lib/efl/interfaces/efl_gfx_color_class.eo
@@ -1,10 +1,11 @@
1import efl_gfx_types; 1import efl_gfx_types;
2 2
3interface Efl.Gfx.Color_Class 3mixin Efl.Gfx.Color_Class
4{ 4{
5 [[Efl Gfx Color Class interface]] 5 [[Efl Gfx Color Class mixin class]]
6 data: null;
6 methods { 7 methods {
7 @property color_class { 8 @property color_class @pure_virtual {
8 set { 9 set {
9 [[Set the color of color class. 10 [[Set the color of color class.
10 11
@@ -46,7 +47,47 @@ interface Efl.Gfx.Color_Class
46 a: int; [[The alpha value]] 47 a: int; [[The alpha value]]
47 } 48 }
48 } 49 }
49 @property color_class_description { 50 @property color_class_code {
51 set {
52 [[Set the hex color string of color class.
53
54 This function sets the color values for a color class. This will
55 cause all edje parts in the specified object that have the specified
56 color class to have their colors multiplied by these values.
57
58 The first color is the object, the second is the text outline, and
59 the third is the text shadow. (Note that the second two only apply
60 to text parts).
61
62 Setting color emits a signal "color_class,set" with source being
63 the given color.
64
65 Note: These color values are expected to be premultiplied by the alpha.]]
66 return: bool; [[$true if setting the color succeeded, $false otherwise]]
67 }
68 get {
69 [[Get the hex color string of color class.
70
71 This function gets the color values for a color class. If no explicit
72 object color is set, then global values will be used.
73
74 The first color is the object, the second is the text outline, and
75 the third is the text shadow. (Note that the second two only apply
76 to text parts).
77
78 Returns NULL if the color class cannot be fetched.
79
80 Note: These color values are expected to be premultiplied by $a.]]
81 }
82 keys {
83 color_class: string; [[The name of color class]]
84 layer: Efl.Gfx.Color_Class_Layer @optional; [[The layer to set the color]]
85 }
86 values {
87 colorcode: string; [[the hex color code.]]
88 }
89 }
90 @property color_class_description @pure_virtual {
50 get { 91 get {
51 [[Get the description of a color class. 92 [[Get the description of a color class.
52 93
@@ -59,7 +100,7 @@ interface Efl.Gfx.Color_Class
59 description: string; [[The description of the target color class or $null if not found]] 100 description: string; [[The description of the target color class or $null if not found]]
60 } 101 }
61 } 102 }
62 color_class_del { 103 color_class_del @pure_virtual {
63 [[Delete the color class. 104 [[Delete the color class.
64 105
65 This function deletes any values for the specified color class. 106 This function deletes any values for the specified color class.
@@ -73,7 +114,7 @@ interface Efl.Gfx.Color_Class
73 @in color_class: string; [[The name of color_class]] 114 @in color_class: string; [[The name of color_class]]
74 } 115 }
75 } 116 }
76 color_class_clear { 117 color_class_clear @pure_virtual {
77 [[Delete all color classes defined in object level. 118 [[Delete all color classes defined in object level.
78 119
79 This function deletes any color classes defined in object level. 120 This function deletes any color classes defined in object level.
diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c
index 4e2490a6c7..0ede9908f8 100644
--- a/src/lib/efl/interfaces/efl_interfaces_main.c
+++ b/src/lib/efl/interfaces/efl_interfaces_main.c
@@ -35,7 +35,6 @@
35#include "interfaces/efl_gfx_fill.eo.c" 35#include "interfaces/efl_gfx_fill.eo.c"
36#include "interfaces/efl_gfx_view.eo.c" 36#include "interfaces/efl_gfx_view.eo.c"
37 37
38#include "interfaces/efl_gfx_color_class.eo.c"
39#include "interfaces/efl_gfx_text_class.eo.c" 38#include "interfaces/efl_gfx_text_class.eo.c"
40#include "interfaces/efl_gfx_size_class.eo.c" 39#include "interfaces/efl_gfx_size_class.eo.c"
41 40