summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2016-07-01 11:52:39 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-01 17:20:40 +0900
commiteffe9b169658ec10f2edca087e4cfd4d8cea8dcf (patch)
tree92310a816f854d74e4e02c2514836cabd486fd41 /src
parent9ead2c669d8754e9635a99b7a684376d41f74114 (diff)
gengrid: fix focus issue when prev/next item is disabled
Summary: After setting focus to disabled item, focus does not work properly. It is necessary to consider disabled state of each item when selecting next focused item. Signed-off-by: Jehun Lim <jehun.lim@samsung.com> Test Plan: 1. elementary_test -to 'gengrid disabled item focus' 2. check 'item select on focus disable' 3. move focus to disabled item 4. observe focus and compare before this patch Reviewers: cedric Subscribers: minkyu, cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4115
Diffstat (limited to 'src')
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_gengrid.c72
-rw-r--r--src/lib/elementary/elm_gengrid.c81
3 files changed, 131 insertions, 24 deletions
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 9cdc7b0..f40de25 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -155,6 +155,7 @@ void test_gengrid_item_styles(void *data, Evas_Object *obj, void *event_info);
155void test_gengrid_speed(void *data, Evas_Object *obj, void *event_info); 155void test_gengrid_speed(void *data, Evas_Object *obj, void *event_info);
156void test_gengrid_focus(void *data, Evas_Object *obj, void *event_info); 156void test_gengrid_focus(void *data, Evas_Object *obj, void *event_info);
157void test_gengrid_update(void *data, Evas_Object *obj, void *event_info); 157void test_gengrid_update(void *data, Evas_Object *obj, void *event_info);
158void test_gengrid_disabled_item_focus(void *data, Evas_Object *obj, void *event_info);
158void test_win_state(void *data, Evas_Object *obj, void *event_info); 159void test_win_state(void *data, Evas_Object *obj, void *event_info);
159void test_win_state2(void *data, Evas_Object *obj, void *event_info); 160void test_win_state2(void *data, Evas_Object *obj, void *event_info);
160void test_progressbar(void *data, Evas_Object *obj, void *event_info); 161void test_progressbar(void *data, Evas_Object *obj, void *event_info);
@@ -750,6 +751,7 @@ add_tests:
750 ADD_TEST(NULL, "Lists - Gengrid", "Gengrid Update Speed", test_gengrid_speed); 751 ADD_TEST(NULL, "Lists - Gengrid", "Gengrid Update Speed", test_gengrid_speed);
751 ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Focus", test_gengrid_focus); 752 ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Focus", test_gengrid_focus);
752 ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Update", test_gengrid_update); 753 ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Update", test_gengrid_update);
754 ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Disabled Item Focus", test_gengrid_disabled_item_focus);
753 755
754 //------------------------------// 756 //------------------------------//
755 ADD_TEST(NULL, "General", "Scaling", test_scaling); 757 ADD_TEST(NULL, "General", "Scaling", test_scaling);
diff --git a/src/bin/elementary/test_gengrid.c b/src/bin/elementary/test_gengrid.c
index c2119fa..92a7b01 100644
--- a/src/bin/elementary/test_gengrid.c
+++ b/src/bin/elementary/test_gengrid.c
@@ -2235,3 +2235,75 @@ test_gengrid_update(void *data EINA_UNUSED,
2235 evas_object_resize(win, 600, 600); 2235 evas_object_resize(win, 600, 600);
2236 evas_object_show(win); 2236 evas_object_show(win);
2237} 2237}
2238
2239void
2240test_gengrid_disabled_item_focus(void *data EINA_UNUSED,
2241 Evas_Object *obj EINA_UNUSED,
2242 void *event_info EINA_UNUSED)
2243{
2244 Evas_Object *win, *bx, *obx, *grid, *ck;
2245 Elm_Gengrid_Item_Class *ic;
2246 Item_Data *id;
2247 int i, n;
2248 char buf[PATH_MAX];
2249
2250 win = elm_win_util_standard_add("gengrid_disabled_focus", "Gengrid Disabled Focus");
2251 elm_win_autodel_set(win, EINA_TRUE);
2252
2253 bx = elm_box_add(win);
2254 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2255 elm_win_resize_object_add(win, bx);
2256 evas_object_show(bx);
2257
2258 grid = elm_gengrid_add(win);
2259
2260 elm_gengrid_item_size_set(grid, ELM_SCALE_SIZE(150), ELM_SCALE_SIZE(150));
2261 elm_gengrid_multi_select_set(grid, EINA_FALSE);
2262 evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2263 evas_object_size_hint_min_set(grid, 600, 550);
2264 elm_box_pack_end(bx, grid);
2265 evas_object_show(grid);
2266 evas_object_smart_callback_add(grid, "item,focused", _gengrid_focus_item_cb, "item,focused");
2267 evas_object_smart_callback_add(grid, "item,unfocused", _gengrid_focus_item_cb, "item,unfocused");
2268 evas_object_smart_callback_add(grid, "selected", grid_selected, NULL);
2269
2270 obx = elm_box_add(win);
2271 evas_object_size_hint_weight_set(obx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2272 elm_box_horizontal_set(obx, EINA_TRUE);
2273 elm_box_pack_end(bx, obx);
2274 evas_object_show(obx);
2275
2276 ck = elm_check_add(win);
2277 elm_object_text_set(ck, "Item select on focus disable");
2278 elm_check_state_set(ck, elm_config_item_select_on_focus_disabled_get());
2279 evas_object_smart_callback_add(ck, "changed",
2280 _gg_focus_item_select_on_focus_disable_changed_cb,
2281 NULL);
2282 elm_box_pack_end(obx, ck);
2283 evas_object_show(ck);
2284
2285 ic = elm_gengrid_item_class_new();
2286 ic->item_style = "default";
2287 ic->func.text_get = grid_text_get;
2288 ic->func.content_get = grid_content_get;
2289 ic->func.state_get = NULL;
2290 ic->func.del = grid_del;
2291
2292 n = 0;
2293 for (i = 0; i < 23; i++)
2294 {
2295 id = calloc(1, sizeof(Item_Data));
2296 snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
2297 n = (n + 1) % 9;
2298 id->mode = i;
2299 id->path = eina_stringshare_add(buf);
2300 id->item = elm_gengrid_item_append(grid, ic, id, NULL, NULL);
2301 if (i == 4 || i == 8 || i == 11 || i == 22)
2302 elm_object_item_disabled_set(id->item, EINA_TRUE);
2303 }
2304
2305 elm_gengrid_item_class_free(ic);
2306
2307 evas_object_resize(win, 600, 600);
2308 evas_object_show(win);
2309}
diff --git a/src/lib/elementary/elm_gengrid.c b/src/lib/elementary/elm_gengrid.c
index 1bbe540..3abe857 100644
--- a/src/lib/elementary/elm_gengrid.c
+++ b/src/lib/elementary/elm_gengrid.c
@@ -2075,27 +2075,32 @@ _item_focus_up(Elm_Gengrid_Data *sd)
2075 if (!sd->focused_item) 2075 if (!sd->focused_item)
2076 { 2076 {
2077 prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last); 2077 prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
2078 while ((prev) && (prev->generation < sd->generation)) 2078 while (((prev) && (prev->generation < sd->generation))
2079 || elm_object_item_disabled_get(EO_OBJ(prev)))
2079 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev); 2080 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
2080 elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE);
2081 return EINA_TRUE;
2082 } 2081 }
2083 else 2082 else
2084 { 2083 {
2085 Elm_Object_Item *eo_prev = elm_gengrid_item_prev_get(sd->focused_item); 2084 Elm_Object_Item *eo_prev = elm_gengrid_item_prev_get(sd->focused_item);
2086 if (!eo_prev) return EINA_FALSE; 2085 if (!eo_prev) return EINA_FALSE;
2087 prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
2088 if (eo_prev == sd->focused_item) return EINA_FALSE; 2086 if (eo_prev == sd->focused_item) return EINA_FALSE;
2089 }
2090 2087
2091 for (i = 1; i < sd->nmax; i++) 2088 eo_prev = sd->focused_item;
2092 { 2089 while (eo_prev)
2093 Elm_Object_Item *eo_tmp = 2090 {
2094 elm_gengrid_item_prev_get(EO_OBJ(prev)); 2091 for (i = 0; i < sd->nmax; i++)
2095 if (!eo_tmp) return EINA_FALSE; 2092 {
2096 prev = eo_data_scope_get(eo_tmp, ELM_GENGRID_ITEM_CLASS); 2093 eo_prev = elm_gengrid_item_prev_get(eo_prev);
2094 if (!eo_prev) return EINA_FALSE;
2095 }
2096 if (!elm_object_item_disabled_get(eo_prev)) break;
2097 }
2098
2099 prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
2097 } 2100 }
2098 2101
2102 if (!prev) return EINA_FALSE;
2103
2099 elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE); 2104 elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE);
2100 2105
2101 return EINA_TRUE; 2106 return EINA_TRUE;
@@ -2106,12 +2111,13 @@ _item_focus_down(Elm_Gengrid_Data *sd)
2106{ 2111{
2107 unsigned int i, idx; 2112 unsigned int i, idx;
2108 Elm_Gen_Item *next = NULL; 2113 Elm_Gen_Item *next = NULL;
2109 Elm_Object_Item *eo_tmp = NULL; 2114 Elm_Object_Item *eo_next = NULL;
2110 2115
2111 if (!sd->focused_item) 2116 if (!sd->focused_item)
2112 { 2117 {
2113 next = ELM_GEN_ITEM_FROM_INLIST(sd->items); 2118 next = ELM_GEN_ITEM_FROM_INLIST(sd->items);
2114 while ((next) && (next->generation < sd->generation)) 2119 while (((next) && (next->generation < sd->generation))
2120 || elm_object_item_disabled_get(EO_OBJ(next)))
2115 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next); 2121 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
2116 } 2122 }
2117 else 2123 else
@@ -2125,21 +2131,28 @@ _item_focus_down(Elm_Gengrid_Data *sd)
2125 return EINA_FALSE; 2131 return EINA_FALSE;
2126 if (idx > sd->item_count - sd->nmax) 2132 if (idx > sd->item_count - sd->nmax)
2127 { 2133 {
2128 eo_tmp = elm_gengrid_last_item_get(sd->obj); 2134 eo_next = elm_gengrid_last_item_get(sd->obj);
2129 next = eo_data_scope_get(eo_tmp, ELM_GENGRID_ITEM_CLASS); 2135 if (elm_object_item_disabled_get(eo_next)) return EINA_FALSE;
2130 } 2136 }
2131 else 2137 else
2132 { 2138 {
2133 next = eo_data_scope_get(sd->focused_item, ELM_GENGRID_ITEM_CLASS); 2139 eo_next = sd->focused_item;
2134 for (i = 0; i < sd->nmax; i++) 2140 while (eo_next)
2135 { 2141 {
2136 eo_tmp = elm_gengrid_item_next_get(EO_OBJ(next)); 2142 for (i = 0; i < sd->nmax; i++)
2137 if (!eo_tmp) return EINA_FALSE; 2143 {
2138 next = eo_data_scope_get(eo_tmp, ELM_GENGRID_ITEM_CLASS); 2144 eo_next = elm_gengrid_item_next_get(eo_next);
2145 if (!eo_next) return EINA_FALSE;
2146 }
2147 if (!elm_object_item_disabled_get(eo_next)) break;
2139 } 2148 }
2140 } 2149 }
2150
2151 next = eo_data_scope_get(eo_next, ELM_GENGRID_ITEM_CLASS);
2141 } 2152 }
2142 2153
2154 if (!next) return EINA_FALSE;
2155
2143 elm_object_item_focus_set(EO_OBJ(next), EINA_TRUE); 2156 elm_object_item_focus_set(EO_OBJ(next), EINA_TRUE);
2144 2157
2145 return EINA_TRUE; 2158 return EINA_TRUE;
@@ -2153,17 +2166,27 @@ _item_focus_left(Elm_Gengrid_Data *sd)
2153 if (!sd->focused_item) 2166 if (!sd->focused_item)
2154 { 2167 {
2155 prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last); 2168 prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
2156 while ((prev) && (prev->generation < sd->generation)) 2169 while (((prev) && (prev->generation < sd->generation))
2170 || elm_object_item_disabled_get(EO_OBJ(prev)))
2157 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev); 2171 prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
2158 } 2172 }
2159 else 2173 else
2160 { 2174 {
2161 Elm_Object_Item *eo_prev = elm_gengrid_item_prev_get(sd->focused_item); 2175 Elm_Object_Item *eo_prev = elm_gengrid_item_prev_get(sd->focused_item);
2162 if (!eo_prev) return EINA_FALSE; 2176 if (!eo_prev) return EINA_FALSE;
2163 prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
2164 if (eo_prev == sd->focused_item) return EINA_FALSE; 2177 if (eo_prev == sd->focused_item) return EINA_FALSE;
2178
2179 while (eo_prev)
2180 {
2181 if (!elm_object_item_disabled_get(eo_prev)) break;
2182 eo_prev = elm_gengrid_item_prev_get(eo_prev);
2183 }
2184
2185 prev = eo_data_scope_get(eo_prev, ELM_GENGRID_ITEM_CLASS);
2165 } 2186 }
2166 2187
2188 if (!prev) return EINA_FALSE;
2189
2167 elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE); 2190 elm_object_item_focus_set(EO_OBJ(prev), EINA_TRUE);
2168 2191
2169 return EINA_TRUE; 2192 return EINA_TRUE;
@@ -2177,17 +2200,27 @@ _item_focus_right(Elm_Gengrid_Data *sd)
2177 if (!sd->focused_item) 2200 if (!sd->focused_item)
2178 { 2201 {
2179 next = ELM_GEN_ITEM_FROM_INLIST(sd->items); 2202 next = ELM_GEN_ITEM_FROM_INLIST(sd->items);
2180 while ((next) && (next->generation < sd->generation)) 2203 while (((next) && (next->generation < sd->generation))
2204 || elm_object_item_disabled_get(EO_OBJ(next)))
2181 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next); 2205 next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
2182 } 2206 }
2183 else 2207 else
2184 { 2208 {
2185 Elm_Object_Item *eo_next = elm_gengrid_item_next_get(sd->focused_item); 2209 Elm_Object_Item *eo_next = elm_gengrid_item_next_get(sd->focused_item);
2186 if (!eo_next) return EINA_FALSE; 2210 if (!eo_next) return EINA_FALSE;
2187 next = eo_data_scope_get(eo_next, ELM_GENGRID_ITEM_CLASS);
2188 if (eo_next == sd->focused_item) return EINA_FALSE; 2211 if (eo_next == sd->focused_item) return EINA_FALSE;
2212
2213 while (eo_next)
2214 {
2215 if (!elm_object_item_disabled_get(eo_next)) break;
2216 eo_next = elm_gengrid_item_next_get(eo_next);
2217 }
2218
2219 next = eo_data_scope_get(eo_next, ELM_GENGRID_ITEM_CLASS);
2189 } 2220 }
2190 2221
2222 if (!next) return EINA_FALSE;
2223
2191 elm_object_item_focus_set(EO_OBJ(next), EINA_TRUE); 2224 elm_object_item_focus_set(EO_OBJ(next), EINA_TRUE);
2192 2225
2193 return EINA_TRUE; 2226 return EINA_TRUE;