summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-12-11 19:38:33 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-12-11 19:38:33 +0900
commitf214db5aa8bf0c71a46da424703493b507a83a03 (patch)
tree3cea6c14a5771deb71925223f33cfecb10057000
parente59f59bc58878c1bb55ddc0cca964f733fe527de (diff)
Rework the whole UI with Text/Textblock flip
Also, store all config in EET file. Somehow this isn't as robust as the old Elm_Entry auto save, but no idea what happens.
-rw-r--r--main.c570
1 files changed, 322 insertions, 248 deletions
diff --git a/main.c b/main.c
index 001bf55..3a50912 100644
--- a/main.c
+++ b/main.c
@@ -13,9 +13,6 @@
13#define PANE_V_TOP 30 13#define PANE_V_TOP 30
14#define PANE_H_LEFT 80 14#define PANE_H_LEFT 80
15 15
16const char *DEFAULT_STYLE = "blend(color=red);";
17const char *AUTOSAVE_FILE = "/tmp/textstyle.txt";
18const char *AUTOSAVE_CONTENT = "/tmp/textsample.txt";
19const char *AUTOSAVE_CONFIG = "/tmp/text_styles.cfg"; 16const char *AUTOSAVE_CONFIG = "/tmp/text_styles.cfg";
20 17
21#ifndef _ 18#ifndef _
@@ -30,11 +27,11 @@ Eo *textentry = NULL;
30Eo *paddinglbl = NULL; 27Eo *paddinglbl = NULL;
31Eo *proxies[IMAGE_COUNT] = { NULL }; 28Eo *proxies[IMAGE_COUNT] = { NULL };
32Eo *fsbuttons[IMAGE_COUNT] = { NULL }; 29Eo *fsbuttons[IMAGE_COUNT] = { NULL };
33Eo *textblock = NULL; 30Eo *textblockview = NULL;
31Eo *textblockeditor = NULL;
34Eo *size_spinner = NULL; 32Eo *size_spinner = NULL;
35Eo *frameflip = NULL; 33Eo *frameflip = NULL;
36Ecore_Timer *timer = NULL; 34Ecore_Timer *timer = NULL;
37static int flipcnt = 0;
38 35
39/* Example 1 36/* Example 1
40buffer(fire, src=image1); 37buffer(fire, src=image1);
@@ -47,28 +44,9 @@ blur(10, color=orange, oy=5);
47blur(2, color=white, oy=7); 44blur(2, color=white, oy=7);
48*/ 45*/
49 46
50static Eina_Bool 47static void _style_apply(void);
51_timer_cb(void *data) 48static void _entry_update(void);
52{ 49static void _markup_update(void);
53 Eo *flip = data;
54 elm_flip_go(flip, ELM_FLIP_CUBE_DOWN);
55 if (++flipcnt >= 2)
56 {
57 ecore_timer_del(timer);
58 timer = NULL;
59 return EINA_FALSE;
60 }
61 return EINA_TRUE;
62}
63
64static void
65_flip_play(void)
66{
67 if (flipcnt) flipcnt = 1;
68 if (timer) ecore_timer_reset(timer);
69 else timer = ecore_timer_add(1., _timer_cb, frameflip);
70 elm_flip_go(frameflip, ELM_FLIP_CUBE_DOWN);
71}
72 50
73static void 51static void
74_spacer_add(Eo *box) 52_spacer_add(Eo *box)
@@ -110,10 +88,15 @@ static void
110_config_reload(void) 88_config_reload(void)
111{ 89{
112 Eet_File *ef; 90 Eet_File *ef;
91 Eina_Bool b = EINA_TRUE;
92 void *data;
93 int size = 0;
94 char *utf8;
113 95
114 ef = eet_open(AUTOSAVE_CONFIG, EET_FILE_MODE_READ); 96 ef = eet_open(AUTOSAVE_CONFIG, EET_FILE_MODE_READ);
115 if (!ef) return; 97 if (!ef) return;
116 98
99 // Images
117 for (int k = 0; k < IMAGE_COUNT; k++) 100 for (int k = 0; k < IMAGE_COUNT; k++)
118 { 101 {
119 char *path; 102 char *path;
@@ -128,7 +111,46 @@ _config_reload(void)
128 } 111 }
129 } 112 }
130 113
114 // Flip side
115 data = eet_read(ef, "flipside", &size);
116 if (data)
117 {
118 b = *((Eina_Bool *) data);
119 elm_flip_go_to(frameflip, !b, ELM_FLIP_ROTATE_Y_CENTER_AXIS); // ugly
120 free(data);
121 }
122
123 // Text string
124 utf8 = eet_read(ef, "textentry", &size);
125 if (utf8)
126 {
127 elm_object_text_set(textentry, utf8);
128 free(utf8);
129 }
130
131 // Text style
132 utf8 = eet_read(ef, "styleentry", &size);
133 if (utf8)
134 {
135 elm_object_text_set(styleentry, utf8);
136 free(utf8);
137 }
138
139 // Textblock
140 utf8 = eet_read(ef, "textblockeditor", &size);
141 if (utf8)
142 {
143 char *markup = elm_entry_utf8_to_markup(utf8);
144 elm_object_text_set(textblockeditor, markup);
145 free(markup);
146 free(utf8);
147 }
148
131 eet_close(ef); 149 eet_close(ef);
150
151 _markup_update();
152 _entry_update();
153 _style_apply();
132} 154}
133 155
134static Eina_Bool 156static Eina_Bool
@@ -136,10 +158,16 @@ _config_save(void)
136{ 158{
137 Eet_File *ef; 159 Eet_File *ef;
138 Eina_Bool ok = EINA_TRUE; 160 Eina_Bool ok = EINA_TRUE;
161 char *utf8;
162 Eina_Bool b;
139 163
140 ef = eet_open(AUTOSAVE_CONFIG, EET_FILE_MODE_WRITE); 164 ef = eet_open(AUTOSAVE_CONFIG, EET_FILE_MODE_WRITE);
141 if (!ef) return EINA_FALSE; 165 if (!ef) return EINA_FALSE;
142 166
167 // NOTE: We could be cleaner and use eet_data_write,
168 // but I think that would require more coding
169
170 // Image paths
143 for (int k = 0; k < IMAGE_COUNT; k++) 171 for (int k = 0; k < IMAGE_COUNT; k++)
144 { 172 {
145 const char *path = NULL; 173 const char *path = NULL;
@@ -155,6 +183,34 @@ _config_save(void)
155 } 183 }
156 } 184 }
157 185
186 // Text string
187 utf8 = elm_entry_markup_to_utf8(elm_object_text_get(textentry));
188 if (utf8)
189 {
190 ok &= eet_write(ef, "textentry", utf8, strlen(utf8) + 1, 0);
191 free(utf8);
192 }
193
194 // Text style
195 utf8 = elm_entry_markup_to_utf8(elm_object_text_get(styleentry));
196 if (utf8)
197 {
198 ok &= eet_write(ef, "styleentry", utf8, strlen(utf8) + 1, 0);
199 free(utf8);
200 }
201
202 // Textblock markup
203 utf8 = elm_entry_markup_to_utf8(elm_object_text_get(textblockeditor));
204 if (utf8)
205 {
206 ok &= eet_write(ef, "textblockeditor", utf8, strlen(utf8) + 1, 0);
207 free(utf8);
208 }
209
210 // Current page
211 b = !elm_flip_front_visible_get(frameflip);
212 ok &= eet_write(ef, "flipside", &b, sizeof(b), 0);
213
158 eet_close(ef); 214 eet_close(ef);
159 return ok; 215 return ok;
160} 216}
@@ -224,22 +280,61 @@ _padding_update(void)
224} 280}
225 281
226static void 282static void
227_entry_update_cb(void *data EINA_UNUSED, 283_entry_update(void)
228 Evas_Object *eo, void *event EINA_UNUSED)
229{ 284{
230 const char *str; 285 const char *str;
231 286
232 str = elm_object_text_get(eo); 287 str = elm_object_text_get(textentry);
233 evas_object_text_text_set(textview, str); 288 evas_object_text_text_set(textview, str);
234 _padding_update(); 289 _padding_update();
235} 290}
236 291
237static void 292static void
293_entry_update_cb(void *data EINA_UNUSED,
294 Evas_Object *eo EINA_UNUSED, void *event EINA_UNUSED)
295{
296 _entry_update();
297}
298
299static void
300_textblock_update_cb(void *data EINA_UNUSED,
301 Evas_Object *eo, void *event EINA_UNUSED)
302{
303 const char *str;
304 char *markup;
305
306 str = elm_object_text_get(eo);
307 markup = elm_entry_utf8_to_markup(str);
308 if (!markup) return;
309 elm_object_text_set(textblockeditor, markup);
310 free(markup);
311}
312
313static void
314_markup_update(void)
315{
316 const char *str;
317 char *utf8;
318
319 str = elm_object_text_get(textblockeditor);
320 utf8 = elm_entry_markup_to_utf8(str);
321 if (!utf8) return;
322 elm_object_text_set(textblockview, utf8);
323 free(utf8);
324}
325
326static void
327_markup_update_cb(void *data EINA_UNUSED,
328 Evas_Object *eo EINA_UNUSED, void *event EINA_UNUSED)
329{
330 _markup_update();
331}
332
333static void
238_style_apply(void) 334_style_apply(void)
239{ 335{
240 const char *stylestr, *tbstr; 336 const char *stylestr;
241 char *stylestr_utf8, *tbstr_utf8, *tbstr_new; 337 char *stylestr_utf8;
242 int font_size;
243 338
244 stylestr = elm_object_text_get(styleentry); 339 stylestr = elm_object_text_get(styleentry);
245 stylestr_utf8 = elm_entry_markup_to_utf8(stylestr); 340 stylestr_utf8 = elm_entry_markup_to_utf8(stylestr);
@@ -253,19 +348,7 @@ _style_apply(void)
253 eo_do(textview, evas_obj_text_filter_object_bind(buf, proxies[k])); 348 eo_do(textview, evas_obj_text_filter_object_bind(buf, proxies[k]));
254 } 349 }
255 350
256 // Evas_Object_Textblock
257 font_size = elm_spinner_value_get(size_spinner);
258 tbstr = elm_object_text_get(textentry);
259 tbstr_utf8 = elm_entry_markup_to_utf8(tbstr);
260 for (int k = 0; stylestr_utf8[k]; k++)
261 if (stylestr_utf8[k] == '\n') stylestr_utf8[k] = ';';
262 tbstr_new = malloc(100 + strlen(tbstr_utf8) + strlen(stylestr_utf8));
263 sprintf(tbstr_new, "<style=off font_size=%d filter_chain='%s'>%s</style>",
264 font_size, stylestr_utf8, tbstr_utf8);
265 elm_object_text_set(textblock, tbstr_new);
266
267 free(stylestr_utf8); 351 free(stylestr_utf8);
268 free(tbstr_utf8);
269 352
270 _padding_update(); 353 _padding_update();
271} 354}
@@ -291,7 +374,6 @@ _apply_click_cb(void *data EINA_UNUSED,
291 void *event_info EINA_UNUSED) 374 void *event_info EINA_UNUSED)
292{ 375{
293 _style_apply(); 376 _style_apply();
294 _flip_play();
295} 377}
296 378
297static void 379static void
@@ -329,11 +411,7 @@ _entry_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
329 411
330 if (!strcmp(ev->key, "KP_Enter") || !strcmp(ev->key, "Return")) 412 if (!strcmp(ev->key, "KP_Enter") || !strcmp(ev->key, "Return"))
331 { 413 {
332 if (!down) 414 if (!down) _style_apply();
333 {
334 _style_apply();
335 _flip_play();
336 }
337 return EINA_TRUE; 415 return EINA_TRUE;
338 } 416 }
339 417
@@ -381,167 +459,216 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
381 evas = evas_object_evas_get(win); 459 evas = evas_object_evas_get(win);
382 evas_font_hinting_set(evas, EVAS_FONT_HINTING_AUTO); 460 evas_font_hinting_set(evas, EVAS_FONT_HINTING_AUTO);
383 461
384 // panes 462 // global UI margin
385 panes = elm_panes_add(win); 463 o = elm_frame_add(win);
386 evas_object_show(panes); 464 elm_object_style_set(o, "pad_large");
465 elm_win_resize_object_add(win, o);
466 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
467 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
468 evas_object_show(o);
387 469
470 // L/R panes: Edit + View / Proxies + Quit
471 panes = elm_panes_add(o);
472 evas_object_show(panes);
473 elm_object_part_content_set(o, "default", panes);
388 elm_panes_fixed_set(panes, EINA_FALSE); 474 elm_panes_fixed_set(panes, EINA_FALSE);
389 elm_panes_horizontal_set(panes, EINA_TRUE); 475 elm_panes_horizontal_set(panes, EINA_FALSE);
390
391 elm_win_resize_object_add(win, panes);
392 evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 476 evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
393 evas_object_size_hint_align_set(panes, EVAS_HINT_FILL, EVAS_HINT_FILL); 477 evas_object_size_hint_align_set(panes, EVAS_HINT_FILL, EVAS_HINT_FILL);
394 elm_panes_content_left_size_set(panes, (double) PANE_V_TOP / 100.0); 478 elm_panes_content_left_size_set(panes, (double) PANE_H_LEFT / 100.0);
395 479
396 // top pane: text 480 // Left pane: Frame
397 o = elm_frame_add(panes); 481 flip = elm_flip_add(panes);
398 elm_object_style_set(o, "pad_large");
399 evas_object_show(o);
400 elm_object_part_content_set(panes, "left", o);
401
402 flip = elm_flip_add(o);
403 elm_object_part_content_set(o, "default", flip);
404 evas_object_show(flip); 482 evas_object_show(flip);
405 evas_object_size_hint_weight_set(flip, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 483 evas_object_size_hint_weight_set(flip, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
406 evas_object_size_hint_align_set(flip, EVAS_HINT_FILL, EVAS_HINT_FILL); 484 evas_object_size_hint_align_set(flip, EVAS_HINT_FILL, EVAS_HINT_FILL);
407 elm_flip_interaction_set(flip, ELM_FLIP_INTERACTION_CUBE); 485 elm_flip_interaction_set(flip, ELM_FLIP_INTERACTION_ROTATE);
408 elm_flip_interaction_direction_enabled_set(flip, ELM_FLIP_DIRECTION_UP, EINA_TRUE); 486 elm_flip_interaction_direction_hitsize_set(flip, ELM_FLIP_DIRECTION_UP, 0.1);
409 elm_flip_interaction_direction_enabled_set(flip, ELM_FLIP_DIRECTION_DOWN, EINA_TRUE); 487 elm_flip_interaction_direction_hitsize_set(flip, ELM_FLIP_DIRECTION_LEFT, -1.0);
488 elm_flip_interaction_direction_hitsize_set(flip, ELM_FLIP_DIRECTION_RIGHT, -1.0);
410 elm_flip_interaction_direction_enabled_set(flip, ELM_FLIP_DIRECTION_LEFT, EINA_TRUE); 489 elm_flip_interaction_direction_enabled_set(flip, ELM_FLIP_DIRECTION_LEFT, EINA_TRUE);
411 elm_flip_interaction_direction_enabled_set(flip, ELM_FLIP_DIRECTION_RIGHT, EINA_TRUE); 490 elm_flip_interaction_direction_enabled_set(flip, ELM_FLIP_DIRECTION_RIGHT, EINA_TRUE);
412 elm_flip_interaction_direction_hitsize_set(flip, ELM_FLIP_DIRECTION_UP, 1); 491 elm_object_part_content_set(panes, "left", flip);
413 elm_flip_interaction_direction_hitsize_set(flip, ELM_FLIP_DIRECTION_DOWN, 1);
414 elm_flip_interaction_direction_hitsize_set(flip, ELM_FLIP_DIRECTION_LEFT, 1);
415 elm_flip_interaction_direction_hitsize_set(flip, ELM_FLIP_DIRECTION_RIGHT, 1);
416 frameflip = flip; 492 frameflip = flip;
417 493
418 // cube front 494 // Cube front: Evas_Object_Text + String entry + Style entry
419 { 495 {
496 // Frame with title
420 Eo *fr = elm_frame_add(flip); 497 Eo *fr = elm_frame_add(flip);
421 evas_object_show(fr); 498 evas_object_show(fr);
422 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 499 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
423 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL); 500 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
424 elm_object_style_set(fr, "default"); 501 elm_object_style_set(fr, "default");
425 elm_object_text_set(fr, "Evas_Object_Text"); 502 elm_object_text_set(fr, "Evas_Object_Text");
503 elm_object_part_content_set(flip, "front", fr);
426 504
505 // Split
506 panes2 = elm_panes_add(fr);
507 elm_panes_horizontal_set(panes2, EINA_TRUE);
508 elm_panes_fixed_set(panes2, EINA_FALSE);
509 evas_object_size_hint_weight_set(panes2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
510 evas_object_size_hint_align_set(panes2, EVAS_HINT_FILL, EVAS_HINT_FILL);
511 elm_panes_content_left_size_set(panes2, (double) PANE_V_TOP / 100.);
512 elm_object_part_content_set(fr, "default", panes2);
513
514 // Evas_Object_Text
515 o = evas_object_text_add(fr);
516 evas_object_show(o);
517 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
518 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
519 evas_object_text_font_set(o, FONT_NAME, FONT_SIZE);
520 evas_object_size_hint_align_set(o, 0.0, 0.0);
521 elm_object_part_content_set(panes2, "left", o);
522 textview = o;
523
524 // Vbox with: string + edit entries
427 vbox = elm_box_add(fr); 525 vbox = elm_box_add(fr);
428 evas_object_show(vbox); 526 elm_box_horizontal_set(vbox, EINA_FALSE);
429 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 527 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
430 evas_object_size_hint_align_set(vbox, EVAS_HINT_FILL, EVAS_HINT_FILL); 528 evas_object_size_hint_align_set(vbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
431 529 evas_object_show(vbox);
432 textview = evas_object_text_add(vbox); 530 elm_object_part_content_set(panes2, "right", vbox);
433 evas_object_show(textview); 531
434 evas_object_text_font_set(textview, FONT_NAME, FONT_SIZE); 532 // String entry
435 evas_object_size_hint_align_set(textview, 0.0, 0.0); 533 o = elm_entry_add(vbox);
436 elm_box_pack_end(vbox, textview); 534 evas_object_show(o);
437 535 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
438 _spacer_add(vbox); 536 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
439 537 elm_entry_scrollable_set(o, EINA_TRUE);
440 elm_object_part_content_set(fr, "default", vbox); 538 elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
441 elm_object_part_content_set(flip, "front", fr); 539 elm_entry_single_line_set(o, EINA_TRUE);
540 evas_object_smart_callback_add(o, "changed", _entry_update_cb, NULL);
541 elm_box_pack_end(vbox, o);
542 textentry = o;
543
544 // Style entry
545 o = elm_entry_add(vbox);
546 evas_object_show(o);
547 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
548 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
549 elm_entry_scrollable_set(o, EINA_TRUE);
550 elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
551 elm_entry_single_line_set(o, EINA_FALSE);
552 ok = evas_object_key_grab(o, "Return",
553 evas_key_modifier_mask_get(evas, "Control"),
554 0, EINA_TRUE);
555 if (!ok) fprintf(stderr, "Could not setup Ctrl+Return shortcut\n");
556 ok = evas_object_key_grab(o, "KP_Enter",
557 evas_key_modifier_mask_get(evas, "Control"),
558 0, EINA_TRUE);
559 if (!ok) fprintf(stderr, "Could not setup Ctrl+KP_Enter shortcut\n");
560 elm_object_event_callback_add(o, _entry_cb, NULL);
561 elm_box_pack_end(vbox, o);
562 styleentry = o;
563
564 // Escape to quit - grab doesn't work on 'panes'
565 ok = evas_object_key_grab(o, "Escape", 0, 0, EINA_TRUE);
566 if (!ok) fprintf(stderr, "Could not setup ESC shortcut\n");
567 else elm_object_event_callback_add(o, _panes_key_cb, NULL);
568
569 // Bottom: font size, padding info
570 hbox = elm_box_add(vbox);
571 evas_object_show(hbox);
572 elm_box_pack_end(vbox, hbox);
573 elm_box_horizontal_set(hbox, EINA_TRUE);
574 elm_box_padding_set(hbox, PADDING, PADDING);
575 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.0);
576 evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
577
578 // Size: label
579 o = elm_label_add(hbox);
580 evas_object_show(o);
581 elm_box_pack_end(hbox, o);
582 evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND);
583 evas_object_size_hint_align_set(o, 0.0, EVAS_HINT_FILL);
584 elm_object_text_set(o, _("Size:"));
585
586 // Font size spinner
587 o = elm_spinner_add(hbox);
588 evas_object_show(o);
589 elm_box_pack_end(hbox, o);
590 evas_object_size_hint_weight_set(o, 0.0, 0.0);
591 evas_object_size_hint_align_set(o, 0.0, 0.5);
592 elm_spinner_min_max_set(o, 6.0, 600.0);
593 elm_spinner_step_set(o, 1.0);
594 elm_spinner_value_set(o, FONT_SIZE);
595 elm_spinner_editable_set(o, EINA_TRUE);
596 elm_object_style_set(o, "vertical");
597 evas_object_smart_callback_add(o, "changed", _size_spinner_cb, NULL);
598 evas_object_smart_callback_call(o, "changed", NULL);
599 size_spinner = o;
600
601 // Apply button
602 o = elm_button_add(hbox);
603 evas_object_show(o);
604 elm_box_pack_end(hbox, o);
605 elm_object_text_set(o, _("Apply"));
606 evas_object_smart_callback_add(o, "clicked", _apply_click_cb, NULL);
607
608 // Padding label
609 o = elm_label_add(hbox);
610 evas_object_show(o);
611 elm_box_pack_end(hbox, o);
612 elm_object_text_set(o, _("Padding: "));
613 paddinglbl = o;
614
615 _spacer_add(hbox);
442 } 616 }
443 617
444 // cube back 618 // Cube back: Textblock and full markup editor
445 { 619 {
620 // Frame with title
446 Eo *fr = elm_frame_add(flip); 621 Eo *fr = elm_frame_add(flip);
447 evas_object_show(fr); 622 evas_object_show(fr);
448 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 623 evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
449 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL); 624 evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
450 elm_object_style_set(fr, "default"); 625 elm_object_style_set(fr, "default");
451 elm_object_text_set(fr, "Evas_Object_Textblock"); 626 elm_object_text_set(fr, "Evas_Object_Textblock");
452
453 textblock = elm_entry_add(fr);
454 evas_object_show(textblock);
455 evas_object_size_hint_weight_set(textblock, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
456 evas_object_size_hint_align_set(textblock, EVAS_HINT_FILL, EVAS_HINT_FILL);
457 elm_entry_scrollable_set(textblock, EINA_FALSE);
458 //elm_entry_scrollbar_policy_set(textblock, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
459 elm_entry_editable_set(textblock, EINA_FALSE);
460 evas_object_repeat_events_set(textblock, EINA_TRUE);
461 elm_object_part_content_set(fr, "default", textblock);
462
463 elm_object_part_content_set(flip, "back", fr); 627 elm_object_part_content_set(flip, "back", fr);
464 }
465
466 // helper popup
467 //elm_object_tooltip_text_set(flip, "Drag this frame to switch between Text and Textblock");
468 628
469 // bottom pane: another pane 629 // Split
470 o = elm_frame_add(panes); 630 panes2 = elm_panes_add(fr);
471 elm_object_style_set(o, "pad_large"); 631 elm_panes_horizontal_set(panes2, EINA_TRUE);
472 evas_object_show(o); 632 elm_panes_fixed_set(panes2, EINA_FALSE);
473 elm_object_part_content_set(panes, "right", o); 633 evas_object_size_hint_weight_set(panes2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
474 634 evas_object_size_hint_align_set(panes2, EVAS_HINT_FILL, EVAS_HINT_FILL);
475 vbox = elm_box_add(panes); 635 elm_panes_content_left_size_set(panes2, (double) PANE_V_TOP / 100.);
476 elm_object_part_content_set(o, "default", vbox); 636 elm_object_part_content_set(fr, "default", panes2);
477 637
478 evas_object_show(vbox); 638 // Textblock view
479 evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 639 o = elm_entry_add(vbox);
480 evas_object_size_hint_align_set(vbox, EVAS_HINT_FILL, EVAS_HINT_FILL); 640 evas_object_show(o);
481 elm_box_horizontal_set(vbox, EINA_FALSE); 641 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
482 elm_box_padding_set(vbox, PADDING, PADDING); 642 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
643 elm_entry_editable_set(o, EINA_TRUE);
644 elm_entry_single_line_set(o, EINA_FALSE);
645 elm_entry_scrollable_set(o, EINA_TRUE);
646 elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
647 evas_object_smart_callback_add(o, "changed,user", _textblock_update_cb, NULL);
648 elm_object_part_content_set(panes2, "left", o);
649 textblockview = o;
650
651 // Textblock editor
652 o = elm_entry_add(vbox);
653 evas_object_show(o);
654 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
655 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
656 elm_entry_editable_set(o, EINA_TRUE);
657 elm_entry_single_line_set(o, EINA_FALSE);
658 elm_entry_scrollable_set(o, EINA_TRUE);
659 elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
660 evas_object_smart_callback_add(o, "changed,user", _markup_update_cb, NULL);
661 elm_object_part_content_set(panes2, "right", o);
662 textblockeditor = o;
663 }
483 664
484 o = elm_entry_add(vbox); 665 // Object selector: right side of panes
485 evas_object_show(o); 666 vb = elm_box_add(panes);
486 elm_box_pack_start(vbox, o);
487 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
488 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
489 elm_entry_scrollable_set(o, EINA_TRUE);
490 elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
491 elm_entry_single_line_set(o, EINA_TRUE);
492 evas_object_smart_callback_add(o, "changed", _entry_update_cb, NULL);
493 textentry = o;
494
495 elm_entry_file_set(o, AUTOSAVE_CONTENT, ELM_TEXT_FORMAT_PLAIN_UTF8);
496 elm_entry_autosave_set(o, EINA_TRUE);
497
498 if ((f = eina_file_open(AUTOSAVE_CONTENT, EINA_FALSE)) != NULL)
499 eina_file_close(f);
500 else
501 elm_object_text_set(o, _("Text entry with some effects"));
502
503 // teh second pane is here
504 panes2 = elm_panes_add(o);
505 evas_object_show(panes2);
506 elm_panes_fixed_set(panes2, EINA_FALSE);
507 elm_panes_horizontal_set(panes2, EINA_FALSE);
508 evas_object_size_hint_weight_set(panes2, EVAS_HINT_EXPAND, 0.5);
509 evas_object_size_hint_align_set(panes2, EVAS_HINT_FILL, EVAS_HINT_FILL);
510 elm_panes_content_left_size_set(panes2, (double) PANE_H_LEFT / 100.0);
511 elm_box_pack_end(vbox, panes2);
512
513 // Style sheet: left side of panes2
514 o = elm_entry_add(vbox);
515 evas_object_show(o);
516 elm_object_part_content_set(panes2, "left", o);
517 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
518 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
519 elm_entry_scrollable_set(o, EINA_TRUE);
520 elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
521 elm_entry_single_line_set(o, EINA_FALSE);
522 ok = evas_object_key_grab(o, "Return",
523 evas_key_modifier_mask_get(evas, "Control"),
524 0, EINA_TRUE);
525 if (!ok) fprintf(stderr, "Could not setup Ctrl+Return shortcut\n");
526 ok = evas_object_key_grab(o, "KP_Enter",
527 evas_key_modifier_mask_get(evas, "Control"),
528 0, EINA_TRUE);
529 if (!ok) fprintf(stderr, "Could not setup Ctrl+KP_Enter shortcut\n");
530 elm_object_event_callback_add(o, _entry_cb, NULL);
531 styleentry = o;
532
533 // Escape to quit - grab doesn't work on 'panes'
534 ok = evas_object_key_grab(o, "Escape", 0, 0, EINA_TRUE);
535 if (!ok) fprintf(stderr, "Could not setup ESC shortcut\n");
536 else elm_object_event_callback_add(o, _panes_key_cb, NULL);
537
538 // Object selector: right side of panes2
539 vb = elm_box_add(vbox);
540 evas_object_show(vb); 667 evas_object_show(vb);
541 elm_box_horizontal_set(vb, EINA_FALSE); 668 elm_box_horizontal_set(vb, EINA_FALSE);
542 elm_box_padding_set(vb, PADDING, PADDING); 669 elm_box_padding_set(vb, PADDING, PADDING);
543 evas_object_size_hint_align_set(vb, EVAS_HINT_FILL, EVAS_HINT_FILL); 670 evas_object_size_hint_align_set(vb, EVAS_HINT_FILL, EVAS_HINT_FILL);
544 elm_object_part_content_set(panes2, "right", vb); 671 elm_object_part_content_set(panes, "right", vb);
545 672
546 for (int k = 0; k < IMAGE_COUNT; k++) 673 for (int k = 0; k < IMAGE_COUNT; k++)
547 { 674 {
@@ -585,7 +712,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
585 elm_table_pack(tbl, o, 0, 0, 1, 1); 712 elm_table_pack(tbl, o, 0, 0, 1, 1);
586 fsbuttons[k] = o; 713 fsbuttons[k] = o;
587 714
588 // invisible mouse event rect on top 715 // Invisible mouse event rect on top
589 o = evas_object_rectangle_add(evas); 716 o = evas_object_rectangle_add(evas);
590 evas_object_show(o); 717 evas_object_show(o);
591 evas_object_color_set(o, 0, 0, 0, 0); 718 evas_object_color_set(o, 0, 0, 0, 0);
@@ -594,81 +721,31 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
594 evas_object_size_hint_min_set(o, 50, 50); 721 evas_object_size_hint_min_set(o, 50, 50);
595 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _proxy_frame_mouse_in_event_cb, (void*)(intptr_t)k); 722 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _proxy_frame_mouse_in_event_cb, (void*)(intptr_t)k);
596 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _proxy_frame_mouse_out_event_cb, (void*)(intptr_t)k); 723 evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _proxy_frame_mouse_out_event_cb, (void*)(intptr_t)k);
597 //evas_object_propagate_events_set(o, EINA_TRUE);
598 evas_object_repeat_events_set(o, EINA_TRUE); 724 evas_object_repeat_events_set(o, EINA_TRUE);
599 elm_table_pack(tbl, o, 0, 0, 1, 1); 725 elm_table_pack(tbl, o, 0, 0, 1, 1);
600 } 726 }
601 727
602 // Bottom: font size, padding info and Quit 728 // Reset & Quit: Bottom of the proxy bar
603 hbox = elm_box_add(vbox); 729 {
604 evas_object_show(hbox); 730 hbox = elm_box_add(vb);
605 elm_box_pack_end(vbox, hbox); 731 evas_object_show(hbox);
606 elm_box_horizontal_set(hbox, EINA_TRUE); 732 elm_box_horizontal_set(hbox, EINA_TRUE);
607 elm_box_padding_set(hbox, PADDING, PADDING); 733 elm_box_pack_end(vb, hbox);
608 evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, 0.0); 734
609 evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL); 735 // Reset button
610 736 o = elm_button_add(hbox);
611 // Size: label 737 evas_object_show(o);
612 o = elm_label_add(hbox); 738 elm_box_pack_end(hbox, o);
613 evas_object_show(o); 739 elm_object_text_set(o, _("Reset images"));
614 elm_box_pack_end(hbox, o); 740 evas_object_smart_callback_add(o, "clicked", _reset_click_cb, NULL);
615 evas_object_size_hint_weight_set(o, 0.0, EVAS_HINT_EXPAND); 741
616 evas_object_size_hint_align_set(o, 0.0, EVAS_HINT_FILL); 742 // Quit button
617 elm_object_text_set(o, _("Size:")); 743 o = elm_button_add(hbox);
618 744 evas_object_show(o);
619 // Font size spinner 745 elm_box_pack_end(hbox, o);
620 o = elm_spinner_add(hbox); 746 elm_object_text_set(o, _("Quit"));
621 evas_object_show(o); 747 evas_object_smart_callback_add(o, "clicked", _quit_click_cb, NULL);
622 elm_box_pack_end(hbox, o); 748 }
623 evas_object_size_hint_weight_set(o, 0.0, 0.0);
624 evas_object_size_hint_align_set(o, 0.0, 0.5);
625 elm_spinner_min_max_set(o, 6.0, 600.0);
626 elm_spinner_step_set(o, 1.0);
627 elm_spinner_value_set(o, FONT_SIZE);
628 elm_spinner_editable_set(o, EINA_TRUE);
629 elm_object_style_set(o, "vertical");
630 evas_object_smart_callback_add(o, "changed", _size_spinner_cb, NULL);
631 evas_object_smart_callback_call(o, "changed", NULL);
632 size_spinner = o;
633
634 // Apply button
635 o = elm_button_add(hbox);
636 evas_object_show(o);
637 elm_box_pack_end(hbox, o);
638 elm_object_text_set(o, _("Apply"));
639 evas_object_smart_callback_add(o, "clicked", _apply_click_cb, NULL);
640
641 // Padding label
642 o = elm_label_add(hbox);
643 evas_object_show(o);
644 elm_box_pack_end(hbox, o);
645 elm_object_text_set(o, _("Padding: "));
646 paddinglbl = o;
647
648 _spacer_add(hbox);
649
650 // Reset button
651 o = elm_button_add(hbox);
652 evas_object_show(o);
653 elm_box_pack_end(hbox, o);
654 elm_object_text_set(o, _("Reset images"));
655 evas_object_smart_callback_add(o, "clicked", _reset_click_cb, NULL);
656
657 // Quit button
658 o = elm_button_add(hbox);
659 evas_object_show(o);
660 elm_box_pack_end(hbox, o);
661 elm_object_text_set(o, _("Quit"));
662 evas_object_smart_callback_add(o, "clicked", _quit_click_cb, NULL);
663
664 // Auto save file
665 elm_entry_file_set(styleentry, AUTOSAVE_FILE, ELM_TEXT_FORMAT_PLAIN_UTF8);
666 elm_entry_autosave_set(styleentry, EINA_TRUE);
667
668 if ((f = eina_file_open(AUTOSAVE_FILE, EINA_FALSE)) != NULL)
669 eina_file_close(f);
670 else
671 elm_object_text_set(styleentry, DEFAULT_STYLE);
672 749
673 // Reload config 750 // Reload config
674 _config_reload(); 751 _config_reload();
@@ -676,9 +753,6 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
676 // Apply default style 753 // Apply default style
677 _style_apply(); 754 _style_apply();
678 755
679 // Add some animation at the beginning: switch to Textblock view after 1s
680 _flip_play();
681
682 elm_run(); 756 elm_run();
683 757
684 // Save config 758 // Save config