listmgr: check max width of grid 61/44761/1
authorJehun Lim <jehun.lim@samsung.com>
Mon, 27 Jul 2015 11:42:37 +0000 (20:42 +0900)
committerJehun Lim <jehun.lim@samsung.com>
Mon, 27 Jul 2015 11:45:01 +0000 (20:45 +0900)
Change-Id: Ic8b52f12d40dab1869f2c2c80c1c338cd23d3e84
Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
src/util/listmgr.c
src/util/util.c

index eb8b820..5ae2f61 100644 (file)
@@ -26,6 +26,8 @@
 #include "util/listmgr.h"
 #include "util/util.h"
 
+#define MAX_GRID_WIDTH 1858
+
 #define SCROLLER_STEP_SIZE(x) ((x) + 10)
 
 enum _object_type {
@@ -263,15 +265,19 @@ static Evas_Object *_get_box_first_item(Evas_Object *box)
        return (Evas_Object *)eina_list_nth(list, 0);
 }
 
-static int _get_grid_size(int count, int num_item)
+static int _get_grid_width(int count, int num_item, int item_x)
 {
-       int size;
+       int num_col, width;
 
-       size = count / num_item;
+       num_col = count / num_item;
        if (count % num_item > 0)
-               size++;
+               num_col++;
+
+       width = num_col * item_x;
+       if (width > MAX_GRID_WIDTH)
+               width = MAX_GRID_WIDTH;
 
-       return size;
+       return width;
 }
 
 static bool _draw_play_info(struct listmgr *lmgr)
@@ -318,7 +324,7 @@ static Evas_Object *_draw_list_item(struct listmgr *lmgr, struct group_info *gi)
 {
        Evas_Object *ly, *btn, *grid;
        struct listmgr_data *data;
-       int size;
+       int width;
        char buf[128];
 
        data = lmgr->data;
@@ -361,9 +367,10 @@ static Evas_Object *_draw_list_item(struct listmgr *lmgr, struct group_info *gi)
                return NULL;
        }
 
-       size = _get_grid_size(eina_list_count(gi->list), data->grid_num_item);
+       width = _get_grid_width(eina_list_count(gi->list), data->grid_num_item,
+                               data->grid_item_x);
 
-       evas_object_size_hint_min_set(grid, size * data->grid_item_x,
+       evas_object_size_hint_min_set(grid, width,
                                data->grid_num_item * data->grid_item_y);
 
        elm_object_focus_next_object_set(grid, btn, ELM_FOCUS_UP);
index 28f6f0d..c325b4d 100644 (file)
@@ -69,6 +69,9 @@ Evas_Object *util_add_gengrid(Evas_Object *base,
                        elm_config_scale_get() * item_size_x,
                        elm_config_scale_get() * item_size_y);
 
+       elm_scroller_policy_set(grid, ELM_SCROLLER_POLICY_OFF,
+                       ELM_SCROLLER_POLICY_OFF);
+
        return grid;
 }