summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-02-12 21:10:34 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-13 17:29:32 +0900
commitcd926cc9462b44c5aebab3df4c65152d0cd93a89 (patch)
tree5b3ce533f29453580c2f16890617936ebc9cfd63 /doc
parent56f403589839074f5a54f6f1329cc5dcb64f3114 (diff)
Evas filters: Add a small utility to take some screenshots
Let's add some real screenshots to the documentation! Yay! Fancy effects inlined in the Doxygen! Well... soon :)
Diffstat (limited to 'doc')
-rw-r--r--doc/previews/preview_text_filter.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/doc/previews/preview_text_filter.c b/doc/previews/preview_text_filter.c
new file mode 100644
index 0000000000..d462a1ab87
--- /dev/null
+++ b/doc/previews/preview_text_filter.c
@@ -0,0 +1,118 @@
1/*
2#define EFL_EO_API_SUPPORT 1
3#define EFL_BETA_API_SUPPORT 1
4*/
5
6#include "Eo.h"
7#include "Evas.h"
8#include "Ecore_Evas.h"
9
10#include <stdio.h>
11
12/* Beginning of the file used for taking a shot of an object.
13 * Used for font effect screenshots.
14 */
15
16typedef struct
17{
18 Ecore_Evas *ee;
19 const char *file;
20 const char *key;
21 const char *flags;
22} Widget_Preview_Data;
23
24/* This comes from Elementary's elm_win.c */
25static void
26_shot_do(Widget_Preview_Data *wpd)
27{
28 Ecore_Evas *ee;
29 Evas_Object *o;
30 unsigned int *pixels;
31 int w, h;
32
33 if (!wpd->file) return;
34
35 ecore_evas_manual_render(wpd->ee);
36 pixels = (void *)ecore_evas_buffer_pixels_get(wpd->ee);
37 if (!pixels) return;
38
39 ecore_evas_geometry_get(wpd->ee, NULL, NULL, &w, &h);
40 if ((w < 1) || (h < 1)) return;
41
42 ee = ecore_evas_buffer_new(1, 1);
43 o = evas_object_image_add(ecore_evas_get(ee));
44 evas_object_image_alpha_set(o, ecore_evas_alpha_get(wpd->ee));
45 evas_object_image_size_set(o, w, h);
46 evas_object_image_data_set(o, pixels);
47 if (!evas_object_image_save(o, wpd->file, wpd->key, wpd->flags))
48 fprintf(stderr, "Cannot save window to '%s' (key '%s', flags '%s')\n",
49 wpd->file, wpd->key, wpd->flags);
50
51 ecore_evas_free(ee);
52}
53
54static void
55_usage(const char *argv0, FILE *f)
56{
57 fprintf(f, "Usage: %s <text> <filter code> <output file> [font] [fontsize]\n", argv0);
58}
59
60int
61main(int argc, char **argv)
62{
63 Widget_Preview_Data wpd = { NULL, NULL, NULL };
64 const char *font = "Sans";
65 const char *filter, *text;
66 int fontsize = 32;
67 Evas_Object *o;
68 char *whole_filter;
69 int w, h;
70
71 if (argc < 4)
72 {
73 _usage(argv[0], stderr);
74 return 1;
75 }
76
77 w = 1;
78 h = 1;
79 text = argv[1];
80 filter = argv[2];
81 wpd.file = argv[3];
82 if (argc >= 5) font = argv[4];
83 if (argc >= 6) fontsize = atoi(argv[5]);
84
85 evas_init();
86 ecore_evas_init();
87
88 wpd.ee = ecore_evas_buffer_new(w, h);
89 if (!wpd.ee) return 2;
90
91 ecore_evas_show(wpd.ee);
92 ecore_evas_manual_render_set(wpd.ee, EINA_TRUE);
93
94 o = evas_object_text_add(ecore_evas_get(wpd.ee));
95 evas_object_move(o, 0, 0);
96 evas_object_resize(o, w, h);
97 evas_object_text_font_set(o, font, fontsize);
98 evas_object_text_text_set(o, text);
99 evas_object_color_set(o, 255, 255, 255, 255);
100 evas_object_show(o);
101
102 if (asprintf(&whole_filter, "fill(color = #404040); %s", filter) == -1)
103 return 2;
104 eo_do(o, evas_obj_text_filter_program_set(whole_filter));
105 free(whole_filter);
106
107 ecore_evas_manual_render(wpd.ee);
108 evas_object_geometry_get(o, NULL, NULL, &w, &h);
109 ecore_evas_resize(wpd.ee, w, h);
110
111 _shot_do(&wpd);
112
113 ecore_evas_shutdown();
114 evas_shutdown();
115
116 return 0;
117}
118