summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-01 20:32:04 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-01 20:32:04 +0100
commit944c7f2e652e5e74ed276b53cd5a208075673ea1 (patch)
tree646696bc0776baf5f5e53456808eb0bbef77f54a
parenteb40486b9587e6e3ba0274a9a3409fe12dce1ded (diff)
editor: support changing ui name
-rw-r--r--src/efl_ui_editor/abstract_tree_controller.c8
-rw-r--r--src/efl_ui_editor/base_ui.c6
-rw-r--r--src/efl_ui_editor/base_ui.eflui102
-rw-r--r--src/efl_ui_editor/main.h3
-rw-r--r--src/efl_ui_editor/value_change_text_ui.eflui47
-rw-r--r--src/efl_ui_editor/value_change_ui.c20
-rw-r--r--src/lib/Efl_Ui_Format.h3
-rw-r--r--src/lib/abstract_tree.c6
-rw-r--r--src/lib/abstract_tree.h2
9 files changed, 117 insertions, 80 deletions
diff --git a/src/efl_ui_editor/abstract_tree_controller.c b/src/efl_ui_editor/abstract_tree_controller.c
index f9ddb7a..9d50438 100644
--- a/src/efl_ui_editor/abstract_tree_controller.c
+++ b/src/efl_ui_editor/abstract_tree_controller.c
@@ -338,3 +338,11 @@ change_part_details(Efl_Ui_Node *n, const char *new_details)
338 base_ui_refresh(ui_tree); 338 base_ui_refresh(ui_tree);
339 display_ui_refresh(ui_tree); 339 display_ui_refresh(ui_tree);
340} 340}
341
342void
343change_ui_name(const char *name)
344{
345 efl_ui_name_set(ui_tree, name);
346 base_ui_refresh(ui_tree);
347 display_ui_refresh(ui_tree);
348}
diff --git a/src/efl_ui_editor/base_ui.c b/src/efl_ui_editor/base_ui.c
index cef6f34..f58fd05 100644
--- a/src/efl_ui_editor/base_ui.c
+++ b/src/efl_ui_editor/base_ui.c
@@ -51,6 +51,7 @@ static Eina_Value \
51API_NAME ##_delivery_cb(void *data, const Eina_Value value, const Eina_Future *f) \ 51API_NAME ##_delivery_cb(void *data, const Eina_Value value, const Eina_Future *f) \
52{ \ 52{ \
53 T *stack = data; \ 53 T *stack = data; \
54 (void) stack; \
54 if (eina_value_type_get(&value) != EINA_VALUE_TYPE_ERROR) \ 55 if (eina_value_type_get(&value) != EINA_VALUE_TYPE_ERROR) \
55 { \ 56 { \
56 const char *name; \ 57 const char *name; \
@@ -67,6 +68,9 @@ API_NAME ##_cb (void *data, const Efl_Event *ev) \
67 eina_future_then(f, API_NAME ##_delivery_cb, stack); \ 68 eina_future_then(f, API_NAME ##_delivery_cb, stack); \
68} 69}
69 70
71//called when a new value is set to a parameter
72UI_FEATURE(_change_ui_name, change_ui_name(name), change_string_name(efl_ui_name_get(ui_tree), ev->object), void)
73
70UI_FEATURE(_change_linear_details, change_linear_details(stack->tnode, name), linear_change_ui(stack->tnode, ev->object), Local_Stack); 74UI_FEATURE(_change_linear_details, change_linear_details(stack->tnode, name), linear_change_ui(stack->tnode, ev->object), Local_Stack);
71UI_FEATURE(_change_table_details, change_table_details(stack->tnode, name), table_change_ui(stack->tnode, ev->object), Local_Stack); 75UI_FEATURE(_change_table_details, change_table_details(stack->tnode, name), table_change_ui(stack->tnode, ev->object), Local_Stack);
72UI_FEATURE(_change_part_details, change_part_details(stack->tnode, name), part_change_ui(stack->tnode, ev->object), Local_Stack); 76UI_FEATURE(_change_part_details, change_part_details(stack->tnode, name), part_change_ui(stack->tnode, ev->object), Local_Stack);
@@ -466,7 +470,7 @@ base_ui_init(Efl_Ui_Win *win)
466 base_ui = base_ui_gen(win); 470 base_ui = base_ui_gen(win);
467 efl_content_set(win, base_ui->root); 471 efl_content_set(win, base_ui->root);
468 efl_event_callback_add(base_ui->save, EFL_INPUT_EVENT_CLICKED, _save_cb, NULL); 472 efl_event_callback_add(base_ui->save, EFL_INPUT_EVENT_CLICKED, _save_cb, NULL);
469 efl_ui_widget_disabled_set(base_ui->refresh, EINA_TRUE); 473 efl_event_callback_add(base_ui->ui_name, EFL_INPUT_EVENT_CLICKED, _change_ui_name_cb, NULL);
470 efl_event_callback_add(win, EFL_EVENT_INVALIDATE, _win_gone_cb, NULL); 474 efl_event_callback_add(win, EFL_EVENT_INVALIDATE, _win_gone_cb, NULL);
471 background = base_ui->background; 475 background = base_ui->background;
472} 476}
diff --git a/src/efl_ui_editor/base_ui.eflui b/src/efl_ui_editor/base_ui.eflui
index e0998ca..d6d775f 100644
--- a/src/efl_ui_editor/base_ui.eflui
+++ b/src/efl_ui_editor/base_ui.eflui
@@ -1,60 +1,60 @@
1{ 1{
2 "ui-name" : "Base_Ui", 2 "ui-name" : "Base_Ui",
3 "ui-content" : { 3 "ui-content" : {
4 "type": "Efl.Ui.Panes", 4 "type" : "Efl.Ui.Panes",
5 "id" : "root", 5 "id" : "root",
6 "split_ratio" : 0.2, 6 "split_ratio" : 0.2,
7 "orientation" : vertical, 7 "orientation" : vertical,
8 "pack-part" : [ 8 "pack-part" : [
9 { 9 {
10 "type" : "Efl.Ui.Stack", 10 "type" : "Efl.Ui.Stack",
11 "id" : "prop_stack", 11 "id" : "prop_stack",
12 "part" : "first", 12 "part" : "first",
13 }, 13 },
14 { 14 {
15 "type" : "Efl.Ui.Box",
16 "part" : "second",
17 "pack-linear" : [
18 {
15 "type" : "Efl.Ui.Box", 19 "type" : "Efl.Ui.Box",
16 "part" : "second", 20 "orientation" : horizontal,
21 "hint_weight" : [1.0, 0.0],
22 "hint_size_min" : [[40, 40]],
17 "pack-linear" : [ 23 "pack-linear" : [
18 { 24 {
19 "type" : "Efl.Ui.Box", 25 "type" : "Efl.Ui.Button",
20 "orientation" : horizontal, 26 "id" : "save",
21 "hint_weight" : [1.0, 0.0], 27 "text" : "Save",
22 "hint_size_min" : [[40, 40]], 28 "hint_weight" : [0.1, 1.0],
23 "pack-linear" : [ 29 "content" : {
24 { 30 "type" : "Efl.Ui.Image",
25 "type" : "Efl.Ui.Button", 31 "icon" : "document-save",
26 "id" : "save", 32 },
27 "text" : "Save", 33 },
28 "hint_weight" : [0.1, 1.0], 34 {
29 "content" : { 35 "type" : "Efl.Ui.Button",
30 "type" : "Efl.Ui.Image", 36 "id" : "ui_name",
31 "icon" : "document-save" 37 "text" : "Ui-Name",
32 } 38 "hint_weight" : [0.1, 1.0],
33 }, 39 "content" : {
34 { 40 "type" : "Efl.Ui.Image",
35 "type" : "Efl.Ui.Button", 41 "icon" : "document-send",
36 "id" : "refresh", 42 },
37 "text" : "Refresh", 43 },
38 "hint_weight" : [0.1, 1.0], 44 {
39 "content" : { 45 "type" : "Efl.Canvas.Rectangle",
40 "type" : "Efl.Ui.Image", 46 "color" : [0, 0, 0, 0],
41 "icon" : "document-send" 47 "hint_weight" : [1.0, 1.0],
42 } 48 }
43 }, 49 ],
44 { 50 },
45 "type" : "Efl.Canvas.Rectangle", 51 {
46 "color" : [0, 0, 0, 0], 52 "type" : "Efl.Canvas.Rectangle",
47 "hint_weight" : [1.0, 1.0], 53 "id" : "background",
48 } 54 "hint_weight" : [1.0, 1.0],
49 ] 55 }
50 }, 56 ],
51 { 57 }
52 "type" : "Efl.Canvas.Rectangle", 58 ],
53 "id" : "background", 59 }
54 "hint_weight" : [1.0, 1.0],
55 }
56 ]
57 }
58 ]
59 },
60} 60}
diff --git a/src/efl_ui_editor/main.h b/src/efl_ui_editor/main.h
index 7b467c6..8b1addc 100644
--- a/src/efl_ui_editor/main.h
+++ b/src/efl_ui_editor/main.h
@@ -37,6 +37,8 @@ void safe_file(void);
37void change_linear_details(Efl_Ui_Node *n, const char *new_details); 37void change_linear_details(Efl_Ui_Node *n, const char *new_details);
38void change_table_details(Efl_Ui_Node *n, const char *new_details); 38void change_table_details(Efl_Ui_Node *n, const char *new_details);
39void change_part_details(Efl_Ui_Node *n, const char *new_details); 39void change_part_details(Efl_Ui_Node *n, const char *new_details);
40void change_ui_name(const char *name);
41
40 42
41//UIs for selecting Types and properties 43//UIs for selecting Types and properties
42Eina_Future* select_available_types(void); 44Eina_Future* select_available_types(void);
@@ -45,6 +47,7 @@ Eina_Future* select_available_properties(Efl_Ui_Node *node);
45//UI for selecting a parameter value 47//UI for selecting a parameter value
46Eina_Future *change_value(Outputter_Property_Value *value, Eo *anchor_widget); 48Eina_Future *change_value(Outputter_Property_Value *value, Eo *anchor_widget);
47Eina_Future* change_name(Efl_Ui_Node *node, Eo *anchor_widget); 49Eina_Future* change_name(Efl_Ui_Node *node, Eo *anchor_widget);
50Eina_Future* change_string_name(const char *name, Eo *anchor_widget);
48 51
49Eina_Future* linear_change_ui(Efl_Ui_Node *node, Eo *anchor_widget); 52Eina_Future* linear_change_ui(Efl_Ui_Node *node, Eo *anchor_widget);
50Eina_Future* table_change_ui(Efl_Ui_Node *node, Eo *anchor_widget); 53Eina_Future* table_change_ui(Efl_Ui_Node *node, Eo *anchor_widget);
diff --git a/src/efl_ui_editor/value_change_text_ui.eflui b/src/efl_ui_editor/value_change_text_ui.eflui
index 1991a81..13e6325 100644
--- a/src/efl_ui_editor/value_change_text_ui.eflui
+++ b/src/efl_ui_editor/value_change_text_ui.eflui
@@ -1,28 +1,29 @@
1{ 1{
2 "ui-name" : "Value_Change_Text_Ui", 2 "ui-name" : "Value_Change_Text_Ui",
3 "ui-content" : { 3 "ui-content" : {
4 "type": "Efl.Ui.Popup", 4 "type" : "Efl.Ui.Popup",
5 "id" : "root", 5 "id" : "root",
6 "content" : { 6 "content" : {
7 "type" : "Efl.Ui.Box", 7 "type" : "Efl.Ui.Box",
8 "pack-linear" : [ 8 "pack-linear" : [
9 { 9 {
10 "type" : "Efl.Ui.Textbox", 10 "type" : "Efl.Ui.Textbox",
11 "editable" : false, 11 "id" : "headline",
12 "multiline" : false, 12 "editable" : false,
13 "text" : "Change the text:" 13 "multiline" : false,
14 }, 14 "text" : "<Empty>",
15 { 15 },
16 "type" : "Efl.Ui.Textbox", 16 {
17 "multiline" : false, 17 "type" : "Efl.Ui.Textbox",
18 "id" : "text_selector", 18 "id" : "text_selector",
19 }, 19 "multiline" : false,
20 { 20 },
21 "type" : "Efl.Ui.Button", 21 {
22 "text" : "Set", 22 "type" : "Efl.Ui.Button",
23 "id" : "ok" 23 "id" : "ok",
24 } 24 "text" : "Set",
25 ] 25 }
26 } 26 ],
27 },
27 } 28 }
28} 29}
diff --git a/src/efl_ui_editor/value_change_ui.c b/src/efl_ui_editor/value_change_ui.c
index e6ffba3..49bdeed 100644
--- a/src/efl_ui_editor/value_change_ui.c
+++ b/src/efl_ui_editor/value_change_ui.c
@@ -241,12 +241,11 @@ _name_setting_cb(void *data, const Efl_Event *ev)
241 free(s); 241 free(s);
242} 242}
243 243
244Eina_Future* 244static Eina_Future*
245change_name(Efl_Ui_Node *node, Eo *anchor_widget) 245_change_string_name(const char *title, const char *name, Eo *anchor_widget)
246{ 246{
247 Value_Selection *s = calloc(1, sizeof(Value_Selection)); 247 Value_Selection *s = calloc(1, sizeof(Value_Selection));
248 Value_Change_Text_Ui_Data *data = value_change_text_ui_gen(win); 248 Value_Change_Text_Ui_Data *data = value_change_text_ui_gen(win);
249 const char *id = node_id_get(node);
250 s->ctx = efl_loop_promise_new(efl_main_loop_get()); 249 s->ctx = efl_loop_promise_new(efl_main_loop_get());
251 s->selector = data->text_selector; 250 s->selector = data->text_selector;
252 s->popup = data->root; 251 s->popup = data->root;
@@ -255,10 +254,23 @@ change_name(Efl_Ui_Node *node, Eo *anchor_widget)
255 efl_event_callback_add(data->ok, EFL_INPUT_EVENT_CLICKED, _name_setting_cb, s); 254 efl_event_callback_add(data->ok, EFL_INPUT_EVENT_CLICKED, _name_setting_cb, s);
256 efl_event_callback_add(s->popup, EFL_UI_POPUP_EVENT_BACKWALL_CLICKED, _close_cb, s); 255 efl_event_callback_add(s->popup, EFL_UI_POPUP_EVENT_BACKWALL_CLICKED, _close_cb, s);
257 efl_gfx_entity_visible_set(data->root, EINA_TRUE); 256 efl_gfx_entity_visible_set(data->root, EINA_TRUE);
258 efl_text_set(s->selector, id); 257 efl_text_set(s->selector, efl_ui_name_get(ui_tree));
258 efl_text_set(data->headline, title);
259 259
260 efl_ui_focus_util_focus(s->selector); 260 efl_ui_focus_util_focus(s->selector);
261 efl_text_interactive_all_select(s->selector); 261 efl_text_interactive_all_select(s->selector);
262 262
263 return eina_future_new(s->ctx); 263 return eina_future_new(s->ctx);
264} 264}
265
266Eina_Future*
267change_string_name(const char *name, Eo *anchor_widget)
268{
269 return _change_string_name("Change name", name, anchor_widget);
270}
271
272Eina_Future*
273change_name(Efl_Ui_Node *node, Eo *anchor_widget)
274{
275 return _change_string_name("Change the text", node_id_get(node), anchor_widget);
276}
diff --git a/src/lib/Efl_Ui_Format.h b/src/lib/Efl_Ui_Format.h
index c14f770..29111c2 100644
--- a/src/lib/Efl_Ui_Format.h
+++ b/src/lib/Efl_Ui_Format.h
@@ -1,11 +1,12 @@
1#ifndef EFL_UI_FORMAT_H 1#ifndef EFL_UI_FORMAT_H
2#define EFL_UI_FORMAT_H 1 2#define EFL_UI_FORMAT_H 1
3 3
4typedef struct _Efl_Ui Efl_Ui;
5
4#include <Eina.h> 6#include <Eina.h>
5#include <Eolian.h> 7#include <Eolian.h>
6#include <abstract_tree.h> 8#include <abstract_tree.h>
7 9
8typedef struct _Efl_Ui Efl_Ui;
9 10
10Efl_Ui* efl_ui_format_parse(const char *input_content); 11Efl_Ui* efl_ui_format_parse(const char *input_content);
11Eina_Bool validate(Eolian_State *state, Efl_Ui *ui); 12Eina_Bool validate(Eolian_State *state, Efl_Ui *ui);
diff --git a/src/lib/abstract_tree.c b/src/lib/abstract_tree.c
index 6382673..a5b293b 100644
--- a/src/lib/abstract_tree.c
+++ b/src/lib/abstract_tree.c
@@ -149,6 +149,12 @@ efl_ui_name_set(Efl_Ui *ui, const char *name)
149 ui->name = eina_strdup(name); 149 ui->name = eina_strdup(name);
150} 150}
151 151
152const char *
153efl_ui_name_get(Efl_Ui *ui)
154{
155 return ui->name;
156}
157
152Efl_Ui_Node* 158Efl_Ui_Node*
153efl_ui_content_get(Efl_Ui *ui) 159efl_ui_content_get(Efl_Ui *ui)
154{ 160{
diff --git a/src/lib/abstract_tree.h b/src/lib/abstract_tree.h
index ccb552a..bba530b 100644
--- a/src/lib/abstract_tree.h
+++ b/src/lib/abstract_tree.h
@@ -27,6 +27,8 @@ typedef struct _Efl_Ui_Pack_Pack Efl_Ui_Pack_Pack;
27typedef struct _Efl_Ui_Pack_Basic Efl_Ui_Pack_Basic; 27typedef struct _Efl_Ui_Pack_Basic Efl_Ui_Pack_Basic;
28typedef struct _Efl_Ui_Struct Efl_Ui_Struct; 28typedef struct _Efl_Ui_Struct Efl_Ui_Struct;
29 29
30const char * efl_ui_name_get(Efl_Ui *ui);
31
30void node_delete_children(Efl_Ui_Node *node, enum Efl_Ui_Node_Children_Type type); 32void node_delete_children(Efl_Ui_Node *node, enum Efl_Ui_Node_Children_Type type);
31Efl_Ui_Property* node_property_append(Efl_Ui_Node *n); 33Efl_Ui_Property* node_property_append(Efl_Ui_Node *n);
32void node_id_set(Efl_Ui_Node *n, const char *id); 34void node_id_set(Efl_Ui_Node *n, const char *id);