summaryrefslogtreecommitdiff
path: root/src/examples/edje
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2015-11-19 16:25:04 +0200
committerDaniel Hirt <daniel.hirt@samsung.com>2015-11-24 14:31:29 +0200
commit699a57c7e46e13476b88aa37a0342722919c56d6 (patch)
tree820ecb5da2a0bcc1553eb0a2448e1fef9f5a2c30 /src/examples/edje
parenta7b0b13c439106a82c2c93096c86f5c128e091a9 (diff)
Edje: Add example for hyphenation style
A small example how hyphenation is set as a style in TEXTBLOCK parts.
Diffstat (limited to 'src/examples/edje')
-rw-r--r--src/examples/edje/Makefile.am9
-rw-r--r--src/examples/edje/edje-textblock-hyphenation.c114
-rw-r--r--src/examples/edje/textblock-hyphen.edc29
3 files changed, 149 insertions, 3 deletions
diff --git a/src/examples/edje/Makefile.am b/src/examples/edje/Makefile.am
index cdf1ac316b..8ffc20affa 100644
--- a/src/examples/edje/Makefile.am
+++ b/src/examples/edje/Makefile.am
@@ -49,7 +49,8 @@ toggle_using_filter.edc \
49box_example.edc \ 49box_example.edc \
50embryo_tween_anim.edc \ 50embryo_tween_anim.edc \
51embryo_set_state_anim.edc \ 51embryo_set_state_anim.edc \
52bezier-transition-example.edc 52bezier-transition-example.edc \
53textblock-hyphen.edc
53 54
54DIST_EDCS = $(EDCS) 55DIST_EDCS = $(EDCS)
55 56
@@ -106,7 +107,8 @@ edje-basic2.c \
106signals2.c \ 107signals2.c \
107edje-swallow2.c \ 108edje-swallow2.c \
108edje-multisense.c \ 109edje-multisense.c \
109edje-edit-part-box.c 110edje-edit-part-box.c \
111edje-textblock-hyphenation.c
110 112
111EXTRA_DIST = $(DIST_EDCS) $(DATA_FILES) 113EXTRA_DIST = $(DIST_EDCS) $(DATA_FILES)
112 114
@@ -175,7 +177,8 @@ animations2 \
175edje-basic2 \ 177edje-basic2 \
176signals2 \ 178signals2 \
177edje-swallow2 \ 179edje-swallow2 \
178edje-edit-part-box 180edje-edit-part-box \
181edje-textblock-hyphenation
179 182
180if ENABLE_MULTISENSE 183if ENABLE_MULTISENSE
181EXTRA_PROGRAMS += edje-multisense 184EXTRA_PROGRAMS += edje-multisense
diff --git a/src/examples/edje/edje-textblock-hyphenation.c b/src/examples/edje/edje-textblock-hyphenation.c
new file mode 100644
index 0000000000..3bc53cae22
--- /dev/null
+++ b/src/examples/edje/edje-textblock-hyphenation.c
@@ -0,0 +1,114 @@
1/**
2 * Edje example for hyphenation option with TEXTBLOCK parts
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc swallow.edc && gcc -o edje-textblock-hyphenation edje-textblock-hyphenation.c `pkg-config --libs --cflags evas ecore ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13# include "config.h"
14#else
15# define EINA_UNUSED
16#endif
17
18#ifndef PACKAGE_DATA_DIR
19#define PACKAGE_DATA_DIR "."
20#endif
21
22#include <Ecore.h>
23#include <Ecore_Evas.h>
24#include <Edje.h>
25#include <locale.h>
26
27#define WIDTH (300)
28#define HEIGHT (300)
29
30static void
31_on_delete(Ecore_Evas *ee EINA_UNUSED)
32{
33 ecore_main_loop_quit();
34}
35
36/* here just to keep our example's window size and background image's
37 * size in synchrony */
38static void
39_on_canvas_resize(Ecore_Evas *ee)
40{
41 Evas_Object *bg, *edj;
42 int w;
43 int h;
44
45 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
46 bg = ecore_evas_data_get(ee, "background");
47 evas_object_resize(bg, w, h);
48 edj = ecore_evas_data_get(ee, "edje_obj");
49 evas_object_resize(edj, w, h);
50}
51
52int
53main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
54{
55 const char *edje_file = PACKAGE_DATA_DIR"/textblock-hyphen.edj";
56 Ecore_Evas *ee;
57 Evas *evas;
58 Evas_Object *bg;
59 Evas_Object *edje_obj;
60
61 if (!ecore_evas_init())
62 return EXIT_FAILURE;
63
64 if (!edje_init())
65 goto shutdown_ecore_evas;
66
67 /* this will give you a window with an Evas canvas under the first
68 * engine available */
69 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
70 if (!ee) goto shutdown_edje;
71
72 ecore_evas_callback_delete_request_set(ee, _on_delete);
73 ecore_evas_callback_resize_set(ee, _on_canvas_resize);
74 ecore_evas_title_set(ee, "Edje Textblock Hyphenation");
75
76 evas = ecore_evas_get(ee);
77
78 bg = evas_object_rectangle_add(evas);
79 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
80 evas_object_move(bg, 0, 0); /* at canvas' origin */
81 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
82 evas_object_show(bg);
83 ecore_evas_data_set(ee, "background", bg);
84
85 setlocale(LC_MESSAGES, "en_US.UTF-8");
86
87 edje_obj = edje_object_add(evas);
88
89 edje_object_file_set(edje_obj, edje_file, "example_textblock_hyphenation");
90 evas_object_move(edje_obj, 0, 0); /* at canvas' origin */
91 evas_object_resize(edje_obj, WIDTH, HEIGHT);
92 evas_object_show(edje_obj);
93 ecore_evas_data_set(ee, "edje_obj", edje_obj);
94
95 edje_object_part_text_set(edje_obj, "text_part", "Hello world hyphenation world");
96
97 ecore_evas_show(ee);
98
99 ecore_main_loop_begin();
100
101 ecore_evas_free(ee);
102 ecore_evas_shutdown();
103 edje_shutdown();
104
105 return EXIT_SUCCESS;
106
107 shutdown_edje:
108 edje_shutdown();
109 shutdown_ecore_evas:
110 ecore_evas_shutdown();
111
112 return EXIT_FAILURE;
113}
114
diff --git a/src/examples/edje/textblock-hyphen.edc b/src/examples/edje/textblock-hyphen.edc
new file mode 100644
index 0000000000..6b698e1f1c
--- /dev/null
+++ b/src/examples/edje/textblock-hyphen.edc
@@ -0,0 +1,29 @@
1collections {
2 styles {
3 style { name: "entry_style";
4 base: "font="DejavuSans" font_size=10 color=#000 wrap=hyphenation left_margin=2 right_margin=2";
5 }
6 }
7 group {
8 name: "example_textblock_hyphenation";
9 min: 10 50;
10
11 parts {
12 part {
13 name: "text_part"; type: TEXTBLOCK;
14 description {
15 min: 10 50;
16 state: "default" 0.0;
17 rel1.relative: 0.0 0.0;
18 rel2.relative: 1.0 1.0;
19 text {
20 style: "entry_style";
21 min: 0 1;
22 align: 0.0 0.0;
23 }
24 }
25 }
26 }
27 }
28}
29