elementary: fix elm_image_orient_get/set and add a test case.
authorCedric BAIL <cedric.bail@free.fr>
Thu, 2 Aug 2012 08:15:05 +0000 (08:15 +0000)
committerCedric BAIL <cedric.bail@free.fr>
Thu, 2 Aug 2012 08:15:05 +0000 (08:15 +0000)
SVN revision: 74793

ChangeLog
NEWS
src/bin/Makefile.am
src/bin/test.c
src/bin/test_image.c [new file with mode: 0644]
src/lib/elm_image.c

index 4b98ae9..5ccfc4a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
        * Patch in incomplete access supoprt in ctxpopup and dayselector.
 
+2012-08-02  Cedric Bail
+
+       * Fix elm_image_orient_set/get.
diff --git a/NEWS b/NEWS
index b6323df..13f8019 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,11 +22,12 @@ Additions:
 
 Fixes:
 
-   * Genlist : Fixed genlist expandable effect bug when we expand/contract items with many children very quickly.
-   * Genlist : Realize move items during tree effect only when the item is not in the queue.
+   * Genlist : fixed genlist expandable effect bug when we expand/contract items with many children very quickly.
+   * Genlist : realize move items during tree effect only when the item is not in the queue.
    * Add missing files in the tarball.
    * Fileselector : honor the folder_only option when using EIO
    * Segment Selector : do not abuse user object item data.
+   * Image: fixed elm_image_orient_set/get.
 
 Improvements:
 
index 93fd441..929f5a9 100644 (file)
@@ -75,6 +75,7 @@ test_hoversel.c \
 test_icon.c \
 test_icon_desktops.c \
 test_icon_animated.c \
+test_image.c \
 test_index.c \
 test_inwin.c \
 test_label.c \
index 74abe4f..640b923 100644 (file)
@@ -183,6 +183,7 @@ void test_naviframe_complex(void *data, Evas_Object *obj, void *event_info);
 void test_datetime(void *data, Evas_Object *obj, void *event_info);
 void test_popup(void *data, Evas_Object *obj, void *event_info);
 void test_dayselector(void *data, Evas_Object *obj, void *event_info);
+void test_image(void *data, Evas_Object *obj, void *event_info);
 #ifdef HAVE_EMOTION
 void test_video(void *data, Evas_Object *obj, void *event_info);
 #endif
@@ -466,6 +467,7 @@ add_tests:
    ADD_TEST(NULL, "Images", "Photocam", test_photocam);
    ADD_TEST(NULL, "Images", "Photo", test_photo);
    ADD_TEST(NULL, "Images", "Thumb", test_thumb);
+   ADD_TEST(NULL, "Images", "Image", test_image);
    ADD_TEST(NULL, "Images", "Slideshow", test_slideshow);
 #ifdef HAVE_EMOTION
    ADD_TEST(NULL, "Images", "Video", test_video);
diff --git a/src/bin/test_image.c b/src/bin/test_image.c
new file mode 100644 (file)
index 0000000..1099b8e
--- /dev/null
@@ -0,0 +1,86 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+#include <Elementary.h>
+#ifndef ELM_LIB_QUICKLAUNCH
+
+static const struct {
+   Elm_Image_Orient orient;
+   const char *name;
+} images_orient[] = {
+  { ELM_IMAGE_ORIENT_NONE, "None" },
+  { ELM_IMAGE_ROTATE_90, "Rotate 90" },
+  { ELM_IMAGE_ROTATE_180, "Rotate 180" },
+  { ELM_IMAGE_ROTATE_270, "Rotate 270" },
+  { ELM_IMAGE_FLIP_HORIZONTAL, "Horizontal Flip" },
+  { ELM_IMAGE_FLIP_VERTICAL, "Vertical Flip" },
+  { ELM_IMAGE_FLIP_TRANSPOSE, "Transpose" },
+  { ELM_IMAGE_FLIP_TRANSVERSE, "Transverse" },
+  { 0, NULL }
+};
+
+static void
+my_im_ch(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
+{
+   Evas_Object *win = data;
+   Evas_Object *im = evas_object_data_get(win, "im");
+   Evas_Object *rdg = evas_object_data_get(win, "rdg");
+   Elm_Image_Orient v = elm_radio_value_get(rdg);
+
+   elm_image_orient_set(im, v);
+   fprintf(stderr, "Set %i and got %i\n",
+           v, elm_image_orient_get(im));
+}
+
+void
+test_image(void *data, Evas_Object *obj, void *event_info)
+{
+   Evas_Object *win, *box, *im, *rd, *rdg = NULL;
+   int i;
+
+   win = elm_win_util_standard_add("image test", "Image Test");
+   elm_win_autodel_set(win, EINA_TRUE);
+
+   box = elm_box_add(win);
+   elm_win_resize_object_add(win, box);
+   evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_show(box);
+
+   im = elm_image_add(win);
+   char buf[PATH_MAX];
+   snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
+   elm_image_file_set(im, buf, NULL);
+   elm_image_resizable_set(im, EINA_TRUE, EINA_TRUE);
+   evas_object_size_hint_weight_set(im, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(im, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+   elm_box_pack_end(box, im);
+   evas_object_show(im);
+
+   evas_object_data_set(win, "im", im);
+
+   for (i = 0; images_orient[i].name; ++i)
+     {
+        rd = elm_radio_add(win);
+        evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, EVAS_HINT_FILL);
+        evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
+        elm_radio_state_value_set(rd, images_orient[i].orient);
+        elm_object_text_set(rd, images_orient[i].name);
+        elm_box_pack_end(box, rd);
+        evas_object_show(rd);
+        evas_object_smart_callback_add(rd, "changed", my_im_ch, win);
+        if (!rdg)
+          {
+             rdg = rd;
+             evas_object_data_set(win, "rdg", rdg);
+          }
+        else
+          {
+             elm_radio_group_add(rd, rdg);
+          }
+     }
+
+   evas_object_resize(win, 320, 480);
+   evas_object_show(win);
+}
+#endif
index c9aae5c..4631ad1 100644 (file)
@@ -473,14 +473,21 @@ _elm_image_smart_orient_set(Evas_Object *obj,
      {
       case ELM_IMAGE_FLIP_HORIZONTAL:
         _elm_image_flip_horizontal(sd);
+       sd->orient = orient;
         return;
 
       case ELM_IMAGE_FLIP_VERTICAL:
         _elm_image_flip_vertical(sd);
+       sd->orient = orient;
         return;
 
       case ELM_IMAGE_ROTATE_180:
         _elm_image_smart_rotate_180(sd);
+       sd->orient = orient;
+        return;
+
+     case ELM_IMAGE_ORIENT_NONE:
+        sd->orient = orient;
         return;
 
       default:
@@ -491,8 +498,11 @@ _elm_image_smart_orient_set(Evas_Object *obj,
 
    /* we need separate destination memory if we want to rotate 90 or
     * 270 degree */
-   evas_object_image_data_copy_set(sd->img, data2);
+   data = evas_object_image_data_get(sd->img, EINA_FALSE);
+   if (!data) return;
+   data2 = malloc(sizeof(unsigned char) * (iw * ih * 4));
    if (!data2) return;
+   memcpy(data2, data, sizeof (unsigned char) * (iw * ih * 4));
 
    w = ih;
    ih = iw;
@@ -507,23 +517,27 @@ _elm_image_smart_orient_set(Evas_Object *obj,
       case ELM_IMAGE_FLIP_TRANSPOSE:
         to = data;
         hw = -hw + 1;
+       sd->orient = orient;
         break;
 
       case ELM_IMAGE_FLIP_TRANSVERSE:
         to = data + hw - 1;
         w = -w;
         hw = hw - 1;
+       sd->orient = orient;
         break;
 
       case ELM_IMAGE_ROTATE_90:
         to = data + w - 1;
         hw = -hw - 1;
+       sd->orient = orient;
         break;
 
       case ELM_IMAGE_ROTATE_270:
         to = data + hw - w;
         w = -w;
         hw = hw + 1;
+       sd->orient = orient;
         break;
 
       default:
@@ -545,7 +559,6 @@ _elm_image_smart_orient_set(Evas_Object *obj,
           }
         to += hw;
      }
-   sd->orient = orient;
    if (data2) free(data2);
 
    evas_object_image_data_set(sd->img, data);