diff options
author | Tom Hacohen <tom@stosb.com> | 2010-08-11 14:17:47 +0000 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2010-08-11 14:17:47 +0000 |
commit | faf659b3f1b6abc5c98fddb19ca68662f54993c5 (patch) | |
tree | f6a1037899efda05889a076761359cfe7c42b774 | |
parent | 845bab2130f40ea1f45af7e000763966e8a0cd59 (diff) |
Expedite: Added textblock autoalign test.
SVN revision: 50998
-rw-r--r-- | src/bin/Makefile.am | 1 | ||||
-rw-r--r-- | src/bin/tests.h | 1 | ||||
-rw-r--r-- | src/bin/textblock_auto_align.c | 129 |
3 files changed, 131 insertions, 0 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 0d3f875..4611b51 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am | |||
@@ -87,6 +87,7 @@ text_styles_different_strings.c \ | |||
87 | text_change.c \ | 87 | text_change.c \ |
88 | textblock_basic.c \ | 88 | textblock_basic.c \ |
89 | textblock_intl.c \ | 89 | textblock_intl.c \ |
90 | textblock_auto_align.c \ | ||
90 | rect_blend.c \ | 91 | rect_blend.c \ |
91 | rect_blend_pow2.c \ | 92 | rect_blend_pow2.c \ |
92 | rect_solid.c \ | 93 | rect_solid.c \ |
diff --git a/src/bin/tests.h b/src/bin/tests.h index ec8402c..66e48b0 100644 --- a/src/bin/tests.h +++ b/src/bin/tests.h | |||
@@ -63,6 +63,7 @@ | |||
63 | #include "text_change.c" | 63 | #include "text_change.c" |
64 | #include "textblock_basic.c" | 64 | #include "textblock_basic.c" |
65 | #include "textblock_intl.c" | 65 | #include "textblock_intl.c" |
66 | #include "textblock_auto_align.c" | ||
66 | #include "rect_blend.c" | 67 | #include "rect_blend.c" |
67 | #include "rect_blend_pow2.c" | 68 | #include "rect_blend_pow2.c" |
68 | #include "rect_solid.c" | 69 | #include "rect_solid.c" |
diff --git a/src/bin/textblock_auto_align.c b/src/bin/textblock_auto_align.c new file mode 100644 index 0000000..da5a341 --- /dev/null +++ b/src/bin/textblock_auto_align.c | |||
@@ -0,0 +1,129 @@ | |||
1 | #undef FNAME | ||
2 | #undef NAME | ||
3 | #undef ICON | ||
4 | |||
5 | /* metadata */ | ||
6 | #define FNAME textblock_auto_align_start | ||
7 | #define NAME "Textblock auto align" | ||
8 | #define ICON "text.png" | ||
9 | |||
10 | #ifndef PROTO | ||
11 | # ifndef UI | ||
12 | # include "main.h" | ||
13 | |||
14 | /* standard var */ | ||
15 | static int done = 0; | ||
16 | |||
17 | /* private data */ | ||
18 | static Evas_Object *o_text; | ||
19 | |||
20 | /* setup */ | ||
21 | static void _setup(void) | ||
22 | { | ||
23 | Evas_Object *o; | ||
24 | Evas_Textblock_Style *st; | ||
25 | |||
26 | o = evas_object_textblock_add(evas); | ||
27 | o_text = o; | ||
28 | st = evas_textblock_style_new(); | ||
29 | evas_textblock_style_set | ||
30 | (st, | ||
31 | "DEFAULT='font=Sans font_size=10 color=#000000 wrap=word'" | ||
32 | "br='\n'" | ||
33 | "ps='ps'" | ||
34 | ); | ||
35 | evas_object_textblock_style_set(o, st); | ||
36 | evas_textblock_style_free(st); | ||
37 | evas_object_textblock_clear(o); | ||
38 | |||
39 | evas_object_textblock_text_markup_set | ||
40 | (o, | ||
41 | "This is a test of auto alignment in Evas<ps>" | ||
42 | "<br>" | ||
43 | "This text should be left aligned<ps>" | ||
44 | "\xE2\x80\x8FThis text should be right aligned<ps>" | ||
45 | "\xE2\x80\x8FThis text should be right aligned<br>" | ||
46 | "Same as this text.<ps>" | ||
47 | "This text should be left aligned<br>" | ||
48 | "\xE2\x80\x8FSame as this text." | ||
49 | "<br><br><ps>" | ||
50 | "The word 'זה' should be the rightmost, 'טקסט' after, and 'בעברית' last<br>" | ||
51 | "in the following text:<ps>" | ||
52 | "זה טקסט בעברית<ps>" | ||
53 | "<br>" | ||
54 | "In the next text, the paragraph should be right aligned and the<br>" | ||
55 | "words should appear in the following order: 'דוגמה' first, 'of' second,<br>" | ||
56 | "'טקסט' third, 'english' fourth and 'in' fifth, counting from right to left<ps>" | ||
57 | "דוגמה of טקסט in english." | ||
58 | ); | ||
59 | |||
60 | evas_object_show(o); | ||
61 | |||
62 | done = 0; | ||
63 | } | ||
64 | |||
65 | /* cleanup */ | ||
66 | static void _cleanup(void) | ||
67 | { | ||
68 | evas_object_del(o_text); | ||
69 | } | ||
70 | |||
71 | /* loop - do things */ | ||
72 | static void _loop(double t, int f) | ||
73 | { | ||
74 | Evas_Coord x, y, w, h, w0, h0; | ||
75 | int i = 0; | ||
76 | |||
77 | evas_object_textblock_size_native_get(o_text, &w0, &h0); | ||
78 | w = w0; | ||
79 | h = h0; | ||
80 | w += fabs(sin((double)(f + (i * 13)) / (31.1 * SLOW))) * (w0); | ||
81 | x = (win_w / 2) - (w / 2); | ||
82 | y = (win_h / 2) - (h0 / 2); | ||
83 | evas_object_move(o_text, x, y); | ||
84 | evas_object_resize(o_text, w, h); | ||
85 | |||
86 | FPS_STD(NAME); | ||
87 | } | ||
88 | |||
89 | /* prepend special key handlers if interactive (before STD) */ | ||
90 | static void _key(char *key) | ||
91 | { | ||
92 | KEY_STD; | ||
93 | } | ||
94 | |||
95 | |||
96 | |||
97 | |||
98 | |||
99 | |||
100 | |||
101 | |||
102 | |||
103 | |||
104 | |||
105 | |||
106 | /* template stuff - ignore */ | ||
107 | # endif | ||
108 | #endif | ||
109 | |||
110 | #ifdef UI | ||
111 | _ui_menu_item_add(ICON, NAME, FNAME); | ||
112 | #endif | ||
113 | |||
114 | #ifdef PROTO | ||
115 | void FNAME(void); | ||
116 | #endif | ||
117 | |||
118 | #ifndef PROTO | ||
119 | # ifndef UI | ||
120 | void FNAME(void) | ||
121 | { | ||
122 | ui_func_set(_key, _loop); | ||
123 | _setup(); | ||
124 | } | ||
125 | # endif | ||
126 | #endif | ||
127 | #undef FNAME | ||
128 | #undef NAME | ||
129 | #undef ICON | ||