Added ability to get thumbnail by custom size 98/75998/1
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 22 Jun 2016 08:44:14 +0000 (11:44 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 22 Jun 2016 09:56:48 +0000 (02:56 -0700)
Change-Id: I16d9f41ebb940ed3cd593a81b77968805dc7b763
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/Utils/inc/ThumbnailMaker.h
src/Common/Utils/src/ThumbnailMaker.cpp
src/Conversation/ContactList/Controller/src/ContactListItem.cpp
src/Conversation/ConvList/Controller/src/ConvListItem.cpp
src/MsgThread/Controller/src/BaseThreadListItem.cpp

index ed8692e..76169af 100644 (file)
@@ -50,7 +50,7 @@ namespace Msg
             ThumbId getThumbId(const MsgAddress &address);
             ThumbId getThumbId(const std::string &address);
             ThumbId getThumbId(DefaultThumbs thumb);
-            Evas_Object *getThumbById(Evas_Object *parent, ThumbId id);
+            Evas_Object *getThumbById(Evas_Object *parent, ThumbId id, int thumbSize);
 
         private:
             typedef std::unordered_map<std::string, ThumbId> ContactsMap;
index 3c1bfda..a42e2f2 100644 (file)
 
 using namespace Msg;
 
-const int defaultThumbSize = 80;
 const int defaultCache = 512;
+#define DEFAULT_THUMB_SIZE ELM_SCALE_SIZE(80)
 #define COLOR_BLUE 61, 185, 204, 255
 #define RAND (rand() % 220)
 #define COLOR_RAND RAND, RAND, RAND, 255
 #define MSG_THUMB_STYLE_LIST    "list_ic_user_thumb_masking"
 
+
 ThumbnailMaker::ThumbnailMaker(App &app)
     : m_App(app)
     , m_ContactsMap()
@@ -108,7 +109,7 @@ ThumbnailMaker::ThumbId ThumbnailMaker::getThumbId(DefaultThumbs thumb)
     }
 }
 
-Evas_Object *ThumbnailMaker::getThumbById(Evas_Object *parent, ThumbId id)
+Evas_Object *ThumbnailMaker::getThumbById(Evas_Object *parent, ThumbId id, int thumbSize)
 {
     auto it = m_OriginsMap.find(id);
     if(it == m_OriginsMap.end())
@@ -120,8 +121,9 @@ Evas_Object *ThumbnailMaker::getThumbById(Evas_Object *parent, ThumbId id)
     Evas_Object *origin = it->second;
     Evas_Object *ic = evas_object_image_filled_add(evas_object_evas_get(parent));
     evas_object_image_source_set(ic, origin);
-    evas_object_size_hint_min_set(ic, ELM_SCALE_SIZE(defaultThumbSize), ELM_SCALE_SIZE(defaultThumbSize));
-    evas_object_size_hint_max_set(ic, ELM_SCALE_SIZE(defaultThumbSize), ELM_SCALE_SIZE(defaultThumbSize));
+    int scaledThumbSize = ELM_SCALE_SIZE(thumbSize);
+    evas_object_size_hint_min_set(ic, scaledThumbSize, scaledThumbSize);
+    evas_object_size_hint_max_set(ic, scaledThumbSize, scaledThumbSize);
     View::expand(ic);
     evas_object_show(ic);
     return ic;
@@ -135,8 +137,8 @@ Evas_Object *ThumbnailMaker::makeOriginThumb(Evas_Object *parent, const std::str
 
     Evas_Object *img = makeFace(ic, path);
     elm_object_part_content_set(ic, "content", img);
-    evas_object_resize(ic, ELM_SCALE_SIZE(defaultThumbSize), ELM_SCALE_SIZE(defaultThumbSize));
-    evas_object_move(ic, -ELM_SCALE_SIZE(defaultThumbSize), -ELM_SCALE_SIZE(defaultThumbSize));
+    evas_object_resize(ic, DEFAULT_THUMB_SIZE, DEFAULT_THUMB_SIZE);
+    evas_object_move(ic, -DEFAULT_THUMB_SIZE, -DEFAULT_THUMB_SIZE);
     evas_object_show(ic);
     return ic;
 }
@@ -145,8 +147,8 @@ Evas_Object *ThumbnailMaker::makeDefaultOriginThumb(Evas_Object *parent, const s
 {
     Evas_Object *img = makeFace(parent, path);
     evas_object_color_set(img, COLOR_BLUE);
-    evas_object_resize(img, ELM_SCALE_SIZE(defaultThumbSize), ELM_SCALE_SIZE(defaultThumbSize));
-    evas_object_move(img, -ELM_SCALE_SIZE(defaultThumbSize), -ELM_SCALE_SIZE(defaultThumbSize));
+    evas_object_resize(img, DEFAULT_THUMB_SIZE, DEFAULT_THUMB_SIZE);
+    evas_object_move(img, -DEFAULT_THUMB_SIZE, -DEFAULT_THUMB_SIZE);
     evas_object_show(img);
     return img;
 }
@@ -155,8 +157,8 @@ Evas_Object *ThumbnailMaker::makeFace(Evas_Object *parent, const std::string &pa
 {
     Evas_Object *img = elm_image_add(parent);
     elm_image_file_set(img, path.c_str(), nullptr);
-    evas_object_size_hint_min_set(img, ELM_SCALE_SIZE(defaultThumbSize), ELM_SCALE_SIZE(defaultThumbSize));
-    evas_object_size_hint_max_set(img, ELM_SCALE_SIZE(defaultThumbSize), ELM_SCALE_SIZE(defaultThumbSize));
+    evas_object_size_hint_min_set(img, DEFAULT_THUMB_SIZE, DEFAULT_THUMB_SIZE);
+    evas_object_size_hint_max_set(img, DEFAULT_THUMB_SIZE, DEFAULT_THUMB_SIZE);
     elm_image_aspect_fixed_set(img, EINA_TRUE);
     elm_image_fill_outside_set(img, EINA_TRUE);
     return img;
index b7401f9..567cbfb 100644 (file)
@@ -72,5 +72,6 @@ std::string ContactListItem::getMainText() const
 
 Evas_Object *ContactListItem::getThumbnail() const
 {
-    return m_App.getThumbnailMaker().getThumbById(*getOwner(), m_ThumbId);
+    static const int thumbSize = 80;
+    return m_App.getThumbnailMaker().getThumbById(*getOwner(), m_ThumbId, thumbSize);
 }
index de38e32..6f3245a 100644 (file)
@@ -227,7 +227,8 @@ Evas_Object *ConvListItem::getBubbleContent()
 
 Evas_Object *ConvListItem::getThumbnail()
 {
-    return m_App.getThumbnailMaker().getThumbById(*getOwner(), m_ThumbId);
+    static const int thumbSize = 80;
+    return m_App.getThumbnailMaker().getThumbById(*getOwner(), m_ThumbId, thumbSize);
 }
 
 Evas_Object *ConvListItem::getProgress()
index ea3a624..1de36f9 100644 (file)
@@ -129,7 +129,8 @@ std::string BaseThreadListItem::getTime()
 
 Evas_Object *BaseThreadListItem::getThumbnail()
 {
-    return m_App.getThumbnailMaker().getThumbById(*getOwner(), m_ThumbId);
+    static const int thumbSize = 98;
+    return m_App.getThumbnailMaker().getThumbById(*getOwner(), m_ThumbId, thumbSize);
 }
 
 time_t BaseThreadListItem::getRawTime() const