1 #ifndef ELM_WIDGET_COLORSELECTOR_H
2 #define ELM_WIDGET_COLORSELECTOR_H
3 
4 #include "Elementary.h"
5 #include "elm_color_item_eo.h"
6 #include "elm_colorselector_eo.h"
7 
8 /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
9  * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
10  * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
11  * IT AT RUNTIME.
12  */
13 
14 /**
15  * @addtogroup Widget
16  * @{
17  *
18  * @section elm-colorselector-class The Elementary Colorselector Class
19  *
20  * Elementary, besides having the @ref Colorselector widget, exposes its
21  * foundation -- the Elementary Colorselector Class -- in order to create other
22  * widgets which are a colorselector with some more logic on top.
23  */
24 
25 typedef struct _Color_Bar_Data Color_Bar_Data;
26 
27 /**
28  * Base layout smart data extended with colorselector instance data.
29  */
30 typedef struct _Elm_Colorselector_Data Elm_Colorselector_Data;
31 struct _Elm_Colorselector_Data
32 {
33    /* for the 3 displaying modes of the widget */
34    Evas_Object           *col_bars_area;
35    Evas_Object           *palette_box;
36    Evas_Object           *picker;
37    Evas_Object           *picker_display;
38    Evas_Object           *spinners[4];
39    Evas_Object           *button;
40 
41    struct {
42       int                 x, y;
43       Eina_Bool           in;
44 #ifdef HAVE_ELEMENTARY_X
45       Ecore_X_Window       xroot;
46       Ecore_Event_Handler *mouse_motion;
47       Ecore_Event_Handler *key_up;
48       Ecore_Event_Handler *mouse_up;
49 #endif
50    } grab;
51 
52    /* focus support data */
53    Elm_Object_Item       *focused_item;
54    Eina_List             *focus_items;
55 
56    Eina_List             *items, *selected;
57    Color_Bar_Data        *cb_data[4];
58 
59    Ecore_Timer           *longpress_timer;
60    const char            *palette_name;
61    Evas_Coord             _x, _y, _w, _h;
62 
63    /* color components */
64    int                    r, g, b, a;
65    int                    er, eg, eb;
66 
67    double                 h, s, l;
68    Elm_Colorselector_Mode mode, focused;
69    int                    sel_color_type;
70 
71    Eina_Bool              config_load : 1;
72 };
73 
74 typedef enum _Color_Type
75 {
76    HUE,
77    SATURATION,
78    LIGHTNESS,
79    ALPHA
80 } Color_Type;
81 
82 struct _Color_Bar_Data
83 {
84    Evas_Object *parent;
85    Evas_Object *colorbar;
86    Evas_Object *bar;
87    Evas_Object *lbt;
88    Evas_Object *rbt;
89    Evas_Object *bg_rect;
90    Evas_Object *arrow;
91    Evas_Object *touch_area;
92    Evas_Object *access_obj;
93    Color_Type   color_type;
94 };
95 
96 typedef struct _Elm_Color_Item_Data Elm_Color_Item_Data;
97 struct _Elm_Color_Item_Data
98 {
99    Elm_Widget_Item_Data *base;
100 
101    Evas_Object    *color_obj;
102    Elm_Color_RGBA *color;
103 
104    Eina_Bool       still_in : 1;
105 };
106 
107 typedef struct _Elm_Color_Name Elm_Color_Name;
108 struct _Elm_Color_Name
109 {
110    Elm_Color_RGBA color;
111    const char *name;
112 };
113 
114 /**
115  * @}
116  */
117 
118 #define ELM_COLORSELECTOR_DATA_GET(o, sd) \
119   Elm_Colorselector_Data * sd = efl_data_scope_get(o, ELM_COLORSELECTOR_CLASS)
120 
121 #define ELM_COLORSELECTOR_DATA_GET_OR_RETURN(o, ptr) \
122   ELM_COLORSELECTOR_DATA_GET(o, ptr);                \
123   if (EINA_UNLIKELY(!ptr))                           \
124     {                                                \
125        ERR("No widget data for object %p (%s)",      \
126            o, evas_object_type_get(o));              \
127        return;                                       \
128     }
129 
130 #define ELM_COLORSELECTOR_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
131   ELM_COLORSELECTOR_DATA_GET(o, ptr);                         \
132   if (EINA_UNLIKELY(!ptr))                                    \
133     {                                                         \
134        ERR("No widget data for object %p (%s)",               \
135            o, evas_object_type_get(o));                       \
136        return val;                                            \
137     }
138 
139 #define ELM_COLOR_ITEM_DATA_GET(o, sd) \
140   Elm_Color_Item_Data * sd = efl_data_scope_get(o, ELM_COLOR_ITEM_CLASS)
141 
142 #define ELM_COLORSELECTOR_CHECK(obj)                              \
143   if (EINA_UNLIKELY(!efl_isa((obj), ELM_COLORSELECTOR_CLASS))) \
144     return
145 
146 #define ELM_COLORSELECTOR_ITEM_CHECK(it)                       \
147   if (EINA_UNLIKELY(!efl_isa(it->base->eo_obj, ELM_COLOR_ITEM_CLASS))) \
148     return
149 
150 #define ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, ...)        \
151   if (EINA_UNLIKELY(!efl_isa(it->base->eo_obj, ELM_COLOR_ITEM_CLASS))) \
152     return __VA_ARGS__;
153 
154 #endif
155