From: Jérôme Pinot <ngc891@gmail.com>
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 9 Apr 2012 07:37:02 +0000 (07:37 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 9 Apr 2012 07:37:02 +0000 (07:37 +0000)
Subject: [E-devel] [patch] edje multisense example

Here is a try to have a working edje multisense example to fill up the
doc blank. edje-multisense.c is basically edje_example.c adapted.
I modified the edc, removing dead code, to have only a sample and a tone
example. Can be extended later.

Does the job except that it only plays sound one time per launch. Hope
someone will know why and correct it...

Attached:
- the patch for existing .edc and build system
- the new edje-multisense.c file
- duck.wav a reworked public domain wav sample of a duck quack-quack

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@69962 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/examples/Makefile.am
src/examples/duck.wav [new file with mode: 0644]
src/examples/edje-multisense.c [new file with mode: 0644]
src/examples/multisense.edc

index e3893cd..5c90fde 100644 (file)
@@ -8,8 +8,10 @@ EDJE_CC_FLAGS = $(EDJE_CC_FLAGS_$(V)) -id $(srcdir) -fd $(srcdir)
 examplesdir = $(datadir)/$(PACKAGE)/examples
 
 if ENABLE_MULTISENSE
+MULTISENSE_BIN_FILE = edje-multisense
+MULTISENSE_C_FILE   = edje-multisense.c
 MULTISENSE_EDC_FILE = multisense.edc
-SND_DIR = -sd $(srcdir)
+SND_DIR             = -sd $(srcdir)
 endif
 
 #put here all EDCs one needs to the examples
@@ -41,6 +43,7 @@ files_DATA = \
        red.png \
        test.png \
        Vera.ttf \
+        duck.wav \
        edje-basic.c \
        edje-swallow.c \
        edje-text.c \
@@ -52,7 +55,8 @@ files_DATA = \
        edje-color-class.c \
        edje-perspective.c \
        edje-animations.c \
-       sigtest.c
+       sigtest.c \
+       $(MULTISENSE_C_FILE)
 
 EXTRA_DIST = $(files_DATA)
 
@@ -81,7 +85,8 @@ examples_PROGRAMS = \
        edje-swallow \
        edje-table \
        edje-text \
-       sigtest
+       sigtest \
+       $(MULTISENSE_BIN_FILE)
 
 LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_LIBS@
 
diff --git a/src/examples/duck.wav b/src/examples/duck.wav
new file mode 100644 (file)
index 0000000..04a62dc
Binary files /dev/null and b/src/examples/duck.wav differ
diff --git a/src/examples/edje-multisense.c b/src/examples/edje-multisense.c
new file mode 100644 (file)
index 0000000..c66c568
--- /dev/null
@@ -0,0 +1,80 @@
+/**
+ * Simple example illustrating the very basic functions of multisense
+ *
+ * You'll need at least one Evas engine built for it (excluding the
+ * buffer one) and multisense support ine edje. See stdout/stderr for output.
+ *
+ * @verbatim
+ * gcc -o edje-multisense edje-multisense.c `pkg-config --libs --cflags eina evas ecore ecore-evas edje`
+ * @endverbatim
+ */
+
+#include <Eina.h>
+#include <Evas.h>
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <Edje.h>
+
+#define WIDTH  300
+#define HEIGHT 300
+
+static Evas_Object *create_my_group(Evas *canvas)
+{
+   Evas_Object *edje;
+
+   edje = edje_object_add(canvas);
+   if (!edje)
+     {
+        EINA_LOG_CRIT("could not create edje object!");
+        return NULL;
+     }
+
+   if (!edje_object_file_set(edje, "multisense.edj", "example_group"))
+     {
+        int err = edje_object_load_error_get(edje);
+        const char *errmsg = edje_load_error_str(err);
+        EINA_LOG_ERR("could not load 'example_group' from multisense.edj: %s",
+                     errmsg);
+
+        evas_object_del(edje);
+        return NULL;
+     }
+
+   evas_object_move(edje, 0, 0);
+   evas_object_resize(edje, WIDTH, HEIGHT);
+   evas_object_show(edje);
+   return edje;
+}
+
+int main(int argc, char *argv[])
+{
+   Ecore_Evas *window;
+   Evas *canvas;
+   Evas_Object *edje;
+
+   ecore_evas_init();
+   edje_init();
+
+   window = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
+   if (!window)
+     {
+        EINA_LOG_CRIT("could not create window.");
+        return -1;
+     }
+   canvas = ecore_evas_get(window);
+
+   edje = create_my_group(canvas);
+   if (!edje)
+     return -2;
+
+   ecore_evas_show(window);
+   ecore_main_loop_begin();
+
+   evas_object_del(edje);
+   ecore_evas_free(window);
+
+   edje_shutdown();
+   ecore_evas_shutdown();
+
+   return 0;
+}
index 5a3cf79..3cbaf67 100644 (file)
@@ -1,43 +1,8 @@
-#if 0
 collections {
    sounds {
       sample {
          name: "sound_name1" RAW;
-         source: "8806__jovica__basic-sine-wave-g-1.wav";
-//         source: "sample.wav";
-//         source: "sample-flac10k.wav";
-//         source: "sample-flac10k-mono.wav";
-      }
-//      sample {
-//         name: "sound_name2" COMP;
-//         source: "sample.wav";
-//      }
-/*      
-      sample {
-         name: "sound_name3" LOSSY 0.5;
-         source: "sample.wav";
-      }
-      sample {
-         name: "sound_name4" AS_IS;
-         source: "sample.wav";
-      }
- */
-      sample {
-//         name: "sound_name5" AS_IS;
-//         name: "sound_name5" COMP;
-         name: "sound_name5" RAW;
-//         source: "sample-ogg.wav";
-         source: "sample-ogg-mono.wav";
-//         source: "sample-ogg10k.wav";
-//         source: "sample-flac10k.wav";
-//         source: "sample-flac10k-mono.wav";
-      }
-      sample {
-         name: "sound_name6" AS_IS;
-//         name: "sound_name6" LOSSY 45.0;
-         source: "sample-flac44k-mono.wav";
-//         source: "sample-flac.wav";
-//         source: "sample.ogg";
+         source: "duck.wav";
       }
       tone: "tone-name" 2600;
    }
@@ -95,7 +60,7 @@ collections {
             name: "tone_text";
             type: TEXT;
              mouse_events: 1;
-             repeat_events : 1;
+             repeat_events: 1;
             description {
                state: "default" 0.0;
                rel1.to: "tone_bg";
@@ -115,18 +80,6 @@ collections {
                action: PLAY_SAMPLE "sound_name1" 1.0;
             }
             program {
-               name: "click_sample2";
-               signal: "mouse,down,2";
-               source: "sample_bg";
-               action: PLAY_SAMPLE "sound_name5" 1.0;
-            }
-            program {
-               name: "click_sample3";
-               signal: "mouse,down,3";
-               source: "sample_bg";
-               action: PLAY_SAMPLE "sound_name6" 1.0;
-            }
-            program {
                name: "click_tone";
                signal: "mouse,down,1";
                source: "tone_bg";
@@ -136,4 +89,3 @@ collections {
       }
    }
 }
-#endif