summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShilpa Singh <shilpa.singh@samsung.com>2014-02-08 13:33:58 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-02-08 13:33:58 +0900
commit68f2f6e7f2a8fc432d2b1e455839022f20e71e34 (patch)
tree593ecf1bdff5a332e4271aa43890e435146c16d7
parentf15b796dc330aef45c4dca27659239b8f76b24c0 (diff)
Colorselector: Item Selection/Unselection logic changes and corresponding API additions.
SUMMARY Item should remain selected once pressed. When one item is selected other items should be unselected. No special behavior on long press, item gets selected on mouse up. APIs added are to get current selected item and to programmatically control the selection/unselection of an item. This is patch D515 (had to do by hand).
-rw-r--r--src/bin/test_colorselector.c5
-rw-r--r--src/lib/elm_colorselector.c87
-rw-r--r--src/lib/elm_colorselector_common.h21
-rw-r--r--src/lib/elm_colorselector_eo.h13
-rw-r--r--src/lib/elm_colorselector_legacy.h11
-rw-r--r--src/lib/elm_widget_colorselector.h1
6 files changed, 124 insertions, 14 deletions
diff --git a/src/bin/test_colorselector.c b/src/bin/test_colorselector.c
index 411d7a037..59476326c 100644
--- a/src/bin/test_colorselector.c
+++ b/src/bin/test_colorselector.c
@@ -84,6 +84,7 @@ test_colorselector(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
84 const Eina_List *item_list, *last_item_list; 84 const Eina_List *item_list, *last_item_list;
85 Elm_Object_Item *color_item; 85 Elm_Object_Item *color_item;
86 int r, g, b, a; 86 int r, g, b, a;
87 Elm_Object_Item *item;
87 88
88 win = elm_win_util_standard_add("colorselector", "ColorSelector"); 89 win = elm_win_util_standard_add("colorselector", "ColorSelector");
89 elm_win_autodel_set(win, EINA_TRUE); 90 elm_win_autodel_set(win, EINA_TRUE);
@@ -113,7 +114,9 @@ test_colorselector(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
113 evas_object_show(fr); 114 evas_object_show(fr);
114 115
115 cs = elm_colorselector_add(fr); 116 cs = elm_colorselector_add(fr);
116 elm_colorselector_palette_color_add(cs, 255, 90, 18, 128); 117 item = elm_colorselector_palette_color_add(cs, 255, 90, 18, 128);
118 elm_colorselector_palette_item_selected_set(item, EINA_TRUE);
119
117 elm_colorselector_palette_color_add(cs, 255, 213, 0, 255); 120 elm_colorselector_palette_color_add(cs, 255, 213, 0, 255);
118 elm_colorselector_palette_color_add(cs, 146, 255, 11, 255); 121 elm_colorselector_palette_color_add(cs, 146, 255, 11, 255);
119 elm_colorselector_palette_color_add(cs, 9, 186, 10, 255); 122 elm_colorselector_palette_color_add(cs, 9, 186, 10, 255);
diff --git a/src/lib/elm_colorselector.c b/src/lib/elm_colorselector.c
index 714cd7941..daf326160 100644
--- a/src/lib/elm_colorselector.c
+++ b/src/lib/elm_colorselector.c
@@ -1272,7 +1272,7 @@ _on_color_long_press(void *data)
1272 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd); 1272 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
1273 1273
1274 sd->longpress_timer = NULL; 1274 sd->longpress_timer = NULL;
1275 sd->longpressed = EINA_TRUE; 1275
1276 evas_object_smart_callback_call 1276 evas_object_smart_callback_call
1277 (WIDGET(item), SIG_COLOR_ITEM_LONGPRESSED, item); 1277 (WIDGET(item), SIG_COLOR_ITEM_LONGPRESSED, item);
1278 1278
@@ -1293,8 +1293,6 @@ _on_color_pressed(void *data,
1293 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd); 1293 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
1294 1294
1295 if (ev->button != 1) return; 1295 if (ev->button != 1) return;
1296 elm_object_signal_emit(VIEW(item), "elm,state,selected", "elm");
1297 sd->longpressed = EINA_FALSE;
1298 1296
1299 ecore_timer_del(sd->longpress_timer); 1297 ecore_timer_del(sd->longpress_timer);
1300 sd->longpress_timer = ecore_timer_add 1298 sd->longpress_timer = ecore_timer_add
@@ -1317,15 +1315,17 @@ _on_color_released(void *data,
1317 1315
1318 if (ev->button != 1) return; 1316 if (ev->button != 1) return;
1319 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del); 1317 ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
1320 elm_object_signal_emit(VIEW(item), "elm,state,unselected", "elm"); 1318
1321 if (!sd->longpressed) 1319 elm_object_signal_emit(VIEW(item), "elm,state,selected", "elm");
1322 { 1320 elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g,
1323 elm_colorselector_color_set 1321 item->color->b, item->color->a);
1324 (WIDGET(item), item->color->r, item->color->g, item->color->b, 1322 evas_object_smart_callback_call(WIDGET(item), SIG_COLOR_ITEM_SELECTED,
1325 item->color->a); 1323 item);
1326 evas_object_smart_callback_call 1324
1327 (WIDGET(item), SIG_COLOR_ITEM_SELECTED, item); 1325 temp_item = eina_list_data_get(sd->selected);
1328 } 1326 if (temp_item && (temp_item != item))
1327 elm_object_signal_emit(VIEW(temp_item), "elm,state,unselected", "elm");
1328
1329 EINA_LIST_FOREACH(sd->items, l, temp_item) 1329 EINA_LIST_FOREACH(sd->items, l, temp_item)
1330 if (item == temp_item) sd->selected = l; 1330 if (item == temp_item) sd->selected = l;
1331 sd->focused = ELM_COLORSELECTOR_PALETTE; 1331 sd->focused = ELM_COLORSELECTOR_PALETTE;
@@ -2167,6 +2167,67 @@ _palette_items_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
2167} 2167}
2168 2168
2169EAPI void 2169EAPI void
2170elm_colorselector_palette_item_selected_set(Elm_Object_Item *it,
2171 Eina_Bool selected)
2172{
2173 Elm_Color_Item *temp_item, *item;
2174 item = (Elm_Color_Item *)it;
2175 Eina_List *l;
2176
2177 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
2178 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it);
2179
2180 if (selected)
2181 {
2182 temp_item = eina_list_data_get(sd->selected);
2183 if (item == temp_item) return;
2184 elm_object_signal_emit(VIEW(item), "elm,state,selected", "elm");
2185 elm_colorselector_color_set(WIDGET(item), item->color->r, item->color->g,
2186 item->color->b, item->color->a);
2187 if (temp_item)
2188 elm_object_signal_emit(VIEW(temp_item), "elm,state,unselected", "elm");
2189
2190 EINA_LIST_FOREACH(sd->items, l, temp_item)
2191 if (item == temp_item) sd->selected = l;
2192 }
2193 else
2194 {
2195 elm_object_signal_emit(VIEW(item), "elm,state,unselected", "elm");
2196 sd->selected = NULL;
2197 }
2198}
2199
2200EAPI Eina_Bool
2201elm_colorselector_palette_item_selected_get(const Elm_Object_Item *it)
2202{
2203 Elm_Color_Item *temp_item, *item;
2204 item = (Elm_Color_Item *)it;
2205 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2206 ELM_COLORSELECTOR_DATA_GET(WIDGET(item), sd);
2207
2208 temp_item = eina_list_data_get(sd->selected);
2209 if (item == temp_item) return EINA_TRUE;
2210 else return EINA_FALSE;
2211}
2212
2213EAPI Elm_Object_Item *
2214elm_colorselector_palette_selected_item_get(const Evas_Object *obj)
2215{
2216 ELM_COLORSELECTOR_CHECK(obj) NULL;
2217 Elm_Object_Item *ret = NULL;
2218 eo_do((Eo *) obj, elm_obj_colorselector_palette_selected_item_get(&ret));
2219 return ret;
2220}
2221
2222static void
2223_palette_selected_item_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
2224{
2225 Elm_Object_Item **ret = va_arg(*list, Elm_Object_Item **);
2226 Elm_Colorselector_Smart_Data *sd = _pd;
2227 *ret = eina_list_data_get(sd->selected);
2228}
2229
2230EAPI void
2170elm_colorselector_palette_name_set(Evas_Object *obj, 2231elm_colorselector_palette_name_set(Evas_Object *obj,
2171 const char *palette_name) 2232 const char *palette_name)
2172{ 2233{
@@ -2230,6 +2291,7 @@ _class_constructor(Eo_Class *klass)
2230 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_MODE_GET), _mode_get), 2291 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_MODE_GET), _mode_get),
2231 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_COLOR_ADD), _palette_color_add), 2292 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_COLOR_ADD), _palette_color_add),
2232 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_CLEAR), _palette_clear), 2293 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_CLEAR), _palette_clear),
2294 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_SELECTED_ITEM_GET), _palette_selected_item_get),
2233 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_ITEMS_GET), _palette_items_get), 2295 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_ITEMS_GET), _palette_items_get),
2234 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_SET), _palette_name_set), 2296 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_SET), _palette_name_set),
2235 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_GET), _palette_name_get), 2297 EO_OP_FUNC(ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_GET), _palette_name_get),
@@ -2249,6 +2311,7 @@ static const Eo_Op_Description op_desc[] = {
2249 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_MODE_GET, "Get Colorselector's mode."), 2311 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_MODE_GET, "Get Colorselector's mode."),
2250 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_COLOR_ADD, "Add a new color item to palette."), 2312 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_COLOR_ADD, "Add a new color item to palette."),
2251 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_CLEAR, "Clear the palette items."), 2313 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_CLEAR, "Clear the palette items."),
2314 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_SELECTED_ITEM_GET, "Get Palette's current selected item"),
2252 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_ITEMS_GET, "Get palette's item list"), 2315 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_ITEMS_GET, "Get palette's item list"),
2253 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_SET, "Set current palette's name."), 2316 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_SET, "Set current palette's name."),
2254 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_GET, "Get current palette's name."), 2317 EO_OP_DESCRIPTION(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_GET, "Get current palette's name."),
diff --git a/src/lib/elm_colorselector_common.h b/src/lib/elm_colorselector_common.h
index d39cf56bf..801b41670 100644
--- a/src/lib/elm_colorselector_common.h
+++ b/src/lib/elm_colorselector_common.h
@@ -56,3 +56,24 @@ EAPI void elm_colorselector_palette_item_color_get(const Elm_Object_Item *it, in
56 */ 56 */
57EAPI void elm_colorselector_palette_item_color_set(Elm_Object_Item *it, int r, int g, int b, int a); 57EAPI void elm_colorselector_palette_item_color_set(Elm_Object_Item *it, int r, int g, int b, int a);
58 58
59/**
60 * Get the selected state of color palette item.
61 *
62 * @param it The Colorpalette item
63 * @return EINA_TRUE if the item is selected, EINA_FALSE otherwise.
64 *
65 * @since 1.9
66 * @ingroup Colorselector
67 */
68EAPI Eina_Bool elm_colorselector_palette_item_selected_get(const Elm_Object_Item *it);
69
70/**
71 * Set the selected state of color palette item
72 *
73 * @param it The Colorpalette item
74 * @param selected if it's EINA_TRUE, select the item otherwise, unselect the item
75 *
76 * @since 1.9
77 * @ingroup Colorselector
78 */
79EAPI void elm_colorselector_palette_item_selected_set(Elm_Object_Item *it, Eina_Bool selected);
diff --git a/src/lib/elm_colorselector_eo.h b/src/lib/elm_colorselector_eo.h
index b7ac81a25..b8cc88e9a 100644
--- a/src/lib/elm_colorselector_eo.h
+++ b/src/lib/elm_colorselector_eo.h
@@ -12,6 +12,7 @@ enum
12 ELM_OBJ_COLORSELECTOR_SUB_ID_MODE_GET, 12 ELM_OBJ_COLORSELECTOR_SUB_ID_MODE_GET,
13 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_COLOR_ADD, 13 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_COLOR_ADD,
14 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_CLEAR, 14 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_CLEAR,
15 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_SELECTED_ITEM_GET,
15 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_ITEMS_GET, 16 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_ITEMS_GET,
16 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_SET, 17 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_SET,
17 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_GET, 18 ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_NAME_GET,
@@ -127,6 +128,18 @@ enum
127#define elm_obj_colorselector_palette_items_get(ret) ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_ITEMS_GET), EO_TYPECHECK(const Eina_List **, ret) 128#define elm_obj_colorselector_palette_items_get(ret) ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_ITEMS_GET), EO_TYPECHECK(const Eina_List **, ret)
128 129
129/** 130/**
131 * @def elm_obj_colorselector_palette_selected_item_get
132 * @since 1.9
133 *
134 * Get current selected palette item
135 *
136 * @param[out] ret
137 *
138 * @ingroup Colorselector
139 */
140#define elm_obj_colorselector_palette_selected_item_get(ret) ELM_OBJ_COLORSELECTOR_ID(ELM_OBJ_COLORSELECTOR_SUB_ID_PALETTE_SELECTED_ITEM_GET), EO_TYPECHECK(Elm_Object_Item **, ret)
141
142/**
130 * @def elm_obj_colorselector_palette_name_set 143 * @def elm_obj_colorselector_palette_name_set
131 * @since 1.8 144 * @since 1.8
132 * 145 *
diff --git a/src/lib/elm_colorselector_legacy.h b/src/lib/elm_colorselector_legacy.h
index b366056ef..7a7dd039c 100644
--- a/src/lib/elm_colorselector_legacy.h
+++ b/src/lib/elm_colorselector_legacy.h
@@ -95,6 +95,17 @@ EAPI void elm_colorselector_palette_clear(Evas_Object *obj);
95EAPI const Eina_List *elm_colorselector_palette_items_get(const Evas_Object *obj); 95EAPI const Eina_List *elm_colorselector_palette_items_get(const Evas_Object *obj);
96 96
97/** 97/**
98 * Get the selected item in colorselector palette.
99 *
100 * @param obj The Colorselector object
101 * @return The selected item, or NULL if none is selected.
102 *
103 * @since 1.9
104 * @ingroup Colorselector
105 */
106EAPI Elm_Object_Item *elm_colorselector_palette_selected_item_get(const Evas_Object *obj);
107
108/**
98 * Set current palette's name 109 * Set current palette's name
99 * 110 *
100 * @param obj The Colorselector object 111 * @param obj The Colorselector object
diff --git a/src/lib/elm_widget_colorselector.h b/src/lib/elm_widget_colorselector.h
index 4dbc4acf2..7b1c5ed28 100644
--- a/src/lib/elm_widget_colorselector.h
+++ b/src/lib/elm_widget_colorselector.h
@@ -56,7 +56,6 @@ struct _Elm_Colorselector_Smart_Data
56 Elm_Colorselector_Mode mode, focused; 56 Elm_Colorselector_Mode mode, focused;
57 int sel_color_type; 57 int sel_color_type;
58 58
59 Eina_Bool longpressed : 1;
60 Eina_Bool config_load : 1; 59 Eina_Bool config_load : 1;
61}; 60};
62 61