Efl interface: Add image interface and start using it.
authorTom Hacohen <tom@stosb.com>
Wed, 23 Jul 2014 16:03:40 +0000 (17:03 +0100)
committerTom Hacohen <tom@stosb.com>
Thu, 21 Aug 2014 10:02:11 +0000 (11:02 +0100)
src/Makefile_Efl.am
src/Makefile_Efl_Cxx.am
src/lib/edje/edje_calc.c
src/lib/efl/Efl.h
src/lib/efl/interfaces/efl_image.eo [new file with mode: 0644]
src/lib/efl/interfaces/efl_interfaces_main.c
src/lib/evas/Evas_Legacy.h
src/lib/evas/canvas/evas_image.eo
src/lib/evas/canvas/evas_object_image.c

index 1d0db37ce6e14995c7ef77adda06ba11813e8516..0a4161892fd4c2afab2ff36e39807b6e780b0603 100644 (file)
@@ -1,12 +1,15 @@
 BUILT_SOURCES += \
                  lib/efl/interfaces/efl_file.eo.c \
                  lib/efl/interfaces/efl_file.eo.h \
+                 lib/efl/interfaces/efl_image.eo.c \
+                 lib/efl/interfaces/efl_image.eo.h \
                  lib/efl/interfaces/efl_text_properties.eo.c \
                  lib/efl/interfaces/efl_text_properties.eo.h
 
 efleolianfilesdir = $(datadir)/eolian/include/efl-@VMAJ@
 efleolianfiles_DATA = \
               lib/efl/interfaces/efl_file.eo \
+              lib/efl/interfaces/efl_image.eo \
               lib/efl/interfaces/efl_text_properties.eo
 
 EXTRA_DIST += \
@@ -30,4 +33,5 @@ dist_installed_eflheaders_DATA = \
 installed_eflinterfacesdir = $(includedir)/efl-@VMAJ@/interfaces
 nodist_installed_eflinterfaces_DATA = \
               lib/efl/interfaces/efl_file.eo.h \
+              lib/efl/interfaces/efl_image.eo.h \
               lib/efl/interfaces/efl_text_properties.eo.h
index fb79e62ab895f296c2d46f029bb0345e6047d432..c9b0e231aeb620928785b7b97c29af19ccc70bc3 100644 (file)
@@ -4,6 +4,7 @@ if HAVE_CXX11
 
 generated_efl_cxx_bindings = \
                  lib/efl/interfaces/efl_file.eo.hh \
+                 lib/efl/interfaces/efl_image.eo.hh \
                  lib/efl/interfaces/efl_text_properties.eo.hh
 
 lib/efl/Efl.hh: $(generated_efl_cxx_bindings)
index 57be8640b615ab935807bf7c0f140961964b08e4..3923946db3c7c665f0c89e16d4f4724c8712377a 100644 (file)
@@ -2641,7 +2641,7 @@ _edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj
                                  p3->type.common.fill.y,
                                  p3->type.common.fill.w,
                                  p3->type.common.fill.h),
-         evas_obj_image_smooth_scale_set(p3->smooth),
+         efl_image_smooth_scale_set(p3->smooth),
          evas_obj_image_source_visible_set(chosen_desc->proxy.source_visible),
          evas_obj_image_source_clip_set(chosen_desc->proxy.source_clip));
 }
@@ -2656,7 +2656,7 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj
    eo_do(ep->object,
         evas_obj_image_fill_set(p3->type.common.fill.x, p3->type.common.fill.y,
                                 p3->type.common.fill.w, p3->type.common.fill.h),
-        evas_obj_image_smooth_scale_set(p3->smooth));
+        efl_image_smooth_scale_set(p3->smooth));
    if (chosen_desc->image.border.scale)
      {
         if (p3->type.common.spec.image.border_scale_by > FROM_DOUBLE(0.0))
index 7bccaac7219cb48a4feb21ea30bc28e1f7538261..8821b93706682a40b39b5b3f168388065ede25b7 100644 (file)
@@ -5,6 +5,7 @@
 
 /* Interfaces */
 #include "interfaces/efl_file.eo.h"
+#include "interfaces/efl_image.eo.h"
 #include "interfaces/efl_text_properties.eo.h"
 
 #endif
diff --git a/src/lib/efl/interfaces/efl_image.eo b/src/lib/efl/interfaces/efl_image.eo
new file mode 100644 (file)
index 0000000..a77251e
--- /dev/null
@@ -0,0 +1,56 @@
+interface Efl.Image {
+   legacy_prefix: null;
+   properties {
+      animated {
+         get {
+            /*@
+              Check if an image  can be animated (have multiple frames)
+
+              @return whether the image support animation
+             */
+         }
+         values {
+              bool is_animated; /*@ If it's animated or not. */
+         }
+      }
+      load_size {
+         set {
+            /*@
+              Set the loading size of an image. The image will be loaded into memory as if it was
+              the set size instead of the original size. This can save a lot of memory, and is
+              important for scalable types like svg.
+            */
+         }
+         get {
+         }
+         values {
+            int w; /*@ The new width of the image's load size. */
+            int h; /*@ The new height of the image's load size. */
+         }
+      }
+      smooth_scale {
+         set {
+            /*@
+            Sets whether to use high-quality image scaling algorithm on the
+            given image.
+
+            When enabled, a higher quality image scaling algorithm is used when
+            scaling images to sizes other than the source image's original
+            one. This gives better results but is more computationally
+            expensive.
+            */
+         }
+         get {
+            /*@
+            Retrieves whether the given image is using high-quality
+            image scaling algorithm.
+
+            @return Whether smooth scale is being used.
+            */
+         }
+         values {
+            bool smooth_scale; /*@ Whether to use smooth scale or not. */
+         }
+      }
+   }
+}
index d96e04d4a2c9da50101dd3edf93e8a2ac151f478..0c97154f6323f849f11b801c08e0598e6b6d4143 100644 (file)
@@ -5,4 +5,5 @@
 #include <Efl.h>
 
 #include "interfaces/efl_file.eo.c"
+#include "interfaces/efl_image.eo.c"
 #include "interfaces/efl_text_properties.eo.c"
index 88f9984b5d0f83d9757ba9dc95c3fd522775e48c..11fc985ba76023d3dc753c9ba2f1eaf159a35c41 100644 (file)
@@ -1328,6 +1328,121 @@ none).
  */
 EAPI Eina_Bool evas_object_image_save(const Eo *obj, const char *file, const char *key, const char *flags) EINA_ARG_NONNULL(2);
 
+/**
+ *
+ * Check if an image object can be animated (have multiple frames)
+ *
+ * @return whether obj support animation
+ *
+ * This returns if the image file of an image object is capable of animation
+ * such as an animated gif file might. This is only useful to be called once
+ * the image object file has been set.
+ *
+ * Example:
+ * @code
+ * extern Evas_Object *obj;
+ *
+ * if (evas_object_image_animated_get(obj))
+ * {
+ * int frame_count;
+ * int loop_count;
+ * Evas_Image_Animated_Loop_Hint loop_type;
+ * double duration;
+ *
+ * frame_count = evas_object_image_animated_frame_count_get(obj);
+ * printf("This image has %d frames\n",frame_count);
+ *
+ * duration = evas_object_image_animated_frame_duration_get(obj,1,0);
+ * printf("Frame 1's duration is %f. You had better set object's frame to 2 after this duration using timer\n");
+ *
+ * loop_count = evas_object_image_animated_loop_count_get(obj);
+ * printf("loop count is %d. You had better run loop %d times\n",loop_count,loop_count);
+ *
+ * loop_type = evas_object_image_animated_loop_type_get(obj);
+ * if (loop_type == EVAS_IMAGE_ANIMATED_HINT_LOOP)
+ * printf("You had better set frame like 1->2->3->1->2->3...\n");
+ * else if (loop_type == EVAS_IMAGE_ANIMATED_HINT_PINGPONG)
+ * printf("You had better set frame like 1->2->3->2->1->2...\n");
+ * else
+ * printf("Unknown loop type\n");
+ *
+ * evas_object_image_animated_frame_set(obj,1);
+ * printf("You set image object's frame to 1. You can see frame 1\n");
+ * }
+ * @endcode
+ *
+ * @see evas_object_image_animated_get()
+ * @see evas_object_image_animated_frame_count_get()
+ * @see evas_object_image_animated_loop_type_get()
+ * @see evas_object_image_animated_loop_count_get()
+ * @see evas_object_image_animated_frame_duration_get()
+ * @see evas_object_image_animated_frame_set()
+ * @since 1.1
+ *
+ */
+EAPI Eina_Bool evas_object_image_animated_get(const Eo *obj);
+
+/**
+ *
+ * Set the size of a given image object's source image, when loading
+ * it.
+ *
+ * This function sets a new (loading) size for the given canvas
+ * image.
+ *
+ * @see evas_object_image_load_size_get()
+ *
+ * @param[in] w The new width of the image's load size.
+ * @param[in] h The new height of the image's load size.
+ */
+EAPI void evas_object_image_load_size_set(Eo *obj, int w, int h);
+
+/**
+ *
+ * Get the size of a given image object's source image, when loading
+ * it.
+ *
+ * @note Use @c NULL pointers on the size components you're not
+ * interested in: they'll be ignored by the function.
+ *
+ * @see evas_object_image_load_size_set() for more details
+ *
+ * @param[out] w The new width of the image's load size.
+ * @param[out] h The new height of the image's load size.
+ */
+EAPI void evas_object_image_load_size_get(const Eo *obj, int *w, int *h);
+
+/**
+ *
+ * Sets whether to use high-quality image scaling algorithm on the
+ * given image object.
+ *
+ * When enabled, a higher quality image scaling algorithm is used when
+ * scaling images to sizes other than the source image's original
+ * one. This gives better results but is more computationally
+ * expensive.
+ *
+ * @note Image objects get created originally with smooth scaling @b
+ * on.
+ *
+ * @see evas_object_image_smooth_scale_get()
+ *
+ * @param[in] smooth_scale Whether to use smooth scale or not.
+ */
+EAPI void evas_object_image_smooth_scale_set(Eo *obj, Eina_Bool smooth_scale);
+
+/**
+ *
+ * Retrieves whether the given image object is using high-quality
+ * image scaling algorithm.
+ *
+ * @return Whether smooth scale is being used.
+ *
+ * See @ref evas_object_image_smooth_scale_set() for more details.
+ *
+ */
+EAPI Eina_Bool evas_object_image_smooth_scale_get(const Eo *obj);
+
 #include "canvas/evas_image.eo.legacy.h"
 
 /**
index f2cc61e44b3d628eb3c6f5fdfcf38fbd418a1ead..36a6caf6908619b4df069d7e341baadd80b6d255 100644 (file)
@@ -1,4 +1,4 @@
-class Evas.Image (Evas.Object, Efl.File)
+class Evas.Image (Evas.Object, Efl.File, Efl.Image)
 {
    legacy_prefix: evas_object_image;
    eo_prefix: evas_obj_image;
@@ -214,32 +214,6 @@ class Evas.Image (Evas.Object, Efl.File)
             or not (@c EINA_FALSE). */
          }
       }
-      load_size {
-         set {
-            /*@
-            Set the size of a given image object's source image, when loading
-            it.
-
-            This function sets a new (loading) size for the given canvas
-            image.
-
-            @see evas_object_image_load_size_get() */
-         }
-         get {
-            /*@
-            Get the size of a given image object's source image, when loading
-            it.
-
-            @note Use @c NULL pointers on the size components you're not
-            interested in: they'll be ignored by the function.
-
-            @see evas_object_image_load_size_set() for more details */
-         }
-         values {
-            int w; /*@ The new width of the image's load size. */
-            int h; /*@ The new height of the image's load size. */
-         }
-      }
       border {
          set {
             /*@
@@ -295,35 +269,6 @@ class Evas.Image (Evas.Object, Efl.File)
             int b; /*@ The border's bottom width. */
          }
       }
-      smooth_scale {
-         set {
-            /*@
-            Sets whether to use high-quality image scaling algorithm on the
-            given image object.
-
-            When enabled, a higher quality image scaling algorithm is used when
-            scaling images to sizes other than the source image's original
-            one. This gives better results but is more computationally
-            expensive.
-
-            @note Image objects get created originally with smooth scaling @b
-            on.
-
-            @see evas_object_image_smooth_scale_get() */
-         }
-         get {
-            /*@
-            Retrieves whether the given image object is using high-quality
-            image scaling algorithm.
-
-            @return Whether smooth scale is being used.
-
-            See @ref evas_object_image_smooth_scale_set() for more details. */
-         }
-         values {
-            bool smooth_scale; /*@ Whether to use smooth scale or not. */
-         }
-      }
       border_scale {
          set {
             /*@
@@ -849,60 +794,6 @@ class Evas.Image (Evas.Object, Efl.File)
             return: int @warn_unused;
          }
       }
-      animated {
-         get {
-            /*@
-            Check if an image object can be animated (have multiple frames)
-
-            @return whether obj support animation
-
-            This returns if the image file of an image object is capable of animation
-            such as an animated gif file might. This is only useful to be called once
-            the image object file has been set.
-
-            Example:
-            @code
-            extern Evas_Object *obj;
-
-            if (evas_object_image_animated_get(obj))
-            {
-            int frame_count;
-            int loop_count;
-            Evas_Image_Animated_Loop_Hint loop_type;
-            double duration;
-
-            frame_count = evas_object_image_animated_frame_count_get(obj);
-            printf("This image has %d frames\n",frame_count);
-
-            duration = evas_object_image_animated_frame_duration_get(obj,1,0);
-            printf("Frame 1's duration is %f. You had better set object's frame to 2 after this duration using timer\n");
-
-            loop_count = evas_object_image_animated_loop_count_get(obj);
-            printf("loop count is %d. You had better run loop %d times\n",loop_count,loop_count);
-
-            loop_type = evas_object_image_animated_loop_type_get(obj);
-            if (loop_type == EVAS_IMAGE_ANIMATED_HINT_LOOP)
-            printf("You had better set frame like 1->2->3->1->2->3...\n");
-            else if (loop_type == EVAS_IMAGE_ANIMATED_HINT_PINGPONG)
-            printf("You had better set frame like 1->2->3->2->1->2...\n");
-            else
-            printf("Unknown loop type\n");
-
-            evas_object_image_animated_frame_set(obj,1);
-            printf("You set image object's frame to 1. You can see frame 1\n");
-            }
-            @endcode
-
-            @see evas_object_image_animated_get()
-            @see evas_object_image_animated_frame_count_get()
-            @see evas_object_image_animated_loop_type_get()
-            @see evas_object_image_animated_loop_count_get()
-            @see evas_object_image_animated_frame_duration_get()
-            @see evas_object_image_animated_frame_set()
-            @since 1.1 */
-            return: bool;
-         }
-      }
       animated_loop_type {
          get {
             /*@
@@ -1178,5 +1069,10 @@ class Evas.Image (Evas.Object, Efl.File)
       Efl.File.file.set;
       Efl.File.file.get;
       Efl.File.save;
+      Efl.Image.animated.get;
+      Efl.Image.load_size.set;
+      Efl.Image.load_size.get;
+      Efl.Image.smooth_scale.set;
+      Efl.Image.smooth_scale.get;
    }
 }
index f6e4fd0cc1f1deb18dc74cd8cfe00ee51190ee86..b6f3b17a566417e9f457de27f7366097722fd2e2 100644 (file)
@@ -1455,7 +1455,7 @@ _evas_image_alpha_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
 }
 
 EOLIAN static void
-_evas_image_smooth_scale_set(Eo *eo_obj, Evas_Image_Data *o, Eina_Bool smooth_scale)
+_evas_image_efl_image_smooth_scale_set(Eo *eo_obj, Evas_Image_Data *o, Eina_Bool smooth_scale)
 {
    Evas_Object_Protected_Data *obj;
 
@@ -1472,7 +1472,7 @@ _evas_image_smooth_scale_set(Eo *eo_obj, Evas_Image_Data *o, Eina_Bool smooth_sc
 }
 
 EOLIAN static Eina_Bool
-_evas_image_smooth_scale_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
+_evas_image_efl_image_smooth_scale_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
 {
    return o->cur->smooth_scale;
 }
@@ -1694,7 +1694,7 @@ _evas_image_load_dpi_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
 }
 
 EOLIAN static void
-_evas_image_load_size_set(Eo *eo_obj, Evas_Image_Data *o, int w, int h)
+_evas_image_efl_image_load_size_set(Eo *eo_obj, Evas_Image_Data *o, int w, int h)
 {
    if ((o->load_opts->w == w) && (o->load_opts->h == h)) return;
 
@@ -1718,7 +1718,7 @@ _evas_image_load_size_set(Eo *eo_obj, Evas_Image_Data *o, int w, int h)
 }
 
 EOLIAN static void
-_evas_image_load_size_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, int *w, int *h)
+_evas_image_efl_image_load_size_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, int *w, int *h)
 {
    if (w) *w = o->load_opts->w;
    if (h) *h = o->load_opts->h;
@@ -2055,7 +2055,7 @@ _evas_image_region_support_get(Eo *eo_obj, Evas_Image_Data *o)
 
 /* animated feature */
 EOLIAN static Eina_Bool
-_evas_image_animated_get(Eo *eo_obj, Evas_Image_Data *o)
+_evas_image_efl_image_animated_get(Eo *eo_obj, Evas_Image_Data *o)
 {
    Eina_Bool animated;
    Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
@@ -4979,4 +4979,34 @@ evas_object_image_save(const Eo *obj, const char *file, const char *key, const c
    return eo_do((Eo *) obj, efl_file_save(file, key, flags));
 }
 
+EAPI Eina_Bool
+evas_object_image_animated_get(const Eo *obj)
+{
+   return eo_do((Eo *) obj, efl_image_animated_get());
+}
+
+EAPI void
+evas_object_image_load_size_set(Eo *obj, int w, int h)
+{
+   eo_do((Eo *) obj, efl_image_load_size_set(w, h));
+}
+
+EAPI void
+evas_object_image_load_size_get(const Eo *obj, int *w, int *h)
+{
+   eo_do((Eo *) obj, efl_image_load_size_get(w, h));
+}
+
+EAPI void
+evas_object_image_smooth_scale_set(Eo *obj, Eina_Bool smooth_scale)
+{
+   eo_do((Eo *) obj, efl_image_smooth_scale_set(smooth_scale));
+}
+
+EAPI Eina_Bool
+evas_object_image_smooth_scale_get(const Eo *obj)
+{
+   return eo_do((Eo *) obj, efl_image_smooth_scale_get());
+}
+
 #include "canvas/evas_image.eo.c"