diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/examples/ecore_evas_buffer_example_02.c | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/libraries/ecore/src/examples/ecore_evas_buffer_example_02.c b/libraries/ecore/src/examples/ecore_evas_buffer_example_02.c new file mode 100644 index 0000000..29b7b3d --- /dev/null +++ b/libraries/ecore/src/examples/ecore_evas_buffer_example_02.c | |||
@@ -0,0 +1,126 @@ | |||
1 | /** | ||
2 | * Simple Ecore_Evas example on the Evas buffer engine wrapper | ||
3 | * functions. | ||
4 | * | ||
5 | * You must have Evas compiled with the buffer engine. | ||
6 | * | ||
7 | * Compile with: | ||
8 | * | ||
9 | * @verbatim | ||
10 | * gcc -o evas-buffer-simple evas-buffer-simple.c `pkg-config --libs --cflags evas evas-software-buffer` | ||
11 | * @endverbatim | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #ifdef HAVE_CONFIG_H | ||
16 | |||
17 | #include "config.h" | ||
18 | #else | ||
19 | #define __UNUSED__ | ||
20 | #define PACKAGE_EXAMPLES_DIR "." | ||
21 | #endif | ||
22 | |||
23 | #include <Ecore.h> | ||
24 | #include <Ecore_Evas.h> | ||
25 | #include <stdio.h> | ||
26 | |||
27 | #define WIDTH (320) | ||
28 | #define HEIGHT (240) | ||
29 | |||
30 | static Ecore_Evas *ee; | ||
31 | static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png"; | ||
32 | |||
33 | static void | ||
34 | _on_destroy(Ecore_Evas *ee __UNUSED__) | ||
35 | { | ||
36 | ecore_main_loop_quit(); | ||
37 | } | ||
38 | |||
39 | int | ||
40 | main(void) | ||
41 | { | ||
42 | Evas *canvas, *sub_canvas; | ||
43 | Evas_Object *bg, *r1, *r2, *r3; /* "sub" canvas objects */ | ||
44 | Evas_Object *border, *img; /* canvas objects */ | ||
45 | Ecore_Evas *sub_ee; | ||
46 | |||
47 | ecore_evas_init(); | ||
48 | |||
49 | /* this will give you a window with an Evas canvas under the first | ||
50 | * engine available */ | ||
51 | ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); | ||
52 | if (!ee) goto error; | ||
53 | |||
54 | ecore_evas_size_min_set(ee, WIDTH, HEIGHT); | ||
55 | ecore_evas_size_max_set(ee, WIDTH, HEIGHT); | ||
56 | |||
57 | ecore_evas_callback_delete_request_set(ee, _on_destroy); | ||
58 | ecore_evas_title_set(ee, "Ecore_Evas buffer (image) example"); | ||
59 | ecore_evas_show(ee); | ||
60 | |||
61 | canvas = ecore_evas_get(ee); | ||
62 | |||
63 | bg = evas_object_rectangle_add(canvas); | ||
64 | evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ | ||
65 | evas_object_move(bg, 0, 0); /* at origin */ | ||
66 | evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ | ||
67 | evas_object_show(bg); | ||
68 | |||
69 | /* this is a border around the image containing a scene of another | ||
70 | * canvas */ | ||
71 | border = evas_object_image_filled_add(canvas); | ||
72 | evas_object_image_file_set(border, border_img_path, NULL); | ||
73 | evas_object_image_border_set(border, 3, 3, 3, 3); | ||
74 | evas_object_image_border_center_fill_set(border, EVAS_BORDER_FILL_NONE); | ||
75 | |||
76 | evas_object_move(border, WIDTH / 6, HEIGHT / 6); | ||
77 | evas_object_resize(border, (2 * WIDTH) / 3, (2 * HEIGHT) / 3); | ||
78 | evas_object_show(border); | ||
79 | |||
80 | img = ecore_evas_object_image_new(ee); | ||
81 | evas_object_image_filled_set(img, EINA_TRUE); | ||
82 | evas_object_image_size_set( | ||
83 | img, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6); | ||
84 | sub_ee = ecore_evas_object_ecore_evas_get(img); | ||
85 | sub_canvas = ecore_evas_object_evas_get(img); | ||
86 | |||
87 | evas_object_move(img, (WIDTH / 6) + 3, (HEIGHT / 6) + 3); | ||
88 | |||
89 | /* apply the same size on both! */ | ||
90 | evas_object_resize(img, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6); | ||
91 | ecore_evas_resize(sub_ee, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6); | ||
92 | |||
93 | r1 = evas_object_rectangle_add(sub_canvas); | ||
94 | evas_object_color_set(r1, 255, 0, 0, 255); /* 100% opaque red */ | ||
95 | evas_object_move(r1, 10, 10); | ||
96 | evas_object_resize(r1, 100, 100); | ||
97 | evas_object_show(r1); | ||
98 | |||
99 | r2 = evas_object_rectangle_add(sub_canvas); | ||
100 | evas_object_color_set(r2, 0, 128, 0, 128); /* 50% opaque green */ | ||
101 | evas_object_move(r2, 10, 10); | ||
102 | evas_object_resize(r2, 50, 50); | ||
103 | evas_object_show(r2); | ||
104 | |||
105 | r3 = evas_object_rectangle_add(sub_canvas); | ||
106 | evas_object_color_set(r3, 0, 128, 0, 255); /* 100% opaque dark green */ | ||
107 | evas_object_move(r3, 60, 60); | ||
108 | evas_object_resize(r3, 50, 50); | ||
109 | evas_object_show(r3); | ||
110 | |||
111 | evas_object_show(img); | ||
112 | ecore_main_loop_begin(); | ||
113 | |||
114 | ecore_evas_free(ee); | ||
115 | ecore_evas_shutdown(); | ||
116 | |||
117 | return 0; | ||
118 | |||
119 | error: | ||
120 | fprintf(stderr, "You got to have at least one Evas engine built" | ||
121 | " and linked up to ecore-evas for this example to run" | ||
122 | " properly.\n"); | ||
123 | ecore_evas_shutdown(); | ||
124 | return -1; | ||
125 | } | ||
126 | |||