summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorYakov Goldberg <yakov.g@samsung.com>2014-11-30 15:28:11 +0200
committerYakov Goldberg <yakov.g@samsung.com>2014-11-30 16:26:58 +0200
commite936bf0c04a6be0356a6e0e0c4b671ecd458b68c (patch)
tree5f5a904b36812bb864d092c779dddd27c42a9c6e /src/bin
parent2a6358b370bbec3a4e6f3d897d73d8165362c4ce (diff)
draw border around drop target
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/egui_gui/editor.c82
1 files changed, 61 insertions, 21 deletions
diff --git a/src/bin/egui_gui/editor.c b/src/bin/egui_gui/editor.c
index d576a07..c20014e 100644
--- a/src/bin/egui_gui/editor.c
+++ b/src/bin/egui_gui/editor.c
@@ -168,17 +168,36 @@ static Eina_Bool
168_marker_mouse_in(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); 168_marker_mouse_in(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
169static Eina_Bool 169static Eina_Bool
170_marker_mouse_out(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info); 170_marker_mouse_out(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info);
171
172enum
173{
174 BORDER_SELECTION,
175 BORDER_DROP_TARGET
176};
177
171#define STR(par) #par 178#define STR(par) #par
172 179
173#define LINE(id, x, y, l, w, visibility) \ 180#define LINE(id, color, x, y, l, w, visibility) \
174 ({\ 181 ({\
175 Eo *line = NULL;\ 182 Eo *line = NULL;\
176 eo_do(g->main_win->main_win, line = eo_key_data_get(STR(id)));\ 183 eo_do(g->main_win->main_win, line = eo_key_data_get(STR(id"_"color)));\
177 if (!line)\ 184 if (!line)\
178 {\ 185 {\
179 line = eo_add(EVAS_RECTANGLE_CLASS, g->main_win->main_win);\ 186 line = eo_add(EVAS_RECTANGLE_CLASS, g->main_win->main_win);\
180 eo_do(g->main_win->main_win, eo_key_data_set(STR(id), line, NULL));\ 187 eo_do(g->main_win->main_win, eo_key_data_set(STR(id"_"color), line, NULL));\
181 eo_do(line, evas_obj_color_set(0, 255, 0, 255));\ 188 switch (color) \
189 {\
190 case BORDER_SELECTION:\
191 {\
192 eo_do(line, evas_obj_color_set(0, 255, 0, 255));\
193 break;\
194 }\
195 case BORDER_DROP_TARGET:\
196 {\
197 eo_do(line, evas_obj_color_set(85, 200, 248, 255));\
198 break;\
199 }\
200 }\
182 eo_do(evas_object_smart_parent_get(g->main_win->main_box), evas_obj_smart_member_add(line)); \ 201 eo_do(evas_object_smart_parent_get(g->main_win->main_box), evas_obj_smart_member_add(line)); \
183 }\ 202 }\
184 eo_do(line, evas_obj_visibility_set(visibility));\ 203 eo_do(line, evas_obj_visibility_set(visibility));\
@@ -211,7 +230,7 @@ _marker_mouse_out(void *data, Eo *obj, const Eo_Event_Description *desc, void *e
211/* Draws border around obj, Evas is taken from base_obj; 230/* Draws border around obj, Evas is taken from base_obj;
212 * markers and lines are saved in base_obj*/ 231 * markers and lines are saved in base_obj*/
213static void 232static void
214_wdg_border_draw(const Gui_Widget *wdg, Eina_Bool visibility) 233_wdg_border_draw(const Gui_Widget *wdg, Eina_Bool visibility, int border_type_color)
215{ 234{
216 const Gui_Session *session = gui_context_editor_session_get(_active_context_get()); 235 const Gui_Session *session = gui_context_editor_session_get(_active_context_get());
217 Eo *obj = NULL; 236 Eo *obj = NULL;
@@ -276,19 +295,35 @@ _wdg_border_draw(const Gui_Widget *wdg, Eina_Bool visibility)
276 } 295 }
277 } 296 }
278 297
279 LINE(BORDER_TOP, ox - 1, oy - 1, lw, 1, visibility);
280 LINE(BORDER_BOTTOM, ox - 1, oy + oh + 1, lw, 1, visibility);
281 LINE(BORDER_RIGHT, ox + ow + 1, oy - 1, 1, lh, visibility);
282 LINE(BORDER_LEFT, ox - 1, oy - 1, 1, lh, visibility);
283 298
284 MARKER(BORDER_MARKER_TOP_LEFT, ox - 1 - hs - 1, oy - 1 - hs - 1, visibility); 299 switch (border_type_color)
285 MARKER(BORDER_MARKER_TOP, ox + ow / 2 - hs / 2, oy - 1 - hs - 1, visibility); 300 {
286 MARKER(BORDER_MARKER_TOP_RIGHT, ox + ow + 1, oy - 1 - hs - 1, visibility); 301 case BORDER_SELECTION:
287 MARKER(BORDER_MARKER_RIGHT, ox + ow + 1, oy + oh / 2 - hs / 2, visibility); 302 {
288 MARKER(BORDER_MARKER_BOTTOM_RIGHT, ox + ow + 1, oy + oh + 1, visibility); 303 LINE(BORDER_TOP, BORDER_SELECTION, ox - 1, oy - 1, lw, 1, visibility);
289 MARKER(BORDER_MARKER_BOTTOM, ox + ow / 2 - hs / 2, oy + oh + 1, visibility); 304 LINE(BORDER_BOTTOM, BORDER_SELECTION, ox - 1, oy + oh + 1, lw, 1, visibility);
290 MARKER(BORDER_MARKER_BOTTOM_LEFT, ox - 1 - hs - 1, oy + oh + 1, visibility); 305 LINE(BORDER_RIGHT, BORDER_SELECTION, ox + ow + 1, oy - 1, 1, lh, visibility);
291 MARKER(BORDER_MARKER_LEFT, ox - 1 - hs - 1 , oy + oh / 2 - hs / 2, visibility); 306 LINE(BORDER_LEFT, BORDER_SELECTION, ox - 1, oy - 1, 1, lh, visibility);
307
308 MARKER(BORDER_MARKER_TOP_LEFT, ox - 1 - hs - 1, oy - 1 - hs - 1, visibility);
309 MARKER(BORDER_MARKER_TOP, ox + ow / 2 - hs / 2, oy - 1 - hs - 1, visibility);
310 MARKER(BORDER_MARKER_TOP_RIGHT, ox + ow + 1, oy - 1 - hs - 1, visibility);
311 MARKER(BORDER_MARKER_RIGHT, ox + ow + 1, oy + oh / 2 - hs / 2, visibility);
312 MARKER(BORDER_MARKER_BOTTOM_RIGHT, ox + ow + 1, oy + oh + 1, visibility);
313 MARKER(BORDER_MARKER_BOTTOM, ox + ow / 2 - hs / 2, oy + oh + 1, visibility);
314 MARKER(BORDER_MARKER_BOTTOM_LEFT, ox - 1 - hs - 1, oy + oh + 1, visibility);
315 MARKER(BORDER_MARKER_LEFT, ox - 1 - hs - 1 , oy + oh / 2 - hs / 2, visibility);
316 break;
317 }
318 case BORDER_DROP_TARGET:
319 {
320 LINE(BORDER_TOP, BORDER_DROP_TARGET, ox - 1, oy - 1, lw, 1, visibility);
321 LINE(BORDER_BOTTOM, BORDER_DROP_TARGET, ox - 1, oy + oh + 1, lw, 1, visibility);
322 LINE(BORDER_RIGHT, BORDER_DROP_TARGET, ox + ow + 1, oy - 1, 1, lh, visibility);
323 LINE(BORDER_LEFT, BORDER_DROP_TARGET, ox - 1, oy - 1, 1, lh, visibility);
324 break;
325 }
326 }
292} 327}
293#undef LINE 328#undef LINE
294#undef MARKER 329#undef MARKER
@@ -380,14 +415,14 @@ _editor_wdg_selected_set(const Gui_Widget *wdg)
380 /* Hide previous border*/ 415 /* Hide previous border*/
381 if (old_wdg) 416 if (old_wdg)
382 { 417 {
383 _wdg_border_draw(old_wdg, EINA_FALSE); 418 _wdg_border_draw(old_wdg, EINA_FALSE, BORDER_SELECTION);
384 } 419 }
385 else 420 else
386 { 421 {
387 /* During context call _win_resize() will be called. 422 /* During context call _win_resize() will be called.
388 * It will draw border around win, but widget was not selected yet. 423 * It will draw border around win, but widget was not selected yet.
389 * So need to hide border. */ 424 * So need to hide border. */
390 _wdg_border_draw(NULL, EINA_FALSE); 425 _wdg_border_draw(NULL, EINA_FALSE, BORDER_SELECTION);
391 } 426 }
392 427
393 /* Show new border*/ 428 /* Show new border*/
@@ -1112,11 +1147,13 @@ _drop_target_main_wdg_enter(void *data, Evas_Object *obj)
1112 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(wdg_context_get(wdg)); 1147 Gui_Session *session = (Gui_Session *) gui_context_editor_session_get(wdg_context_get(wdg));
1113 di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA); 1148 di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA);
1114 canvas = session_eo_get(session, wdg); 1149 canvas = session_eo_get(session, wdg);
1150 _wdg_border_draw(wdg, EINA_TRUE, BORDER_DROP_TARGET);
1115 } 1151 }
1116 else if (canvas_drop_target != NULL) 1152 else if (canvas_drop_target != NULL)
1117 { 1153 {
1118 di = eo_do(canvas_drop_target, eo_key_data_get(EDITOR_DND_DATA)); 1154 di = eo_do(canvas_drop_target, eo_key_data_get(EDITOR_DND_DATA));
1119 canvas = canvas_drop_target; 1155 canvas = canvas_drop_target;
1156 _wdg_border_draw(NULL, EINA_FALSE, BORDER_DROP_TARGET);
1120 } 1157 }
1121 else 1158 else
1122 { 1159 {
@@ -1160,6 +1197,7 @@ static void
1160_drop_target_enter(void *data, Evas_Object *obj EINA_UNUSED) 1197_drop_target_enter(void *data, Evas_Object *obj EINA_UNUSED)
1161{ 1198{
1162 Gui_Widget *wdg = data; 1199 Gui_Widget *wdg = data;
1200 _wdg_border_draw(wdg, EINA_TRUE, BORDER_DROP_TARGET);
1163 Eo *wdg_eo = NULL; 1201 Eo *wdg_eo = NULL;
1164 ERR("Enter: %s", wdg_name_get(wdg)); 1202 ERR("Enter: %s", wdg_name_get(wdg));
1165 DnD_Info *di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA); 1203 DnD_Info *di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA);
@@ -1259,6 +1297,7 @@ _drop_target_drop(void *data, Evas_Object *obj, Elm_Selection_Data *ev)
1259 Gui_Widget *wdg = data; 1297 Gui_Widget *wdg = data;
1260 Eo *canvas_drop_target = obj; 1298 Eo *canvas_drop_target = obj;
1261 DnD_Info *di; 1299 DnD_Info *di;
1300 _wdg_border_draw(NULL, EINA_FALSE, BORDER_DROP_TARGET);
1262 if (wdg) 1301 if (wdg)
1263 { 1302 {
1264 di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA); 1303 di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA);
@@ -1406,6 +1445,7 @@ _drop_target_pos(void *data, Eo *obj, Evas_Coord x, Evas_Coord y, Elm_Xdnd_Actio
1406 { 1445 {
1407 eo_do(wdg_eo, evas_obj_position_get(&obj_x, &obj_y)); 1446 eo_do(wdg_eo, evas_obj_position_get(&obj_x, &obj_y));
1408 } 1447 }
1448 _wdg_border_draw(wdg, EINA_TRUE, BORDER_DROP_TARGET);
1409 } 1449 }
1410 else if (canvas_drop_target != NULL) 1450 else if (canvas_drop_target != NULL)
1411 { 1451 {
@@ -1829,7 +1869,7 @@ _wdg_parent_win_reload(const Gui_Widget *wdg)
1829 /* Create window from beginning. */ 1869 /* Create window from beginning. */
1830 _iter_widget_create(pwin, canvas_get()); 1870 _iter_widget_create(pwin, canvas_get());
1831 /* Hide border of window, which is drawn when win is recreated and resized */ 1871 /* Hide border of window, which is drawn when win is recreated and resized */
1832 _wdg_border_draw(NULL, EINA_FALSE); 1872 _wdg_border_draw(NULL, EINA_FALSE, BORDER_SELECTION);
1833} 1873}
1834 1874
1835static void 1875static void
@@ -3458,7 +3498,7 @@ _wdg_border_draw_on_idle(void *data EINA_UNUSED)
3458 const Gui_Widget *wdg = _editor_wdg_selected_get(); 3498 const Gui_Widget *wdg = _editor_wdg_selected_get();
3459 if (wdg) 3499 if (wdg)
3460 { 3500 {
3461 _wdg_border_draw(wdg, EINA_TRUE); 3501 _wdg_border_draw(wdg, EINA_TRUE, BORDER_SELECTION);
3462 } 3502 }
3463 return ECORE_CALLBACK_RENEW; 3503 return ECORE_CALLBACK_RENEW;
3464} 3504}