diff options
author | Yakov Goldberg <yakov.g@samsung.com> | 2013-12-22 14:10:28 +0200 |
---|---|---|
committer | Yakov Goldberg <yakov.g@samsung.com> | 2013-12-22 14:10:28 +0200 |
commit | 4330488648da58d8bd7ed2f1446648a421c24b5e (patch) | |
tree | b3afc86c19145192f6c807dd2eeb2b87a5caf08e | |
parent | 14f3a04adbcba2878739aca36e259208e4da4bce (diff) | |
parent | d37cbb4890476404471663e3a1e83c40728542d0 (diff) |
Merge branch 'develop'v0.2.0
51 files changed, 7290 insertions, 4046 deletions
@@ -1,24 +1,46 @@ | |||
1 | Features: | 1 | Features: |
2 | -------- | 2 | -------- |
3 | - Espion: support parameters whose types can be double and defines | 3 | -1 User callbacks: |
4 | - Factory: add all the widgets / DnD | 4 | - add entries / user data has to be represented with a hoversel for the type + value |
5 | - Database: fill / add display names | 5 | - return value of the callback has to be an integer; condition can test the value and act differently |
6 | - Multiple simulations modes: | 6 | -1 0 and 1 accepted |
7 | - UI: | 7 | -2 more values/nesting conditions |
8 | - hoversel (mode) and button to launch | 8 | -1 Containers generically support: box, menus... |
9 | - list of launched simulations | 9 | -1 Deletion by the user - have to register callback to set: |
10 | - Eo* must move from Gui_Widget to some simulation context | 10 | - public widgets pointers as NULL in generator. |
11 | - Stop simulation | 11 | - Eo pointers to NULL in simulator. |
12 | -1 Factory: add all the widgets / DnD | ||
13 | -2 Espion: support parameters whose types can be double and defines | ||
14 | -1 Resources manager: | ||
15 | - use it for images/edj... | ||
16 | - DB has to indicate property expects ResourceId and not filepath | ||
17 | -1 Generator: come back on all the generation process | ||
18 | - Integration with: | ||
19 | -1 Enventor: | ||
20 | - invocation from GUI | ||
21 | - we may need a resource panel where we can set the paths to the images... | ||
22 | - Enventor needs to be launched with edc | ||
23 | -2 Eolian library: | ||
24 | - Egui invokes Eolian to determine if a property is a method or a property | ||
25 | - If property, request the Eo1/Eo2 get op id to retrieve info from the object | ||
26 | -2 Espion: | ||
27 | - via network (option in espion and in egui application importer menu) | ||
28 | - establish a protocol between them | ||
12 | 29 | ||
13 | Fixes: | 30 | Fixes: |
14 | ----- | 31 | ----- |
15 | - Egui: | 32 | - Egui: |
16 | - Fix value types for parameters in property view. | 33 | - Fix value types for parameters in property view. |
34 | - Resize sub-windows according to application resolution | ||
35 | - Don't propagate events when selecting widget | ||
36 | - refactor _callbacks_expand (propview.c) | ||
17 | 37 | ||
18 | Improvements: | 38 | Improvements: |
19 | ------------ | 39 | ------------ |
20 | - Prettify the UI | 40 | - Prettify the UI |
21 | - stringshare | 41 | - stringshare |
42 | - need to think how handle _prop_new_value, which is outside of gui_widget | ||
43 | - is it possible to remove prop_validate(), and validate value in gui_value_set()? | ||
22 | - wdg, cb, action, seq: ptr->id... | 44 | - wdg, cb, action, seq: ptr->id... |
23 | - Have to improve the egui UI | 45 | - Have to improve the egui UI |
24 | - goal: give an identity to egui -> recognizable just by the UI | 46 | - goal: give an identity to egui -> recognizable just by the UI |
@@ -26,8 +48,12 @@ Improvements: | |||
26 | - entries to improve: min size... | 48 | - entries to improve: min size... |
27 | - When DnD widget around canvas, bind it around objects. | 49 | - When DnD widget around canvas, bind it around objects. |
28 | - add scroll_bars to layout windows, if actual size is larger than frame | 50 | - add scroll_bars to layout windows, if actual size is larger than frame |
29 | - connect window's visibility to its frame | ||
30 | - DnD widget from one box to another; content_set, etc. | 51 | - DnD widget from one box to another; content_set, etc. |
52 | - _action_dep_resolve uses active_context_get() because there is no another way to find widget. | ||
53 | |||
54 | - Draw border around box and other containers, to see its size. | ||
55 | - think about dependency in action's property | ||
56 | - A lot of logs to add, it will help us to debug | ||
31 | 57 | ||
32 | Open issues: | 58 | Open issues: |
33 | ----------- | 59 | ----------- |
@@ -37,13 +63,28 @@ Known EFL bugs: | |||
37 | -------------- | 63 | -------------- |
38 | - FILE SELECTOR | 64 | - FILE SELECTOR |
39 | - button: if size_set will be before part_text_set, text will be ellipsed!!! need some fixes in recalculation | 65 | - button: if size_set will be before part_text_set, text will be ellipsed!!! need some fixes in recalculation |
66 | - Sequence add: force panel show because RETURN key is propagated to panel | ||
67 | - Hoversel with a lot of elements prevent access to those not displayed on the screen | ||
40 | 68 | ||
41 | Future: | 69 | Future: |
42 | ------ | 70 | ------ |
71 | - Link to Eolian to retrieve description of functions (popup) | ||
43 | - Generator: source files in different formats | 72 | - Generator: source files in different formats |
44 | - 3D representation of the exploded window: | 73 | - 3D representation of the exploded window: |
45 | - shows every widget-layer of the win (win, containers, basic) created by the user | 74 | - shows every widget-layer of the win (win, containers, basic) created by the user |
46 | - Evas objects | 75 | - Evas objects |
76 | - undo/redo: to implement this, we need to keep opposite operation for each method: like pack_end -> unpack | ||
77 | Moreover, if method receives several objects as parameters, we need to know, which parameter is subject and which is object. | ||
78 | T.e. pack_before(box, but2, but1) -> unpack(box, box2), here we need to remember, that oppossite for pack_before method (unpack) | ||
79 | must work with 1st parameter of pack_before, t.e. box2. | ||
80 | - Recording scenario usable for automated tests and Tizen PLM issues: | ||
81 | - via espion or simulator? in simulator, button to record & run | ||
82 | - can we use Exactness? | ||
83 | - do we need to associate the scenario to an app? | ||
84 | - Screenshot feature: | ||
85 | - for tests, demos | ||
86 | - one jpeg per window | ||
87 | - Exactness? | ||
47 | 88 | ||
48 | Miscellaneous: | 89 | Miscellaneous: |
49 | ------------- | 90 | ------------- |
@@ -70,3 +111,11 @@ Miscellaneous: | |||
70 | - no? invoke child code generation and then do as yes | 111 | - no? invoke child code generation and then do as yes |
71 | - Insert the buffer into the global context buffer | 112 | - Insert the buffer into the global context buffer |
72 | - If action == modif or user, just generate code into buffer. | 113 | - If action == modif or user, just generate code into buffer. |
114 | |||
115 | Add Instructions file: | ||
116 | --------------------- | ||
117 | - Install GraphViz: | ||
118 | sudo add-apt-repository ppa:gviz-adm/graphviz-dev | ||
119 | sudo apt-get update | ||
120 | sudo apt-get install libgraphviz4 | ||
121 | sudo apt-get install libgraphviz-dev | ||
diff --git a/cmake/Modules/FindCGraph.cmake b/cmake/Modules/FindCGraph.cmake new file mode 100644 index 0000000..200efe1 --- /dev/null +++ b/cmake/Modules/FindCGraph.cmake | |||
@@ -0,0 +1,41 @@ | |||
1 | # - Try to find GraphViz | ||
2 | # Once done this will define | ||
3 | # CGRAPH_FOUND - System has GraphViz | ||
4 | # CGRAPH_INCLUDE_DIRS - The GraphViz include directories | ||
5 | # CGRAPH_LIBRARIES - The libraries needed to use GraphViz | ||
6 | # CGRAPH_LDFLAGS_OTHER - Other LDFLAGS needed te use GraphViz | ||
7 | # CGRAPH_DEFINITIONS - Compiler switches required for using GraphViz | ||
8 | |||
9 | find_package(PkgConfig) | ||
10 | if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1") | ||
11 | # "QUIET" was introduced in 2.8.2 | ||
12 | set(_QUIET QUIET) | ||
13 | endif () | ||
14 | pkg_check_modules(PC_LIBCGRAPH ${_QUIET} libcgraph) | ||
15 | |||
16 | set (CGRAPH_MIN_VERSION "2.35.0.0") | ||
17 | if ("${PC_LIBCGRAPH_VERSION}" VERSION_LESS ${CGRAPH_MIN_VERSION}) | ||
18 | MESSAGE(STATUS "libcgraph version required: ${CGRAPH_MIN_VERSION}. Current version: ${PC_LIBCGRAPH_VERSION}.") | ||
19 | else() | ||
20 | SET(LIBCGRAPH_REQUIRED_VERSION 1) | ||
21 | endif() | ||
22 | |||
23 | if (LIBCGRAPH_REQUIRED_VERSION) | ||
24 | find_path(CGRAPH_INCLUDE_DIR cgraph.h | ||
25 | HINTS ${PC_LIBCGRAPH_INCLUDEDIR} ${PC_LIBCCGRAPH_INCLUDE_DIRS} | ||
26 | PATH_SUFFIXES cgraph ) | ||
27 | |||
28 | find_library(CGRAPH_LIBRARY NAMES cgraph libcgraph | ||
29 | HINTS ${PC_LIBCGRAPH_LIBDIR} ${PC_LIBCGRAPH_LIBRARY_DIRS} ) | ||
30 | |||
31 | set(CGRAPH_INCLUDE_DIRS ${CGRAPH_INCLUDE_DIR}) | ||
32 | set(CGRAPH_LIBRARIES ${CGRAPH_LIBRARY} ) | ||
33 | |||
34 | #include(FindPackageHandleStandardArgs) | ||
35 | # handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE | ||
36 | # if all listed variables are TRUE | ||
37 | find_package_handle_standard_args(cgraph DEFAULT_MSG | ||
38 | CGRAPH_LIBRARY) | ||
39 | endif (LIBCGRAPH_REQUIRED_VERSION) | ||
40 | |||
41 | mark_as_advanced(CGRAPH_INCLUDE_DIR CGRAPH_LIBRARY) | ||
diff --git a/cmake/Modules/FindGvc.cmake b/cmake/Modules/FindGvc.cmake new file mode 100644 index 0000000..5bcb911 --- /dev/null +++ b/cmake/Modules/FindGvc.cmake | |||
@@ -0,0 +1,41 @@ | |||
1 | # - Try to find GraphViz | ||
2 | # Once done this will define | ||
3 | # GVC_FOUND - System has GraphViz | ||
4 | # GVC_INCLUDE_DIRS - The GraphViz include directories | ||
5 | # GVC_LIBRARIES - The libraries needed to use GraphViz | ||
6 | # GVC_LDFLAGS_OTHER - Other LDFLAGS needed te use GraphViz | ||
7 | # GVC_DEFINITIONS - Compiler switches required for using GraphViz | ||
8 | |||
9 | find_package(PkgConfig) | ||
10 | if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER "2.8.1") | ||
11 | # "QUIET" was introduced in 2.8.2 | ||
12 | set(_QUIET QUIET) | ||
13 | endif () | ||
14 | |||
15 | pkg_check_modules(PC_LIBGVC ${_QUIET} libgvc) | ||
16 | set (LIBGVC_MIN_VERSION "2.35.0.0") | ||
17 | if ("${PC_LIBGVC_VERSION}" VERSION_LESS ${LIBGVC_MIN_VERSION}) | ||
18 | MESSAGE(STATUS "libgvc version required: ${LIBGVC_MIN_VERSION}. Current version: ${PC_LIBGVC_VERSION}.") | ||
19 | else() | ||
20 | SET(LIBGVC_REQUIRED_VERSION 1) | ||
21 | endif() | ||
22 | |||
23 | if (LIBGVC_REQUIRED_VERSION) | ||
24 | find_path(GVC_INCLUDE_DIR gvc.h | ||
25 | HINTS ${PC_LIBGVC_INCLUDEDIR} ${PC_LIBCGVC_INCLUDE_DIRS} | ||
26 | PATH_SUFFIXES gvc ) | ||
27 | |||
28 | find_library(GVC_LIBRARY NAMES gvc libgvc | ||
29 | HINTS ${PC_LIBGVC_LIBDIR} ${PC_LIBGVC_LIBRARY_DIRS} ) | ||
30 | |||
31 | set(GVC_INCLUDE_DIRS ${GVC_INCLUDE_DIR}) | ||
32 | set(GVC_LIBRARIES ${GVC_LIBRARY} ) | ||
33 | |||
34 | #include(FindPackageHandleStandardArgs) | ||
35 | # handle the QUIETLY and REQUIRED arguments and set EINA_FOUND to TRUE | ||
36 | # if all listed variables are TRUE | ||
37 | find_package_handle_standard_args(gvc DEFAULT_MSG | ||
38 | GVC_LIBRARY) | ||
39 | endif (LIBGVC_REQUIRED_VERSION) | ||
40 | |||
41 | mark_as_advanced(GVC_INCLUDE_DIR GVC_LIBRARY) | ||
diff --git a/py/func_names.json b/py/func_names.json index e6f65fe..5badd0d 100644 --- a/py/func_names.json +++ b/py/func_names.json | |||
@@ -3,26 +3,38 @@ | |||
3 | [ | 3 | [ |
4 | { | 4 | { |
5 | "tokens" : ["evas_obj_color", "set"], | 5 | "tokens" : ["evas_obj_color", "set"], |
6 | "name" : "color_set" | 6 | "name" : "color_set", |
7 | "display_name" : "Color" | ||
7 | }, | 8 | }, |
8 | { | 9 | { |
9 | "tokens" : ["evas_obj_size_set"], | 10 | "tokens" : ["evas_obj_size_set"], |
10 | "name" : "size_set" }, | 11 | "name" : "size_set", |
12 | "display_name" : "Size" | ||
13 | }, | ||
11 | { | 14 | { |
12 | "tokens" : ["evas_obj_position", "set"], | 15 | "tokens" : ["evas_obj_position", "set"], |
13 | "name" : "position_set" | 16 | "name" : "position_set", |
17 | "display_name" : "Position" | ||
14 | }, | 18 | }, |
15 | { | 19 | { |
16 | "tokens" : ["evas_obj_size_hint_weight","set"], | 20 | "tokens" : ["evas_obj_size_hint_weight","set"], |
17 | "name" : "size_hint_weight_set" | 21 | "name" : "size_hint_weight_set", |
22 | "display_name" : "Size Hint Weight" | ||
18 | }, | 23 | }, |
19 | { | 24 | { |
20 | "tokens" : ["evas_obj_size_hint_aspect","set"], | 25 | "tokens" : ["evas_obj_size_hint_aspect","set"], |
21 | "name" : "size_hint_aspect_set" | 26 | "name" : "size_hint_aspect_set", |
27 | "display_name" : "Size Hint Aspect" | ||
22 | }, | 28 | }, |
23 | { | 29 | { |
24 | "tokens" : ["evas_obj_size_hint_align","set"], | 30 | "tokens" : ["evas_obj_size_hint_align","set"], |
25 | "name" : "size_hint_align_set" | 31 | "name" : "size_hint_align_set", |
32 | "display_name" : "Size Hint Align" | ||
33 | }, | ||
34 | { | ||
35 | "tokens" : ["evas_obj_size_hint_min","set"], | ||
36 | "name" : "size_hint_min_set", | ||
37 | "display_name" : "Size Hint Min" | ||
26 | }, | 38 | }, |
27 | { | 39 | { |
28 | "tokens" : ["evas_obj_visibility_set"], | 40 | "tokens" : ["evas_obj_visibility_set"], |
@@ -31,261 +43,347 @@ | |||
31 | }, | 43 | }, |
32 | { | 44 | { |
33 | "tokens" : ["elm_obj_bg_color_set"], | 45 | "tokens" : ["elm_obj_bg_color_set"], |
34 | "name" : "bg_color_set" | 46 | "name" : "bg_color_set", |
47 | "display_name" : "Bg Color" | ||
35 | }, | 48 | }, |
36 | { | 49 | { |
37 | "tokens" : ["elm_obj_bg_file_set"], | 50 | "tokens" : ["elm_obj_bg_file_set"], |
38 | "name" : "bg_file_set" | 51 | "name" : "bg_file_set", |
52 | "display_name" : "Bg File" | ||
39 | }, | 53 | }, |
40 | { | 54 | { |
41 | "tokens" : ["elm_obj_win_title_set"], | 55 | "tokens" : ["elm_obj_win_title_set"], |
42 | "name" : "title_set" | 56 | "name" : "title_set", |
57 | "display_name" : "Title" | ||
43 | }, | 58 | }, |
44 | { | 59 | { |
45 | "tokens" : ["elm_obj_win","autodel_set"], | 60 | "tokens" : ["elm_obj_win","autodel_set"], |
46 | "name" : "autodel_set" | 61 | "name" : "autodel_set", |
62 | "display_name" : "Autodel" | ||
47 | }, | 63 | }, |
48 | { | 64 | { |
49 | "tokens" : ["elm_obj_win_constructor"], | 65 | "tokens" : ["elm_obj_win_constructor"], |
50 | "name" : "" | 66 | "name" : "", |
67 | "display_name" : "Constructor" | ||
51 | }, | 68 | }, |
52 | { | 69 | { |
53 | "tokens" : ["elm_obj_win_resize_object_add"], | 70 | "tokens" : ["elm_obj_win_resize_object_add"], |
54 | "name" : "resize_object_add", | 71 | "name" : "resize_object_add", |
55 | "flags" : ["MULTI_PROPERTY", "CHANGE_ON_ACTIVATE", "UPDATE_PARENT"] | 72 | "flags" : ["MULTI_PROPERTY", "CHANGE_ON_ACTIVATE", "UPDATE_PARENT"], |
73 | "display_name" : "Resize Object" | ||
74 | }, | ||
75 | { | ||
76 | "tokens" : ["elm_obj_win_modal_set"], | ||
77 | "name" : "modal", | ||
78 | "display_name" : "Modal" | ||
56 | }, | 79 | }, |
57 | { | 80 | { |
58 | "tokens" : ["elm_wdg_style_set"], | 81 | "tokens" : ["elm_wdg_style_set"], |
59 | "name" : "style_set" | 82 | "name" : "style_set", |
83 | "display_name" : "Style" | ||
60 | }, | 84 | }, |
61 | { | 85 | { |
62 | "tokens" : ["elm_wdg_part_text_set"], | 86 | "tokens" : ["elm_wdg_part_text_set"], |
63 | "name" : "part_text_set" | 87 | "name" : "part_text_set", |
88 | "display_name" : "Part Text" | ||
64 | }, | 89 | }, |
65 | { | 90 | { |
66 | "tokens" : ["elm_wdg_disabled_set"], | 91 | "tokens" : ["elm_wdg_disabled_set"], |
67 | "name" : "disabled" | 92 | "name" : "disabled", |
93 | "display_name" : "Disabled" | ||
68 | }, | 94 | }, |
69 | { | 95 | { |
70 | "tokens" : ["elm_wdg_access_info_set"], | 96 | "tokens" : ["elm_wdg_access_info_set"], |
71 | "name" : "access_info_set" | 97 | "name" : "access_info_set", |
98 | "display_name" : "Access Info" | ||
72 | }, | 99 | }, |
73 | { | 100 | { |
74 | "tokens" : ["elm_obj_container_content_set"], | 101 | "tokens" : ["elm_obj_container_content_set"], |
75 | "name" : "content_set", | 102 | "name" : "content_set", |
76 | "flags" : ["CHANGE_ON_ACTIVATE", "UPDATE_PARENT"] | 103 | "flags" : ["CHANGE_ON_ACTIVATE", "UPDATE_PARENT"], |
104 | "display_name" : "Content" | ||
77 | }, | 105 | }, |
78 | { | 106 | { |
79 | "tokens" : ["elm_obj_box_pack_end"], | 107 | "tokens" : ["elm_obj_box_pack_end"], |
80 | "name" : "pack_end", | 108 | "name" : "pack_end", |
81 | "flags" : ["MULTI_PROPERTY", "CHANGE_ON_ACTIVATE", "UPDATE_PARENT"] | 109 | "flags" : ["MULTI_PROPERTY", "CHANGE_ON_ACTIVATE", "UPDATE_PARENT"], |
110 | "display_name" : "Pack End" | ||
111 | }, | ||
112 | { | ||
113 | "tokens" : ["elm_obj_box_pack_after"], | ||
114 | "name" : "pack_after", | ||
115 | "flags" : ["MULTI_PROPERTY", "CHANGE_ON_ACTIVATE", "UPDATE_PARENT"], | ||
116 | "display_name" : "Pack After" | ||
82 | }, | 117 | }, |
83 | { | 118 | { |
84 | "tokens" : ["elm_scrollable_interface_bounce_allow_set"], | 119 | "tokens" : ["elm_scrollable_interface_bounce_allow_set"], |
85 | "name" : "bounce_allow" | 120 | "name" : "bounce_allow", |
121 | "display_name" : "Bounce Allow" | ||
86 | }, | 122 | }, |
87 | { | 123 | { |
88 | "tokens" : ["elm_scrollable_interface_policy_set"], | 124 | "tokens" : ["elm_scrollable_interface_policy_set"], |
89 | "name" : "policy" | 125 | "name" : "policy", |
126 | "display_name" : "Policy" | ||
90 | }, | 127 | }, |
91 | { | 128 | { |
92 | "tokens" : ["elm_obj_image_file_set"], | 129 | "tokens" : ["elm_obj_image_file_set"], |
93 | "name" : "image_file_set" | 130 | "name" : "image_file_set", |
131 | "display_name" : "Image File" | ||
94 | }, | 132 | }, |
95 | { | 133 | { |
96 | "tokens" : ["elm_obj_image_resizable_set"], | 134 | "tokens" : ["elm_obj_image_resizable_set"], |
97 | "name" : "image_resizable_set" | 135 | "name" : "image_resizable_set", |
136 | "display_name" : "Resizable" | ||
98 | }, | 137 | }, |
99 | { | 138 | { |
100 | "tokens" : ["elm_obj_button_autorepeat_set"], | 139 | "tokens" : ["elm_obj_button_autorepeat_set"], |
101 | "name" : "autorepeat_set" | 140 | "name" : "autorepeat_set", |
141 | "display_name" : "Autorepeat" | ||
102 | }, | 142 | }, |
103 | { | 143 | { |
104 | "tokens" : ["elm_obj_button_autorepeat_initial_timeout_set"], | 144 | "tokens" : ["elm_obj_button_autorepeat_initial_timeout_set"], |
105 | "name" : "autorepeat_initial_timeout_set" | 145 | "name" : "autorepeat_initial_timeout_set", |
146 | "display_name" : "Autorepeat Initial Timeout" | ||
106 | }, | 147 | }, |
107 | { | 148 | { |
108 | "tokens" : ["elm_obj_button_autorepeat_gap_timeout_set"], | 149 | "tokens" : ["elm_obj_button_autorepeat_gap_timeout_set"], |
109 | "name" : "autorepeat_gap_timeout_set" | 150 | "name" : "autorepeat_gap_timeout_set", |
151 | "display_name" : "Autorepeat Gap Timeout" | ||
110 | }, | 152 | }, |
111 | { | 153 | { |
112 | "tokens" : ["elm_obj_check_state_set"], | 154 | "tokens" : ["elm_obj_check_state_set"], |
113 | "name" : "check_state" | 155 | "name" : "check_state", |
156 | "display_name" : "State" | ||
114 | }, | 157 | }, |
115 | { | 158 | { |
116 | "tokens" : ["elm_obj_entry_single_line_set"], | 159 | "tokens" : ["elm_obj_entry_single_line_set"], |
117 | "name" : "single_line" | 160 | "name" : "single_line", |
161 | "display_name" : "Single Line" | ||
162 | }, | ||
163 | { | ||
164 | "tokens" : ["elm_obj_entry_text_style_user_push"], | ||
165 | "name" : "text_style_user_push", | ||
166 | "display_name" : "User style" | ||
118 | }, | 167 | }, |
119 | { | 168 | { |
120 | "tokens" : ["elm_obj_entry_scrollable_set"], | 169 | "tokens" : ["elm_obj_entry_scrollable_set"], |
121 | "name" : "scrollable" | 170 | "name" : "scrollable", |
171 | "display_name" : "Scrollable" | ||
122 | }, | 172 | }, |
123 | { | 173 | { |
124 | "tokens" : ["elm_obj_frame_autocollapse_set"], | 174 | "tokens" : ["elm_obj_frame_autocollapse_set"], |
125 | "name" : "autocollapse" | 175 | "name" : "autocollapse", |
176 | "display_name" : "Autocollapse" | ||
126 | }, | 177 | }, |
127 | { | 178 | { |
128 | "tokens" : ["elm_obj_box_horizontal_set"], | 179 | "tokens" : ["elm_obj_box_horizontal_set"], |
129 | "name" : "horizontal" | 180 | "name" : "horizontal", |
130 | }, | 181 | "display_name" : "Horizontal" |
131 | { | ||
132 | "tokens" : ["elm_obj_box_clear"], | ||
133 | "name" : "clear" | ||
134 | }, | 182 | }, |
135 | { | 183 | { |
136 | "tokens" : ["elm_obj_box_align_set"], | 184 | "tokens" : ["elm_obj_box_align_set"], |
137 | "name" : "box_align" | 185 | "name" : "box_align", |
186 | "display_name" : "Alignment" | ||
138 | }, | 187 | }, |
139 | { | 188 | { |
140 | "tokens" : ["elm_obj_grid_size_set"], | 189 | "tokens" : ["elm_obj_grid_size_set"], |
141 | "name" : "grid_size" | 190 | "name" : "grid_size", |
191 | "display_name" : "Grid Size" | ||
142 | }, | 192 | }, |
143 | { | 193 | { |
144 | "tokens" : ["elm_obj_grid_pack"], | 194 | "tokens" : ["elm_obj_grid_pack"], |
145 | "name" : "grid_pack" | 195 | "name" : "grid_pack", |
196 | "display_name" : "Pack" | ||
146 | }, | 197 | }, |
147 | { | 198 | { |
148 | "tokens" : ["elm_obj_panel_hidden_set"], | 199 | "tokens" : ["elm_obj_panel_hidden_set"], |
149 | "name" : "panel_hidden" | 200 | "name" : "panel_hidden", |
201 | "display_name" : "Hidden" | ||
150 | }, | 202 | }, |
151 | { | 203 | { |
152 | "tokens" : ["elm_obj_panel_orient_set"], | 204 | "tokens" : ["elm_obj_panel_orient_set"], |
153 | "name" : "panel_orient" | 205 | "name" : "panel_orient", |
206 | "display_name" : "Orientation" | ||
154 | }, | 207 | }, |
155 | { | 208 | { |
156 | "tokens" : ["elm_obj_panes_horizontal_set"], | 209 | "tokens" : ["elm_obj_panes_horizontal_set"], |
157 | "name" : "panes_horizontal" | 210 | "name" : "horizontal", |
211 | "display_name" : "Horizontal" | ||
212 | }, | ||
213 | { | ||
214 | "tokens" : ["elm_obj_panes_fixed_set"], | ||
215 | "name" : "fixed", | ||
216 | "display_name" : "Fixed" | ||
217 | }, | ||
218 | { | ||
219 | "tokens" : ["elm_obj_panes_content_left_size_set"], | ||
220 | "name" : "content_left_size", | ||
221 | "display_name" : "Content Left Size" | ||
158 | }, | 222 | }, |
159 | { | 223 | { |
160 | "tokens" : ["elm_obj_fileselector_path_set"], | 224 | "tokens" : ["elm_obj_fileselector_path_set"], |
161 | "name" : "fileselector_path" | 225 | "name" : "fileselector_path", |
226 | "display_name" : "Path" | ||
162 | }, | 227 | }, |
163 | { | 228 | { |
164 | "tokens" : ["elm_obj_table_pack_set"], | 229 | "tokens" : ["elm_obj_table_pack_set"], |
165 | "name" : "table_pack_set" | 230 | "name" : "table_pack_set", |
231 | "display_name" : "Pack Set" | ||
166 | }, | 232 | }, |
167 | { | 233 | { |
168 | "tokens" : ["elm_obj_table_pack_get"], | 234 | "tokens" : ["elm_obj_table_pack_get"], |
169 | "name" : "table_pack_get" | 235 | "name" : "table_pack_get", |
236 | "display_name" : "Pack get" | ||
170 | }, | 237 | }, |
171 | { | 238 | { |
172 | "tokens" : ["elm_obj_table_pack"], | 239 | "tokens" : ["elm_obj_table_pack"], |
173 | "name" : "table_pack" | 240 | "name" : "table_pack", |
241 | "display_name" : "Pack" | ||
242 | }, | ||
243 | { | ||
244 | "tokens" : ["elm_obj_table_padding_set"], | ||
245 | "name" : "table_padding", | ||
246 | "display_name" : "Padding" | ||
174 | }, | 247 | }, |
175 | { | 248 | { |
176 | "tokens" : ["elm_obj_separator_horizontal_set"], | 249 | "tokens" : ["elm_obj_separator_horizontal_set"], |
177 | "name" : "horizontal" | 250 | "name" : "horizontal", |
251 | "display_name" : "Horizontal" | ||
178 | }, | 252 | }, |
179 | { | 253 | { |
180 | "tokens" : ["elm_obj_flip_go"], | 254 | "tokens" : ["elm_obj_flip_go"], |
181 | "name" : "flip_go" | 255 | "name" : "flip_go", |
256 | "display_name" : "Flip Go" | ||
182 | }, | 257 | }, |
183 | { | 258 | { |
184 | "tokens" : ["elm_obj_layout_file_set"], | 259 | "tokens" : ["elm_obj_layout_file_set"], |
185 | "name" : "layout_file_set" | 260 | "name" : "layout_file_set", |
261 | "display_name" : "Layout File" | ||
186 | }, | 262 | }, |
187 | { | 263 | { |
188 | "tokens" : ["elm_obj_win_focus_highlight_enabled_set"], | 264 | "tokens" : ["elm_obj_win_focus_highlight_enabled_set"], |
189 | "name" : "win_focus_highlight_enabled_set" | 265 | "name" : "win_focus_highlight_enabled_set", |
266 | "display_name" : "Focus Highlight Enabled" | ||
267 | }, | ||
268 | { | ||
269 | "tokens" : ["elm_obj_toolbar_shrink_mode_set"], | ||
270 | "name" : "shrink_mode", | ||
271 | "display_name" : "Shrink Mode" | ||
272 | }, | ||
273 | { | ||
274 | "tokens" : ["elm_obj_toolbar_select_mode_set"], | ||
275 | "name" : "select_mode", | ||
276 | "display_name" : "Select Mode" | ||
277 | }, | ||
278 | { | ||
279 | "tokens" : ["elm_obj_toolbar_icon_size_set"], | ||
280 | "name" : "icon_size", | ||
281 | "display_name" : "Icon Size" | ||
190 | } | 282 | } |
191 | ], | 283 | ], |
192 | 284 | ||
193 | "CLASSES" : [ | 285 | "CLASSES" : [ |
194 | "elm_notify", | 286 | "Elm_Notify", |
195 | "Scrollable_Interface", | 287 | "Evas_Scrollable_Interface", |
196 | "elm_image", | 288 | "Elm_Image", |
197 | "elm_hover", | 289 | "Elm_Hover", |
198 | "elm_layout", | 290 | "Elm_Gengrid_Pan", |
199 | "elm_actionslider", | 291 | "Elm_Layout", |
200 | "Selectable_Interface", | 292 | "Elm_Actionslider", |
201 | "elm_spinner", | 293 | "Evas_Selectable_Interface", |
202 | "elm_calendar", | 294 | "Elm_Spinner", |
203 | "elm_toolbar", | 295 | "Evas_Object", |
204 | "elm_progressbar", | 296 | "Elm_Calendar", |
205 | "elm_panel", | 297 | "Elm_Access", |
206 | "elm_access", | 298 | "Elm_Toolbar", |
207 | "elm_mapbuf", | 299 | "Elm_Progressbar", |
208 | "elm_entry", | 300 | "Elm_Panel", |
209 | "Evas_Object_Smart_Clipped", | 301 | "Elm_Mapbuf", |
210 | "elm_flipselector", | 302 | "Elm_Entry", |
211 | "elm_video", | 303 | "Evas_Smart_Clipped", |
212 | "elm_index", | 304 | "Elm_Flipselector", |
213 | "Evas_Object_Box", | 305 | "Elm_Video", |
214 | "elm_ctxpopup", | 306 | "Evas_Box", |
307 | "Elm_Check", | ||
215 | "Evas", | 308 | "Evas", |
216 | "elm_radio", | 309 | "Elm_Radio", |
217 | "elm_diskselector", | 310 | "Elm_Diskselector", |
218 | "elm_colorselector", | 311 | "Elm_Colorselector", |
219 | "elm_prefs", | 312 | "Elm_Container", |
220 | "elm_web", | 313 | "Elm_Prefs", |
221 | "elm_interface_scrollable", | 314 | "Elm_App_Server_View", |
222 | "Evas_Object_Line", | 315 | "Elm_App_Server", |
223 | "Draggable_Interface", | 316 | "Elm_Web", |
224 | "elm_dayselector", | 317 | "Elm_Interface_Scrollable", |
225 | "Evas_Object_Image", | 318 | "Evas_Line", |
226 | "elm_fileselector_button", | 319 | "Evas_Draggable_Interface", |
227 | "elm_thumb", | 320 | "Elm_Dayselector", |
228 | "elm_systray", | 321 | "Evas_Image", |
322 | "Elm_Fileselector_Button", | ||
323 | "Elm_Thumb", | ||
324 | "Elm_Systray", | ||
229 | "Evas_Common_Interface", | 325 | "Evas_Common_Interface", |
230 | "elm_conformant", | 326 | "Elm_Index", |
231 | "Evas_Object_Textblock", | 327 | "Elm_Conformant", |
232 | "elm_map", | 328 | "Evas_Textblock", |
233 | "Clickable_Interface", | 329 | "Elm_Map", |
234 | "elm_route", | 330 | "Elm_Route", |
235 | "elm_pan", | 331 | "Elm_Pan", |
236 | "Zoomable_Interface", | 332 | "Evas_Zoomable_Interface", |
237 | "elm_check", | 333 | "Elm_Ctxpopup", |
238 | "Evas_Object", | 334 | "Eo_Abstract_Class", |
239 | "elm_widget", | 335 | "Elm_Widget", |
240 | "elm_segment_control", | 336 | "Elm_Segment_Control", |
241 | "elm_frame", | 337 | "Elm_Frame", |
242 | "elm_glview", | 338 | "Elm_Glview", |
243 | "elm_naviframe", | 339 | "Elm_Naviframe", |
244 | "elm_flip", | 340 | "Elm_Flip", |
245 | "elm_gengrid_pan", | 341 | "Elm_Datetime", |
246 | "elm_datetime", | 342 | "Elm_App_Client", |
247 | "elm_button", | 343 | "Elm_Button", |
248 | "elm_photocam_pan", | 344 | "Elm_Photocam_Pan", |
249 | "elm_player", | 345 | "Elm_Player", |
250 | "Evas_Object_Text", | 346 | "Evas_Text", |
251 | "elm_icon", | 347 | "Elm_Icon", |
252 | "elm_genlist", | 348 | "Elm_Genlist", |
253 | "elm_slider", | 349 | "Elm_Slider", |
254 | "elm_table", | 350 | "Elm_Table", |
255 | "elm_panes", | 351 | "Eo_Base", |
256 | "elm_fileselector", | 352 | "Elm_Panes", |
257 | "Evas_Object_Grid", | 353 | "Elm_Fileselector", |
258 | "elm_slideshow", | 354 | "Evas_Grid", |
259 | "elm_multibuttonentry", | 355 | "Elm_Slideshow", |
260 | "evas_object_textgrid", | 356 | "Elm_Multibuttonentry", |
261 | "Evas_Object_Table", | 357 | "Evas_Textgrid", |
262 | "elm_fileselector_entry", | 358 | "Evas_Table", |
263 | "Evas_Object_Rectangle", | 359 | "Elm_Fileselector_Entry", |
264 | "elm_grid", | 360 | "Evas_Rectangle", |
361 | "Elm_Grid", | ||
265 | "Evas_Out", | 362 | "Evas_Out", |
266 | "elm_clock", | 363 | "Elm_Clock", |
267 | "elm_gesture_layer", | 364 | "Elm_App_Client_View", |
268 | "elm_menu", | 365 | "Elm_Gesture_Layer", |
269 | "elm_hoversel", | 366 | "Elm_Menu", |
270 | "elm_bubble", | 367 | "Elm_Hoversel", |
271 | "elm_list", | 368 | "Elm_Bubble", |
272 | "elm_container", | 369 | "Elm_List", |
273 | "elm_photo", | 370 | "Evas_Clickable_Interface", |
274 | "elm_map_pan", | 371 | "Elm_Genlist_Pan", |
275 | "elm_scroller", | 372 | "Elm_Map_Pan", |
276 | "Evas_Object_Polygon", | 373 | "Elm_Scroller", |
277 | "elm_win", | 374 | "Evas_Polygon", |
278 | "elm_gengrid", | 375 | "Elm_Win", |
279 | "elm_box", | 376 | "Elm_Gengrid", |
280 | "elm_plug", | 377 | "Elm_Box", |
281 | "elm_popup", | 378 | "Elm_Plug", |
282 | "elm_bg", | 379 | "Elm_Popup", |
283 | "elm_inwin", | 380 | "Elm_Bg", |
284 | "elm_separator", | 381 | "Elm_Inwin", |
285 | "Signal_Interface", | 382 | "Elm_Separator", |
286 | "Evas_Object_Smart", | 383 | "Evas_Signal_Interface", |
287 | "elm_genlist_pan", | 384 | "Evas_Smart", |
288 | "elm_label", | 385 | "Elm_Photo", |
289 | "elm_photocam"] | 386 | "Elm_Label", |
387 | "Elm_Photocam"] | ||
290 | } | 388 | } |
291 | 389 | ||
diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt index 20fdc79..443f2bb 100644 --- a/src/bin/CMakeLists.txt +++ b/src/bin/CMakeLists.txt | |||
@@ -1,13 +1,15 @@ | |||
1 | set(CMAKE_BUILD_TYPE Debug) | 1 | set(CMAKE_BUILD_TYPE Debug) |
2 | 2 | ||
3 | include_directories (${CMAKE_SOURCE_DIR}/src/lib) | 3 | include_directories (${CMAKE_SOURCE_DIR}/src/lib) |
4 | include_directories (${CMAKE_SOURCE_DIR}/src/bin/egui_gui) | ||
4 | 5 | ||
5 | link_directories (${CMAKE_SOURCE_DIR}/src/lib) | 6 | link_directories (${CMAKE_SOURCE_DIR}/src/lib) |
6 | link_directories (${PC_LIBELEMENTARY_LIBRARY_DIRS}) | 7 | link_directories (${PC_LIBELEMENTARY_LIBRARY_DIRS}) |
7 | 8 | ||
8 | add_executable(egui main.c egui_layout.c egui_logic.c props_helper.c objtree.c propview.c seqview.c editor.c) | 9 | set(TARGET egui_cmd) |
9 | 10 | ||
10 | add_definitions(${EGUI_COMMON_DEFINITIONS}) | 11 | add_definitions(${EGUI_COMMON_DEFINITIONS}) |
12 | add_executable(${TARGET} main.c) | ||
11 | 13 | ||
12 | include_directories( | 14 | include_directories( |
13 | ${EINA_INCLUDE_DIRS} | 15 | ${EINA_INCLUDE_DIRS} |
@@ -16,7 +18,7 @@ include_directories( | |||
16 | ${ELEMENTARY_INCLUDE_DIRS} | 18 | ${ELEMENTARY_INCLUDE_DIRS} |
17 | ) | 19 | ) |
18 | 20 | ||
19 | target_link_libraries (egui | 21 | target_link_libraries (${TARGET} |
20 | guiparser | 22 | guiparser |
21 | ${EINA_LIBRARIES} | 23 | ${EINA_LIBRARIES} |
22 | ${ECORE_LIBRARIES} | 24 | ${ECORE_LIBRARIES} |
@@ -25,3 +27,10 @@ target_link_libraries (egui | |||
25 | ecore_file | 27 | ecore_file |
26 | ) | 28 | ) |
27 | 29 | ||
30 | # Save current dir because we want to know path to soutce file to build egui | ||
31 | SET(EGUI_BINARY_SRC ${CMAKE_CURRENT_LIST_DIR}) | ||
32 | # Save build path of egui_cmd, because we want to copy egui to the same folder | ||
33 | SET(EGUI_BINARY_BLD ${CMAKE_CURRENT_BINARY_DIR}) | ||
34 | |||
35 | add_subdirectory(egui_gui) | ||
36 | #add_subdirectory(egui_auto) | ||
diff --git a/src/bin/editor.c b/src/bin/editor.c deleted file mode 100644 index b1eaa99..0000000 --- a/src/bin/editor.c +++ /dev/null | |||
@@ -1,958 +0,0 @@ | |||
1 | |||
2 | #include "egui_log.h" | ||
3 | #include "ffi_glue.h" | ||
4 | #include "ffi_abstraction.h" | ||
5 | #include "gui_widget.h" | ||
6 | #include "props_helper.h" | ||
7 | #include "objtree.h" | ||
8 | #include "propview.h" | ||
9 | #include "seqview.h" | ||
10 | #include "editor.h" | ||
11 | #include "egui_logic.h" | ||
12 | |||
13 | #include <Elementary.h> | ||
14 | |||
15 | #define SELECTED_WDG "slctd_wdg" | ||
16 | |||
17 | static void _prop_update_from_propview(void *data, Eo *obj, void *ev); | ||
18 | static void _prop_del_from_propview(void *data, Eo *obj, void *ev); | ||
19 | static void _widget_selected_from_objtree(void *data, Evas_Object *obj, void *event_info); | ||
20 | |||
21 | int | ||
22 | which_border(Evas_Coord x, Evas_Coord y, Evas_Coord ow, Evas_Coord oh) | ||
23 | { | ||
24 | /* Width of border to catch callback. */ | ||
25 | Evas_Coord bw = 10; | ||
26 | int lr = 0, tb = 0; | ||
27 | if (x < bw) lr = BORDER_LEFT; | ||
28 | else if (x > ow - bw) lr = BORDER_RIGHT; | ||
29 | if (y < bw) tb = BORDER_TOP; | ||
30 | else if (y > oh - bw) tb = BORDER_BOTTOM; | ||
31 | return lr | tb; | ||
32 | } | ||
33 | |||
34 | static void | ||
35 | _on_mouse_move_widget_drag(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, | ||
36 | void *event_info) | ||
37 | { | ||
38 | Gui_Context *ctx = data; | ||
39 | static int cx, cy; | ||
40 | Evas_Coord x, y, ox, oy, ow, oh, dx, dy; | ||
41 | int wb = 0; | ||
42 | Evas_Event_Mouse_Move *ev = event_info; | ||
43 | |||
44 | /*FIXME: remove static stuff after tripple callback wil be fixed*/ | ||
45 | if ((cx == ev->cur.canvas.x) && (cy == ev->cur.canvas.y)) | ||
46 | return; | ||
47 | |||
48 | eo_do(obj, evas_obj_position_get(&ox, &oy)); | ||
49 | eo_do(obj, evas_obj_size_get(&ow, &oh)); | ||
50 | |||
51 | // ERR("obj name: %s; x: %d; y: %d ", wdg_name_get(wdg_by_eo_find(ctx, obj)), ox, oy); | ||
52 | dx = ev->cur.canvas.x - ev->prev.canvas.x; | ||
53 | dy = ev->cur.canvas.y - ev->prev.canvas.y; | ||
54 | |||
55 | /*absolute coords within object, calculate with prev position!*/ | ||
56 | x = ev->prev.canvas.x - ox; | ||
57 | y = ev->prev.canvas.y - oy; | ||
58 | |||
59 | wb = which_border(x, y, ow, oh); | ||
60 | |||
61 | /* if dragging not border, update coords*/ | ||
62 | if (wb == BORDER_OUT) | ||
63 | { | ||
64 | ox = ox + dx; | ||
65 | oy = oy + dy; | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | if (wb & BORDER_LEFT) | ||
70 | { | ||
71 | ow = ow - dx; | ||
72 | ox = ox + dx; | ||
73 | } | ||
74 | else if (wb & BORDER_RIGHT) | ||
75 | { | ||
76 | ow = ow + dx; | ||
77 | } | ||
78 | |||
79 | if (wb & BORDER_TOP) | ||
80 | { | ||
81 | oh = oh - dy; | ||
82 | oy = oy + dy; | ||
83 | } | ||
84 | else if (wb & BORDER_BOTTOM) | ||
85 | { | ||
86 | oh = oh + dy; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | eo_do(obj, evas_obj_position_set(ox, oy)); | ||
91 | eo_do(obj, evas_obj_size_set(ow, oh)); | ||
92 | { | ||
93 | Gui_Widget *wdg = wdg_by_eo_find(ctx, obj); | ||
94 | Gui_Widget_Property *prop; | ||
95 | Gui_Value *val; | ||
96 | |||
97 | if (wdg) | ||
98 | { | ||
99 | prop = wdg_prop_get(wdg, "size_set"); | ||
100 | if (prop) | ||
101 | { | ||
102 | val = prop_value_nth_get(prop, 0); | ||
103 | gui_value_set(val, GUI_TYPE_SINT, &ow); | ||
104 | val = prop_value_nth_get(prop, 1); | ||
105 | gui_value_set(val, GUI_TYPE_SINT, &oh); | ||
106 | propview_item_update(prop); | ||
107 | } | ||
108 | |||
109 | prop = wdg_prop_get(wdg, "position_set"); | ||
110 | if (prop) | ||
111 | { | ||
112 | val = prop_value_nth_get(prop, 0); | ||
113 | gui_value_set(val, GUI_TYPE_SINT, &ox); | ||
114 | val = prop_value_nth_get(prop, 1); | ||
115 | gui_value_set(val, GUI_TYPE_SINT, &oy); | ||
116 | propview_item_update(prop); | ||
117 | } | ||
118 | } | ||
119 | } | ||
120 | |||
121 | cx = ev->cur.canvas.x; | ||
122 | cy = ev->cur.canvas.y; | ||
123 | } | ||
124 | |||
125 | static void | ||
126 | _frame_mouse_move(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *fr, void *event_info) | ||
127 | { | ||
128 | Evas_Coord x, y, ox, oy, ow, oh, dx, dy; | ||
129 | Evas_Event_Mouse_Move *ev = event_info; | ||
130 | |||
131 | eo_do(fr, evas_obj_position_get(&ox, &oy)); | ||
132 | eo_do(fr, evas_obj_size_get(&ow, &oh)); | ||
133 | |||
134 | dx = ev->cur.canvas.x - ev->prev.canvas.x; | ||
135 | dy = ev->cur.canvas.y - ev->prev.canvas.y; | ||
136 | |||
137 | int wb = 0; | ||
138 | /*absolute coords within object, calculate with prev position!*/ | ||
139 | x = ev->prev.canvas.x - ox; | ||
140 | y = ev->prev.canvas.y - oy; | ||
141 | |||
142 | wb = which_border(x, y, ow, oh); | ||
143 | |||
144 | if (wb == BORDER_OUT) | ||
145 | { | ||
146 | ox = ox + dx; | ||
147 | oy = oy + dy; | ||
148 | } | ||
149 | else | ||
150 | { | ||
151 | if (wb & BORDER_LEFT) | ||
152 | { | ||
153 | ow = ow - dx; | ||
154 | ox = ox + dx; | ||
155 | } | ||
156 | else if (wb & BORDER_RIGHT) | ||
157 | { | ||
158 | ow = ow + dx; | ||
159 | } | ||
160 | |||
161 | if (wb & BORDER_TOP) | ||
162 | { | ||
163 | oh = oh - dy; | ||
164 | oy = oy + dy; | ||
165 | } | ||
166 | else if (wb & BORDER_BOTTOM) | ||
167 | { | ||
168 | oh = oh + dy; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | Gui_Widget *wdg; | ||
173 | Gui_Widget_Property *prop; | ||
174 | Gui_Value *val; | ||
175 | |||
176 | eo_do(fr, eo_base_data_get("winwdg", (void**)(&wdg))); | ||
177 | |||
178 | manager_init(); | ||
179 | prop = wdg_prop_get(wdg, SIZE_SET); | ||
180 | if (prop) | ||
181 | { | ||
182 | val = prop_value_nth_get(prop, 0); | ||
183 | gui_value_set(val, GUI_TYPE_SINT, &ow); | ||
184 | val = prop_value_nth_get(prop, 1); | ||
185 | gui_value_set(val, GUI_TYPE_SINT, &oh); | ||
186 | propview_item_update(prop); | ||
187 | /* win has size prop, so move it through manager*/ | ||
188 | manager_wdg_prop_eo_do_call(wdg, prop, MODE_EDITOR, NULL); | ||
189 | } | ||
190 | |||
191 | /* FIXME: Move frame here, because we don't know if win must have position property*/ | ||
192 | eo_do(fr, evas_obj_position_set(ox, oy)); | ||
193 | prop = wdg_prop_get(wdg, POSITION_SET); | ||
194 | if (prop) | ||
195 | { | ||
196 | val = prop_value_nth_get(prop, 0); | ||
197 | gui_value_set(val, GUI_TYPE_SINT, &ox); | ||
198 | val = prop_value_nth_get(prop, 1); | ||
199 | gui_value_set(val, GUI_TYPE_SINT, &oy); | ||
200 | propview_item_update(prop); | ||
201 | } | ||
202 | #if 0 | ||
203 | /* FIXME: if win and its image is in frame, shoul it be resized?*/ | ||
204 | Eo *inwin, *inwin_img; | ||
205 | inwin = wdg_eo_get(wdg); | ||
206 | inwin_img = elm_win_inlined_image_object_get(inwin); | ||
207 | evas_object_move(inwin, ox, oy); | ||
208 | evas_object_resize(inwin, ow, oh); | ||
209 | evas_object_move(inwin_img, ox, oy); | ||
210 | evas_object_resize(inwin_img, ow, oh); | ||
211 | #endif | ||
212 | manager_shutdown(); | ||
213 | } | ||
214 | |||
215 | #if 0 | ||
216 | static void | ||
217 | _mouse_move_over(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | ||
218 | { | ||
219 | /* Can be used later, to show change size arrows on focused object*/ | ||
220 | Evas_Event_Mouse_Move *ev = event_info; | ||
221 | Evas_Coord x, y; | ||
222 | Evas_Coord ox, oy, ow, oh; | ||
223 | Eina_Bool focused; | ||
224 | |||
225 | eo_do(obj, evas_obj_focus_get(&focused)); | ||
226 | eo_do(obj, evas_obj_position_get(&ox, &oy)); | ||
227 | eo_do(obj, evas_obj_size_get(&ow, &oh)); | ||
228 | |||
229 | x = ev->cur.canvas.x; | ||
230 | y = ev->cur.canvas.y; | ||
231 | |||
232 | ERR("Mouse is moving over obj: %p; evas: %p; %i %i", obj, evas_object_evas_get(obj), x, y); | ||
233 | |||
234 | switch (which_border(x - ox, y - oy, ow, oh)) | ||
235 | { | ||
236 | case BORDER_LEFT: | ||
237 | { | ||
238 | ERR("LEFT"); | ||
239 | break; | ||
240 | } | ||
241 | case BORDER_RIGHT: | ||
242 | { | ||
243 | ERR("RIGHT"); | ||
244 | break; | ||
245 | } | ||
246 | case BORDER_TOP: | ||
247 | { | ||
248 | ERR("TOP"); | ||
249 | break; | ||
250 | } | ||
251 | case BORDER_BOTTOM: | ||
252 | { | ||
253 | ERR("BOTTOM"); | ||
254 | break; | ||
255 | } | ||
256 | default: | ||
257 | break; | ||
258 | } | ||
259 | } | ||
260 | #endif | ||
261 | |||
262 | #if 0 | ||
263 | static void | ||
264 | _mouse_in(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) | ||
265 | { | ||
266 | ERR("Mouse IN obj name: obj: %p; evas: %p", obj, evas_object_evas_get(obj)); | ||
267 | evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_over, NULL); | ||
268 | } | ||
269 | |||
270 | static void | ||
271 | _mouse_out(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) | ||
272 | { | ||
273 | ERR("Mouse OUT obj name: obj: %p; evas: %p", obj, evas_object_evas_get(obj)); | ||
274 | evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_over); | ||
275 | } | ||
276 | #endif | ||
277 | void | ||
278 | editor_wdg_selected_set(const Gui_Widget *wdg) | ||
279 | { | ||
280 | if (wdg) gui_context_data_set(wdg_context_get(wdg), SELECTED_WDG, (Gui_Widget *) wdg); | ||
281 | else gui_context_data_set(active_context_get(), SELECTED_WDG, NULL); | ||
282 | |||
283 | if (!wdg) return; | ||
284 | Eo *obj = wdg_eo_get(wdg); | ||
285 | /* Stack up */ | ||
286 | eo_do(obj, evas_obj_raise()); | ||
287 | /* Set focus */ | ||
288 | eo_do(obj, evas_obj_focus_set(EINA_TRUE)); | ||
289 | } | ||
290 | |||
291 | const Gui_Widget* | ||
292 | editor_wdg_selected_get() | ||
293 | { | ||
294 | return gui_context_data_get(active_context_get(), SELECTED_WDG); | ||
295 | } | ||
296 | |||
297 | /* Second parameter is used to indicate if the wdg has to be deleted */ | ||
298 | static void | ||
299 | _iter_del_widget(Gui_Widget *wdg, Eina_Bool del_wdg) | ||
300 | { | ||
301 | Eina_List *children = NULL, *l, *l2; | ||
302 | Gui_Widget *w; | ||
303 | |||
304 | /* Windows are iterated separately, so if m_win == NULL, t.e. its parent is NULL | ||
305 | * so current object is not win. | ||
306 | * If iterated object is win, I create it as inlined_image and add frame to simulate win.*/ | ||
307 | |||
308 | children = wdg_children_list_get(wdg); | ||
309 | EINA_LIST_FOREACH_SAFE(children, l, l2, w) | ||
310 | { | ||
311 | _iter_del_widget(w, del_wdg); | ||
312 | } | ||
313 | manager_wdg_eo_del_call(wdg, MODE_EDITOR, NULL); | ||
314 | if (del_wdg) wdg_del(wdg); | ||
315 | } | ||
316 | |||
317 | void | ||
318 | _editor_selected_wdg_del_cb() | ||
319 | { | ||
320 | const Gui_Widget *wdg = editor_wdg_selected_get(); | ||
321 | if (!wdg) return; | ||
322 | editor_wdg_selected_set(NULL); | ||
323 | _iter_del_widget((Gui_Widget *) wdg, EINA_TRUE); | ||
324 | } | ||
325 | |||
326 | static void | ||
327 | _key_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | ||
328 | { | ||
329 | // Gui_Context *ctx = data; | ||
330 | ERR("key down"); | ||
331 | } | ||
332 | |||
333 | /* Callback, which adds MOUSE_MOVE callback, | ||
334 | * to implement drag-and-drop in editor mode*/ | ||
335 | static void | ||
336 | _mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) | ||
337 | { | ||
338 | Gui_Context *ctx = data; | ||
339 | Gui_Widget *wdg = wdg_by_eo_find(ctx, obj); | ||
340 | EINA_SAFETY_ON_NULL_RETURN(wdg); | ||
341 | |||
342 | evas_object_focus_set(wdg_eo_get(wdg), EINA_TRUE); | ||
343 | editor_wdg_selected_set(wdg); | ||
344 | objtree_item_selected_set(wdg); | ||
345 | |||
346 | evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move_widget_drag, ctx); | ||
347 | //ERR("obj name: %s, obj: %p; evas: %p", wdg_name_get(wdg), obj, evas_object_evas_get(obj)); | ||
348 | } | ||
349 | |||
350 | /* Callback, which deletes MOUSE_MOVE callback, | ||
351 | * to implement drag-and-drop*/ | ||
352 | //static void | ||
353 | //_mouse_up(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) | ||
354 | static Eina_Bool | ||
355 | _mouse_up(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
356 | { | ||
357 | /* Delete all callbacks, | ||
358 | * because sometimes _mouse_down is called several times. */ | ||
359 | while(evas_object_event_callback_del | ||
360 | (obj, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move_widget_drag)); | ||
361 | return EO_CALLBACK_CONTINUE; | ||
362 | } | ||
363 | |||
364 | static void | ||
365 | _frame_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) | ||
366 | { | ||
367 | Gui_Widget *wdg; | ||
368 | eo_do(obj, evas_obj_raise()); | ||
369 | eo_do(obj, evas_obj_focus_set(EINA_TRUE)); | ||
370 | |||
371 | eo_do(obj, eo_base_data_get("winwdg", (void**)(&wdg))); | ||
372 | eo_do(obj, evas_obj_focus_set(EINA_TRUE)); | ||
373 | |||
374 | editor_wdg_selected_set(wdg); | ||
375 | objtree_item_selected_set(wdg); | ||
376 | |||
377 | evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _frame_mouse_move, NULL); | ||
378 | } | ||
379 | |||
380 | static Eina_Bool | ||
381 | _frame_mouse_up(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
382 | { | ||
383 | evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _frame_mouse_move); | ||
384 | return EO_CALLBACK_CONTINUE; | ||
385 | } | ||
386 | |||
387 | /* Second parameter is used only as parent for INLINED windows*/ | ||
388 | static void | ||
389 | _iter_widget(Gui_Widget *wdg, const Eo *parent_win) | ||
390 | { | ||
391 | Eina_List *children = NULL, *l; | ||
392 | Gui_Widget *w; | ||
393 | |||
394 | if (wdg_state_get(wdg) < STATE_VALIDATED) | ||
395 | { | ||
396 | ERR("Widget: \"%s\" was not validated, so can't be simulated.", wdg_name_get(wdg)); | ||
397 | return; | ||
398 | } | ||
399 | /* Windows are iterated separately. If parent is NULL, means that current object is not win. | ||
400 | * If iterated object is win, I create it as inlined_image and add frame to simulate win.*/ | ||
401 | Eina_Bool created; | ||
402 | created = manager_wdg_eo_add_call(wdg, MODE_EDITOR, (void *)parent_win); | ||
403 | |||
404 | if (created) | ||
405 | { | ||
406 | manager_wdg_eo_do_call(wdg, MODE_EDITOR, NULL); | ||
407 | manager_wdg_eo_do_delayed_call(wdg, MODE_EDITOR, NULL); | ||
408 | |||
409 | children = wdg_children_list_get(wdg); | ||
410 | EINA_LIST_FOREACH(children, l, w) | ||
411 | { | ||
412 | /* Window can not have child windows, so pass NULL. */ | ||
413 | _iter_widget(w, NULL); | ||
414 | } | ||
415 | } | ||
416 | } | ||
417 | |||
418 | static Eina_Bool | ||
419 | _win_resize(void *data EINA_UNUSED, Eo *o, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
420 | { | ||
421 | Evas_Coord ow = 0, oh = 0; | ||
422 | Eo *fr = NULL; | ||
423 | eo_do(o, evas_obj_size_get(&ow, &oh)); | ||
424 | Eo *inwin_img = elm_win_inlined_image_object_get(o); | ||
425 | /* FIXME: comment it? */ | ||
426 | evas_object_resize(inwin_img, ow, oh); | ||
427 | eo_do(o, eo_base_data_get("frame", (void **) &fr)); | ||
428 | evas_object_resize(fr, ow, oh); | ||
429 | return EO_CALLBACK_CONTINUE; | ||
430 | } | ||
431 | |||
432 | static Eina_Bool | ||
433 | _editor_eo_do(const Gui_Widget *wdg, void *_prop, void *data EINA_UNUSED) | ||
434 | { | ||
435 | Eina_Bool ret; | ||
436 | ret = _ffi_eo_do(wdg, _prop); | ||
437 | |||
438 | if (IS_WIN(wdg) && !strcmp(prop_name_get(_prop), TITLE_SET)) | ||
439 | { | ||
440 | char *title = WDG_NTH_VALUE_STRING_GET(wdg, TITLE_SET, 0); | ||
441 | Eo *fr = NULL, *o = wdg_eo_get(wdg); | ||
442 | eo_do(o, eo_base_data_get("frame", (void **) &fr)); | ||
443 | elm_object_text_set(fr, title); | ||
444 | } | ||
445 | return ret; | ||
446 | } | ||
447 | |||
448 | static Eina_Bool | ||
449 | _widget_del(Gui_Widget *wdg, void *data EINA_UNUSED) | ||
450 | { | ||
451 | Eo *o = wdg_eo_get(wdg); | ||
452 | if (IS_WIN(wdg)) | ||
453 | { | ||
454 | Eo *fr = NULL; | ||
455 | eo_do(o, eo_base_data_get("frame", (void **) &fr)); | ||
456 | if (fr) | ||
457 | { | ||
458 | elm_object_content_unset(fr); | ||
459 | eo_do(o, eo_base_data_del("frame")); | ||
460 | eo_do(fr, eo_base_data_del("winwdg")); | ||
461 | |||
462 | eo_ref(fr); | ||
463 | eo_del(fr); | ||
464 | } | ||
465 | } | ||
466 | objtree_item_remove(wdg); | ||
467 | wdg_eo_set(wdg, NULL); | ||
468 | eo_ref(o); | ||
469 | eo_del(o); | ||
470 | return EINA_TRUE; | ||
471 | } | ||
472 | |||
473 | static Eina_Bool | ||
474 | _widget_add(const Gui_Widget *wdg, void *data) | ||
475 | { | ||
476 | Eo *o; | ||
477 | if (!IS_WIN(wdg)) | ||
478 | { | ||
479 | o = _ffi_eo_add(wdg); | ||
480 | if (!o) return EINA_FALSE; | ||
481 | evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _key_down, wdg_context_get(wdg)); | ||
482 | evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, wdg_context_get(wdg)); | ||
483 | //evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _mouse_up, NULL); | ||
484 | eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_UP, _mouse_up, NULL)); | ||
485 | /* To avoid dragging box, when want to drag button. */ | ||
486 | evas_object_propagate_events_set(o, EINA_FALSE); | ||
487 | /* Add callbacks to show widget resize arrows */ | ||
488 | #if 0 | ||
489 | evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _mouse_in, NULL); | ||
490 | evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _mouse_out, NULL); | ||
491 | #endif | ||
492 | /* Add specific callbacks, related to UI. */ | ||
493 | } | ||
494 | else | ||
495 | { | ||
496 | Eo *fr; | ||
497 | Eo *parent_win = data; | ||
498 | /* | ||
499 | if (!parent_win) | ||
500 | { | ||
501 | parent_win = wdg_eo_get(wdg_parent_get(wdg)); | ||
502 | } | ||
503 | */ | ||
504 | |||
505 | o = eo_add_custom(ELM_OBJ_WIN_CLASS, parent_win, elm_obj_win_constructor(NULL, ELM_WIN_INLINED_IMAGE)); | ||
506 | if (!o) return EINA_FALSE; | ||
507 | |||
508 | Eo *io = elm_win_inlined_image_object_get(o); | ||
509 | evas_object_propagate_events_set(io, EINA_FALSE); | ||
510 | |||
511 | fr = eo_add(ELM_OBJ_FRAME_CLASS, parent_win); | ||
512 | /* Unref everything and later ref it before delete */ | ||
513 | eo_unref(fr); | ||
514 | eo_do(o, eo_base_data_set("frame", fr, NULL)); | ||
515 | |||
516 | //evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
517 | //evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
518 | elm_object_text_set(fr, elm_win_title_get(o)); | ||
519 | eo_do(fr, | ||
520 | evas_obj_visibility_set(EINA_TRUE), | ||
521 | elm_obj_frame_autocollapse_set(EINA_TRUE)); | ||
522 | |||
523 | evas_object_event_callback_add(fr, EVAS_CALLBACK_MOUSE_DOWN, _frame_mouse_down, NULL); | ||
524 | eo_do(fr, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_UP, _frame_mouse_up, NULL)); | ||
525 | eo_do(fr, eo_base_data_set("winwdg", wdg, NULL)); | ||
526 | elm_object_content_set(fr, io); | ||
527 | |||
528 | eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_RESIZE, _win_resize, NULL)); | ||
529 | /* Get size from properties of window. */ | ||
530 | static Evas_Coord ox = 150, oy = 50; | ||
531 | evas_object_move(fr, ox, oy); | ||
532 | evas_object_move(io, ox, oy); | ||
533 | // ox = oy = ox + 30; | ||
534 | } | ||
535 | |||
536 | eo_unref(o); | ||
537 | wdg_eo_set((Gui_Widget *) wdg, o); | ||
538 | return EINA_TRUE; | ||
539 | } | ||
540 | |||
541 | void | ||
542 | editor_init() | ||
543 | { | ||
544 | Action_Functions *funcs = manager_action_functions_get(MODE_EDITOR); | ||
545 | funcs->wdg_add = _widget_add; | ||
546 | funcs->wdg_del = _widget_del; | ||
547 | funcs->prop_add = _editor_eo_do; | ||
548 | |||
549 | PropViewCbs *prop_cbs = propview_cbs_get(); | ||
550 | prop_cbs->property_update_cb_func = _prop_update_from_propview; | ||
551 | prop_cbs->property_delete_cb_func = _prop_del_from_propview; | ||
552 | |||
553 | ObjTreeViewCbs *objtree_cbs = objtree_cbs_get(); | ||
554 | objtree_cbs->item_selection_cb_func = _widget_selected_from_objtree; | ||
555 | } | ||
556 | |||
557 | Eina_Bool | ||
558 | editor_ctx_call(const Gui_Context *ctx) | ||
559 | { | ||
560 | EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_FALSE); | ||
561 | |||
562 | manager_init(); | ||
563 | Eina_List *list, *l; | ||
564 | Gui_Widget *wdg; | ||
565 | |||
566 | /* in editor, we iterate only over windows which don't have parent. */ | ||
567 | list = gui_context_win_list_get(ctx); | ||
568 | EINA_LIST_FOREACH(list, l, wdg) | ||
569 | { | ||
570 | /* if window has parent widget, it will be iterated as child*/ | ||
571 | if (wdg_parent_get(wdg)) | ||
572 | { | ||
573 | ERR("Window: \"%s\" has parent. It should not happen. We have bug!", wdg_name_get(wdg)); | ||
574 | continue; | ||
575 | } | ||
576 | |||
577 | /* All windows should be shown in main gui window. */ | ||
578 | _iter_widget(wdg, canvas_get()); | ||
579 | } | ||
580 | /* Set context for objtree. */ | ||
581 | objtree_context_set(ctx); | ||
582 | seqview_fill(ctx); | ||
583 | manager_shutdown(); | ||
584 | return EINA_TRUE; | ||
585 | } | ||
586 | |||
587 | /* Remove only Eo objects, not internal widget tree.*/ | ||
588 | Eina_Bool | ||
589 | editor_layout_clear(const Gui_Context *ctx) | ||
590 | { | ||
591 | EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_FALSE); | ||
592 | |||
593 | manager_init(); | ||
594 | |||
595 | Eina_List *list, *l; | ||
596 | Gui_Widget *wdg; | ||
597 | |||
598 | /* in editor, we iterate only over windows which don't have parent. */ | ||
599 | list = gui_context_win_list_get(ctx); | ||
600 | EINA_LIST_FOREACH(list, l, wdg) | ||
601 | { | ||
602 | /* if window have parent widget, it will be iterated as child*/ | ||
603 | if (wdg_parent_get(wdg)) continue; | ||
604 | |||
605 | /* if there is no parent window for widget, | ||
606 | * it means it will be shown in main gui window. */ | ||
607 | _iter_del_widget(wdg, EINA_FALSE); | ||
608 | } | ||
609 | /* Set context for objtree. */ | ||
610 | manager_shutdown(); | ||
611 | return EINA_TRUE; | ||
612 | } | ||
613 | |||
614 | void | ||
615 | editor_factory_wdg_create(const char *class_name) | ||
616 | { | ||
617 | const Gui_Widget *parent_win = NULL; | ||
618 | const char *parent_name = NULL; | ||
619 | Gui_Widget *wdg; | ||
620 | const Gui_Widget *focused_wdg = editor_wdg_selected_get(); | ||
621 | const Gui_Context *ctx = active_context_get(); | ||
622 | |||
623 | if (!ctx) | ||
624 | { | ||
625 | ERR("No active context"); | ||
626 | return; | ||
627 | } | ||
628 | |||
629 | /*If adding non window widget*/ | ||
630 | if (strcmp(class_name, DB_DEF_WIN_CLASS)) | ||
631 | { | ||
632 | if (!focused_wdg) return; | ||
633 | parent_win = wdg_parent_win_wdg_get(focused_wdg); | ||
634 | parent_name = wdg_name_get(parent_win); | ||
635 | } | ||
636 | |||
637 | char *new_name = gui_context_free_name_get(ctx, class_name); | ||
638 | |||
639 | wdg = wdg_new(new_name); | ||
640 | free(new_name); | ||
641 | wdg_class_name_set(wdg, class_name); | ||
642 | wdg_append(ctx, wdg); | ||
643 | wdg_parent_set(wdg, parent_name); | ||
644 | |||
645 | /*Add default visibility property*/ | ||
646 | Gui_Widget_Property *prop; | ||
647 | Gui_Value *val; | ||
648 | Eina_Bool b = EINA_TRUE; | ||
649 | prop = prop_new(VISIBILITY_SET); | ||
650 | val = gui_value_new(); | ||
651 | gui_value_set(val, GUI_TYPE_BOOL, &b); | ||
652 | prop_value_append(prop, val); | ||
653 | wdg_prop_add(wdg, prop); | ||
654 | |||
655 | if (IS_WIN(wdg)) | ||
656 | { | ||
657 | /* By default, the window is created in the first action */ | ||
658 | Gui_Sequence *seq = sequence_get(ctx, "BigBang"); | ||
659 | /* Generate BigBand action if does not exist */ | ||
660 | if (!seq) seq = sequence_new(ctx, "BigBang"); | ||
661 | Gui_Action *action = action_new(seq); | ||
662 | action_creation_set(action, wdg_name_get(wdg)); | ||
663 | seqview_fill(ctx); | ||
664 | |||
665 | prop = prop_new(CONSTRUCTOR); | ||
666 | val = gui_value_new(); | ||
667 | gui_value_set(val, GUI_TYPE_STRING, ELM_OBJ_WIN_CONSTRUCTOR); | ||
668 | prop_value_append(prop, val); | ||
669 | wdg_prop_add(wdg, prop); | ||
670 | |||
671 | prop = prop_new(ELM_OBJ_WIN_CONSTRUCTOR); | ||
672 | val = gui_value_new(); | ||
673 | gui_value_set(val, GUI_TYPE_NULL, NULL); | ||
674 | prop_value_append(prop, val); | ||
675 | val = gui_value_new(); | ||
676 | gui_value_set(val, GUI_TYPE_ENUM, "ELM_WIN_BASIC"); | ||
677 | prop_value_append(prop, val); | ||
678 | wdg_prop_add(wdg, prop); | ||
679 | |||
680 | int i = 200; | ||
681 | prop = prop_new(SIZE_SET); | ||
682 | val = gui_value_new(); | ||
683 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
684 | prop_value_append(prop, val); | ||
685 | val = gui_value_new(); | ||
686 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
687 | prop_value_append(prop, val); | ||
688 | wdg_prop_add(wdg, prop); | ||
689 | |||
690 | prop = prop_new(TITLE_SET); | ||
691 | val = gui_value_new(); | ||
692 | gui_value_set(val, GUI_TYPE_STRING, wdg_name_get(wdg)); | ||
693 | prop_value_append(prop, val); | ||
694 | wdg_prop_add(wdg, prop); | ||
695 | } | ||
696 | else | ||
697 | { | ||
698 | prop = prop_new(PART_TEXT_SET); | ||
699 | val = gui_value_new(); | ||
700 | gui_value_set(val, GUI_TYPE_NULL, NULL); | ||
701 | prop_value_append(prop, val); | ||
702 | val = gui_value_new(); | ||
703 | gui_value_set(val, GUI_TYPE_STRING, wdg_name_get(wdg)); | ||
704 | prop_value_append(prop, val); | ||
705 | wdg_prop_add(wdg, prop); | ||
706 | |||
707 | int i = 255; | ||
708 | prop = prop_new(COLOR_SET); | ||
709 | val = gui_value_new(); | ||
710 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
711 | prop_value_append(prop, val); | ||
712 | val = gui_value_new(); | ||
713 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
714 | prop_value_append(prop, val); | ||
715 | val = gui_value_new(); | ||
716 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
717 | prop_value_append(prop, val); | ||
718 | val = gui_value_new(); | ||
719 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
720 | prop_value_append(prop, val); | ||
721 | wdg_prop_add(wdg, prop); | ||
722 | |||
723 | i = 0; | ||
724 | prop = prop_new(POSITION_SET); | ||
725 | val = gui_value_new(); | ||
726 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
727 | prop_value_append(prop, val); | ||
728 | val = gui_value_new(); | ||
729 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
730 | prop_value_append(prop, val); | ||
731 | wdg_prop_add(wdg, prop); | ||
732 | |||
733 | double d = 1; | ||
734 | prop = prop_new(SIZE_HINT_WEIGHT_SET); | ||
735 | val = gui_value_new(); | ||
736 | gui_value_set(val, GUI_TYPE_DOUBLE, &d); | ||
737 | prop_value_append(prop, val); | ||
738 | val = gui_value_new(); | ||
739 | gui_value_set(val, GUI_TYPE_DOUBLE, &d); | ||
740 | prop_value_append(prop, val); | ||
741 | wdg_prop_add(wdg, prop); | ||
742 | } | ||
743 | |||
744 | wdg_validate(wdg); | ||
745 | |||
746 | manager_init(); | ||
747 | |||
748 | Eo *pw = NULL; | ||
749 | if (IS_WIN(wdg)) pw = (Eo *)canvas_get(); | ||
750 | manager_wdg_eo_add_call(wdg, MODE_EDITOR, pw); | ||
751 | |||
752 | objtree_item_contracted_set(NULL); | ||
753 | |||
754 | editor_wdg_selected_set(wdg); | ||
755 | objtree_item_selected_set(wdg); | ||
756 | manager_wdg_eo_do_call(wdg, MODE_EDITOR, NULL); | ||
757 | manager_shutdown(); | ||
758 | } | ||
759 | |||
760 | void | ||
761 | editor_layout_refresh() | ||
762 | { | ||
763 | const Gui_Context *ctx = active_context_get(); | ||
764 | editor_layout_clear(ctx); | ||
765 | editor_ctx_call(ctx); | ||
766 | } | ||
767 | |||
768 | /* onChange callback for all properties edit fields. | ||
769 | * If currently there is no such property in the widget, it will be added. | ||
770 | * The given object is the one created in the properties view for each parameter. | ||
771 | */ | ||
772 | static void | ||
773 | _prop_update_from_propview(void *data EINA_UNUSED, Eo *obj, void *event_info) | ||
774 | { | ||
775 | Par_Field_Data *pfd = NULL; | ||
776 | const Eo_Class *kl = eo_class_get(obj); | ||
777 | Op_Desc *op; | ||
778 | Gui_Widget *wdg; | ||
779 | Gui_Widget_Property *prop; | ||
780 | int idx; | ||
781 | Gui_Value *val; | ||
782 | Eina_Bool prop_add = EINA_FALSE; | ||
783 | |||
784 | /* Get data for changed field. */ | ||
785 | eo_do(obj, eo_base_data_get("editor", (void **) &pfd)); | ||
786 | op = pfd->it_data->op_desc; | ||
787 | wdg = pfd->it_data->wdg; | ||
788 | prop = pfd->it_data->prop; | ||
789 | idx = pfd->par_idx; | ||
790 | |||
791 | /* If property doesn't exist, create it with some default values. */ | ||
792 | if (!prop) | ||
793 | { | ||
794 | prop = prop_create_for_op(op); | ||
795 | /* Raise flag, that property is newly created and must be added to widget. */ | ||
796 | prop_add = EINA_TRUE; | ||
797 | } | ||
798 | /* Get value which need to be changed.*/ | ||
799 | val = prop_value_nth_get(prop, idx); | ||
800 | |||
801 | /* Get new value from edit field. | ||
802 | * And update Gui_Value with new value. */ | ||
803 | Gui_Type type = db_op_desc_nth_par_type_get(op, idx); | ||
804 | if (kl == ELM_OBJ_ENTRY_CLASS) | ||
805 | { | ||
806 | const char *entry_data = elm_entry_entry_get(obj); | ||
807 | if (type == GUI_TYPE_STRING) | ||
808 | { | ||
809 | /* FIXME: part_text_set can receive NULL as parameter. | ||
810 | * But because of this, I can't write "null"*/ | ||
811 | if (!strcmp(entry_data, "null")) | ||
812 | { | ||
813 | gui_value_set(val, GUI_TYPE_NULL, NULL); | ||
814 | } | ||
815 | else | ||
816 | { | ||
817 | gui_value_type_set(val, type); | ||
818 | gui_value_string_set(val, entry_data); | ||
819 | } | ||
820 | } | ||
821 | /* FIXME: there is problem with content_set; because prev content must be unset; or need to redraw from the beginning*/ | ||
822 | else if (type == GUI_TYPE_OBJECT) | ||
823 | { | ||
824 | const char *cur_param = gui_value_string_get(val); | ||
825 | Gui_Widget *cur_param_wdg = wdg_get(active_context_get(), cur_param); | ||
826 | Gui_Widget *new_param_wdg = wdg_get(active_context_get(), entry_data); | ||
827 | /* GUI_TYPE_OBJECT ops depend on other widgets, check that widget exists. | ||
828 | * or new one not equal old one.*/ | ||
829 | if ((!new_param_wdg) || (cur_param_wdg == new_param_wdg)) | ||
830 | { | ||
831 | goto end; | ||
832 | } | ||
833 | |||
834 | /* Update parent, if op supports it. */ | ||
835 | if (db_op_desc_flag_get(op) & UPDATE_PARENT) | ||
836 | { | ||
837 | /* If I simply change value in prop: t.e. "but1"->"but2" change parent of "but1".*/ | ||
838 | const Gui_Widget* parent_win = wdg_parent_win_wdg_get(new_param_wdg); | ||
839 | objtree_item_contracted_set(parent_win); | ||
840 | if (cur_param_wdg) | ||
841 | { | ||
842 | wdg_parent_set(cur_param_wdg, wdg_name_get(parent_win)); | ||
843 | } | ||
844 | wdg_parent_set(new_param_wdg, wdg_name_get(wdg)); | ||
845 | objtree_item_selected_set(wdg); | ||
846 | } | ||
847 | |||
848 | gui_value_type_set(val, type); | ||
849 | gui_value_string_set(val, entry_data); | ||
850 | } | ||
851 | else if (type == GUI_TYPE_SINT) | ||
852 | { | ||
853 | int number = atoi(entry_data); | ||
854 | gui_value_set(val, type, &number); | ||
855 | } | ||
856 | else if (type == GUI_TYPE_DOUBLE) | ||
857 | { | ||
858 | double number = atof(entry_data); | ||
859 | gui_value_set(val, type, &number); | ||
860 | } | ||
861 | } | ||
862 | if (kl == ELM_OBJ_CHECK_CLASS) | ||
863 | { | ||
864 | Eina_Bool state; | ||
865 | eo_do(obj, elm_obj_check_state_get(&state)); | ||
866 | gui_value_set(val, type, &state); | ||
867 | } | ||
868 | if (kl == ELM_OBJ_HOVERSEL_CLASS) | ||
869 | { | ||
870 | const char *new_enum_value = elm_object_item_part_text_get(event_info, NULL); | ||
871 | /* Set selected string on hover */ | ||
872 | elm_object_text_set(obj, new_enum_value); | ||
873 | /* Get new value depending on type of edit field. | ||
874 | * And update value. */ | ||
875 | if (type == GUI_TYPE_ENUM || type == GUI_TYPE_OBJECT) | ||
876 | { | ||
877 | gui_value_set(val, type, (void *) new_enum_value); | ||
878 | } | ||
879 | if (type == GUI_TYPE_OBJECT) | ||
880 | { | ||
881 | /* Update parent, if op supports it. */ | ||
882 | if (db_op_desc_flag_get(op) & UPDATE_PARENT) | ||
883 | { | ||
884 | /* If I simply change value in prop: t.e. "but1"->"but2" change parent of "but1".*/ | ||
885 | Gui_Widget *new_param_wdg = wdg_get(active_context_get(), new_enum_value); | ||
886 | const Gui_Widget* parent_win = wdg_parent_win_wdg_get(new_param_wdg); | ||
887 | objtree_item_contracted_set(parent_win); | ||
888 | wdg_parent_set(new_param_wdg, wdg_name_get(wdg)); | ||
889 | objtree_item_selected_set(wdg); | ||
890 | } | ||
891 | } | ||
892 | } | ||
893 | |||
894 | if (prop_add) | ||
895 | { | ||
896 | wdg_prop_add(wdg, prop); | ||
897 | pfd->it_data->prop = prop; | ||
898 | } | ||
899 | /* Validate widget and call for eo_func of current prop, | ||
900 | * in order to update layout. */ | ||
901 | if (wdg_validate(wdg)) | ||
902 | { | ||
903 | manager_init(); | ||
904 | manager_wdg_prop_eo_do_call(wdg, prop, MODE_EDITOR, NULL); | ||
905 | manager_shutdown(); | ||
906 | /* Rebuild view when property like "pack_end". */ | ||
907 | if (db_op_desc_flag_get(op) & MULTI_PROPERTY) | ||
908 | propview_build(wdg); | ||
909 | return; | ||
910 | } | ||
911 | end: | ||
912 | /* If property was newly created, delete it. */ | ||
913 | if (prop_add) prop_del(prop); | ||
914 | } | ||
915 | |||
916 | static void | ||
917 | _prop_del_from_propview(void *data, Eo *obj EINA_UNUSED, void *ev EINA_UNUSED) | ||
918 | { | ||
919 | const Gui_Widget *wdg = editor_wdg_selected_get(); | ||
920 | Gui_Widget_Property *prop = data; | ||
921 | const Op_Desc *op = prop_op_desc_get(prop); | ||
922 | Gui_Value *val; | ||
923 | Eina_List *l; | ||
924 | |||
925 | /* Change parent, when removing property like "pack_end". */ | ||
926 | if (db_op_desc_flag_get(op) & UPDATE_PARENT) | ||
927 | { | ||
928 | EINA_LIST_FOREACH(prop_value_get(prop), l, val) | ||
929 | { | ||
930 | if (gui_value_type_get(val) == GUI_TYPE_OBJECT) | ||
931 | { | ||
932 | Gui_Widget *param_wdg = wdg_get(active_context_get(), gui_value_string_get(val)); | ||
933 | if (param_wdg) | ||
934 | { | ||
935 | const Gui_Widget *parent_win = wdg_parent_win_wdg_get(param_wdg); | ||
936 | /* Do it to update list. */ | ||
937 | objtree_item_contracted_set(parent_win); | ||
938 | wdg_parent_set(param_wdg, wdg_name_get(parent_win)); | ||
939 | objtree_item_selected_set(wdg); | ||
940 | } | ||
941 | } | ||
942 | } | ||
943 | } | ||
944 | |||
945 | wdg_prop_del((Gui_Widget *) wdg, prop); | ||
946 | editor_layout_refresh(); | ||
947 | editor_wdg_selected_set(wdg); | ||
948 | objtree_item_selected_set(wdg); | ||
949 | } | ||
950 | |||
951 | static void | ||
952 | _widget_selected_from_objtree(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) | ||
953 | { | ||
954 | Gui_Widget *wdg = elm_object_item_data_get(event_info); | ||
955 | editor_wdg_selected_set(wdg); | ||
956 | if (wdg) propview_build(wdg); | ||
957 | } | ||
958 | |||
diff --git a/src/bin/editor.h b/src/bin/editor.h deleted file mode 100644 index 3265d54..0000000 --- a/src/bin/editor.h +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | |||
2 | #ifndef _EDITOR_H | ||
3 | #define _EDITOR_H | ||
4 | |||
5 | #include "gui_widget.h" | ||
6 | #include <Elementary.h> | ||
7 | |||
8 | enum { | ||
9 | BORDER_OUT = 0, | ||
10 | BORDER_LEFT = 1 << 0, | ||
11 | BORDER_RIGHT = 1 << 1, | ||
12 | BORDER_TOP = 1 << 2, | ||
13 | BORDER_BOTTOM = 1 << 3 | ||
14 | }; | ||
15 | |||
16 | Eina_Bool | ||
17 | editor_ctx_call(const Gui_Context *ctx); | ||
18 | |||
19 | Eina_Bool | ||
20 | editor_layout_clear(const Gui_Context *ctx); | ||
21 | |||
22 | void | ||
23 | editor_layout_refresh(); | ||
24 | |||
25 | void | ||
26 | editor_factory_wdg_create(const char *class_name); | ||
27 | |||
28 | void | ||
29 | _editor_selected_wdg_del_cb(); | ||
30 | |||
31 | int | ||
32 | which_border(Evas_Coord x, Evas_Coord y, Evas_Coord ow, Evas_Coord oh); | ||
33 | |||
34 | void | ||
35 | editor_wdg_selected_set(const Gui_Widget *wdg); | ||
36 | |||
37 | const Gui_Widget* | ||
38 | editor_wdg_selected_get(); | ||
39 | |||
40 | void | ||
41 | editor_init(); | ||
42 | |||
43 | #endif | ||
diff --git a/src/bin/egui_gui/CMakeLists.txt b/src/bin/egui_gui/CMakeLists.txt new file mode 100644 index 0000000..22d688e --- /dev/null +++ b/src/bin/egui_gui/CMakeLists.txt | |||
@@ -0,0 +1,134 @@ | |||
1 | set(CMAKE_BUILD_TYPE Debug) | ||
2 | |||
3 | find_package(Gvc QUIET) | ||
4 | find_package(CGraph QUIET) | ||
5 | |||
6 | if (GVC_FOUND AND CGRAPH_FOUND) | ||
7 | add_definitions(-DHAVE_GRAPHVIZ) | ||
8 | endif (GVC_FOUND AND CGRAPH_FOUND) | ||
9 | |||
10 | include_directories (${CMAKE_SOURCE_DIR}/src/lib) | ||
11 | |||
12 | link_directories (${CMAKE_SOURCE_DIR}/src/lib) | ||
13 | link_directories (${PC_LIBELEMENTARY_LIBRARY_DIRS}) | ||
14 | |||
15 | #add -DGUI_MODE to build gui executable | ||
16 | add_definitions(-DGUI_MODE) | ||
17 | |||
18 | include_directories( | ||
19 | ${EINA_INCLUDE_DIRS} | ||
20 | ${ECORE_INCLUDE_DIRS} | ||
21 | ${EVAS_INCLUDE_DIRS} | ||
22 | ${ELEMENTARY_INCLUDE_DIRS} | ||
23 | ${GVC_INCLUDE_DIRS} | ||
24 | ${CGRAPH_INCLUDE_DIRS} | ||
25 | ) | ||
26 | |||
27 | ############################ | ||
28 | # building our stable egui | ||
29 | # by copying files | ||
30 | ############################ | ||
31 | |||
32 | add_custom_target(delete_files | ||
33 | COMMENT "Deleting previously autogenerated \"egui_layout.c/h files\"" | ||
34 | COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/egui_layout.* | ||
35 | COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/tmp/egui_layout.* | ||
36 | ) | ||
37 | |||
38 | set(TARGET egui) | ||
39 | |||
40 | add_executable(${TARGET} | ||
41 | ${EGUI_BINARY_SRC}/main.c | ||
42 | egui_layout.c | ||
43 | egui_logic.c | ||
44 | props_helper.c | ||
45 | objtree.c | ||
46 | propview.c | ||
47 | seqview.c | ||
48 | editor.c | ||
49 | ) | ||
50 | |||
51 | # we need to copy egui_layout json files into c/h files. | ||
52 | # OUTPUT says that executable depends on these files | ||
53 | add_custom_command ( | ||
54 | OUTPUT egui_layout.c egui_layout.h | ||
55 | COMMENT "Copying egui_layout.c/h" | ||
56 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/egui_layout_c.json egui_layout.c | ||
57 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/egui_layout_h.json egui_layout.h | ||
58 | ) | ||
59 | |||
60 | #need to add /egui/build/src/bin/egui/egui_gui as INCLUDE dir because prev command generates file in build dir | ||
61 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
62 | |||
63 | add_dependencies(${TARGET} delete_files) | ||
64 | target_link_libraries (${TARGET} | ||
65 | guiparser | ||
66 | ${EINA_LIBRARIES} | ||
67 | ${ECORE_LIBRARIES} | ||
68 | ${EVAS_LIBRARIES} | ||
69 | ${ELEMENTARY_LIBRARIES} | ||
70 | ${GVC_LIBRARIES} | ||
71 | ${CGRAPH_LIBRARIES} | ||
72 | ecore_file | ||
73 | ) | ||
74 | |||
75 | #copy egui from /build/egui_gui/ to /build | ||
76 | add_custom_command (TARGET ${TARGET} | ||
77 | POST_BUILD | ||
78 | COMMENT "Post: Copying egui into usual build dir" | ||
79 | COMMAND ${CMAKE_COMMAND} -E copy ${TARGET} ${EGUI_BINARY_BLD}/${TARGET} | ||
80 | #delete generated files | ||
81 | COMMAND ${CMAKE_COMMAND} -E remove egui_layout.* | ||
82 | ) | ||
83 | |||
84 | ############################ | ||
85 | # building our experimantal egui | ||
86 | # by generating files | ||
87 | ############################ | ||
88 | set(TARGET2 egui_auto) | ||
89 | |||
90 | add_executable(${TARGET2} | ||
91 | ${EGUI_BINARY_SRC}/main.c | ||
92 | tmp/egui_layout.c | ||
93 | egui_logic.c | ||
94 | props_helper.c | ||
95 | objtree.c | ||
96 | propview.c | ||
97 | seqview.c | ||
98 | editor.c) | ||
99 | # add this dependency to force build one after another, | ||
100 | # in order to delete and generate files in proper order | ||
101 | add_dependencies(${TARGET2} ${TARGET}) | ||
102 | add_dependencies(${TARGET2} delete_files) | ||
103 | |||
104 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/tmp) | ||
105 | |||
106 | #generate c/h files from json. | ||
107 | # here i need to put these files into another path, because I can't again use OUTPUT egui_layout.c egui_layout.h. | ||
108 | # Because cmake will think, that our egui_auto depends on files | ||
109 | # egui_layout.c/h which were copied for target egui and will build with them | ||
110 | add_custom_command ( | ||
111 | OUTPUT tmp/egui_layout.c tmp/egui_layout.h | ||
112 | COMMENT "Generating gui layout from JSON" | ||
113 | COMMAND ${CMAKE_COMMAND} -E make_directory tmp | ||
114 | COMMAND ${EGUI_BINARY_BLD}/egui_cmd -f ${CMAKE_CURRENT_SOURCE_DIR}/egui_layout_c.json -g -o egui_layout -p ./tmp | ||
115 | ) | ||
116 | |||
117 | target_link_libraries (${TARGET2} | ||
118 | guiparser | ||
119 | ${EINA_LIBRARIES} | ||
120 | ${ECORE_LIBRARIES} | ||
121 | ${EVAS_LIBRARIES} | ||
122 | ${ELEMENTARY_LIBRARIES} | ||
123 | ${GVC_LIBRARIES} | ||
124 | ${CGRAPH_LIBRARIES} | ||
125 | ecore_file | ||
126 | ) | ||
127 | |||
128 | #copy egui_auto from /build/egui_gui/tmp to /build | ||
129 | add_custom_command (TARGET ${TARGET2} | ||
130 | POST_BUILD | ||
131 | COMMENT "Post: Copying egui_auto into usual build dir" | ||
132 | COMMAND ${CMAKE_COMMAND} -E copy ${TARGET2} ${EGUI_BINARY_BLD}/${TARGET2} | ||
133 | COMMAND ${CMAKE_COMMAND} -E remove_directory tmp | ||
134 | ) | ||
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c new file mode 100644 index 0000000..da8d87d --- /dev/null +++ b/src/bin/egui_gui/editor.c | |||
@@ -0,0 +1,1629 @@ | |||
1 | |||
2 | #include "egui_log.h" | ||
3 | #include "ffi_glue.h" | ||
4 | #include "ffi_abstraction.h" | ||
5 | #include "gui_widget.h" | ||
6 | #include "props_helper.h" | ||
7 | #include "objtree.h" | ||
8 | #include "propview.h" | ||
9 | #include "seqview.h" | ||
10 | #include "gui_parser.h" | ||
11 | #include "egui_logic_private.h" | ||
12 | |||
13 | #include <Elementary.h> | ||
14 | #include "elm_widget.h" | ||
15 | |||
16 | #define SELECTED_WDG "slctd_wdg" | ||
17 | #define WIN_INFO "win_info_key" | ||
18 | #define DEP_PROP_LIST "dependent_property_list_key" | ||
19 | |||
20 | |||
21 | Gui_Session *_editor_session = NULL; | ||
22 | static Gui_Context *_active_ctx = NULL; | ||
23 | static It_Data_Type _propsview_toolbar_selected_item_type = DESCRIPTION_TYPE; | ||
24 | |||
25 | void | ||
26 | _active_context_set(Gui_Context *ctx) | ||
27 | { | ||
28 | _active_ctx = ctx; | ||
29 | } | ||
30 | |||
31 | Gui_Context * | ||
32 | _active_context_get() | ||
33 | { | ||
34 | return _active_ctx; | ||
35 | } | ||
36 | /* function to resolve dependency between action and widget when deleting widget.*/ | ||
37 | extern Eina_Bool | ||
38 | _action_dep_resolve(Gui_Action *action, Eina_Bool adding, Dep_Mode mode); | ||
39 | |||
40 | typedef enum { | ||
41 | BORDER_OUT = 0, | ||
42 | BORDER_LEFT = 1 << 0, | ||
43 | BORDER_RIGHT = 1 << 1, | ||
44 | BORDER_TOP = 1 << 2, | ||
45 | BORDER_BOTTOM = 1 << 3, | ||
46 | /* Need separate names for borders and markers. They are used as keys in hash. */ | ||
47 | BORDER_MARKER_LEFT = BORDER_LEFT, | ||
48 | BORDER_MARKER_RIGHT = BORDER_RIGHT, | ||
49 | BORDER_MARKER_TOP = BORDER_TOP, | ||
50 | BORDER_MARKER_BOTTOM = BORDER_BOTTOM, | ||
51 | |||
52 | BORDER_MARKER_TOP_LEFT = BORDER_MARKER_TOP | BORDER_MARKER_LEFT, | ||
53 | BORDER_MARKER_TOP_RIGHT = BORDER_MARKER_TOP | BORDER_MARKER_RIGHT, | ||
54 | |||
55 | BORDER_MARKER_BOTTOM_LEFT = BORDER_MARKER_BOTTOM | BORDER_MARKER_LEFT, | ||
56 | BORDER_MARKER_BOTTOM_RIGHT = BORDER_MARKER_BOTTOM | BORDER_MARKER_RIGHT | ||
57 | |||
58 | } Border_Type; | ||
59 | |||
60 | typedef struct _Win_Info | ||
61 | { | ||
62 | Eo *frame; | ||
63 | } Win_Info; | ||
64 | |||
65 | static Win_Info* | ||
66 | win_info_new() | ||
67 | { | ||
68 | return calloc(1, sizeof(Win_Info)); | ||
69 | } | ||
70 | |||
71 | static void | ||
72 | win_info_frame_set(Win_Info *wi, Eo *fr) | ||
73 | { | ||
74 | wi->frame = fr; | ||
75 | } | ||
76 | |||
77 | static Eo* | ||
78 | win_info_frame_get(const Win_Info *wi) | ||
79 | { | ||
80 | return wi->frame; | ||
81 | } | ||
82 | |||
83 | /*This is a helper to add/delete dependent properties to/from widget. | ||
84 | * Func is called when property is activated or deleted.*/ | ||
85 | static Eina_Bool | ||
86 | _prop_dep_resolve(Gui_Widget_Property *prop, Eina_Bool adding) | ||
87 | { | ||
88 | EINA_SAFETY_ON_NULL_RETURN_VAL(prop, EINA_FALSE); | ||
89 | |||
90 | Eina_List *values_lst, *itr; | ||
91 | Gui_Value *gui_value; | ||
92 | |||
93 | values_lst = prop_value_get(prop); | ||
94 | |||
95 | EINA_LIST_FOREACH(values_lst, itr, gui_value) | ||
96 | { | ||
97 | if (gui_value_type_get(gui_value) == GUI_TYPE_OBJECT) | ||
98 | { | ||
99 | char *wdg_name = gui_value_string_get(gui_value); | ||
100 | Gui_Widget *w = wdg_get(wdg_context_get(prop_wdg_get(prop)), wdg_name); | ||
101 | if (!w) | ||
102 | { | ||
103 | ERR("Somehow widget '%s' doesn't exist", wdg_name); | ||
104 | return EINA_TRUE; | ||
105 | } | ||
106 | Eina_List *dep_props_list = wdg_data_get(w, DEP_PROP_LIST); | ||
107 | if (adding) | ||
108 | { | ||
109 | dep_props_list = eina_list_append(dep_props_list, prop); | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | if (eina_list_data_find(dep_props_list, prop)) | ||
114 | { | ||
115 | dep_props_list = eina_list_remove(dep_props_list, prop); | ||
116 | } | ||
117 | } | ||
118 | wdg_data_set(w, DEP_PROP_LIST, dep_props_list); | ||
119 | } | ||
120 | } | ||
121 | return EINA_TRUE; | ||
122 | } | ||
123 | |||
124 | /* Iterate over each dependent property and delete it from its widget. | ||
125 | * T.e. when deleting button, "pack_end" will be dependent property. | ||
126 | * So delete this property from box.*/ | ||
127 | static void | ||
128 | _wdg_dep_del(Gui_Widget *wdg) | ||
129 | { | ||
130 | Gui_Widget_Property *prop; | ||
131 | Eina_List *lst = wdg_data_get(wdg, DEP_PROP_LIST); | ||
132 | Eina_List *itr, *itr_next; | ||
133 | wdg_data_set(wdg, DEP_PROP_LIST, NULL); | ||
134 | |||
135 | /* Iterate over each dependency, and delete this prop from each widget */ | ||
136 | /* Make FOREACH_SAFE, because _prop_dep_resolve removes items from this list*/ | ||
137 | EINA_LIST_FOREACH_SAFE(lst, itr, itr_next, prop) | ||
138 | { | ||
139 | Gui_Widget *w; | ||
140 | _prop_dep_resolve(prop, EINA_FALSE); | ||
141 | w = (Gui_Widget *) prop_wdg_get(prop); | ||
142 | wdg_prop_del(w, prop); | ||
143 | } | ||
144 | eina_list_free(lst); | ||
145 | |||
146 | /* Iterate over each property; | ||
147 | * and delete dependencies from each widget, which depend on this prop. */ | ||
148 | lst = wdg_prop_list_get(wdg); | ||
149 | EINA_LIST_FOREACH(lst, itr, prop) | ||
150 | { | ||
151 | _prop_dep_resolve(prop, EINA_FALSE); | ||
152 | } | ||
153 | |||
154 | /* Iterate over actions, widget depends on. */ | ||
155 | Gui_Action *action; | ||
156 | lst = wdg_data_get(wdg, DEP_ACTION_LIST); | ||
157 | EINA_LIST_FOREACH_SAFE(lst, itr, itr_next, action) | ||
158 | { | ||
159 | /* Delete action like in func _action_del. */ | ||
160 | Gui_Sequence *seq = action_sequence_get(action); | ||
161 | Eina_List *actions_list = sequence_actions_list_get(seq); | ||
162 | Elm_Object_Item *it = action_data_get(action); | ||
163 | _action_dep_resolve(action, EINA_FALSE, DEP_ALL); | ||
164 | if (eina_list_count(actions_list) > 1) | ||
165 | { | ||
166 | if (it) elm_object_item_del(it); | ||
167 | action_del(action); | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | action_reset(action); | ||
172 | if (it) elm_genlist_item_update(it); | ||
173 | } | ||
174 | } | ||
175 | /* list for this widget will be operated inside _action_dep_resolve. | ||
176 | * so need to get it one more time. | ||
177 | * Moreover this func deletes iterated action from this list, so it will be free by the end, | ||
178 | * so don't need to call eina_list_free() */ | ||
179 | lst = wdg_data_get(wdg, DEP_ACTION_LIST); | ||
180 | eina_list_free(lst); | ||
181 | } | ||
182 | |||
183 | static void | ||
184 | _canvas_free_coords_get(Gui_Context *ctx, Evas_Coord *x, Evas_Coord *y) | ||
185 | { | ||
186 | Evas_Coord x0 = 340, y0 = 120, w0 = 1060, h0 = 900, retx, rety, ymax = 120; | ||
187 | Eina_List *win_list = gui_context_win_list_get(ctx); | ||
188 | Eina_List *itr; | ||
189 | Gui_Widget *wdg; | ||
190 | retx = x0; | ||
191 | rety = y0; | ||
192 | EINA_LIST_FOREACH(win_list, itr, wdg) | ||
193 | { | ||
194 | Evas_Coord fx, fy, fw, fh; | ||
195 | Win_Info *wi = wdg_data_get(wdg, WIN_INFO); | ||
196 | if (wi) | ||
197 | { | ||
198 | eo_do(win_info_frame_get(wi), evas_obj_size_get(&fw, &fh)); | ||
199 | eo_do(win_info_frame_get(wi), evas_obj_position_get(&fx, &fy)); | ||
200 | if ((fx + fw) < (x0 + w0 - 100)) | ||
201 | { | ||
202 | retx = fx + fw; | ||
203 | if ((fy + fh) > ymax) | ||
204 | ymax = fy + fh; | ||
205 | } | ||
206 | else | ||
207 | { | ||
208 | retx = x0; | ||
209 | rety = ymax; | ||
210 | if (rety > (y0 + h0)) rety = y0; | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | if (x) *x = retx; | ||
215 | if (y) *y = rety; | ||
216 | } | ||
217 | |||
218 | int | ||
219 | which_border(Evas_Coord x, Evas_Coord y, Evas_Coord ow, Evas_Coord oh) | ||
220 | { | ||
221 | /* Width of border to catch callback. */ | ||
222 | Evas_Coord bw = 10; | ||
223 | int lr = 0, tb = 0; | ||
224 | if (x < bw) lr = BORDER_LEFT; | ||
225 | else if (x > ow - bw) lr = BORDER_RIGHT; | ||
226 | if (y < bw) tb = BORDER_TOP; | ||
227 | else if (y > oh - bw) tb = BORDER_BOTTOM; | ||
228 | return lr | tb; | ||
229 | } | ||
230 | |||
231 | static Eina_Bool | ||
232 | _marker_mouse_down(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); | ||
233 | static Eina_Bool | ||
234 | _marker_mouse_up(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); | ||
235 | static Eina_Bool | ||
236 | _marker_mouse_in(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); | ||
237 | static Eina_Bool | ||
238 | _marker_mouse_out(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); | ||
239 | #define STR(par) #par | ||
240 | |||
241 | #define LINE(base_obj, id, x, y, l, w, visibility) \ | ||
242 | ({\ | ||
243 | Eo *line = NULL;\ | ||
244 | eo_do(base_obj, eo_base_data_get(STR(id), (void **) &line));\ | ||
245 | if (!line)\ | ||
246 | {\ | ||
247 | line = eo_add(EVAS_OBJ_RECTANGLE_CLASS, evas_object_evas_get(base_obj));\ | ||
248 | eo_unref(line);\ | ||
249 | eo_do(base_obj, eo_base_data_set(STR(id), line, NULL));\ | ||
250 | eo_do(line, evas_obj_color_set(0, 255, 0, 255));\ | ||
251 | }\ | ||
252 | eo_do(line, evas_obj_visibility_set(visibility));\ | ||
253 | eo_do(line, evas_obj_position_set(x, y));\ | ||
254 | eo_do(line, evas_obj_size_set(l, w));\ | ||
255 | eo_do(line, evas_obj_raise());\ | ||
256 | }) | ||
257 | |||
258 | #define MARKER(base_obj, id, x, y, visibility) \ | ||
259 | ({ \ | ||
260 | Eo *_m = NULL;\ | ||
261 | eo_do(base_obj, eo_base_data_get(STR(id), (void **) &_m));\ | ||
262 | if (!_m)\ | ||
263 | {\ | ||
264 | _m = eo_add(EVAS_OBJ_RECTANGLE_CLASS, evas_object_evas_get(base_obj));\ | ||
265 | eo_unref(_m);\ | ||
266 | eo_do(base_obj, eo_base_data_set(STR(id), _m, NULL));\ | ||
267 | eo_do(_m, evas_obj_color_set(0, 255, 0, 255));\ | ||
268 | eo_do(_m, evas_obj_size_set(7, 7));\ | ||
269 | eo_do(_m, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_DOWN, _marker_mouse_down, (void *) id)); \ | ||
270 | eo_do(_m, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_UP, _marker_mouse_up, (void *) id)); \ | ||
271 | eo_do(_m, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_IN, _marker_mouse_in, (void *) id)); \ | ||
272 | eo_do(_m, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_OUT, _marker_mouse_out, (void *) id)); \ | ||
273 | }\ | ||
274 | eo_do(_m, evas_obj_position_set(x, y)); \ | ||
275 | eo_do(_m, evas_obj_raise());\ | ||
276 | eo_do(_m, evas_obj_visibility_set(visibility));\ | ||
277 | }) | ||
278 | |||
279 | /* Draws border around obj, Evas is taken from base_obj; | ||
280 | * markers and lines are saved in base_obj*/ | ||
281 | static void | ||
282 | _border_draw(const Eo *base_obj, Eo *obj, Eina_Bool visibility) | ||
283 | { | ||
284 | Evas_Coord ox = 0, oy = 0, ow = 0, oh = 0, minw = 0, minh = 0; | ||
285 | Evas_Coord lw = 0 , lh = 0, hs = 5; | ||
286 | |||
287 | /* This is made, to have opportunity to pass NULL and hide border.*/ | ||
288 | if (obj) | ||
289 | { | ||
290 | eo_do(obj, evas_obj_position_get(&ox, &oy)); | ||
291 | eo_do(obj, evas_obj_size_hint_min_get(&minw, &minh)); | ||
292 | eo_do(obj, evas_obj_size_get(&ow, &oh)); | ||
293 | if (ow < minw) ow = minw; | ||
294 | if (oh < minh) oh = minh; | ||
295 | |||
296 | lw = ow + 2; | ||
297 | lh = oh + 2; | ||
298 | } | ||
299 | |||
300 | LINE(base_obj, BORDER_TOP, ox - 1, oy - 1, lw, 1, visibility); | ||
301 | LINE(base_obj, BORDER_BOTTOM, ox - 1, oy + oh + 1, lw, 1, visibility); | ||
302 | LINE(base_obj, BORDER_RIGHT, ox + ow + 1, oy - 1, 1, lh, visibility); | ||
303 | LINE(base_obj, BORDER_LEFT, ox - 1, oy - 1, 1, lh, visibility); | ||
304 | |||
305 | MARKER(base_obj, BORDER_MARKER_TOP_LEFT, ox - 1 - hs / 2, oy - 1 - hs / 2, visibility); | ||
306 | MARKER(base_obj, BORDER_MARKER_TOP, ox + ow / 2 - hs / 2, oy - 1 - hs / 2, visibility); | ||
307 | MARKER(base_obj, BORDER_MARKER_TOP_RIGHT, ox + ow + 1 - hs / 2, oy - 1 - hs / 2, visibility); | ||
308 | MARKER(base_obj, BORDER_MARKER_RIGHT, ox + ow + 1 - hs / 2, oy + oh / 2 - hs / 2, visibility); | ||
309 | MARKER(base_obj, BORDER_MARKER_BOTTOM_RIGHT, ox + ow + 1 - hs / 2, oy + oh + 1 - hs / 2, visibility); | ||
310 | MARKER(base_obj, BORDER_MARKER_BOTTOM, ox + ow / 2 - hs / 2, oy + oh + 1 - hs / 2, visibility); | ||
311 | MARKER(base_obj, BORDER_MARKER_BOTTOM_LEFT, ox - 1 - hs / 2, oy + oh + 1 - hs / 2, visibility); | ||
312 | MARKER(base_obj, BORDER_MARKER_LEFT, ox - 1 - hs / 2, oy + oh / 2 - hs / 2, visibility); | ||
313 | } | ||
314 | |||
315 | static void | ||
316 | _wdg_border_draw(const Gui_Widget *wdg, Eina_Bool visibility) | ||
317 | { | ||
318 | Eo *obj = session_eo_get(_editor_session, wdg); | ||
319 | if (!obj) return; | ||
320 | const Gui_Widget *win_wdg = wdg_parent_win_wdg_get(wdg); | ||
321 | if (!win_wdg) return; | ||
322 | Eo *win_wdg_eo; | ||
323 | win_wdg_eo = session_eo_get(_editor_session, win_wdg); | ||
324 | _border_draw(win_wdg_eo, obj, visibility); | ||
325 | } | ||
326 | #undef LINE | ||
327 | #undef MARKER | ||
328 | #undef STR | ||
329 | |||
330 | static void | ||
331 | _on_mouse_move_widget_drag(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, | ||
332 | void *event_info) | ||
333 | { | ||
334 | Gui_Context *ctx = data; | ||
335 | static int cx, cy; | ||
336 | Evas_Coord ox, oy; | ||
337 | Evas_Event_Mouse_Move *ev = event_info; | ||
338 | |||
339 | /*FIXME: remove static stuff after tripple callback wil be fixed*/ | ||
340 | if ((cx == ev->cur.canvas.x) && (cy == ev->cur.canvas.y)) | ||
341 | return; | ||
342 | |||
343 | eo_do(obj, evas_obj_position_get(&ox, &oy)); | ||
344 | ox = ox + (ev->cur.canvas.x - ev->prev.canvas.x); | ||
345 | oy = oy + (ev->cur.canvas.y - ev->prev.canvas.y); | ||
346 | |||
347 | eo_do(obj, evas_obj_position_set(ox, oy)); | ||
348 | { | ||
349 | Gui_Widget *wdg = wdg_find_by_eo(_editor_session, ctx, obj); | ||
350 | Gui_Widget_Property *prop; | ||
351 | Gui_Value *val; | ||
352 | |||
353 | if (wdg) | ||
354 | { | ||
355 | _wdg_border_draw(wdg, EINA_TRUE); | ||
356 | |||
357 | prop = wdg_prop_get(wdg, POSITION_SET); | ||
358 | if (prop) | ||
359 | { | ||
360 | val = prop_value_nth_get(prop, 0); | ||
361 | gui_value_set(val, GUI_TYPE_SINT, &ox); | ||
362 | val = prop_value_nth_get(prop, 1); | ||
363 | gui_value_set(val, GUI_TYPE_SINT, &oy); | ||
364 | propview_item_update(prop); | ||
365 | } | ||
366 | } | ||
367 | } | ||
368 | cx = ev->cur.canvas.x; | ||
369 | cy = ev->cur.canvas.y; | ||
370 | } | ||
371 | |||
372 | static void | ||
373 | _frame_mouse_move(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *fr, void *event_info) | ||
374 | { | ||
375 | Evas_Coord ox, oy; | ||
376 | Evas_Event_Mouse_Move *ev = event_info; | ||
377 | Gui_Widget *wdg; | ||
378 | Gui_Widget_Property *prop; | ||
379 | |||
380 | eo_do(fr, evas_obj_position_get(&ox, &oy)); | ||
381 | |||
382 | ox = ox + (ev->cur.canvas.x - ev->prev.canvas.x); | ||
383 | oy = oy + (ev->cur.canvas.y - ev->prev.canvas.y); | ||
384 | |||
385 | eo_do(fr, eo_base_data_get("winwdg", (void**)(&wdg))); | ||
386 | |||
387 | /* FIXME: Move frame here, because we don't know if win must have position property*/ | ||
388 | eo_do(fr, evas_obj_position_set(ox, oy)); | ||
389 | prop = wdg_prop_get(wdg, POSITION_SET); | ||
390 | if (prop) | ||
391 | { | ||
392 | Gui_Value *val; | ||
393 | val = prop_value_nth_get(prop, 0); | ||
394 | gui_value_set(val, GUI_TYPE_SINT, &ox); | ||
395 | val = prop_value_nth_get(prop, 1); | ||
396 | gui_value_set(val, GUI_TYPE_SINT, &oy); | ||
397 | propview_item_update(prop); | ||
398 | } | ||
399 | |||
400 | /* Redraw win border, when moving frame. */ | ||
401 | _border_draw(canvas_get(), fr, EINA_TRUE); | ||
402 | } | ||
403 | |||
404 | static const Gui_Widget* | ||
405 | _editor_wdg_selected_get() | ||
406 | { | ||
407 | Gui_Context *ctx = _active_context_get(); | ||
408 | if (!ctx) return NULL; | ||
409 | return gui_context_data_get(ctx, SELECTED_WDG); | ||
410 | } | ||
411 | |||
412 | static void | ||
413 | _editor_wdg_selected_set(const Gui_Widget *wdg) | ||
414 | { | ||
415 | const Gui_Widget *old_wdg = _editor_wdg_selected_get(); | ||
416 | if ((old_wdg) && (old_wdg == wdg)) return; | ||
417 | |||
418 | /* Hide previous border*/ | ||
419 | if (old_wdg) | ||
420 | { | ||
421 | if (IS_WIN(old_wdg)) | ||
422 | { | ||
423 | Win_Info *wi = wdg_data_get(old_wdg, WIN_INFO); | ||
424 | Eo *fr = win_info_frame_get(wi); | ||
425 | _border_draw(canvas_get(), fr, EINA_FALSE); | ||
426 | } | ||
427 | else | ||
428 | { | ||
429 | _wdg_border_draw(old_wdg, EINA_FALSE); | ||
430 | } | ||
431 | } | ||
432 | else | ||
433 | { | ||
434 | /* During context call _win_resize() will be called. | ||
435 | * It will draw border around win, but widget was not selected yet. | ||
436 | * So need to hide border. */ | ||
437 | _border_draw(canvas_get(), NULL, EINA_FALSE); | ||
438 | } | ||
439 | |||
440 | /* Show new border*/ | ||
441 | if (wdg) | ||
442 | { | ||
443 | Gui_Context *ctx = wdg_context_get(wdg); | ||
444 | gui_context_data_set(ctx, SELECTED_WDG, (Gui_Widget *) wdg); | ||
445 | |||
446 | Eo *obj = session_eo_get(_editor_session, wdg); | ||
447 | /* Stack up */ | ||
448 | // eo_do(obj, evas_obj_raise()); | ||
449 | /* Set focus */ | ||
450 | eo_do(obj, evas_obj_focus_set(EINA_TRUE)); | ||
451 | if (IS_WIN(wdg)) | ||
452 | { | ||
453 | Win_Info *wi = wdg_data_get(wdg, WIN_INFO); | ||
454 | Eo *fr = win_info_frame_get(wi); | ||
455 | _border_draw(canvas_get(), fr, EINA_TRUE); | ||
456 | } | ||
457 | else | ||
458 | { | ||
459 | _wdg_border_draw(wdg, EINA_TRUE); | ||
460 | } | ||
461 | } | ||
462 | else | ||
463 | { | ||
464 | gui_context_data_set(_active_context_get(), SELECTED_WDG, NULL); | ||
465 | } | ||
466 | } | ||
467 | |||
468 | /* Second parameter is used to indicate if the wdg has to be deleted */ | ||
469 | static void | ||
470 | _iter_widget_delete(Gui_Widget *wdg, Eina_Bool del_wdg) | ||
471 | { | ||
472 | Eina_List *children = NULL, *l, *l2; | ||
473 | Gui_Widget *w; | ||
474 | |||
475 | children = wdg_children_list_get(wdg); | ||
476 | EINA_LIST_FOREACH_SAFE(children, l, l2, w) | ||
477 | { | ||
478 | _iter_widget_delete(w, del_wdg); | ||
479 | } | ||
480 | |||
481 | /* If widget is Win, look for its frame and unset content, but don't delete frame. */ | ||
482 | if (IS_WIN(wdg)) | ||
483 | { | ||
484 | Win_Info *wi = wdg_data_get(wdg, WIN_INFO); | ||
485 | Eo *fr = win_info_frame_get(wi); | ||
486 | if (fr) | ||
487 | { | ||
488 | elm_object_content_unset(fr); | ||
489 | if (del_wdg) | ||
490 | { | ||
491 | wdg_data_set(wdg, WIN_INFO, NULL); | ||
492 | free(wi); | ||
493 | eo_do(fr, eo_base_data_del("winwdg")); | ||
494 | eo_ref(fr); | ||
495 | eo_del(fr); | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | manager_widget_delete(_editor_session, wdg, MODE_EDITOR, NULL); | ||
500 | |||
501 | if (del_wdg) | ||
502 | { | ||
503 | _wdg_dep_del(wdg); | ||
504 | wdg_del(wdg); | ||
505 | } | ||
506 | /* This function is called when widget is deleted or context refreshed. | ||
507 | * This case is for context refresh: clear list of dependencies.*/ | ||
508 | else | ||
509 | { | ||
510 | Eina_List *lst = wdg_data_get(wdg, DEP_PROP_LIST); | ||
511 | eina_list_free(lst); | ||
512 | wdg_data_set(wdg, DEP_PROP_LIST, NULL); | ||
513 | } | ||
514 | } | ||
515 | |||
516 | static void | ||
517 | _key_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | ||
518 | { | ||
519 | // Gui_Context *ctx = data; | ||
520 | ERR("key down"); | ||
521 | } | ||
522 | |||
523 | /* Callback, which adds MOUSE_MOVE callback, | ||
524 | * to implement drag-and-drop in editor mode*/ | ||
525 | static void | ||
526 | _mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) | ||
527 | { | ||
528 | Gui_Context *ctx = data; | ||
529 | Gui_Widget *wdg = wdg_find_by_eo(_editor_session, ctx, obj); | ||
530 | EINA_SAFETY_ON_NULL_RETURN(wdg); | ||
531 | |||
532 | Eo *wdg_eo = session_eo_get(_editor_session, wdg); | ||
533 | evas_object_focus_set(wdg_eo, EINA_TRUE); | ||
534 | _editor_wdg_selected_set(wdg); | ||
535 | objtree_item_selected_set(wdg); | ||
536 | |||
537 | evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move_widget_drag, ctx); | ||
538 | } | ||
539 | |||
540 | /* Callback, which deletes MOUSE_MOVE callback, | ||
541 | * to implement drag-and-drop*/ | ||
542 | static Eina_Bool | ||
543 | _mouse_up(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
544 | { | ||
545 | /* Delete all callbacks, | ||
546 | * because sometimes _mouse_down is called several times. */ | ||
547 | while(evas_object_event_callback_del | ||
548 | (obj, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move_widget_drag)); | ||
549 | return EO_CALLBACK_CONTINUE; | ||
550 | } | ||
551 | |||
552 | static Eina_Bool | ||
553 | _marker_mouse_move(void *data, Eo *marker EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info) | ||
554 | { | ||
555 | Eo *weo; | ||
556 | Evas_Coord ox, oy, ow, oh, minw, minh, dx, dy; | ||
557 | Evas_Event_Mouse_Move *ev = event_info; | ||
558 | Border_Type border = (int) data; | ||
559 | |||
560 | Eo *cur_logo = NULL; | ||
561 | const Gui_Widget *wdg = _editor_wdg_selected_get(); | ||
562 | |||
563 | dx = ev->cur.canvas.x - ev->prev.canvas.x; | ||
564 | dy = ev->cur.canvas.y - ev->prev.canvas.y; | ||
565 | |||
566 | /* in base object cursor description is save. | ||
567 | * base object is win's Eo for widget, | ||
568 | * and canvas(main window) for frame. */ | ||
569 | const Eo *base_obj; | ||
570 | if (IS_WIN(wdg)) | ||
571 | { | ||
572 | base_obj = canvas_get(); | ||
573 | Win_Info *wi = wdg_data_get(wdg, WIN_INFO); | ||
574 | weo = win_info_frame_get(wi); | ||
575 | |||
576 | /* When resizing frame, we need to get min width and height form window. | ||
577 | * And don't forget deltas*/ | ||
578 | Eo *ww = session_eo_get(_editor_session, wdg); | ||
579 | eo_do(ww, evas_obj_size_hint_min_get(&minw, &minh)); | ||
580 | int dw, dh; | ||
581 | eo_do(weo, eo_base_data_get("dw", (void **) &dw)); | ||
582 | eo_do(weo, eo_base_data_get("dh", (void **) &dh)); | ||
583 | minw += dw; | ||
584 | minh += dh; | ||
585 | } | ||
586 | else | ||
587 | { | ||
588 | const Gui_Widget *win_wdg = wdg_parent_win_wdg_get(wdg); | ||
589 | base_obj = session_eo_get(_editor_session, win_wdg); | ||
590 | /* Eo object of widget. */ | ||
591 | weo = session_eo_get(_editor_session, wdg); | ||
592 | eo_do(weo, evas_obj_size_hint_min_get(&minw, &minh)); | ||
593 | } | ||
594 | |||
595 | eo_do(base_obj, eo_base_data_get("cursor", (void **) &cur_logo)); | ||
596 | if (cur_logo) | ||
597 | eo_do(cur_logo, evas_obj_position_set(ev->cur.canvas.x + 7, ev->cur.canvas.y + 5)); | ||
598 | |||
599 | eo_do(weo, evas_obj_position_get(&ox, &oy)); | ||
600 | eo_do(weo, evas_obj_size_get(&ow, &oh)); | ||
601 | |||
602 | if (border & BORDER_MARKER_LEFT) | ||
603 | { | ||
604 | if ((ev->prev.canvas.x < ox) && ((ow - dx) > 0) && ((ow - dx) >= minw)) | ||
605 | { | ||
606 | ow = ow - dx; | ||
607 | ox = ox + dx; | ||
608 | } | ||
609 | } | ||
610 | else if (border & BORDER_MARKER_RIGHT) | ||
611 | { | ||
612 | if ((ev->prev.canvas.x > (ox + ow)) && ((ow + dx) >= minw)) | ||
613 | { | ||
614 | ow = ow + dx; | ||
615 | } | ||
616 | } | ||
617 | |||
618 | if (border & BORDER_MARKER_TOP) | ||
619 | { | ||
620 | if ((ev->prev.canvas.y < oy) && ((oh - dy) > 0) && ((oh - dy) >= minh)) | ||
621 | { | ||
622 | oh = oh - dy; | ||
623 | oy = oy + dy; | ||
624 | } | ||
625 | } | ||
626 | else if (border & BORDER_MARKER_BOTTOM) | ||
627 | { | ||
628 | if ((ev->prev.canvas.y >= (oy + oh)) && ((oh + dy) >= minh)) | ||
629 | { | ||
630 | oh = oh + dy; | ||
631 | } | ||
632 | } | ||
633 | |||
634 | eo_do(weo, evas_obj_position_set(ox, oy)); | ||
635 | eo_do(weo, evas_obj_size_set(ow, oh)); | ||
636 | |||
637 | if (IS_WIN(wdg)) | ||
638 | { | ||
639 | Gui_Widget_Property *prop; | ||
640 | Gui_Value *val; | ||
641 | |||
642 | prop = wdg_prop_get(wdg, SIZE_SET); | ||
643 | if (prop) | ||
644 | { | ||
645 | Evas_Coord dw, dh; | ||
646 | eo_do(weo, eo_base_data_get("dw", (void **) &dw)); | ||
647 | eo_do(weo, eo_base_data_get("dh", (void **) &dh)); | ||
648 | /* ow and oh are frame's sizes, we need to subtract delta, | ||
649 | * to get window's size.*/ | ||
650 | ow = ow - dw; | ||
651 | oh = oh - dh; | ||
652 | |||
653 | val = prop_value_nth_get(prop, 0); | ||
654 | gui_value_set(val, GUI_TYPE_SINT, &ow); | ||
655 | val = prop_value_nth_get(prop, 1); | ||
656 | gui_value_set(val, GUI_TYPE_SINT, &oh); | ||
657 | propview_item_update(prop); | ||
658 | /* win has size prop, so move it through manager*/ | ||
659 | manager_widget_property_add(_editor_session, wdg, prop, MODE_EDITOR, NULL); | ||
660 | } | ||
661 | } | ||
662 | else | ||
663 | { | ||
664 | /* This probably should be in _wdg_resize(), | ||
665 | * but it interferes when updating size and position from Propview. */ | ||
666 | Gui_Widget_Property *prop; | ||
667 | Gui_Value *val; | ||
668 | prop = wdg_prop_get(wdg, SIZE_SET); | ||
669 | if (prop) | ||
670 | { | ||
671 | val = prop_value_nth_get(prop, 0); | ||
672 | gui_value_set(val, GUI_TYPE_SINT, &ow); | ||
673 | val = prop_value_nth_get(prop, 1); | ||
674 | gui_value_set(val, GUI_TYPE_SINT, &oh); | ||
675 | propview_item_update(prop); | ||
676 | } | ||
677 | |||
678 | prop = wdg_prop_get(wdg, POSITION_SET); | ||
679 | if (prop) | ||
680 | { | ||
681 | val = prop_value_nth_get(prop, 0); | ||
682 | gui_value_set(val, GUI_TYPE_SINT, &ox); | ||
683 | val = prop_value_nth_get(prop, 1); | ||
684 | gui_value_set(val, GUI_TYPE_SINT, &oy); | ||
685 | propview_item_update(prop); | ||
686 | } | ||
687 | } | ||
688 | |||
689 | return EO_CALLBACK_CONTINUE; | ||
690 | } | ||
691 | |||
692 | static Eina_Bool | ||
693 | _marker_mouse_down(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
694 | { | ||
695 | eo_do(obj, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_MOVE, _marker_mouse_move, data)); | ||
696 | return EO_CALLBACK_CONTINUE; | ||
697 | } | ||
698 | |||
699 | static Eina_Bool | ||
700 | _marker_mouse_up(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
701 | { | ||
702 | eo_do(obj, eo_event_callback_del(EVAS_OBJECT_EVENT_MOUSE_MOVE, _marker_mouse_move, data)); | ||
703 | return EO_CALLBACK_CONTINUE; | ||
704 | } | ||
705 | |||
706 | static Eina_Bool | ||
707 | _marker_mouse_in(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
708 | { | ||
709 | Evas_Coord sz = 17, trans_size = 25; | ||
710 | Evas_Event_Mouse_Down *ev = event_info; | ||
711 | |||
712 | const Gui_Widget *wdg = _editor_wdg_selected_get(); | ||
713 | |||
714 | const Eo *base_obj; | ||
715 | if (IS_WIN(wdg)) | ||
716 | { | ||
717 | base_obj = canvas_get(); | ||
718 | } | ||
719 | else | ||
720 | { | ||
721 | const Gui_Widget *win_wdg = wdg_parent_win_wdg_get(wdg); | ||
722 | base_obj = session_eo_get(_editor_session, win_wdg); | ||
723 | } | ||
724 | |||
725 | /* This is "arrow" icon which flows around cursor. */ | ||
726 | Eo *cur_logo; | ||
727 | eo_do(base_obj, eo_base_data_get("cursor", (void **) &cur_logo)); | ||
728 | |||
729 | if (!cur_logo) | ||
730 | { | ||
731 | cur_logo = eo_add(ELM_OBJ_IMAGE_CLASS, obj); | ||
732 | eo_unref(cur_logo); | ||
733 | eo_do(cur_logo, evas_obj_size_set(sz, sz)); | ||
734 | eo_do(cur_logo, elm_obj_image_resizable_set(EINA_TRUE, EINA_TRUE)); | ||
735 | |||
736 | char path[100]; | ||
737 | getcwd(path, sizeof(path)); | ||
738 | sprintf(path, "%s/src/data/images/resize_red.png", path); | ||
739 | eo_do(cur_logo, elm_obj_image_file_set(path, NULL, NULL)); | ||
740 | //eo_do(h, elm_obj_image_file_set("/home/yakov/e17/elementary/data/themes/img/icon_border_resize.png", NULL, NULL)); | ||
741 | eo_do(base_obj, eo_base_data_set("cursor", cur_logo, NULL)); | ||
742 | |||
743 | Elm_Transit *trans; | ||
744 | trans = elm_transit_add(); | ||
745 | elm_transit_object_add(trans, cur_logo); | ||
746 | |||
747 | elm_transit_effect_resizing_add(trans, sz, sz, trans_size, trans_size); | ||
748 | elm_transit_duration_set(trans, 0.3); | ||
749 | elm_transit_auto_reverse_set(trans, EINA_TRUE); | ||
750 | elm_transit_repeat_times_set(trans, -1); | ||
751 | elm_transit_go(trans); | ||
752 | } | ||
753 | eo_do(cur_logo, evas_obj_visibility_set(EINA_TRUE)); | ||
754 | eo_do(cur_logo, evas_obj_raise()); | ||
755 | eo_do(cur_logo, evas_obj_position_set(ev->canvas.x + 7, ev->canvas.y + 8)); | ||
756 | |||
757 | return EO_CALLBACK_CONTINUE; | ||
758 | } | ||
759 | |||
760 | static Eina_Bool | ||
761 | _marker_mouse_out(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
762 | { | ||
763 | Eo *cur_logo = NULL; | ||
764 | const Gui_Widget *wdg = _editor_wdg_selected_get(); | ||
765 | |||
766 | const Eo *base_obj; | ||
767 | if (IS_WIN(wdg)) | ||
768 | { | ||
769 | base_obj = canvas_get(); | ||
770 | } | ||
771 | else | ||
772 | { | ||
773 | const Gui_Widget *win_wdg = wdg_parent_win_wdg_get(wdg); | ||
774 | base_obj = session_eo_get(_editor_session, win_wdg); | ||
775 | } | ||
776 | |||
777 | eo_do(base_obj, eo_base_data_get("cursor", (void **) &cur_logo)); | ||
778 | |||
779 | if (!cur_logo) | ||
780 | return EO_CALLBACK_CONTINUE; | ||
781 | |||
782 | eo_do(cur_logo, evas_obj_visibility_set(EINA_FALSE)); | ||
783 | return EO_CALLBACK_CONTINUE; | ||
784 | } | ||
785 | |||
786 | static void | ||
787 | _frame_mouse_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED) | ||
788 | { | ||
789 | Gui_Widget *wdg; | ||
790 | eo_do(obj, evas_obj_raise()); | ||
791 | eo_do(obj, evas_obj_focus_set(EINA_TRUE)); | ||
792 | |||
793 | eo_do(obj, eo_base_data_get("winwdg", (void**)(&wdg))); | ||
794 | eo_do(obj, evas_obj_focus_set(EINA_TRUE)); | ||
795 | |||
796 | _editor_wdg_selected_set(wdg); | ||
797 | objtree_item_selected_set(wdg); | ||
798 | |||
799 | evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _frame_mouse_move, NULL); | ||
800 | } | ||
801 | |||
802 | static Eina_Bool | ||
803 | _frame_mouse_up(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
804 | { | ||
805 | evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _frame_mouse_move); | ||
806 | return EO_CALLBACK_CONTINUE; | ||
807 | } | ||
808 | |||
809 | /* Second parameter is used only as parent for INLINED windows*/ | ||
810 | static void | ||
811 | _iter_widget_create(Gui_Widget *wdg, const Eo *parent_win) | ||
812 | { | ||
813 | Eina_List *children = NULL, *l; | ||
814 | Gui_Widget *w; | ||
815 | |||
816 | if (wdg_state_get(wdg) < STATE_VALIDATED) | ||
817 | { | ||
818 | ERR("Widget: \"%s\" was not validated, so can't be simulated.", wdg_name_get(wdg)); | ||
819 | return; | ||
820 | } | ||
821 | /* Windows are iterated separately. If parent is NULL, means that current object is not win. | ||
822 | * If iterated object is win, I create it as inlined_image and add frame to simulate win.*/ | ||
823 | Eina_Bool created; | ||
824 | created = manager_widget_create(_editor_session, wdg, MODE_EDITOR, (void *)parent_win); | ||
825 | |||
826 | if (created) | ||
827 | { | ||
828 | manager_widget_configure(_editor_session, wdg, MODE_EDITOR, NULL); | ||
829 | |||
830 | children = wdg_children_list_get(wdg); | ||
831 | EINA_LIST_FOREACH(children, l, w) | ||
832 | { | ||
833 | /* Window can not have child windows, so pass NULL. */ | ||
834 | _iter_widget_create(w, NULL); | ||
835 | } | ||
836 | } | ||
837 | } | ||
838 | |||
839 | static Eina_Bool | ||
840 | _wdg_resize(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
841 | { | ||
842 | Evas_Coord ow = 0, oh = 0, minw = 0, minh = 0; | ||
843 | |||
844 | const Gui_Context *ctx = _active_context_get(); | ||
845 | Gui_Widget *wdg = wdg_find_by_eo(_editor_session, ctx, obj);\ | ||
846 | Gui_Widget *selected_wdg = gui_context_data_get(ctx, SELECTED_WDG); | ||
847 | if (wdg != selected_wdg) | ||
848 | return EO_CALLBACK_CONTINUE; | ||
849 | |||
850 | eo_do(obj, evas_obj_size_hint_min_get(&minw, &minh)); | ||
851 | eo_do(obj, evas_obj_size_get(&ow, &oh)); | ||
852 | if (ow < minw) ow = minw; | ||
853 | if (oh < minh) oh = minh; | ||
854 | eo_do(obj, evas_obj_size_set(ow, oh)); | ||
855 | |||
856 | /* This is commented here because, it makes unavailable | ||
857 | * change position and size from Proverty View. | ||
858 | * This is going to be in _marker_mouse_move() for a while*/ | ||
859 | #if 0 | ||
860 | if (wdg) | ||
861 | { | ||
862 | Gui_Widget_Property *prop; | ||
863 | Gui_Value *val; | ||
864 | prop = wdg_prop_get(wdg, SIZE_SET); | ||
865 | if (prop) | ||
866 | { | ||
867 | val = prop_value_nth_get(prop, 0); | ||
868 | gui_value_set(val, GUI_TYPE_SINT, &ow); | ||
869 | val = prop_value_nth_get(prop, 1); | ||
870 | gui_value_set(val, GUI_TYPE_SINT, &oh); | ||
871 | propview_item_update(prop); | ||
872 | } | ||
873 | |||
874 | int ox, oy; | ||
875 | eo_do(obj, evas_obj_position_get(&ox, &oy)); | ||
876 | prop = wdg_prop_get(wdg, POSITION_SET); | ||
877 | if (prop) | ||
878 | { | ||
879 | val = prop_value_nth_get(prop, 0); | ||
880 | gui_value_set(val, GUI_TYPE_SINT, &ox); | ||
881 | val = prop_value_nth_get(prop, 1); | ||
882 | gui_value_set(val, GUI_TYPE_SINT, &oy); | ||
883 | propview_item_update(prop); | ||
884 | } | ||
885 | } | ||
886 | #endif | ||
887 | |||
888 | _wdg_border_draw(wdg, EINA_TRUE); | ||
889 | return EO_CALLBACK_CONTINUE; | ||
890 | } | ||
891 | |||
892 | static Eina_Bool | ||
893 | _win_resize(void *data EINA_UNUSED, Eo *o, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
894 | { | ||
895 | Evas_Coord ow = 0, oh = 0, minw = 0, minh = 0; | ||
896 | Eo *fr = NULL; | ||
897 | |||
898 | eo_do(o, evas_obj_size_hint_min_get(&minw, &minh)); | ||
899 | eo_do(o, evas_obj_size_get(&ow, &oh)); | ||
900 | if (ow < minw) ow = minw; | ||
901 | if (oh < minh) oh = minh; | ||
902 | |||
903 | Eo *inwin_img = elm_win_inlined_image_object_get(o); | ||
904 | /* FIXME: comment it? */ | ||
905 | eo_do(inwin_img, evas_obj_size_set(ow, oh)); | ||
906 | eo_do(o, eo_base_data_get("frame", (void **) &fr)); | ||
907 | |||
908 | int dw, dh; | ||
909 | eo_do(fr, eo_base_data_get("dw", (void **) &dw)); | ||
910 | eo_do(fr, eo_base_data_get("dh", (void **) &dh)); | ||
911 | eo_do(fr, evas_obj_size_set(ow + dw, oh + dh)); | ||
912 | |||
913 | _border_draw(canvas_get(), fr, EINA_TRUE); | ||
914 | return EO_CALLBACK_CONTINUE; | ||
915 | } | ||
916 | |||
917 | static Eina_Bool | ||
918 | _widget_prop_add(Gui_Session *session, const Gui_Widget *wdg, void *_prop, void *data EINA_UNUSED) | ||
919 | { | ||
920 | Eina_Bool ret = _ffi_eo_do(session, wdg, _prop); | ||
921 | if (ret) | ||
922 | { | ||
923 | _prop_dep_resolve(_prop, EINA_TRUE); | ||
924 | } | ||
925 | |||
926 | if (IS_WIN(wdg)) | ||
927 | { | ||
928 | Eo *fr = NULL, *o = session_eo_get(session, wdg); | ||
929 | eo_do(o, eo_base_data_get("frame", (void **) &fr)); | ||
930 | |||
931 | if (!strcmp(prop_name_get(_prop), TITLE_SET)) | ||
932 | { | ||
933 | char *title = WDG_NTH_VALUE_STRING_GET(wdg, TITLE_SET, 0); | ||
934 | eo_do(fr, elm_wdg_part_text_set(NULL, title)); | ||
935 | } | ||
936 | else if (!strcmp(prop_name_get(_prop), VISIBILITY_SET)) | ||
937 | { | ||
938 | Eina_Bool visibility; | ||
939 | eo_do(o, evas_obj_visibility_get(&visibility)); | ||
940 | eo_do(fr, evas_obj_visibility_set(visibility)); | ||
941 | /* Always show windows in editor. This made for the case, when eo_do call | ||
942 | * is going on file load*/ | ||
943 | eo_do(o, evas_obj_visibility_set(EINA_TRUE)); | ||
944 | eo_do(fr, evas_obj_visibility_set(EINA_TRUE)); | ||
945 | } | ||
946 | } | ||
947 | return ret; | ||
948 | } | ||
949 | |||
950 | static Eina_Bool | ||
951 | _widget_del(Gui_Session *session, const Gui_Widget *wdg, void *data EINA_UNUSED) | ||
952 | { | ||
953 | Eo *o = session_eo_get(session, wdg); | ||
954 | objtree_item_remove(wdg); | ||
955 | session_wdg_existence_set(session, wdg, EINA_FALSE); | ||
956 | eo_ref(o); | ||
957 | eo_del(o); | ||
958 | return EINA_TRUE; | ||
959 | } | ||
960 | |||
961 | static Eina_Bool | ||
962 | _widget_add(Gui_Session *session, const Gui_Widget *wdg, void *data) | ||
963 | { | ||
964 | Eo *o; | ||
965 | if (!IS_WIN(wdg)) | ||
966 | { | ||
967 | o = _ffi_eo_add(session, wdg); | ||
968 | if (!o) return EINA_FALSE; | ||
969 | evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _key_down, wdg_context_get(wdg)); | ||
970 | evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, wdg_context_get(wdg)); | ||
971 | //evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _mouse_up, NULL); | ||
972 | eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_UP, _mouse_up, NULL)); | ||
973 | /* To avoid dragging box, when want to drag button. */ | ||
974 | evas_object_propagate_events_set(o, EINA_FALSE); | ||
975 | /* Add callbacks to show widget resize arrows */ | ||
976 | #if 0 | ||
977 | evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, _mouse_in, NULL); | ||
978 | evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, _mouse_out, NULL); | ||
979 | #endif | ||
980 | eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_RESIZE, _wdg_resize, NULL)); | ||
981 | /* Add specific callbacks, related to UI. */ | ||
982 | } | ||
983 | else | ||
984 | { | ||
985 | Eo *fr; | ||
986 | Eo *parent_win = data; | ||
987 | /* | ||
988 | if (!parent_win) | ||
989 | { | ||
990 | parent_win = wdg_eo_get(wdg_parent_get(wdg)); | ||
991 | } | ||
992 | */ | ||
993 | |||
994 | o = eo_add_custom(ELM_OBJ_WIN_CLASS, parent_win, elm_obj_win_constructor(NULL, ELM_WIN_INLINED_IMAGE)); | ||
995 | if (!o) return EINA_FALSE; | ||
996 | |||
997 | Eo *io = elm_win_inlined_image_object_get(o); | ||
998 | evas_object_propagate_events_set(io, EINA_FALSE); | ||
999 | |||
1000 | Win_Info *wi = wdg_data_get(wdg, WIN_INFO); | ||
1001 | |||
1002 | if (!wi) | ||
1003 | { | ||
1004 | Evas_Coord x, y; | ||
1005 | fr = eo_add(ELM_OBJ_FRAME_CLASS, parent_win); | ||
1006 | _canvas_free_coords_get(wdg_context_get(wdg), &x, &y); | ||
1007 | eo_do(fr, evas_obj_position_set(x, y)); | ||
1008 | /* Unref everything and later ref it before delete */ | ||
1009 | eo_unref(fr); | ||
1010 | wi = win_info_new(); | ||
1011 | win_info_frame_set(wi, fr); | ||
1012 | wdg_data_set(wdg, WIN_INFO, wi); | ||
1013 | |||
1014 | //evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
1015 | //evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
1016 | elm_object_text_set(fr, elm_win_title_get(o)); | ||
1017 | eo_do(fr, | ||
1018 | evas_obj_visibility_set(EINA_TRUE), | ||
1019 | elm_obj_frame_autocollapse_set(EINA_TRUE)); | ||
1020 | |||
1021 | evas_object_event_callback_add(fr, EVAS_CALLBACK_MOUSE_DOWN, _frame_mouse_down, NULL); | ||
1022 | eo_do(fr, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_UP, _frame_mouse_up, NULL)); | ||
1023 | eo_do(fr, eo_base_data_set("winwdg", wdg, NULL)); | ||
1024 | } | ||
1025 | fr = win_info_frame_get(wi); | ||
1026 | eo_do(o, eo_base_data_set("frame", fr, NULL)); | ||
1027 | elm_object_content_set(fr, io); | ||
1028 | |||
1029 | eo_do(o, eo_event_callback_add(EVAS_OBJECT_EVENT_RESIZE, _win_resize, NULL)); | ||
1030 | /* Get size from properties of window. */ | ||
1031 | Evas_Coord ox = 150, oy = 50; | ||
1032 | eo_do(fr, evas_obj_position_get(&ox, &oy)); | ||
1033 | eo_do(io, evas_obj_position_set(ox, oy)); | ||
1034 | |||
1035 | { | ||
1036 | /* When set image as content to frame, image is smaller then frame. | ||
1037 | * So we want to calculate delta, to resize in proper way. | ||
1038 | * For this simulate resizing of image and frame. | ||
1039 | * Suppose 50, 50 is desired size for window, | ||
1040 | * and frame can be a litter bit smaller.*/ | ||
1041 | Evas_Coord dw, dh; | ||
1042 | Evas_Coord im_w, im_h; | ||
1043 | Evas_Coord ow = 50, oh = 50; | ||
1044 | /* Set desired size.*/ | ||
1045 | eo_do(io, evas_obj_size_set(ow, oh)); | ||
1046 | eo_do(fr, evas_obj_size_set(ow, oh)); | ||
1047 | /* Get size of image (which is smaller, because frame is 50, 50)*/ | ||
1048 | eo_do(io, evas_obj_size_get(&im_w, &im_h)); | ||
1049 | /* Calculate deltas*/ | ||
1050 | dw = ow - im_w; | ||
1051 | dh = oh - im_h; | ||
1052 | /* Save deltas in frame data*/ | ||
1053 | eo_do(fr, eo_base_data_set("dw", (void *) dw, NULL)); | ||
1054 | eo_do(fr, eo_base_data_set("dh", (void *) dh, NULL)); | ||
1055 | /* Resize properly. */ | ||
1056 | eo_do(fr, evas_obj_size_set(ow + dw, oh + dh)); | ||
1057 | eo_do(io, evas_obj_size_set(ow, oh)); | ||
1058 | } | ||
1059 | } | ||
1060 | |||
1061 | eo_unref(o); | ||
1062 | session_eo_set(session, wdg, o); | ||
1063 | Eina_List *lst = NULL; | ||
1064 | wdg_data_set(wdg, DEP_PROP_LIST, lst); | ||
1065 | return EINA_TRUE; | ||
1066 | } | ||
1067 | |||
1068 | /* Remove only Eo objects or also widgets*/ | ||
1069 | static Eina_Bool | ||
1070 | _editor_layout_clear(const Gui_Context *ctx, Eina_Bool delete_widgets) | ||
1071 | { | ||
1072 | EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_FALSE); | ||
1073 | |||
1074 | Eina_List *list, *itr, *itr2; | ||
1075 | Gui_Widget *wdg; | ||
1076 | |||
1077 | /* in editor, we iterate only over windows which don't have parent. */ | ||
1078 | list = gui_context_win_list_get(ctx); | ||
1079 | EINA_LIST_FOREACH_SAFE(list, itr, itr2, wdg) | ||
1080 | { | ||
1081 | _iter_widget_delete(wdg, delete_widgets); | ||
1082 | } | ||
1083 | return EINA_TRUE; | ||
1084 | } | ||
1085 | |||
1086 | static Eina_Bool | ||
1087 | _editor_ctx_call(const Gui_Context *ctx) | ||
1088 | { | ||
1089 | EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_FALSE); | ||
1090 | |||
1091 | Eina_List *list, *l; | ||
1092 | Gui_Widget *wdg; | ||
1093 | |||
1094 | /* in editor, we iterate only over windows which don't have parent. */ | ||
1095 | list = gui_context_win_list_get(ctx); | ||
1096 | EINA_LIST_FOREACH(list, l, wdg) | ||
1097 | { | ||
1098 | /* if window has parent widget, it will be iterated as child*/ | ||
1099 | if (wdg_parent_get(wdg)) | ||
1100 | { | ||
1101 | ERR("Window: \"%s\" has parent. It should not happen. We have bug!", wdg_name_get(wdg)); | ||
1102 | continue; | ||
1103 | } | ||
1104 | |||
1105 | /* All windows should be shown in main gui window. */ | ||
1106 | _iter_widget_create(wdg, canvas_get()); | ||
1107 | } | ||
1108 | /* Set context for objtree. */ | ||
1109 | objtree_item_contracted_set(NULL); | ||
1110 | /* During context call _win_resize() will be called. | ||
1111 | * It will draw border around win, but widget was not selected yet. | ||
1112 | * So need to hide border. */ | ||
1113 | _editor_wdg_selected_set(NULL); | ||
1114 | return EINA_TRUE; | ||
1115 | } | ||
1116 | |||
1117 | /* Remove only Eo objects or also widgets*/ | ||
1118 | static Eina_Bool | ||
1119 | _editor_widget_clear(Gui_Widget *wdg) | ||
1120 | { | ||
1121 | EINA_SAFETY_ON_NULL_RETURN_VAL(wdg, EINA_FALSE); | ||
1122 | |||
1123 | _iter_widget_delete(wdg, EINA_FALSE); | ||
1124 | return EINA_TRUE; | ||
1125 | } | ||
1126 | |||
1127 | static void | ||
1128 | _editor_selected_wdg_del_cb() | ||
1129 | { | ||
1130 | Gui_Widget *wdg = (Gui_Widget *) _editor_wdg_selected_get(); | ||
1131 | if (!wdg) return; | ||
1132 | const Gui_Widget *parent_wdg = wdg_parent_get((Gui_Widget *) wdg); | ||
1133 | _editor_wdg_selected_set(NULL); | ||
1134 | _iter_widget_delete(wdg, EINA_TRUE); | ||
1135 | |||
1136 | /* if parent_wdg is not NULL, it's not window, so it has parent. | ||
1137 | * if parent wdg is NULL, wdg is window, so just delete it. */ | ||
1138 | if (parent_wdg) | ||
1139 | { | ||
1140 | Gui_Widget *pwin = (Gui_Widget *) wdg_parent_win_wdg_get(parent_wdg); | ||
1141 | _editor_widget_clear((Gui_Widget *) pwin); | ||
1142 | _iter_widget_create(pwin, canvas_get()); | ||
1143 | } | ||
1144 | propview_build(NULL, _propsview_toolbar_selected_item_type); | ||
1145 | /*close objtree list*/ | ||
1146 | objtree_item_contracted_set(NULL); | ||
1147 | /* Set selected widget: t.e. if I delete button, box will be selected after. | ||
1148 | * If I delete window, main item will be selected. */ | ||
1149 | objtree_item_selected_set(parent_wdg); | ||
1150 | _editor_wdg_selected_set(parent_wdg); | ||
1151 | } | ||
1152 | |||
1153 | static void | ||
1154 | _editor_factory_wdg_create(const char *class_name) | ||
1155 | { | ||
1156 | const Gui_Widget *parent_win = NULL; | ||
1157 | const char *parent_name = NULL; | ||
1158 | Gui_Widget *wdg; | ||
1159 | const Gui_Widget *focused_wdg = _editor_wdg_selected_get(); | ||
1160 | const Gui_Context *ctx = _active_context_get(); | ||
1161 | |||
1162 | if (!ctx) | ||
1163 | { | ||
1164 | ERR("No active context"); | ||
1165 | return; | ||
1166 | } | ||
1167 | |||
1168 | /*If adding non window widget*/ | ||
1169 | if (strcmp(class_name, DB_DEF_WIN_CLASS)) | ||
1170 | { | ||
1171 | if (!focused_wdg) return; | ||
1172 | parent_win = wdg_parent_win_wdg_get(focused_wdg); | ||
1173 | parent_name = wdg_name_get(parent_win); | ||
1174 | } | ||
1175 | |||
1176 | char *new_name = gui_context_free_name_get(ctx, class_name); | ||
1177 | |||
1178 | wdg = wdg_new(new_name); | ||
1179 | free(new_name); | ||
1180 | wdg_class_name_set(wdg, class_name); | ||
1181 | wdg_append(ctx, wdg); | ||
1182 | wdg_parent_set(wdg, parent_name); | ||
1183 | |||
1184 | /*Add default visibility property*/ | ||
1185 | Gui_Widget_Property *prop; | ||
1186 | Gui_Value *val; | ||
1187 | Eina_Bool b = EINA_TRUE; | ||
1188 | Op_Desc *op; | ||
1189 | op = db_mro_op_desc_get(class_name, VISIBILITY_SET); | ||
1190 | prop = prop_create_for_op(op); | ||
1191 | val = prop_value_nth_get(prop, 0); | ||
1192 | gui_value_set(val, GUI_TYPE_BOOL, &b); | ||
1193 | wdg_prop_add(wdg, prop); | ||
1194 | |||
1195 | if (IS_WIN(wdg)) | ||
1196 | { | ||
1197 | /* By default, the window is created in the first action */ | ||
1198 | Gui_Sequence *seq = sequence_get(ctx, "BigBang"); | ||
1199 | /* Generate BigBand action if does not exist */ | ||
1200 | if (!seq) seq = sequence_new(ctx, "BigBang"); | ||
1201 | Gui_Action *action = action_new(seq); | ||
1202 | action_creation_set(action, wdg_name_get(wdg)); | ||
1203 | _action_dep_resolve(action, EINA_TRUE, DEP_ACTION); | ||
1204 | seqview_fill(ctx); | ||
1205 | |||
1206 | op = db_mro_op_desc_get(class_name, CONSTRUCTOR); | ||
1207 | prop = prop_create_for_op(op); | ||
1208 | val = prop_value_nth_get(prop, 0); | ||
1209 | gui_value_set(val, GUI_TYPE_STRING, ELM_OBJ_WIN_CONSTRUCTOR); | ||
1210 | wdg_prop_add(wdg, prop); | ||
1211 | |||
1212 | op = db_mro_op_desc_get(class_name, ELM_OBJ_WIN_CONSTRUCTOR); | ||
1213 | prop = prop_create_for_op(op); | ||
1214 | val = prop_value_nth_get(prop, 0); | ||
1215 | gui_value_set(val, GUI_TYPE_NULL, NULL); | ||
1216 | val = prop_value_nth_get(prop, 1); | ||
1217 | gui_value_set(val, GUI_TYPE_ENUM, "ELM_WIN_BASIC"); | ||
1218 | wdg_prop_add(wdg, prop); | ||
1219 | |||
1220 | int i = 200; | ||
1221 | op = db_mro_op_desc_get(class_name, SIZE_SET); | ||
1222 | prop = prop_create_for_op(op); | ||
1223 | val = prop_value_nth_get(prop, 0); | ||
1224 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
1225 | val = prop_value_nth_get(prop, 1); | ||
1226 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
1227 | wdg_prop_add(wdg, prop); | ||
1228 | |||
1229 | op = db_mro_op_desc_get(class_name, TITLE_SET); | ||
1230 | prop = prop_create_for_op(op); | ||
1231 | val = prop_value_nth_get(prop, 0); | ||
1232 | gui_value_set(val, GUI_TYPE_STRING, wdg_name_get(wdg)); | ||
1233 | wdg_prop_add(wdg, prop); | ||
1234 | } | ||
1235 | else | ||
1236 | { | ||
1237 | op = db_mro_op_desc_get(class_name, PART_TEXT_SET); | ||
1238 | prop = prop_create_for_op(op); | ||
1239 | val = prop_value_nth_get(prop, 0); | ||
1240 | gui_value_set(val, GUI_TYPE_NULL, NULL); | ||
1241 | val = prop_value_nth_get(prop, 1); | ||
1242 | gui_value_set(val, GUI_TYPE_STRING, wdg_name_get(wdg)); | ||
1243 | wdg_prop_add(wdg, prop); | ||
1244 | |||
1245 | #if 0 | ||
1246 | int i = 255; | ||
1247 | op = db_mro_op_desc_get(class_name, COLOR_SET); | ||
1248 | prop = prop_create_for_op(op); | ||
1249 | val = prop_value_nth_get(prop, 0); | ||
1250 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
1251 | val = prop_value_nth_get(prop, 1); | ||
1252 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
1253 | val = prop_value_nth_get(prop, 2); | ||
1254 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
1255 | val = prop_value_nth_get(prop, 3); | ||
1256 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
1257 | wdg_prop_add(wdg, prop); | ||
1258 | |||
1259 | i = 0; | ||
1260 | op = db_mro_op_desc_get(class_name, POSITION_SET); | ||
1261 | prop = prop_create_for_op(op); | ||
1262 | val = prop_value_nth_get(prop, 0); | ||
1263 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
1264 | val = prop_value_nth_get(prop, 1); | ||
1265 | gui_value_set(val, GUI_TYPE_SINT, &i); | ||
1266 | wdg_prop_add(wdg, prop); | ||
1267 | #endif | ||
1268 | double d = 1; | ||
1269 | op = db_mro_op_desc_get(class_name, SIZE_HINT_WEIGHT_SET); | ||
1270 | prop = prop_create_for_op(op); | ||
1271 | val = prop_value_nth_get(prop, 0); | ||
1272 | gui_value_set(val, GUI_TYPE_DOUBLE, &d); | ||
1273 | val = prop_value_nth_get(prop, 1); | ||
1274 | gui_value_set(val, GUI_TYPE_DOUBLE, &d); | ||
1275 | wdg_prop_add(wdg, prop); | ||
1276 | } | ||
1277 | |||
1278 | wdg_validate(wdg); | ||
1279 | |||
1280 | Eo *pw = NULL; | ||
1281 | if (IS_WIN(wdg)) pw = (Eo *)canvas_get(); | ||
1282 | manager_widget_create(_editor_session, wdg, MODE_EDITOR, pw); | ||
1283 | |||
1284 | objtree_item_contracted_set(NULL); | ||
1285 | |||
1286 | _editor_wdg_selected_set(wdg); | ||
1287 | objtree_item_selected_set(wdg); | ||
1288 | manager_widget_configure(_editor_session, wdg, MODE_EDITOR, NULL); | ||
1289 | } | ||
1290 | |||
1291 | static void | ||
1292 | _editor_shutdown() | ||
1293 | { | ||
1294 | target_db_shutdown(); | ||
1295 | seqview_shutdown(); | ||
1296 | propview_scrollbox_unset(); | ||
1297 | objtree_list_unset(); | ||
1298 | session_del(_editor_session); | ||
1299 | } | ||
1300 | |||
1301 | /* onChange callback for all properties edit fields. | ||
1302 | * If currently there is no such property in the widget, it will be added. | ||
1303 | * The given object is the one created in the properties view for each parameter. | ||
1304 | */ | ||
1305 | static void | ||
1306 | _prop_update_from_propview(void *data EINA_UNUSED, Eo *obj, void *event_info) | ||
1307 | { | ||
1308 | Par_Field_Data *pfd = NULL; | ||
1309 | const Eo_Class *kl = eo_class_get(obj); | ||
1310 | Op_Desc *op; | ||
1311 | Gui_Widget *wdg; | ||
1312 | Gui_Widget_Property *prop; | ||
1313 | int idx; | ||
1314 | Gui_Value *val; | ||
1315 | Eina_Bool prop_add = EINA_FALSE; | ||
1316 | Eina_Bool reload_win = EINA_FALSE; | ||
1317 | |||
1318 | /* Get data for changed field. */ | ||
1319 | eo_do(obj, eo_base_data_get("editor", (void **) &pfd)); | ||
1320 | op = pfd->it_data->op_desc; | ||
1321 | wdg = pfd->it_data->wdg; | ||
1322 | prop = pfd->it_data->prop; | ||
1323 | idx = pfd->par_idx; | ||
1324 | |||
1325 | /* If property doesn't exist, create it with some default values. */ | ||
1326 | if (!prop) | ||
1327 | { | ||
1328 | prop = prop_create_for_op(op); | ||
1329 | /* Raise flag, that property is newly created and must be added to widget. */ | ||
1330 | prop_add = EINA_TRUE; | ||
1331 | } | ||
1332 | /* Get value which need to be changed.*/ | ||
1333 | val = prop_value_nth_get(prop, idx); | ||
1334 | |||
1335 | /* Get new value from edit field. | ||
1336 | * And update Gui_Value with new value. */ | ||
1337 | Gui_Type type = db_op_desc_nth_par_type_get(op, idx); | ||
1338 | if (kl == ELM_OBJ_ENTRY_CLASS) | ||
1339 | { | ||
1340 | const char *entry_data = elm_entry_entry_get(obj); | ||
1341 | if (type == GUI_TYPE_STRING) | ||
1342 | { | ||
1343 | /* FIXME: part_text_set can receive NULL as parameter. | ||
1344 | * But because of this, I can't write "null"*/ | ||
1345 | if (!strcmp(entry_data, "null")) | ||
1346 | { | ||
1347 | gui_value_set(val, GUI_TYPE_NULL, NULL); | ||
1348 | } | ||
1349 | else | ||
1350 | { | ||
1351 | gui_value_type_set(val, type); | ||
1352 | gui_value_string_set(val, entry_data); | ||
1353 | } | ||
1354 | } | ||
1355 | else if (type == GUI_TYPE_SINT) | ||
1356 | { | ||
1357 | int number = atoi(entry_data); | ||
1358 | gui_value_set(val, type, &number); | ||
1359 | } | ||
1360 | else if (type == GUI_TYPE_DOUBLE) | ||
1361 | { | ||
1362 | double number = atof(entry_data); | ||
1363 | gui_value_set(val, type, &number); | ||
1364 | } | ||
1365 | } | ||
1366 | if (kl == ELM_OBJ_CHECK_CLASS) | ||
1367 | { | ||
1368 | Eina_Bool state; | ||
1369 | eo_do(obj, elm_obj_check_state_get(&state)); | ||
1370 | gui_value_set(val, type, &state); | ||
1371 | } | ||
1372 | if (kl == ELM_OBJ_HOVERSEL_CLASS) | ||
1373 | { | ||
1374 | const char *new_enum_value = elm_object_item_part_text_get(event_info, NULL); | ||
1375 | /* Set selected string on hover */ | ||
1376 | elm_object_text_set(obj, new_enum_value); | ||
1377 | /* Get new value depending on type of edit field. | ||
1378 | * And update value. */ | ||
1379 | if (type == GUI_TYPE_ENUM) | ||
1380 | { | ||
1381 | gui_value_set(val, type, (void *) new_enum_value); | ||
1382 | } | ||
1383 | /* FIXME: there is problem with content_set; because prev content must be unset; or need to redraw from the beginning*/ | ||
1384 | if (type == GUI_TYPE_OBJECT) | ||
1385 | { | ||
1386 | const char *cur_param = gui_value_string_get(val); | ||
1387 | Gui_Widget *cur_param_wdg = wdg_get(_active_context_get(), cur_param); | ||
1388 | Gui_Widget *new_param_wdg = wdg_get(_active_context_get(), new_enum_value); | ||
1389 | /* GUI_TYPE_OBJECT ops depend on other widgets, check that widget exists. | ||
1390 | * or new one not equal old one.*/ | ||
1391 | if ((!new_param_wdg) || (cur_param_wdg == new_param_wdg)) | ||
1392 | { | ||
1393 | goto end; | ||
1394 | } | ||
1395 | /* If I simply change value in prop: t.e. "but1"->"but2" change parent of "but1".*/ | ||
1396 | /* and change dependencies. */ | ||
1397 | _prop_dep_resolve(prop, EINA_FALSE); | ||
1398 | gui_value_set(val, type, (void *) new_enum_value); | ||
1399 | |||
1400 | /* Update parent, if op supports it. */ | ||
1401 | if (db_op_desc_flag_get(op) & UPDATE_PARENT) | ||
1402 | { | ||
1403 | const Gui_Widget* parent_win = wdg_parent_win_wdg_get(new_param_wdg); | ||
1404 | objtree_item_contracted_set(parent_win); | ||
1405 | if (cur_param_wdg) | ||
1406 | { | ||
1407 | wdg_parent_set(cur_param_wdg, wdg_name_get(parent_win)); | ||
1408 | } | ||
1409 | wdg_parent_set(new_param_wdg, wdg_name_get(wdg)); | ||
1410 | objtree_item_selected_set(wdg); | ||
1411 | } | ||
1412 | if (cur_param) reload_win = EINA_TRUE; | ||
1413 | } | ||
1414 | } | ||
1415 | |||
1416 | if (prop_add) | ||
1417 | { | ||
1418 | wdg_prop_add(wdg, prop); | ||
1419 | pfd->it_data->prop = prop; | ||
1420 | } | ||
1421 | /* Validate property and call for eo_func of current prop, | ||
1422 | * in order to update layout. */ | ||
1423 | if (prop_validate(prop)) | ||
1424 | { | ||
1425 | if (reload_win) | ||
1426 | { | ||
1427 | Gui_Widget *pwin = (Gui_Widget *) wdg_parent_win_wdg_get(wdg); | ||
1428 | _editor_widget_clear((Gui_Widget *) pwin); | ||
1429 | propview_build(NULL, _propsview_toolbar_selected_item_type); | ||
1430 | _iter_widget_create(pwin, canvas_get()); | ||
1431 | _editor_wdg_selected_set(wdg); | ||
1432 | objtree_item_contracted_set(NULL); | ||
1433 | objtree_item_selected_set(wdg); | ||
1434 | } | ||
1435 | else | ||
1436 | { | ||
1437 | /* Don't do anything with win if prop is VISIBILITY*/ | ||
1438 | if (IS_WIN(wdg) && (!strcmp(prop_name_get(prop), VISIBILITY_SET))) | ||
1439 | { | ||
1440 | } | ||
1441 | else | ||
1442 | { | ||
1443 | manager_widget_property_add(_editor_session, wdg, prop, MODE_EDITOR, NULL); | ||
1444 | if (!strcmp(prop_name_get(prop), POSITION_SET)) | ||
1445 | { | ||
1446 | _wdg_border_draw(wdg, EINA_TRUE); | ||
1447 | } | ||
1448 | } | ||
1449 | /* Rebuild view when property like "pack_end". */ | ||
1450 | if (db_op_desc_flag_get(op) & MULTI_PROPERTY) | ||
1451 | propview_build(wdg, _propsview_toolbar_selected_item_type); | ||
1452 | } | ||
1453 | return; | ||
1454 | } | ||
1455 | /* FIXME: add return here? */ | ||
1456 | end: | ||
1457 | /* If property was newly created, delete it. */ | ||
1458 | if (prop_add) prop_del(prop); | ||
1459 | } | ||
1460 | |||
1461 | static void | ||
1462 | _prop_del_from_propview(void *data, Eo *obj EINA_UNUSED, void *ev EINA_UNUSED) | ||
1463 | { | ||
1464 | const Gui_Widget *wdg = _editor_wdg_selected_get(); | ||
1465 | Gui_Widget_Property *prop = data; | ||
1466 | const Op_Desc *op = prop_op_desc_get(prop); | ||
1467 | Gui_Value *val; | ||
1468 | Eina_List *l; | ||
1469 | |||
1470 | /* Change parent, when removing property like "pack_end". */ | ||
1471 | if (db_op_desc_flag_get(op) & UPDATE_PARENT) | ||
1472 | { | ||
1473 | EINA_LIST_FOREACH(prop_value_get(prop), l, val) | ||
1474 | { | ||
1475 | if (gui_value_type_get(val) == GUI_TYPE_OBJECT) | ||
1476 | { | ||
1477 | Gui_Widget *param_wdg = wdg_get(_active_context_get(), gui_value_string_get(val)); | ||
1478 | if (param_wdg) | ||
1479 | { | ||
1480 | const Gui_Widget *parent_win = wdg_parent_win_wdg_get(param_wdg); | ||
1481 | /* Do it to update list. */ | ||
1482 | objtree_item_contracted_set(parent_win); | ||
1483 | wdg_parent_set(param_wdg, wdg_name_get(parent_win)); | ||
1484 | objtree_item_selected_set(wdg); | ||
1485 | } | ||
1486 | } | ||
1487 | } | ||
1488 | } | ||
1489 | |||
1490 | Gui_Widget *pwin = (Gui_Widget *) wdg_parent_win_wdg_get(wdg); | ||
1491 | _editor_widget_clear((Gui_Widget *) pwin); | ||
1492 | |||
1493 | /*Before deleting property iterate over its parameters and remove pointer to this prop from widgets, | ||
1494 | * which depend on it. */ | ||
1495 | _prop_dep_resolve(prop, EINA_FALSE); | ||
1496 | wdg_prop_del((Gui_Widget *) wdg, prop); | ||
1497 | propview_build(NULL, _propsview_toolbar_selected_item_type); | ||
1498 | |||
1499 | _iter_widget_create(pwin, canvas_get()); | ||
1500 | _editor_wdg_selected_set(wdg); | ||
1501 | objtree_item_contracted_set(NULL); | ||
1502 | objtree_item_selected_set(wdg); | ||
1503 | } | ||
1504 | |||
1505 | static void | ||
1506 | _widget_selected_from_objtree(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) | ||
1507 | { | ||
1508 | Gui_Widget *wdg = elm_object_item_data_get(event_info); | ||
1509 | _editor_wdg_selected_set(wdg); | ||
1510 | propview_build(wdg, _propsview_toolbar_selected_item_type); | ||
1511 | } | ||
1512 | |||
1513 | static void | ||
1514 | _propsview_toolbar_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | ||
1515 | { | ||
1516 | const Gui_Widget *wdg = _editor_wdg_selected_get(); | ||
1517 | |||
1518 | if (!strcmp(data, "Description")) | ||
1519 | { | ||
1520 | _propsview_toolbar_selected_item_type = DESCRIPTION_TYPE; | ||
1521 | } | ||
1522 | else if (!strcmp(data, "Properties")) | ||
1523 | { | ||
1524 | _propsview_toolbar_selected_item_type = PROPERTY_TYPE; | ||
1525 | } | ||
1526 | else if (!strcmp(data, "Callbacks")) | ||
1527 | { | ||
1528 | _propsview_toolbar_selected_item_type = CALLBACK_TYPE; | ||
1529 | } | ||
1530 | |||
1531 | propview_build(wdg, _propsview_toolbar_selected_item_type); | ||
1532 | } | ||
1533 | |||
1534 | static void | ||
1535 | _project_close(const Gui_Context *ctx) | ||
1536 | { | ||
1537 | if (ctx) | ||
1538 | { | ||
1539 | /* Set selected widget to NULL, in order to hide border. */ | ||
1540 | _editor_wdg_selected_set(NULL); | ||
1541 | _editor_layout_clear(_active_ctx, EINA_TRUE); | ||
1542 | gui_context_del((Gui_Context *) ctx); | ||
1543 | } | ||
1544 | _active_context_set(NULL); | ||
1545 | /* Clear lists. */ | ||
1546 | objtree_context_set(NULL); | ||
1547 | propview_build(NULL, _propsview_toolbar_selected_item_type); | ||
1548 | seqview_fill(NULL); | ||
1549 | } | ||
1550 | |||
1551 | static Eina_Bool | ||
1552 | _project_new(char *filename) | ||
1553 | { | ||
1554 | Gui_Context *ctx; | ||
1555 | ctx = gui_context_new(); | ||
1556 | if (!ctx) | ||
1557 | { | ||
1558 | ERR("Can not create context: %p", ctx); | ||
1559 | return EINA_FALSE; | ||
1560 | } | ||
1561 | |||
1562 | if (filename) | ||
1563 | { | ||
1564 | if (!gui_parser_json_file_read(ctx, filename)) | ||
1565 | { | ||
1566 | gui_context_del(ctx); | ||
1567 | return EINA_FALSE; | ||
1568 | } | ||
1569 | } | ||
1570 | |||
1571 | /* FIXME: handle return values */ | ||
1572 | gui_context_validate(ctx); | ||
1573 | _active_context_set(ctx); | ||
1574 | objtree_context_set(ctx); | ||
1575 | seqview_fill(ctx); | ||
1576 | |||
1577 | /*resolve action dependencies | ||
1578 | * FIXME: put it in other place? | ||
1579 | * Action dependencies affect only on editor, so I need to resolve it somewhere during context resolving. */ | ||
1580 | Eina_List *itr; | ||
1581 | Gui_Sequence *seq = NULL; | ||
1582 | EINA_LIST_FOREACH(gui_context_seq_list_get(ctx), itr, seq) | ||
1583 | { | ||
1584 | Eina_List *itr2; | ||
1585 | Gui_Action *action; | ||
1586 | EINA_LIST_FOREACH(sequence_actions_list_get(seq), itr2, action) | ||
1587 | { | ||
1588 | _action_dep_resolve(action, EINA_TRUE, DEP_ALL); | ||
1589 | } | ||
1590 | } | ||
1591 | |||
1592 | _editor_ctx_call(ctx); | ||
1593 | return EINA_TRUE; | ||
1594 | } | ||
1595 | |||
1596 | void | ||
1597 | editor_init(GuiLogicCbs *_guilogic_cbs, Eo *objlist, Eo *scrollbox, Eo *seqlist) | ||
1598 | { | ||
1599 | Action_Functions *funcs = manager_action_functions_get(MODE_EDITOR); | ||
1600 | funcs->wdg_add = _widget_add; | ||
1601 | funcs->wdg_del = _widget_del; | ||
1602 | funcs->prop_add = _widget_prop_add; | ||
1603 | |||
1604 | PropViewCbs *prop_cbs = propview_cbs_get(); | ||
1605 | prop_cbs->property_update_cb_func = _prop_update_from_propview; | ||
1606 | prop_cbs->property_delete_cb_func = _prop_del_from_propview; | ||
1607 | |||
1608 | ObjTreeViewCbs *objtree_cbs = objtree_cbs_get(); | ||
1609 | objtree_cbs->item_selection_cb_func = _widget_selected_from_objtree; | ||
1610 | |||
1611 | _guilogic_cbs->_layout_clear = _editor_layout_clear; | ||
1612 | _guilogic_cbs->_editor_ctx_call = _editor_ctx_call; | ||
1613 | _guilogic_cbs->_editor_selected_wdg_del_cb = _editor_selected_wdg_del_cb; | ||
1614 | _guilogic_cbs->_editor_factory_wdg_create = _editor_factory_wdg_create; | ||
1615 | _guilogic_cbs->_editor_shutdown = _editor_shutdown; | ||
1616 | _guilogic_cbs->_project_close = _project_close; | ||
1617 | _guilogic_cbs->_project_new = _project_new; | ||
1618 | _guilogic_cbs->_propsview_toolbar_clicked = _propsview_toolbar_clicked; | ||
1619 | |||
1620 | _guilogic_cbs->_seqview_fill = seqview_fill; | ||
1621 | |||
1622 | _editor_session = session_new(); | ||
1623 | |||
1624 | objtree_list_set(objlist); | ||
1625 | propview_scrollbox_set(scrollbox); | ||
1626 | seqview_init(seqlist); | ||
1627 | target_db_init(); | ||
1628 | } | ||
1629 | |||
diff --git a/src/bin/egui_gui/egui_layout_c.json b/src/bin/egui_gui/egui_layout_c.json new file mode 100644 index 0000000..d463165 --- /dev/null +++ b/src/bin/egui_gui/egui_layout_c.json | |||
@@ -0,0 +1,2395 @@ | |||
1 | #include <Elementary.h> | ||
2 | #include "elm_widget.h" | ||
3 | #include "elm_widget_container.h" | ||
4 | #include "elm_interface_scrollable.h" | ||
5 | #include "egui_layout.h" | ||
6 | |||
7 | static GUI pub_widgets; | ||
8 | static Eo *main_win; | ||
9 | static Eo *sequences_buttons_box; | ||
10 | static Eo *button_sequence_add; | ||
11 | static Eo *seq_add_entry; | ||
12 | |||
13 | /* @egui | ||
14 | { | ||
15 | "entry_activate": | ||
16 | { | ||
17 | "Desc": | ||
18 | { | ||
19 | "type":"sequence" | ||
20 | }, | ||
21 | "Actions": | ||
22 | { | ||
23 | "User":["_seq_add_entry_activate_cb", ""], | ||
24 | "Modification":["button_sequence_add", "disabled", [false]] | ||
25 | } | ||
26 | } | ||
27 | } | ||
28 | @!egui */ | ||
29 | static Eina_Bool | ||
30 | _sequence_entry_activate_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
31 | { | ||
32 | extern Eina_Bool _seq_add_entry_activate_cb(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); | ||
33 | if (!_seq_add_entry_activate_cb(NULL, obj, desc, event_info)) return EO_CALLBACK_STOP; | ||
34 | eo_do(button_sequence_add, elm_wdg_disabled_set(EINA_FALSE)); | ||
35 | return EO_CALLBACK_CONTINUE; | ||
36 | } | ||
37 | |||
38 | void | ||
39 | _create_gvc_win() | ||
40 | { | ||
41 | Eo *gvc_win; | ||
42 | Eo *gvc_img; | ||
43 | |||
44 | /* @egui | ||
45 | { | ||
46 | "gvc_win": | ||
47 | { | ||
48 | "Desc": | ||
49 | { | ||
50 | "parent":null, | ||
51 | "class":"Elm_Win", | ||
52 | "type":"widget" | ||
53 | }, | ||
54 | "Properties": | ||
55 | { | ||
56 | "constructor":["elm_obj_win_constructor"], | ||
57 | "elm_obj_win_constructor":["Graph", "ELM_WIN_BASIC"], | ||
58 | "title_set":["Graph View"], | ||
59 | "autodel_set":[true], | ||
60 | "size_set":[400, 400], | ||
61 | "resize_object_add":["gvc_img"], | ||
62 | "visibility_set":[true] | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | @!egui */ | ||
67 | gvc_win = eo_add_custom(ELM_OBJ_WIN_CLASS, NULL, elm_obj_win_constructor("Graph", ELM_WIN_BASIC)); | ||
68 | eo_unref(gvc_win); | ||
69 | eo_do(gvc_win, elm_obj_win_title_set("Graph View")); | ||
70 | eo_do(gvc_win, elm_obj_win_autodel_set(EINA_TRUE)); | ||
71 | eo_do(gvc_win, evas_obj_size_set(400, 400)); | ||
72 | /* @egui | ||
73 | { | ||
74 | "gvc_img": | ||
75 | { | ||
76 | "Desc": | ||
77 | { | ||
78 | "parent":"gvc_win", | ||
79 | "class":"Elm_Image", | ||
80 | "type":"widget" | ||
81 | }, | ||
82 | "Properties": | ||
83 | { | ||
84 | "size_hint_weight_set":[1, 1], | ||
85 | "image_file_set":["/tmp/truc.png", null, null], | ||
86 | "visibility_set":[true] | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | @!egui */ | ||
91 | gvc_img = eo_add(ELM_OBJ_IMAGE_CLASS, gvc_win); | ||
92 | eo_unref(gvc_img); | ||
93 | eo_do(gvc_img, evas_obj_size_hint_weight_set(1.000000, 1.000000)); | ||
94 | eo_do(gvc_img, elm_obj_image_file_set("/tmp/truc.png", NULL, NULL)); | ||
95 | eo_do(gvc_img, evas_obj_visibility_set(EINA_TRUE)); | ||
96 | eo_do(gvc_win, elm_obj_win_resize_object_add(gvc_img)); | ||
97 | eo_do(gvc_win, evas_obj_visibility_set(EINA_TRUE)); | ||
98 | } | ||
99 | |||
100 | |||
101 | /* @egui | ||
102 | { | ||
103 | "graphviz_button_clicked": | ||
104 | { | ||
105 | "Desc": | ||
106 | { | ||
107 | "type":"sequence" | ||
108 | }, | ||
109 | "Actions": | ||
110 | { | ||
111 | "Creation":"gvc_win" | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | @!egui */ | ||
116 | static Eina_Bool | ||
117 | _sequence_graphviz_button_clicked_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
118 | { | ||
119 | _create_gvc_win(); | ||
120 | |||
121 | return EO_CALLBACK_CONTINUE; | ||
122 | } | ||
123 | |||
124 | |||
125 | /* @egui | ||
126 | { | ||
127 | "del_button_clicked": | ||
128 | { | ||
129 | "Desc": | ||
130 | { | ||
131 | "type":"sequence" | ||
132 | }, | ||
133 | "Actions": | ||
134 | { | ||
135 | "User":["_action_or_seq_del", ""] | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | @!egui */ | ||
140 | static Eina_Bool | ||
141 | _sequence_del_button_clicked_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
142 | { | ||
143 | extern Eina_Bool _action_or_seq_del(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); | ||
144 | if (!_action_or_seq_del(NULL, obj, desc, event_info)) return EO_CALLBACK_STOP; | ||
145 | return EO_CALLBACK_CONTINUE; | ||
146 | } | ||
147 | |||
148 | static void | ||
149 | _create_fs_win() | ||
150 | { | ||
151 | Eo *fs_win; | ||
152 | Eo *bg2; | ||
153 | Eo *vbox; | ||
154 | Eo *fileselector; | ||
155 | |||
156 | /* @egui | ||
157 | { | ||
158 | "fs_win": | ||
159 | { | ||
160 | "Desc": | ||
161 | { | ||
162 | "parent":null, | ||
163 | "class":"Elm_Win", | ||
164 | "public":true, | ||
165 | "type":"widget" | ||
166 | }, | ||
167 | "Properties": | ||
168 | { | ||
169 | "constructor":["elm_obj_win_constructor"], | ||
170 | "elm_obj_win_constructor":[null, "ELM_WIN_BASIC"], | ||
171 | "title_set":["Select file"], | ||
172 | "autodel_set":[true], | ||
173 | "size_set":[300, 450], | ||
174 | "resize_object_add":["bg2"], | ||
175 | "resize_object_add":["vbox"], | ||
176 | "modal":[true], | ||
177 | "visibility_set":[true] | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | @!egui */ | ||
182 | fs_win = eo_add_custom(ELM_OBJ_WIN_CLASS, main_win, elm_obj_win_constructor(NULL, ELM_WIN_BASIC)); | ||
183 | eo_unref(fs_win); | ||
184 | pub_widgets.fs_win = fs_win; | ||
185 | eo_do(fs_win, elm_obj_win_modal_set(EINA_TRUE)); | ||
186 | eo_do(fs_win, elm_obj_win_title_set("Select file")); | ||
187 | eo_do(fs_win, elm_obj_win_autodel_set(EINA_TRUE)); | ||
188 | eo_do(fs_win, evas_obj_size_set(300, 450)); | ||
189 | /* @egui | ||
190 | { | ||
191 | "bg2": | ||
192 | { | ||
193 | "Desc": | ||
194 | { | ||
195 | "parent":"fs_win", | ||
196 | "class":"Elm_Bg", | ||
197 | "type":"widget" | ||
198 | }, | ||
199 | "Properties": | ||
200 | { | ||
201 | "bg_color_set":[80, 80, 80, 255], | ||
202 | "size_hint_weight_set":[1, 1], | ||
203 | "visibility_set":[true] | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | @!egui */ | ||
208 | bg2 = eo_add(ELM_OBJ_BG_CLASS, fs_win); | ||
209 | eo_unref(bg2); | ||
210 | eo_do(bg2, elm_obj_bg_color_set(80, 80, 80, 255)); | ||
211 | eo_do(bg2, evas_obj_size_hint_weight_set(1.000000, 1.000000)); | ||
212 | eo_do(bg2, evas_obj_visibility_set(EINA_TRUE)); | ||
213 | eo_do(fs_win, elm_obj_win_resize_object_add(bg2)); | ||
214 | /* @egui | ||
215 | { | ||
216 | "vbox": | ||
217 | { | ||
218 | "Desc": | ||
219 | { | ||
220 | "parent":"fs_win", | ||
221 | "class":"Elm_Box", | ||
222 | "type":"widget" | ||
223 | }, | ||
224 | "Properties": | ||
225 | { | ||
226 | "size_hint_weight_set":[1, 1], | ||
227 | "pack_end":["fileselector"], | ||
228 | "visibility_set":[true] | ||
229 | } | ||
230 | } | ||
231 | } | ||
232 | @!egui */ | ||
233 | vbox = eo_add(ELM_OBJ_BOX_CLASS, fs_win); | ||
234 | eo_unref(vbox); | ||
235 | eo_do(vbox, evas_obj_size_hint_weight_set(1.000000, 1.000000)); | ||
236 | eo_do(vbox, evas_obj_visibility_set(EINA_TRUE)); | ||
237 | eo_do(fs_win, elm_obj_win_resize_object_add(vbox)); | ||
238 | /* @egui | ||
239 | { | ||
240 | "fileselector": | ||
241 | { | ||
242 | "Desc": | ||
243 | { | ||
244 | "parent":"vbox", | ||
245 | "class":"Elm_Fileselector", | ||
246 | "public":true, | ||
247 | "type":"widget" | ||
248 | }, | ||
249 | "Properties": | ||
250 | { | ||
251 | "size_hint_weight_set":[1, 1], | ||
252 | "size_hint_align_set":[-1, -1], | ||
253 | "visibility_set":[true] | ||
254 | } | ||
255 | } | ||
256 | } | ||
257 | @!egui */ | ||
258 | fileselector = eo_add(ELM_OBJ_FILESELECTOR_CLASS, vbox); | ||
259 | eo_unref(fileselector); | ||
260 | pub_widgets.fileselector = fileselector; | ||
261 | eo_do(fileselector, evas_obj_size_hint_weight_set(1.000000, 1.000000)); | ||
262 | eo_do(fileselector, evas_obj_size_hint_align_set(-1.000000, -1.000000)); | ||
263 | eo_do(fileselector, evas_obj_visibility_set(EINA_TRUE)); | ||
264 | eo_do(vbox, elm_obj_box_pack_end(fileselector)); | ||
265 | eo_do(fs_win, evas_obj_visibility_set(EINA_TRUE)); | ||
266 | } | ||
267 | |||
268 | |||
269 | /* @egui | ||
270 | { | ||
271 | "fs_win_show": | ||
272 | { | ||
273 | "Desc": | ||
274 | { | ||
275 | "type":"sequence" | ||
276 | }, | ||
277 | "Actions": | ||
278 | { | ||
279 | "Creation":"fs_win" | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | @!egui */ | ||
284 | Eina_Bool | ||
285 | _sequence_fs_win_show_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
286 | { | ||
287 | _create_fs_win(); | ||
288 | |||
289 | return EO_CALLBACK_CONTINUE; | ||
290 | } | ||
291 | |||
292 | |||
293 | /* @egui | ||
294 | { | ||
295 | "seq_add_entry_pack": | ||
296 | { | ||
297 | "Desc": | ||
298 | { | ||
299 | "type":"sequence" | ||
300 | }, | ||
301 | "Actions": | ||
302 | { | ||
303 | "Modification":["sequences_buttons_box", "pack_after", ["seq_add_entry", "button_sequence_add"]], | ||
304 | "Modification":["seq_add_entry", "visibility_set", [true]], | ||
305 | "Modification":["button_sequence_add", "disabled", [true]] | ||
306 | } | ||
307 | } | ||
308 | } | ||
309 | @!egui */ | ||
310 | static Eina_Bool | ||
311 | _sequence_seq_add_entry_pack_execute(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) | ||
312 | { | ||
313 | eo_do(sequences_buttons_box, elm_obj_box_pack_after(seq_add_entry, button_sequence_add)); | ||
314 | eo_do(seq_add_entry, evas_obj_visibility_set(EINA_TRUE)); | ||
315 | eo_do(button_sequence_add, elm_wdg_disabled_set(EINA_TRUE)); | ||
316 | return EO_CALLBACK_CONTINUE; | ||
317 | } | ||
318 | |||
319 |