do not resize recent image when size is less then 100px 34/45634/1
authorSoohye Shin <soohye.shin@samsung.com>
Mon, 10 Aug 2015 05:00:21 +0000 (14:00 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Mon, 10 Aug 2015 05:00:21 +0000 (14:00 +0900)
Change-Id: I5f56b8785ddc950913789568c210f5ed027a21d4
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
src/view/view_recent.c

index 5319f3a7f4dca467b6fdec5e6e6599bd1055690f..01c55dce7ea28416cfb49a813f1338c41fbc32f2 100644 (file)
@@ -29,6 +29,7 @@
 
 #define MESSAGE_NO_CONTENTS "No Contents"
 #define PADDING_BOX 26
+#define IMAGE_MAX_SIZE 100
 
 enum input_handler_type {
        INPUT_HANDLER_TYPE_EO,
@@ -307,6 +308,36 @@ static void _set_item_bg(struct color_data bg, Evas_Object *eo,
        elm_object_part_content_set(eo, part, rect);
 }
 
+static Evas_Object *_set_thumb(Evas_Object *eo, const char *file,
+               const char *part)
+{
+       Evas_Object *image;
+       int w, h;
+
+       image = elm_image_add(eo);
+       if (!image) {
+               _ERR("failed to add image");
+               return NULL;
+       }
+
+       if (!elm_image_file_set(image, file, NULL)) {
+               if (!elm_image_file_set(image, IMAGE_RECENT_THUMB_APP, NULL)) {
+                       _ERR("failed to set image file");
+                       evas_object_del(image);
+                       return NULL;
+               }
+       }
+       elm_image_object_size_get(image, &w, &h);
+       if (w < IMAGE_MAX_SIZE && h < IMAGE_MAX_SIZE)
+               elm_image_resizable_set(image, EINA_FALSE, EINA_FALSE);
+       else
+               elm_image_fill_outside_set(image, EINA_TRUE);
+
+       elm_object_part_content_set(eo, part, image);
+
+       return image;
+}
+
 static struct _bar_item *_pack_item(struct _priv *priv, Evas_Object *box,
                struct datamgr_item *di)
 {
@@ -354,16 +385,12 @@ static struct _bar_item *_pack_item(struct _priv *priv, Evas_Object *box,
        }
 
        if (di->icon) {
-               thumb = utils_add_icon(eo, di->icon, PART_RECENT_THUMBNAIL);
+               thumb = _set_thumb(eo, di->icon, PART_RECENT_THUMBNAIL);
                if (!thumb) {
                        _ERR("failed to add thumb");
-                       thumb = utils_add_icon(eo, IMAGE_RECENT_THUMB_APP,
-                                       PART_RECENT_THUMBNAIL);
-                       if (!thumb) {
-                               evas_object_del(eo);
-                               free(bi);
-                               return NULL;
-                       }
+                       evas_object_del(eo);
+                       free(bi);
+                       return NULL;
                }
        }