Add example of efl_canvas_vg_node raise/lower/stack_above/stack_below 84/240484/5
authorPatryk Kaczmarek <patryk.k@partner.samsung.com>
Thu, 6 Aug 2020 14:14:36 +0000 (16:14 +0200)
committerHermet Park <chuneon.park@samsung.com>
Wed, 19 Aug 2020 01:12:47 +0000 (01:12 +0000)
Change-Id: I88c7de6a8e9455ffaa6e814d3babc786cfb6cb5f

src/examples/evas/evas-vg-node.c [new file with mode: 0644]
src/examples/evas/meson.build

diff --git a/src/examples/evas/evas-vg-node.c b/src/examples/evas/evas-vg-node.c
new file mode 100644 (file)
index 0000000..013ee9f
--- /dev/null
@@ -0,0 +1,142 @@
+/**
+ * gcc -o evas-vg-node evas-vg-node.c `pkg-config --libs --cflags ecore ecore-evas`
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#else
+#define PACKAGE_EXAMPLES_DIR "."
+#endif
+
+#define WIDTH  400
+#define HEIGHT 400
+
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+
+struct content
+{
+   Ecore_Evas  *ee;
+   Evas        *ev;
+   Evas_Object *bg;
+   Evas_Object *vg;
+
+};
+static struct  content cnt;
+
+
+static void
+_on_delete(Ecore_Evas *ee EINA_UNUSED)
+{
+   ecore_main_loop_quit();
+}
+
+static void
+_canvas_resize_cb(Ecore_Evas *ee)
+{
+   int w, h;
+   ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
+   evas_object_resize(cnt.bg, w, h);
+   evas_object_resize(cnt.vg, w, h);
+}
+
+static void
+_on_keydown(void        *data  EINA_UNUSED,
+            Evas        *evas  EINA_UNUSED,
+            Evas_Object *o,
+            void        *einfo)
+{
+   Evas_Event_Key_Down *ei = einfo;
+   evas_object_key_grab(o, "q", 0, 0, EINA_TRUE);
+
+   if ( !strcmp(ei->key, "q"))
+        _on_delete(cnt.ee);
+}
+
+int
+main(void)
+{
+   Efl_VG *shape = NULL;
+   Efl_VG *shape2 = NULL;
+   Efl_VG *shape3 = NULL;
+   Efl_VG *shape4 = NULL;
+   Efl_VG *shape5 = NULL;
+   Efl_VG *shape6 = NULL;
+   Efl_VG *container = NULL;
+
+   if (!ecore_evas_init())
+     return EXIT_FAILURE;
+
+
+   cnt.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
+   if ( !cnt.ee)
+     {
+        ecore_evas_shutdown();
+        return -1;
+     }
+
+   ecore_evas_callback_delete_request_set(cnt.ee, _on_delete);
+   ecore_evas_callback_resize_set(cnt.ee, _canvas_resize_cb);
+   ecore_evas_show(cnt.ee);
+
+   cnt.ev = ecore_evas_get(cnt.ee);
+   cnt.bg = evas_object_rectangle_add(cnt.ev);
+   evas_object_color_set(cnt.bg, 255, 255, 255, 255);
+   evas_object_focus_set(cnt.bg, EINA_TRUE);
+   evas_object_show(cnt.bg);
+
+   evas_object_event_callback_add(cnt.bg, EVAS_CALLBACK_KEY_DOWN, _on_keydown, NULL);
+
+   cnt.vg = evas_object_vg_add(cnt.ev);
+   evas_object_show(cnt.vg);
+
+   _canvas_resize_cb(cnt.ee);
+
+   container = evas_vg_container_add(cnt.vg);
+
+   shape = evas_vg_shape_add(container);
+   evas_vg_shape_append_rect(shape, 10, 10, 100, 100, 5, 5);
+   evas_vg_shape_stroke_color_set(shape, 255,0 , 0, 255);
+   evas_vg_shape_stroke_width_set(shape, 3);
+
+   shape2 = evas_vg_shape_add(container);
+   evas_vg_shape_append_rect(shape2, 120, 10, 100, 100, 0, 0);
+   evas_vg_shape_stroke_color_set(shape2, 0, 255, 0, 255);
+   evas_vg_shape_stroke_width_set(shape2, 3);
+   evas_vg_node_color_set(shape2, 255, 255, 0, 255);
+
+   shape3 = evas_vg_shape_add(container);
+   evas_vg_shape_append_rect(shape3, 230, 10, 100, 100, 0, 0);
+   evas_vg_shape_stroke_color_set(shape3, 0, 255, 0, 255);
+   evas_vg_shape_stroke_width_set(shape3, 3);
+   evas_vg_node_color_set(shape3, 255, 0, 0, 255);
+
+   shape4 = evas_vg_shape_add(container);
+   evas_vg_shape_append_rect(shape4, 50, 50, 250, 250, 0, 0);
+   evas_vg_shape_stroke_color_set(shape4, 0, 200, 100, 255);
+   evas_vg_shape_stroke_width_set(shape4, 3);
+   evas_vg_node_color_set(shape4, 100, 125, 150, 255);
+
+   shape5 = evas_vg_shape_add(container);
+   evas_vg_shape_append_rect(shape5, 230, 120, 100, 100, 0, 0);
+   evas_vg_shape_stroke_color_set(shape5, 0, 255, 0, 255);
+   evas_vg_shape_stroke_width_set(shape5, 3);
+   evas_vg_node_color_set(shape5, 0, 0, 255, 255);
+
+   shape6 = evas_vg_shape_add(container);
+   evas_vg_shape_append_rect(shape6, 20, 70, 100, 100, 0, 0);
+   evas_vg_shape_stroke_color_set(shape6, 5, 5, 5, 255);
+   evas_vg_shape_stroke_width_set(shape6, 3);
+   evas_vg_node_color_set(shape6, 5, 5, 5, 255);
+
+   evas_vg_node_raise(shape2);
+   evas_vg_node_lower(shape6);
+   evas_vg_node_stack_above(shape3, shape4);
+   evas_vg_node_stack_below(shape, shape6);
+
+   evas_object_vg_root_node_set(cnt.vg, container);
+   ecore_main_loop_begin();
+   ecore_evas_shutdown();
+
+   return 0;
+}
index 47927d3..157655e 100644 (file)
@@ -38,6 +38,7 @@ examples = [
   'evas-vg-batman',
   'evas-vg-simple',
   'evas-vg-json',
+  'evas-vg-node',
   'efl-canvas-animation',
   'efl-canvas-vg-simple',
   'evas-vg-circles',