summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2016-04-15 15:10:49 +0900
committerJaehwan Kim <jae.hwan.kim@samsung.com>2016-04-15 15:10:49 +0900
commit726c6171bf8606b7c1679ae13c5720afe53c630b (patch)
treec163778c92bdd9a2db486b02c2295635313f342f
parentd162a5e6e1518564299fa20611fee00322029234 (diff)
Elementary Toolbar: Send order signals when a item is added/removed
Summary: Send order signals for changing item's state according to its order. It does not affect to existing themes. It sends the following signals. elm,order,first,item elm,order,default,item elm,order,last,item @feature Test Plan: N/A Reviewers: woohyun, jaehwan, eagleeye, cedric Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3883
-rw-r--r--src/lib/elementary/elm_toolbar.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/lib/elementary/elm_toolbar.c b/src/lib/elementary/elm_toolbar.c
index 1611969f7b..6c1662fffc 100644
--- a/src/lib/elementary/elm_toolbar.c
+++ b/src/lib/elementary/elm_toolbar.c
@@ -1179,6 +1179,95 @@ _item_select(Elm_Toolbar_Item_Data *it)
1179 elm_interface_atspi_accessible_state_changed_signal_emit(EO_OBJ(it), ELM_ATSPI_STATE_SELECTED, EINA_TRUE); 1179 elm_interface_atspi_accessible_state_changed_signal_emit(EO_OBJ(it), ELM_ATSPI_STATE_SELECTED, EINA_TRUE);
1180} 1180}
1181 1181
1182/* Send order signals when item is added/deleted.
1183 * If the given item is on deletion, item_on_deletion should be EINA_TRUE. */
1184static void
1185_elm_toolbar_item_order_signal_emit(Elm_Toolbar_Data *sd,
1186 Elm_Toolbar_Item_Data *it,
1187 Eina_List *prev_list,
1188 Eina_Bool item_on_deletion)
1189{
1190 Elm_Toolbar_Item_Data *first_it = NULL, *last_it = NULL;
1191 Evas_Object *first_it_view = NULL, *last_it_view = NULL;
1192 Elm_Toolbar_Item_Data *prev_first_it = NULL, *prev_last_it = NULL;
1193 Evas_Object *prev_first_it_view = NULL, *prev_last_it_view = NULL;
1194 Eina_List *list;
1195
1196 list = evas_object_box_children_get(sd->bx);
1197
1198 if (!list) return;
1199
1200 if (prev_list)
1201 {
1202 prev_first_it_view = eina_list_data_get(prev_list);
1203 prev_last_it_view = eina_list_data_get(eina_list_last(prev_list));
1204 prev_first_it = evas_object_data_get(prev_first_it_view, "item");
1205 prev_last_it = evas_object_data_get(prev_last_it_view, "item");
1206 }
1207
1208 first_it_view = eina_list_data_get(list);
1209 last_it_view = eina_list_data_get(eina_list_last(list));
1210 first_it = evas_object_data_get(first_it_view, "item");
1211 last_it = evas_object_data_get(last_it_view, "item");
1212
1213 if (prev_first_it)
1214 {
1215 if ((prev_first_it != first_it) && (prev_first_it != last_it))
1216 elm_layout_signal_emit(VIEW(prev_first_it), "elm,order,default,item", "elm");
1217 else if (prev_first_it == last_it)
1218 elm_layout_signal_emit(VIEW(prev_first_it), "elm,order,last,item", "elm");
1219 }
1220
1221 if (prev_last_it)
1222 {
1223 if ((prev_last_it != last_it) && (prev_last_it != first_it))
1224 elm_layout_signal_emit(VIEW(prev_last_it), "elm,order,default,item", "elm");
1225 else if (prev_last_it == first_it)
1226 elm_layout_signal_emit(VIEW(prev_last_it), "elm,order,first,item", "elm");
1227 }
1228
1229 if (it)
1230 {
1231 if (!item_on_deletion)
1232 {
1233 if (first_it == last_it)
1234 {
1235 elm_layout_signal_emit(VIEW(it), "elm,order,first,item", "elm");
1236 elm_layout_signal_emit(VIEW(it), "elm,order,last,item", "elm");
1237 }
1238 else if (it == first_it)
1239 {
1240 elm_layout_signal_emit(VIEW(it), "elm,order,first,item", "elm");
1241 }
1242 else if (it == last_it)
1243 {
1244 elm_layout_signal_emit(VIEW(it), "elm,order,last,item", "elm");
1245 }
1246 }
1247 else if (first_it != last_it)
1248 {
1249 if (it == first_it)
1250 {
1251 Eina_List *next_l = eina_list_next(list);
1252 first_it_view = eina_list_data_get(next_l);
1253 first_it = evas_object_data_get(first_it_view, "item");
1254
1255 elm_layout_signal_emit(first_it_view, "elm,order,first,item", "elm");
1256 }
1257 else if (it == last_it)
1258 {
1259 Eina_List *prev_l = eina_list_prev(eina_list_last(list));
1260 last_it_view = eina_list_data_get(prev_l);
1261 last_it = evas_object_data_get(last_it_view, "item");
1262
1263 elm_layout_signal_emit(last_it_view, "elm,order,last,item", "elm");
1264 }
1265 }
1266 }
1267
1268 eina_list_free(list);
1269}
1270
1182static void 1271static void
1183_item_del(Elm_Toolbar_Item_Data *it) 1272_item_del(Elm_Toolbar_Item_Data *it)
1184{ 1273{
@@ -1187,6 +1276,8 @@ _item_del(Elm_Toolbar_Item_Data *it)
1187 1276
1188 _item_unselect(it); 1277 _item_unselect(it);
1189 1278
1279 _elm_toolbar_item_order_signal_emit(sd, it, NULL, EINA_TRUE);
1280
1190 EINA_LIST_FREE(it->states, it_state) 1281 EINA_LIST_FREE(it->states, it_state)
1191 { 1282 {
1192 if (it->icon == it_state->icon) 1283 if (it->icon == it_state->icon)
@@ -3027,11 +3118,14 @@ _elm_toolbar_item_append(Eo *obj, Elm_Toolbar_Data *sd, const char *icon, const
3027{ 3118{
3028 Elm_Toolbar_Item_Data *it; 3119 Elm_Toolbar_Item_Data *it;
3029 double scale; 3120 double scale;
3121 Eina_List *prev_list;
3030 3122
3031 it = _item_new(obj, icon, label, func, data); 3123 it = _item_new(obj, icon, label, func, data);
3032 if (!it) return NULL; 3124 if (!it) return NULL;
3033 scale = (elm_widget_scale_get(obj) * elm_config_scale_get()); 3125 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
3034 3126
3127 prev_list = evas_object_box_children_get(sd->bx);
3128
3035 sd->items = eina_inlist_append(sd->items, EINA_INLIST_GET(it)); 3129 sd->items = eina_inlist_append(sd->items, EINA_INLIST_GET(it));
3036 evas_object_box_append(sd->bx, VIEW(it)); 3130 evas_object_box_append(sd->bx, VIEW(it));
3037 evas_object_show(VIEW(it)); 3131 evas_object_show(VIEW(it));
@@ -3039,6 +3133,9 @@ _elm_toolbar_item_append(Eo *obj, Elm_Toolbar_Data *sd, const char *icon, const
3039 _item_theme_hook(obj, it, scale, sd->icon_size); 3133 _item_theme_hook(obj, it, scale, sd->icon_size);
3040 sd->item_count++; 3134 sd->item_count++;
3041 3135
3136 _elm_toolbar_item_order_signal_emit(sd, it, prev_list, EINA_FALSE);
3137 eina_list_free(prev_list);
3138
3042 return EO_OBJ(it); 3139 return EO_OBJ(it);
3043} 3140}
3044 3141
@@ -3047,17 +3144,23 @@ _elm_toolbar_item_prepend(Eo *obj, Elm_Toolbar_Data *sd, const char *icon, const
3047{ 3144{
3048 Elm_Toolbar_Item_Data *it; 3145 Elm_Toolbar_Item_Data *it;
3049 double scale; 3146 double scale;
3147 Eina_List *prev_list;
3050 3148
3051 it = _item_new(obj, icon, label, func, data); 3149 it = _item_new(obj, icon, label, func, data);
3052 if (!it) return NULL; 3150 if (!it) return NULL;
3053 scale = (elm_widget_scale_get(obj) * elm_config_scale_get()); 3151 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
3054 3152
3153 prev_list = evas_object_box_children_get(sd->bx);
3154
3055 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(it)); 3155 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(it));
3056 evas_object_box_prepend(sd->bx, VIEW(it)); 3156 evas_object_box_prepend(sd->bx, VIEW(it));
3057 evas_object_show(VIEW(it)); 3157 evas_object_show(VIEW(it));
3058 _item_theme_hook(obj, it, scale, sd->icon_size); 3158 _item_theme_hook(obj, it, scale, sd->icon_size);
3059 sd->item_count++; 3159 sd->item_count++;
3060 3160
3161 _elm_toolbar_item_order_signal_emit(sd, it, prev_list, EINA_FALSE);
3162 eina_list_free(prev_list);
3163
3061 return EO_OBJ(it); 3164 return EO_OBJ(it);
3062} 3165}
3063 3166
@@ -3066,6 +3169,7 @@ _elm_toolbar_item_insert_before(Eo *obj, Elm_Toolbar_Data *sd, Elm_Object_Item *
3066{ 3169{
3067 Elm_Toolbar_Item_Data *it; 3170 Elm_Toolbar_Item_Data *it;
3068 double scale; 3171 double scale;
3172 Eina_List *prev_list;
3069 3173
3070 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_before, NULL); 3174 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_before, NULL);
3071 ELM_TOOLBAR_ITEM_DATA_GET(eo_before, _before); 3175 ELM_TOOLBAR_ITEM_DATA_GET(eo_before, _before);
@@ -3075,12 +3179,17 @@ _elm_toolbar_item_insert_before(Eo *obj, Elm_Toolbar_Data *sd, Elm_Object_Item *
3075 if (!it) return NULL; 3179 if (!it) return NULL;
3076 scale = (elm_widget_scale_get(obj) * elm_config_scale_get()); 3180 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
3077 3181
3182 prev_list = evas_object_box_children_get(sd->bx);
3183
3078 sd->items = eina_inlist_prepend_relative 3184 sd->items = eina_inlist_prepend_relative
3079 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_before)); 3185 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_before));
3080 evas_object_box_insert_before(sd->bx, VIEW(it), VIEW(_before)); 3186 evas_object_box_insert_before(sd->bx, VIEW(it), VIEW(_before));
3081 _item_theme_hook(obj, it, scale, sd->icon_size); 3187 _item_theme_hook(obj, it, scale, sd->icon_size);
3082 sd->item_count++; 3188 sd->item_count++;
3083 3189
3190 _elm_toolbar_item_order_signal_emit(sd, it, prev_list, EINA_FALSE);
3191 eina_list_free(prev_list);
3192
3084 return EO_OBJ(it); 3193 return EO_OBJ(it);
3085} 3194}
3086 3195
@@ -3089,6 +3198,7 @@ _elm_toolbar_item_insert_after(Eo *obj, Elm_Toolbar_Data *sd, Elm_Object_Item *e
3089{ 3198{
3090 Elm_Toolbar_Item_Data *it; 3199 Elm_Toolbar_Item_Data *it;
3091 double scale; 3200 double scale;
3201 Eina_List *prev_list;
3092 3202
3093 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_after, NULL); 3203 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_after, NULL);
3094 ELM_TOOLBAR_ITEM_DATA_GET(eo_after, _after); 3204 ELM_TOOLBAR_ITEM_DATA_GET(eo_after, _after);
@@ -3098,12 +3208,17 @@ _elm_toolbar_item_insert_after(Eo *obj, Elm_Toolbar_Data *sd, Elm_Object_Item *e
3098 if (!it) return NULL; 3208 if (!it) return NULL;
3099 scale = (elm_widget_scale_get(obj) * elm_config_scale_get()); 3209 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
3100 3210
3211 prev_list = evas_object_box_children_get(sd->bx);
3212
3101 sd->items = eina_inlist_append_relative 3213 sd->items = eina_inlist_append_relative
3102 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_after)); 3214 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_after));
3103 evas_object_box_insert_after(sd->bx, VIEW(it), VIEW(_after)); 3215 evas_object_box_insert_after(sd->bx, VIEW(it), VIEW(_after));
3104 _item_theme_hook(obj, it, scale, sd->icon_size); 3216 _item_theme_hook(obj, it, scale, sd->icon_size);
3105 sd->item_count++; 3217 sd->item_count++;
3106 3218
3219 _elm_toolbar_item_order_signal_emit(sd, it, prev_list, EINA_FALSE);
3220 eina_list_free(prev_list);
3221
3107 return EO_OBJ(it); 3222 return EO_OBJ(it);
3108} 3223}
3109 3224