summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-05-28 18:33:40 +0300
committerYakov Goldberg <yakov.g@samsung.com>2014-05-28 18:33:40 +0300
commit79e44fd178d6784b05745733e2e1dff0837de6eb (patch)
tree1213d48e50b137ebb65cd0a05b55ee09073e993b
parent6c10b6bb60e3578c7752c2b271f901a37efba2ab (diff)
add fileselector for image resources
-rw-r--r--TODO2
-rw-r--r--src/bin/egui_gui/egui_layout_c.json27
-rw-r--r--src/bin/egui_gui/egui_layout_h.json1
-rw-r--r--src/bin/egui_gui/rmview.c155
4 files changed, 137 insertions, 48 deletions
diff --git a/TODO b/TODO
index 78fd982..a206454 100644
--- a/TODO
+++ b/TODO
@@ -60,8 +60,6 @@ Fixes:
60 - Resize sub-windows according to application resolution 60 - Resize sub-windows according to application resolution
61 - Don't propagate events when selecting widget 61 - Don't propagate events when selecting widget
62- refactor _callbacks_expand (propview.c) 62- refactor _callbacks_expand (propview.c)
63- why the resource name is needed in the resource manager? Could be calculated easily.
64- why there is no file selector for the images? it seems weird to have to type the path.
65 63
66Improvements: 64Improvements:
67------------ 65------------
diff --git a/src/bin/egui_gui/egui_layout_c.json b/src/bin/egui_gui/egui_layout_c.json
index 37f4362..f1517ca 100644
--- a/src/bin/egui_gui/egui_layout_c.json
+++ b/src/bin/egui_gui/egui_layout_c.json
@@ -420,6 +420,7 @@ _create_rm_win()
420 Eo *rm_value_entry; 420 Eo *rm_value_entry;
421 Eo *rm_cb_type_hoversel; 421 Eo *rm_cb_type_hoversel;
422 Eo *rm_seq_pub_check; 422 Eo *rm_seq_pub_check;
423 Eo *rm_image_fileselector;
423 Eo *rm_button_add; 424 Eo *rm_button_add;
424 425
425/* @egui 426/* @egui
@@ -743,6 +744,32 @@ _create_rm_win()
743 eo_do(rm_cb_type_hoversel, elm_obj_hoversel_hover_parent_set(rm_win)); 744 eo_do(rm_cb_type_hoversel, elm_obj_hoversel_hover_parent_set(rm_win));
744/* @egui 745/* @egui
745{ 746{
747 "rm_image_fileselector":
748 {
749 "Desc":
750 {
751 "parent":"rm_buttons_box",
752 "class":"Elm_Fileselector_Entry",
753 "public":true,
754 "type":"widget"
755 },
756 "Properties":
757 {
758 "size_hint_weight":[1, 1],
759 "size_hint_align":[-1, 0],
760 "part_text":[null, "..."]
761 }
762 }
763 }
764@!egui */
765 rm_image_fileselector = eo_add(ELM_OBJ_FILESELECTOR_ENTRY_CLASS, rm_buttons_box);
766 eo_unref(rm_image_fileselector);
767 pub_widgets.rm_image_fileselector = rm_image_fileselector;
768 eo_do(rm_image_fileselector, evas_obj_size_hint_weight_set(1, 0.0));
769 eo_do(rm_image_fileselector, evas_obj_size_hint_align_set(EVAS_HINT_FILL, 0));
770 eo_do(rm_image_fileselector, elm_obj_widget_part_text_set(NULL, "..."));
771/* @egui
772{
746 "rm_button_add": 773 "rm_button_add":
747 { 774 {
748 "Desc": 775 "Desc":
diff --git a/src/bin/egui_gui/egui_layout_h.json b/src/bin/egui_gui/egui_layout_h.json
index e3683e1..102a93d 100644
--- a/src/bin/egui_gui/egui_layout_h.json
+++ b/src/bin/egui_gui/egui_layout_h.json
@@ -15,6 +15,7 @@ typedef struct
15 Eo *rm_value_entry; 15 Eo *rm_value_entry;
16 Eo *rm_cb_type_hoversel; 16 Eo *rm_cb_type_hoversel;
17 Eo *rm_seq_pub_check; 17 Eo *rm_seq_pub_check;
18 Eo *rm_image_fileselector;
18 Eo *rm_button_add; 19 Eo *rm_button_add;
19 Eo *main_win; 20 Eo *main_win;
20 Eo *canvas_bg; 21 Eo *canvas_bg;
diff --git a/src/bin/egui_gui/rmview.c b/src/bin/egui_gui/rmview.c
index c0a4ed1..4d76d9f 100644
--- a/src/bin/egui_gui/rmview.c
+++ b/src/bin/egui_gui/rmview.c
@@ -10,6 +10,7 @@
10#include "elm_widget.h" 10#include "elm_widget.h"
11#include "elm_widget_container.h" 11#include "elm_widget_container.h"
12#include "elm_interface_scrollable.h" 12#include "elm_interface_scrollable.h"
13#include "elm_interface_fileselector.h"
13 14
14#define _STR_RMVIEW "rmview" 15#define _STR_RMVIEW "rmview"
15 16
@@ -98,6 +99,20 @@ _rmview_entry_add(Eo *parent, const char* str)
98} 99}
99 100
100static Eo* 101static Eo*
102_rmview_fs_entry_add(Eo *parent, const char* str)
103{
104 Eo *en;
105 en = eo_add(ELM_OBJ_FILESELECTOR_ENTRY_CLASS, parent);
106 eo_unref(en);
107 eo_do(en,
108 evas_obj_size_hint_weight_set(1, 0.0),
109 evas_obj_size_hint_align_set(EVAS_HINT_FILL, 0),
110 elm_obj_widget_part_text_set(NULL, str),
111 evas_obj_visibility_set(EINA_TRUE));
112 return en;
113}
114
115static Eo*
101_rmview_button_add(Eo *parent, const char* str) 116_rmview_button_add(Eo *parent, const char* str)
102{ 117{
103 Eo *bt; 118 Eo *bt;
@@ -156,6 +171,21 @@ _res_changed(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc E
156 /* Toggle bit, in order to know if change needed */ 171 /* Toggle bit, in order to know if change needed */
157 f_data->it_data->changed ^= (1 << 1); 172 f_data->it_data->changed ^= (1 << 1);
158 } 173 }
174 else if (res_type == RESOURCE_IMAGE)
175 {
176 entry_field = f_data->it_data->en2;
177 eo_do(entry_field, str = elm_interface_fileselector_path_get());
178 res_str = resource_value_get(f_data->it_data->res);
179 /* Set bit, in order to know if change needed */
180 if (strcmp(str, res_str))
181 {
182 f_data->it_data->changed |= (1 << 1);
183 }
184 else
185 {
186 f_data->it_data->changed &= ~(1 << 1);
187 }
188 }
159 else 189 else
160 { 190 {
161 entry_field = f_data->it_data->en2; 191 entry_field = f_data->it_data->en2;
@@ -215,6 +245,14 @@ _bt_save_clicked(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *de
215 Gui_Sequence *seq = sequence_get(ctx, seq_id); 245 Gui_Sequence *seq = sequence_get(ctx, seq_id);
216 sequence_public_set(seq, state); 246 sequence_public_set(seq, state);
217 } 247 }
248 else if (res_type == RESOURCE_IMAGE)
249 {
250 eo_do(f_data->it_data->en2, str = elm_interface_fileselector_path_get());
251 if (strlen(str))
252 {
253 resource_value_set(res, str);
254 }
255 }
218 else 256 else
219 { 257 {
220 eo_do(f_data->it_data->en2, str = elm_obj_widget_part_text_get(NULL)); 258 eo_do(f_data->it_data->en2, str = elm_obj_widget_part_text_get(NULL));
@@ -368,12 +406,23 @@ _rmview_build(Rmview_Resource_Type type)
368 } 406 }
369 case RESOURCE_IMAGE: 407 case RESOURCE_IMAGE:
370 { 408 {
409 /*
371 en = _rmview_entry_add(g->rm_table, value); 410 en = _rmview_entry_add(g->rm_table, value);
372 it_data->en2 = en; 411 it_data->en2 = en;
373 eo_do(g->rm_table, elm_obj_table_pack(en, table_col++, table_line, 1, 1)); 412 eo_do(g->rm_table, elm_obj_table_pack(en, table_col++, table_line, 1, 1));
374 data = RMVIEW_FIELD_DATA_BUILD(1, it_data); 413 data = RMVIEW_FIELD_DATA_BUILD(1, it_data);
375 eo_do(en, eo_key_data_set(_STR_RMVIEW, data, _field_data_free)); 414 eo_do(en, eo_key_data_set(_STR_RMVIEW, data, _field_data_free));
376 eo_do(en, eo_event_callback_add(ELM_ENTRY_EVENT_CHANGED_USER, _res_changed, NULL)); 415 eo_do(en, eo_event_callback_add(ELM_ENTRY_EVENT_CHANGED_USER, _res_changed, NULL));
416 */
417
418 en = _rmview_fs_entry_add(g->rm_table, "...");
419 eo_do(en, elm_interface_fileselector_path_set(value));
420
421 it_data->en2 = en;
422 eo_do(g->rm_table, elm_obj_table_pack(en, table_col++, table_line, 1, 1));
423 data = RMVIEW_FIELD_DATA_BUILD(1, it_data);
424 eo_do(en, eo_key_data_set(_STR_RMVIEW, data, _field_data_free));
425 eo_do(en, eo_event_callback_add(ELM_FILESELECTOR_ENTRY_EVENT_CHANGED, _res_changed, NULL));
377 break; 426 break;
378 } 427 }
379 case RESOURCE_SEQUENCE: 428 case RESOURCE_SEQUENCE:
@@ -425,6 +474,53 @@ _rmview_build(Rmview_Resource_Type type)
425 table_line++; 474 table_line++;
426 } 475 }
427 } 476 }
477 /* Adding last line of buttons to add new resources. */
478 {
479 eo_do(g->rm_buttons_box, elm_obj_box_unpack_all());
480 eo_do(g->rm_buttons_box, elm_obj_box_pack_end(g->rm_alias_entry));
481
482 eo_do(g->rm_value_entry, evas_obj_visibility_set(EINA_FALSE));
483 eo_do(g->rm_seq_pub_check, evas_obj_visibility_set(EINA_FALSE));
484 eo_do(g->rm_cb_type_hoversel, evas_obj_visibility_set(EINA_FALSE));
485 eo_do(g->rm_image_fileselector, evas_obj_visibility_set(EINA_FALSE));
486
487 switch (_rmview_toolbar_selected_type )
488 {
489 case RMVIEW_IMAGE:
490 {
491 eo_do(g->rm_image_fileselector, evas_obj_visibility_set(EINA_TRUE));
492 eo_do(g->rm_buttons_box, elm_obj_box_pack_end(g->rm_image_fileselector));
493 break;
494 }
495 case RMVIEW_CALLBACK:
496 {
497 eo_do(g->rm_value_entry, evas_obj_visibility_set(EINA_TRUE));
498 eo_do(g->rm_cb_type_hoversel, evas_obj_visibility_set(EINA_TRUE));
499 eo_do(g->rm_buttons_box, elm_obj_box_pack_end(g->rm_value_entry));
500 eo_do(g->rm_buttons_box, elm_obj_box_pack_end(g->rm_cb_type_hoversel));
501 break;
502 }
503 case RMVIEW_SEQUENCE:
504 {
505 eo_do(g->rm_seq_pub_check, evas_obj_visibility_set(EINA_TRUE));
506 eo_do(g->rm_value_entry, evas_obj_visibility_set(EINA_FALSE));
507 eo_do(g->rm_buttons_box, elm_obj_box_pack_end(g->rm_seq_pub_check));
508 break;
509 }
510 case RMVIEW_STRING:
511 {
512 eo_do(g->rm_value_entry, evas_obj_visibility_set(EINA_TRUE));
513 eo_do(g->rm_buttons_box, elm_obj_box_pack_end(g->rm_value_entry));
514 break;
515 }
516 default:
517 {
518 ERR("switch - default: %d", _rmview_toolbar_selected_type);
519 }
520 }
521
522 eo_do(g->rm_buttons_box, elm_obj_box_pack_end(g->rm_button_add));
523 }
428} 524}
429 525
430/* Delete window callback. */ 526/* Delete window callback. */
@@ -439,55 +535,11 @@ static void
439_rmview_toolbar_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 535_rmview_toolbar_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
440{ 536{
441 Rmview_Resource_Type type = (int) (intptr_t) data; 537 Rmview_Resource_Type type = (int) (intptr_t) data;
442 GUI *_g = get_gui();
443 538
444 if (_rmview_toolbar_selected_type == type) 539 if (_rmview_toolbar_selected_type == type)
445 return; 540 return;
446 _rmview_toolbar_selected_type = type; 541 _rmview_toolbar_selected_type = type;
447 542
448
449
450 eo_do(_g->rm_buttons_box, elm_obj_box_unpack_all());
451 eo_do(_g->rm_buttons_box, elm_obj_box_pack_end(_g->rm_alias_entry));
452 eo_do(_g->rm_value_entry, evas_obj_visibility_set(EINA_TRUE));
453
454
455 eo_do(_g->rm_seq_pub_check, evas_obj_visibility_set(EINA_FALSE));
456 eo_do(_g->rm_cb_type_hoversel, evas_obj_visibility_set(EINA_FALSE));
457
458 switch (_rmview_toolbar_selected_type )
459 {
460 case RMVIEW_IMAGE:
461 {
462 eo_do(_g->rm_buttons_box, elm_obj_box_pack_end(_g->rm_value_entry));
463 break;
464 }
465 case RMVIEW_CALLBACK:
466 {
467 eo_do(_g->rm_cb_type_hoversel, evas_obj_visibility_set(EINA_TRUE));
468 eo_do(_g->rm_buttons_box, elm_obj_box_pack_end(_g->rm_value_entry));
469 eo_do(_g->rm_buttons_box, elm_obj_box_pack_end(_g->rm_cb_type_hoversel));
470 break;
471 }
472 case RMVIEW_SEQUENCE:
473 {
474 eo_do(_g->rm_seq_pub_check, evas_obj_visibility_set(EINA_TRUE));
475 eo_do(_g->rm_value_entry, evas_obj_visibility_set(EINA_FALSE));
476 eo_do(_g->rm_buttons_box, elm_obj_box_pack_end(_g->rm_seq_pub_check));
477 break;
478 }
479 case RMVIEW_STRING:
480 {
481 eo_do(_g->rm_buttons_box, elm_obj_box_pack_end(_g->rm_value_entry));
482 break;
483 }
484 default:
485 {
486 ERR("switch - default: %d", _rmview_toolbar_selected_type);
487 }
488 }
489
490 eo_do(_g->rm_buttons_box, elm_obj_box_pack_end(_g->rm_button_add));
491 _rmview_build(type); 543 _rmview_build(type);
492} 544}
493 545
@@ -500,9 +552,8 @@ _rm_add_button_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Eve
500 const char *alias_str = NULL, *value_str = NULL; 552 const char *alias_str = NULL, *value_str = NULL;
501 const Gui_Context *ctx = _active_context_get(); 553 const Gui_Context *ctx = _active_context_get();
502 eo_do(_g->rm_alias_entry, alias_str = elm_obj_widget_part_text_get(NULL)); 554 eo_do(_g->rm_alias_entry, alias_str = elm_obj_widget_part_text_get(NULL));
503 eo_do(_g->rm_value_entry, value_str = elm_obj_widget_part_text_get(NULL));
504 555
505 if (!strlen(alias_str) || (!strlen(value_str) && _rmview_toolbar_selected_type != RMVIEW_SEQUENCE)) 556 if (!strlen(alias_str))
506 return EO_CALLBACK_CONTINUE; 557 return EO_CALLBACK_CONTINUE;
507 558
508 if (gui_context_dep_data_get_id_by_name(ctx, alias_str)) 559 if (gui_context_dep_data_get_id_by_name(ctx, alias_str))
@@ -554,6 +605,13 @@ _rm_add_button_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Eve
554 } 605 }
555 } 606 }
556 607
608 if ((res_type != RESOURCE_SEQUENCE) && (res_type != RESOURCE_IMAGE))
609 {
610 eo_do(_g->rm_value_entry, value_str = elm_obj_widget_part_text_get(NULL));
611 if (!strlen(value_str))
612 return EO_CALLBACK_CONTINUE;
613 }
614
557 gui_res = gui_context_resource_new((Gui_Context *) ctx, res_type, alias_str); 615 gui_res = gui_context_resource_new((Gui_Context *) ctx, res_type, alias_str);
558 if (!gui_res) 616 if (!gui_res)
559 { 617 {
@@ -570,6 +628,11 @@ _rm_add_button_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Eve
570 sequence_public_set(seq, state); 628 sequence_public_set(seq, state);
571 seqview_fill(ctx); 629 seqview_fill(ctx);
572 } 630 }
631 else if (res_type == RESOURCE_IMAGE)
632 {
633 eo_do(_g->rm_image_fileselector, value_str = elm_interface_fileselector_path_get());
634 resource_value_set(gui_res, value_str);
635 }
573 else 636 else
574 { 637 {
575 resource_value_set(gui_res, value_str); 638 resource_value_set(gui_res, value_str);