cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=23892343cce3b561e98dd050821cad0bed1ce887

commit 23892343cce3b561e98dd050821cad0bed1ce887
Author: Julien Isorce <j.iso...@samsung.com>
Date:   Thu Aug 21 11:18:41 2014 +0200

    evas: add example to test transparent background
    
    Summary:
    
    Reviewers: raster, devilhorns, cedric
    
    Subscribers: capOM, cedric
    
    Differential Revision: https://phab.enlightenment.org/D1228
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/examples/evas/Makefile.am        |   5 ++
 src/examples/evas/evas-transparent.c | 108 +++++++++++++++++++++++++++++++++++
 2 files changed, 113 insertions(+)

diff --git a/src/examples/evas/Makefile.am b/src/examples/evas/Makefile.am
index 8ce8cf0..18a7ed9 100644
--- a/src/examples/evas/Makefile.am
+++ b/src/examples/evas/Makefile.am
@@ -167,6 +167,11 @@ evas_table_SOURCES = evas-table.c
 evas_table_LDADD = $(ECORE_EVAS_COMMON_LDADD)
 evas_table_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS)
 
+EXTRA_PROGRAMS += evas_transparent
+evas_transparent_SOURCES = evas-transparent.c
+evas_transparent_LDADD = $(ECORE_EVAS_COMMON_LDADD)
+evas_transparent_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS)
+
 EXTRA_PROGRAMS += evas_multi_touch
 evas_multi_touch_SOURCES = evas-multi-touch.c
 evas_multi_touch_LDADD = $(ECORE_EVAS_COMMON_LDADD)
diff --git a/src/examples/evas/evas-transparent.c 
b/src/examples/evas/evas-transparent.c
new file mode 100644
index 0000000..56dd752
--- /dev/null
+++ b/src/examples/evas/evas-transparent.c
@@ -0,0 +1,108 @@
+/**
+ * Simple Evas example illustrating a trasnparent window
+ *
+ * @verbatim
+ * gcc -o evas-transparent evas-transparent.c `pkg-config --libs --cflags evas 
ecore ecore-evas eina`
+ * @endverbatim
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define WIDTH  (640)
+#define HEIGHT (480)
+
+static const char *commands = \
+  "commands are:\n"
+  "\tn - turn on alpha"
+  "\tm - turn off alpha"
+  "\th - print help\n";
+
+struct exemple_data
+{
+   Ecore_Evas  *ee;
+   Evas        *evas;
+   Evas_Object *bg;
+};
+
+static struct exemple_data d;
+
+static void
+_on_keydown(void        *data EINA_UNUSED,
+            Evas        *evas EINA_UNUSED,
+            Evas_Object *o EINA_UNUSED,
+            void        *einfo)
+{
+   Evas_Event_Key_Down *ev = einfo;
+
+   if (strcmp(ev->key, "h") == 0) /* print help */
+     {
+        fprintf(stdout, "%s",  commands);
+        return;
+     }
+
+   if (strcmp(ev->key, "n") == 0)
+     {
+        ecore_evas_alpha_set(d.ee, EINA_TRUE);
+
+        fprintf(stdout, "turn on alpha\n");
+        return;
+     }
+
+   if (strcmp(ev->key, "m") == 0)
+     {
+        ecore_evas_alpha_set(d.ee, EINA_FALSE);
+
+        fprintf(stdout, "turn off alpha\n");
+        return;
+     }
+}
+
+static void
+_on_delete(Ecore_Evas *ee EINA_UNUSED)
+{
+   ecore_main_loop_quit();
+}
+
+int
+main(void)
+{
+   if (!ecore_evas_init())
+     return EXIT_FAILURE;
+
+   d.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
+   if (!d.ee)
+     goto panic;
+
+   ecore_evas_callback_delete_request_set(d.ee, _on_delete);
+   ecore_evas_show(d.ee);
+
+   d.evas = ecore_evas_get(d.ee);
+
+   d.bg = evas_object_rectangle_add(d.evas);
+   evas_object_color_set(d.bg, 0, 0, 0, 0);
+   evas_object_show(d.bg);
+
+   evas_object_focus_set(d.bg, EINA_TRUE);
+   evas_object_event_callback_add(d.bg, EVAS_CALLBACK_KEY_DOWN,
+                                  _on_keydown, NULL);
+   ecore_main_loop_begin();
+   ecore_evas_shutdown();
+   return 0;
+
+panic:
+   fprintf(stderr, "You got to have at least one evas engine built and linked"
+                   " up to ecore-evas for this example to run properly.\n");
+   return -2;
+}
+

-- 


Reply via email to