yakov pushed a commit to branch master.

http://git.enlightenment.org/tools/erigo.git/commit/?id=e9b2d1347dc11ac6e7f4665473aa641303285832

commit e9b2d1347dc11ac6e7f4665473aa641303285832
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Thu Jun 4 15:33:46 2015 +0300

    Implement canvas with scrolling
---
 src/bin/gui/editor.c         | 267 +++++++++++++++++++++++++++++--------------
 src/bin/gui/egui_layout.json |  56 ++++++++-
 src/bin/gui/egui_logic.c     |   5 +-
 3 files changed, 237 insertions(+), 91 deletions(-)

diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c
index ff620e7..4205650 100644
--- a/src/bin/gui/editor.c
+++ b/src/bin/gui/editor.c
@@ -67,6 +67,9 @@ _wdg_parent_win_reload(const Gui_Widget *wdg);
 static Gui_Context *_active_ctx = NULL;
 static const Egui_Layout_Widgets *g;
 
+Eina_Bool
+_canvas_resize_cb(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description 
*desc EINA_UNUSED, void *event_info EINA_UNUSED);
+
 void
 _active_context_set(Gui_Context *ctx)
 {
@@ -79,14 +82,6 @@ _active_context_get()
    return _active_ctx;
 }
 
-/* Use this function to stack frames and border's lines and markers below 
panes. */
-static void
-_stack_below_panes(Eo *obj)
-{
-   eo_do(obj, efl_gfx_stack_below(g->main_win->right_panes));
-   eo_do(obj, efl_gfx_stack_below(g->main_win->left_panes));
-}
-
 typedef enum {
      BORDER_OUT =    0,
      BORDER_LEFT =   1 << 0,
@@ -149,9 +144,9 @@ widget_name_change(Gui_Widget *wdg, const char *str)
 
 /* x_fix/y_fix - correction of initial position of smart_parent. whis is not 
resized before elm_run. */
 static void
-_canvas_free_coords_get(const Gui_Context *ctx, Evas_Coord x_fix, Evas_Coord 
y_fix, Evas_Coord *x, Evas_Coord *y)
+_canvas_free_coords_get(const Gui_Context *ctx, Evas_Coord *x, Evas_Coord *y)
 {
-   Evas_Coord x0 = 340 + x_fix, y0 = 120 + y_fix, w0 = 1060, h0 = 900, retx, 
rety, ymax = 120;
+   Evas_Coord x0 = 0, y0 = 0, w0 = 1060, h0 = 900, retx, rety, ymax = 120;
    Eina_List *main_widgets = gui_context_main_widgets_get(ctx);
    Eina_List *itr;
    Eid *wdg_id;
@@ -166,8 +161,7 @@ _canvas_free_coords_get(const Gui_Context *ctx, Evas_Coord 
x_fix, Evas_Coord y_f
         Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
         if (wi)
           {
-             eo_do(main_wdg_info_frame_get(wi), efl_gfx_size_get(&fw, &fh));
-             eo_do(main_wdg_info_frame_get(wi), efl_gfx_position_get(&fx, 
&fy));
+             elm_grid_pack_get(main_wdg_info_frame_get(wi), &fx, &fy, &fw, 
&fh);
              if ((fx + fw) < (x0 + w0 - 100))
                {
                   retx = fx + fw;
@@ -239,14 +233,25 @@ enum
              }\
              if (base_obj == canvas_get())\
                {\
-                 eo_do(evas_object_smart_parent_get(g->main_win->left_panes), 
evas_obj_smart_member_add(line)); \
+                 eo_do(base_obj, elm_obj_grid_pack(line, x, y, l, w)); \
                }\
+             else \
+               {\
+                  eo_do(line, efl_gfx_position_set(x, y));\
+                  eo_do(line, efl_gfx_size_set(l, w));\
+               }\
+          }\
+        if (base_obj == canvas_get())\
+          {\
+             elm_grid_pack_set(line, x, y, l, w);\
+          }\
+        else \
+          {\
+             eo_do(line, efl_gfx_position_set(x, y));\
+             eo_do(line, efl_gfx_size_set(l, w));\
           }\
        eo_do(line, efl_gfx_visible_set(visibility));\
-       eo_do(line, efl_gfx_position_set(x, y));\
-       eo_do(line, efl_gfx_size_set(l, w));\
        eo_do(line, efl_gfx_stack_raise());\
-       if (base_obj == canvas_get()) _stack_below_panes(line);\
    })
 
 #define MARKER(base_obj, id, x, y, visibility) \
@@ -258,18 +263,28 @@ enum
            _m = eo_add(EVAS_RECTANGLE_CLASS, base_obj);\
            eo_do(base_obj, eo_key_data_set(STR(id), _m));\
            eo_do(_m, efl_gfx_color_set(0, 255, 0, 255));\
-           eo_do(_m, efl_gfx_size_set(7, 7));\
            eo_do(_m, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_DOWN, 
_marker_mouse_down, (void *) (intptr_t) id)); \
            eo_do(_m, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_IN, 
_marker_mouse_in, (void *) (intptr_t) id)); \
            eo_do(_m, eo_event_callback_add(EVAS_OBJECT_EVENT_MOUSE_OUT, 
_marker_mouse_out, (void *) (intptr_t) id)); \
              if (base_obj == canvas_get())\
                {\
-                 eo_do(evas_object_smart_parent_get(g->main_win->left_panes), 
evas_obj_smart_member_add(_m)); \
+                 eo_do(base_obj, elm_obj_grid_pack(_m, x, y, 7, 7)); \
+               }\
+             else \
+               {\
+                 eo_do(_m, efl_gfx_size_set(7, 7));\
                }\
         }\
-      eo_do(_m, efl_gfx_position_set(x, y)); \
-      eo_do(_m, efl_gfx_visible_set(visibility));\
-      if (base_obj == canvas_get()) _stack_below_panes(_m);\
+        if (base_obj == canvas_get())\
+          {\
+             elm_grid_pack_set(_m, x, y, 7, 7);\
+          }\
+        else \
+          {\
+             eo_do(_m, efl_gfx_position_set(x, y)); \
+          }\
+        eo_do(_m, efl_gfx_visible_set(visibility));\
+        eo_do(_m, efl_gfx_stack_raise());\
     })
 
 /* Draws border around obj, Evas is taken from base_obj;
@@ -310,16 +325,19 @@ _wdg_border_draw(const Gui_Widget *wdg, Eina_Bool 
visibility, int border_type_co
    /* This is made, to have opportunity to pass NULL and hide border.*/
    if (obj)
      {
-        eo_do(obj, efl_gfx_position_get(&ox, &oy));
-
-        /* In case the objects has been shifted outside of the window
-         * e.g with naviframe item push */
-        if (ox < 0 || oy < 0) return;
-
-        eo_do(obj, evas_obj_size_hint_min_get(&minw, &minh));
-        eo_do(obj, efl_gfx_size_get(&ow, &oh));
-        if (ow < minw) ow = minw;
-        if (oh < minh) oh = minh;
+        /* in case of main widgets need to take frame pack coorsd from grid. */
+        if (IS_MAIN(wdg))
+          {
+             elm_grid_pack_get(obj, &ox, &oy, &ow, &oh);
+          }
+        else
+          {
+             eo_do(obj, efl_gfx_position_get(&ox, &oy));
+             eo_do(obj, evas_obj_size_hint_min_get(&minw, &minh),
+                   efl_gfx_size_get(&ow, &oh));
+             if (ow < minw) ow = minw;
+             if (oh < minh) oh = minh;
+          }
 
         lw = ow;
         lh = oh;
@@ -377,12 +395,12 @@ _wdg_border_draw(const Gui_Widget *wdg, Eina_Bool 
visibility, int border_type_co
 static Eina_Bool
 _frame_mouse_move(void *data EINA_UNUSED, Eo *fr, const Eo_Event_Description 
*desc EINA_UNUSED, void *event_info EINA_UNUSED)
 {
-   Evas_Coord ox, oy;
+   Evas_Coord ox, oy, ow, oh;
    Evas_Event_Mouse_Move *ev = event_info;
    Gui_Widget *wdg;
    Gui_Widget_Property *prop;
 
-   eo_do(fr, efl_gfx_position_get(&ox, &oy));
+   elm_grid_pack_get(fr, &ox, &oy, &ow, &oh);
 
    ox = ox + (ev->cur.canvas.x - ev->prev.canvas.x);
    oy = oy + (ev->cur.canvas.y - ev->prev.canvas.y);
@@ -390,7 +408,7 @@ _frame_mouse_move(void *data EINA_UNUSED, Eo *fr, const 
Eo_Event_Description *de
    eo_do(fr, wdg = eo_key_data_get("winwdg"));
 
    /* FIXME: Move frame here, because we don't know if win must have position 
property*/
-   eo_do(fr, efl_gfx_position_set(ox, oy));
+   elm_grid_pack_set(fr, ox, oy, ow, oh);
    prop = wdg_prop_get(wdg, DB_DEF_EFL_GFX_BASE_CLASS, POSITION_SET);
    if (prop)
      {
@@ -442,7 +460,6 @@ _editor_wdg_selected_set(const Gui_Widget *wdg)
         Main_Wdg_Info *wi = wdg_data_get(main_wdg, MAIN_WDG_INFO);
         Eo *fr = main_wdg_info_frame_get(wi);
         eo_do(fr, efl_gfx_stack_raise());
-        _stack_below_panes(fr);
 
         Eo *obj = session_eo_get(gui_context_editor_session_get(ctx), wdg);
         /* Set focus */
@@ -531,8 +548,8 @@ _drag_widget_iterate(Gui_Widget **drag_candidate, const 
Gui_Session *session, Ev
         if (!w)
           continue;
         o = session_eo_get(session, w);
-        eo_do(o, efl_gfx_position_get(&ox, &oy));
-        eo_do(o, efl_gfx_size_get(&ow, &oh));
+        eo_do(o, efl_gfx_position_get(&ox, &oy),
+                 efl_gfx_size_get(&ow, &oh));
         if (((x >= ox) && (x <= ox + ow)) &&
             ((y >= oy) && (y <= oy + oh)))
           {
@@ -680,15 +697,6 @@ _marker_mouse_move(void *data, Eo *marker EINA_UNUSED, 
const Eo_Event_Descriptio
    if (IS_MAIN(wdg))
      {
         base_obj = canvas_get();
-     }
-   else
-     {
-        const Gui_Widget *win_wdg = wdg_main_wdg_get(wdg);
-        base_obj = session_eo_get(session, win_wdg);
-     }
-
-   if (IS_MAIN(wdg))
-     {
         Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
         weo = main_wdg_info_frame_get(wi);
 
@@ -701,23 +709,31 @@ _marker_mouse_move(void *data, Eo *marker EINA_UNUSED, 
const Eo_Event_Descriptio
         eo_do(weo, dh = (intptr_t) eo_key_data_get("dh"));
         minw += dw;
         minh += dh;
+
+        elm_grid_pack_get(weo, &ox, &oy, &ow, &oh);
+        Evas_Coord cx, cy;
+        eo_do(canvas_get(), efl_gfx_position_get(&cx, &cy));
+        /* Calculate cursor coordinates inside grid */
+        canvas_ptr_x = ev->prev.canvas.x - cx;
+        canvas_ptr_y = ev->prev.canvas.y - cy;
      }
    else
      {
+        const Gui_Widget *win_wdg = wdg_main_wdg_get(wdg);
+        base_obj = session_eo_get(session, win_wdg);
         /* Eo object of widget. */
         weo = session_eo_get(session, wdg);
         eo_do(weo, evas_obj_size_hint_min_get(&minw, &minh));
+        eo_do(weo, efl_gfx_position_get(&ox, &oy));
+        eo_do(weo, efl_gfx_size_get(&ow, &oh));
+        canvas_ptr_x = ev->prev.canvas.x;
+        canvas_ptr_y = ev->prev.canvas.y;
      }
-   canvas_ptr_x = ev->prev.canvas.x;
-   canvas_ptr_y = ev->prev.canvas.y;
 
    eo_do(base_obj, cur_logo = eo_key_data_get("cursor"));
    if (cur_logo)
      eo_do(cur_logo, efl_gfx_position_set(ev->cur.canvas.x + 7, 
ev->cur.canvas.y + 5));
 
-   eo_do(weo, efl_gfx_position_get(&ox, &oy));
-   eo_do(weo, efl_gfx_size_get(&ow, &oh));
-
    if (border & BORDER_MARKER_LEFT)
      {
         if ((canvas_ptr_x < ox) && ((ow - dx) > 0) && ((ow - dx) >= minw))
@@ -750,8 +766,16 @@ _marker_mouse_move(void *data, Eo *marker EINA_UNUSED, 
const Eo_Event_Descriptio
           }
      }
 
-   eo_do(weo, efl_gfx_position_set(ox, oy));
-   eo_do(weo, efl_gfx_size_set(ow, oh));
+   /* Set position */
+   if (IS_MAIN(wdg))
+     {
+        elm_grid_pack_set(weo, ox, oy, ow, oh);
+     }
+   else
+     {
+        eo_do(weo, efl_gfx_position_set(ox, oy));
+        eo_do(weo, efl_gfx_size_set(ow, oh));
+     }
 
    if (IS_MAIN(wdg))
      {
@@ -911,6 +935,12 @@ _marker_mouse_up(void *data EINA_UNUSED, Eo *obj, const 
Eo_Event_Description *de
           }
      }
 
+   /* For main widget update canvas size*/
+   if (IS_MAIN(wdg))
+     {
+        _canvas_resize_cb(NULL, g->main_win->canvas_scroller, NULL, NULL);
+     }
+
 end:
    if (_mmd.prop_size)
      {
@@ -1050,7 +1080,7 @@ _frame_mouse_up(void *data EINA_UNUSED, Eo *obj, const 
Eo_Event_Description *des
           {
              /* Check if dragged object is visible.
               * If not, means that _drag_start_cb was called, so need to 
reload main wdg. */
-             Eo *canvas = egui_layout_gui_get()->main_win->canvas_bg;
+             Eo *canvas = egui_layout_gui_get()->main_win->canvas_scroller;
              DnD_Info *di = eo_do_ret(canvas, di, 
eo_key_data_get(EDITOR_DND_DATA));
 
              const Gui_Widget *drag_widget = dnd_drag_wdg_get();
@@ -1070,6 +1100,7 @@ _frame_mouse_up(void *data EINA_UNUSED, Eo *obj, const 
Eo_Event_Description *des
              objtree_item_selected_set(drag_widget);
           }
      }
+   _canvas_resize_cb(NULL, g->main_win->canvas_scroller, NULL, NULL);
    return EO_CALLBACK_CONTINUE;
 }
 
@@ -1216,6 +1247,10 @@ _win_resize(void *data EINA_UNUSED, Eo *o, const 
Eo_Event_Description *desc EINA
    eo_do(fr, dh = (intptr_t) eo_key_data_get("dh"));
    eo_do(fr, efl_gfx_size_set(ow + dw, oh + dh));
 
+   Evas_Coord x, y, w, h;
+   elm_grid_pack_get(fr, &x, &y, &w, &h);
+   elm_grid_pack_set(fr, x, y, ow + dw, oh + dh);
+
    return EO_CALLBACK_CONTINUE;
 }
 
@@ -2120,7 +2155,7 @@ _objtree_drop_cb(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, Elm_Objec
      }
    else
      {
-        canvas = g->main_win->canvas_bg;
+        canvas = g->main_win->canvas_scroller;
      }
    const char *drag_data = ev->data;
    _drop_target_drop(wdg, canvas, drag_data, EINA_TRUE);
@@ -2151,22 +2186,23 @@ _drop_target_pos(void *data, Eo *obj, Evas_Coord x, 
Evas_Coord y, Elm_Xdnd_Actio
    Gui_Widget *wdg = data;
    DnD_Info *di = NULL;
    Eo *wdg_eo = NULL;
-   Evas_Coord obj_x = 0, obj_y = 0;
    /* If wdg == NULL, then canvas is a drop target or we have a error.*/
    if (wdg)
      {
         const Gui_Session *session = 
gui_context_editor_session_get(wdg_context_get(wdg));
         di = wdg_data_get(wdg_main_wdg_get(wdg), EDITOR_DND_DATA);
         wdg_eo = session_eo_get(session, wdg);
-        if (!IS_MAIN(wdg))
-          {
-             eo_do(wdg_eo, efl_gfx_position_get(&obj_x, &obj_y));
-          }
         _wdg_border_draw(wdg, EINA_TRUE, BORDER_DROP_TARGET);
      }
    else if (canvas_drop_target != NULL)
      {
         eo_do(canvas_drop_target, di = eo_key_data_get(EDITOR_DND_DATA));
+        /* I don't know why, but x, y which are passed - they coords in canvas,
+         * but we are inside scroller. */
+        Evas_Coord obj_x = 0, obj_y = 0;
+        eo_do(canvas_drop_target, efl_gfx_position_get(&obj_x, &obj_y));
+        x = x - obj_x;
+        y = y - obj_y;
      }
    else
      {
@@ -2422,7 +2458,7 @@ _drag_start_cb(const Gui_Widget *wdg, const Eo *_wdg_eo)
    Evas_Coord x = 0, y = 0;
    if (IS_MAIN(wdg))
      {
-        _drop_target_main_wdg_enter(NULL, 
egui_layout_gui_get()->main_win->canvas_bg);
+        _drop_target_main_wdg_enter(NULL, 
egui_layout_gui_get()->main_win->canvas_scroller);
         Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
         if (wi)
           {
@@ -2430,7 +2466,7 @@ _drag_start_cb(const Gui_Widget *wdg, const Eo *_wdg_eo)
              eo_do(fr, efl_gfx_position_get(&x, &y));
              eo_do(fr, efl_gfx_visible_set(EINA_FALSE));
           }
-        _drop_target_pos(NULL, egui_layout_gui_get()->main_win->canvas_bg, x, 
y, ELM_XDND_ACTION_UNKNOWN);
+        _drop_target_pos(NULL, 
egui_layout_gui_get()->main_win->canvas_scroller, x, y, 
ELM_XDND_ACTION_UNKNOWN);
      }
    else
      {
@@ -2528,21 +2564,9 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, 
void *data)
 
         if (!wi)
           {
-             Evas_Coord x, y, x_par, y_par;
+             Evas_Coord x, y;
              fr = eo_add(ELM_FRAME_CLASS, parent_win);
 
-             /* This frame does not have any smart as parent. So in order to 
show the frame under panes.
-              * we add this frame as a member of smart object. */
-             if (fr)
-               {
-                  Eo *smart_parent = 
evas_object_smart_parent_get(g->main_win->left_panes);
-                  eo_do(smart_parent, evas_obj_smart_member_add(fr));
-                  _stack_below_panes(fr);
-               }
-
-             Eo *smart_parent = 
evas_object_smart_parent_get(g->main_win->main_box);
-             eo_do(smart_parent, efl_gfx_position_get(&x_par, &y_par));
-
              /* If widget was DnD'ed from factory, these fields won't be 
empty... */
              x = (intptr_t) wdg_data_get(wdg, CURSOR_DROP_X);
              y = (intptr_t) wdg_data_get(wdg, CURSOR_DROP_Y);
@@ -2550,9 +2574,9 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, 
void *data)
              /* ...if they are empty,  calculate automatic coordinates. */
              if ((x == 0) && (y == 0))
                {
-                  _canvas_free_coords_get(wdg_context_get(wdg), x_par, y_par, 
&x, &y);
+                  _canvas_free_coords_get(wdg_context_get(wdg), &x, &y);
                }
-             eo_do(fr, efl_gfx_position_set(x, y));
+             eo_do(canvas_get(), elm_obj_grid_pack(fr, x, y, 0, 0));
 
              wi = main_wdg_info_new();
              main_wdg_info_frame_set(wi, fr);
@@ -2600,8 +2624,7 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, 
void *data)
           }
         /* Get size from properties of window. */
         Evas_Coord ox = 150, oy = 50;
-        eo_do(fr, efl_gfx_position_get(&ox, &oy));
-        eo_do(iwin, efl_gfx_position_set(ox, oy));
+        elm_grid_pack_get(fr, &ox, &oy, NULL, NULL);
 
           {
              /* When set image as content to frame, image is smaller then 
frame.
@@ -2624,9 +2647,10 @@ _widget_add(Gui_Session *session, const Gui_Widget *wdg, 
void *data)
              eo_do(fr, eo_key_data_set("dw", (void *) (intptr_t) dw));
              eo_do(fr, eo_key_data_set("dh", (void *) (intptr_t) dh));
              /* Resize properly. */
-             eo_do(fr, efl_gfx_size_set(ow + dw, oh + dh));
              eo_do(iwin, efl_gfx_size_set(ow, oh));
+             elm_grid_pack_set(fr, ox, oy, ow + dw, oh + dh);
           }
+
         elm_theme_free(theme);
      }
 
@@ -3350,10 +3374,10 @@ _editor_factory_wdg_create(const char *class_name, 
const Gui_Widget *focused_wdg
 void
 editor_shutdown()
 {
-   DnD_Info *di = eo_do_ret(g->main_win->canvas_bg, di, 
eo_key_data_get(EDITOR_DND_DATA));
-   eo_do(g->main_win->canvas_bg, eo_key_data_del(EDITOR_DND_DATA));
+   DnD_Info *di = eo_do_ret(g->main_win->canvas_scroller, di, 
eo_key_data_get(EDITOR_DND_DATA));
+   eo_do(g->main_win->canvas_scroller, eo_key_data_del(EDITOR_DND_DATA));
    free(di);
-   drop_target_wdg_del(NULL, g->main_win->canvas_bg);
+   drop_target_wdg_del(NULL, g->main_win->canvas_scroller);
 
    target_db_shutdown();
    proplayout_shutdown();
@@ -4622,6 +4646,79 @@ _theme_hoversel_fill()
    eo_do(g->main_win->theme_selector_hoversel, 
elm_obj_widget_part_text_set(NULL, theme_name));
 }
 
+/* define the most right and the mos bottom coord of the frames. */
+static void
+_max_coords_get(Evas_Coord *left_x, Evas_Coord *top_y, Evas_Coord *right_x, 
Evas_Coord *bottom_y)
+{
+   Evas_Coord mx = 0, my = 0, mw = 0, mh = 0;
+   *left_x = *top_y = *right_x = *bottom_y = 0;
+   Gui_Context *ctx = _active_context_get();
+   if (!ctx) return;
+
+   Eid *wdg_id;
+   Eina_List *main_widgets = gui_context_main_widgets_get(ctx), *itr;
+   EINA_LIST_FOREACH(main_widgets, itr, wdg_id)
+     {
+        Gui_Widget *wdg = wdg_get(wdg_id);
+        Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
+        Eo *fr = main_wdg_info_frame_get(wi);
+        elm_grid_pack_get(fr, &mx, &my, &mw, &mh);
+        if ((mx + mw) > *right_x) *right_x = mx + mw;
+        if ((my + mh) > *bottom_y) *bottom_y = my + mh;
+        if (*left_x > mx) *left_x = mx;
+        if (*top_y > my) *top_y = my;
+     }
+}
+
+/* Callback called on canvas_scroller resize: t.e. when window or panes is 
resized. */
+Eina_Bool
+_canvas_resize_cb(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description 
*desc EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Evas_Coord right_x, bottom_y, left_x, top_y;
+   _max_coords_get(&left_x, &top_y, &right_x, &bottom_y);
+   if (g)
+     {
+        Evas_Coord dx = 17, dy = 2, w, h;
+        /* Define min grid size the same as scroller size */
+        eo_do(obj, efl_gfx_size_get(&w, &h));
+
+        /* Define most right/bottom size. */
+        w = (w < right_x) ? right_x : w;
+        h = (h < bottom_y) ? bottom_y : h;
+
+        /* Define most left/top size. */
+        w = w + ((left_x < 0) ? (-left_x) : 0);
+        h = h + ((top_y < 0) ? (-top_y) : 0);
+
+        eo_do(g->main_win->canvas_grid, elm_obj_grid_size_set(w - dx, h - dy),
+                                        evas_obj_size_hint_min_set(w - dx, h - 
dy));
+        /* Order scrolling when drag objects to the left/top */
+        if (left_x < 0 || top_y < 0)
+          {
+             Evas_Coord region_x, region_y, region_w, region_h;
+             elm_scroller_region_get(obj, &region_x, &region_y, &region_w, 
&region_h);
+             Eid *wdg_id;
+             Gui_Context *ctx = _active_context_get();
+             if (!ctx) return EO_CALLBACK_CONTINUE;
+             Eina_List *main_widgets = gui_context_main_widgets_get(ctx), *itr;
+             EINA_LIST_FOREACH(main_widgets, itr, wdg_id)
+               {
+                  Evas_Coord fx = 0, fy = 0, fw = 0, fh = 0;
+                  Gui_Widget *wdg = wdg_get(wdg_id);
+                  Main_Wdg_Info *wi = wdg_data_get(wdg, MAIN_WDG_INFO);
+                  Eo *fr = main_wdg_info_frame_get(wi);
+                  elm_grid_pack_get(fr, &fx, &fy, &fw, &fh);
+                  elm_grid_pack_set(fr, (left_x < 0) ? fx - left_x : fx,
+                                        (top_y < 0 )? fy - top_y : fy, fw, fh);
+               }
+             elm_scroller_region_bring_in(obj, (left_x < 0) ? -left_x : 0,
+                                               (top_y < 0) ? -top_y : 0,
+                                               region_w, region_h);
+          }
+     }
+   return EO_CALLBACK_CONTINUE;
+}
+
 void
 editor_init(GuiLogicCbs *_guilogic_cbs)
 {
@@ -4670,8 +4767,8 @@ editor_init(GuiLogicCbs *_guilogic_cbs)
    ecore_idle_enterer_add(_wdg_border_draw_on_idle, NULL);
 
    DnD_Info *di = calloc (1, sizeof(DnD_Info));
-   eo_do(g->main_win->canvas_bg, eo_key_data_set(EDITOR_DND_DATA, di));
-   drop_target_main_wdg_set(NULL, g->main_win->canvas_bg,
+   eo_do(g->main_win->canvas_scroller, eo_key_data_set(EDITOR_DND_DATA, di));
+   drop_target_main_wdg_set(NULL, g->main_win->canvas_scroller,
                             _drop_target_main_wdg_enter, NULL,
                             _drop_target_main_wdg_leave, NULL,
                             _drop_target_pos, NULL,
diff --git a/src/bin/gui/egui_layout.json b/src/bin/gui/egui_layout.json
index 763bc1a..a3122af 100644
--- a/src/bin/gui/egui_layout.json
+++ b/src/bin/gui/egui_layout.json
@@ -40,7 +40,8 @@
       "_custom_theme_add_button_clicked":"_custom_theme_add_button_clicked",
       "_custom_theme_del_button_clicked":"_custom_theme_del_button_clicked",
       "_theme_selector_hover_selected_cb":"_theme_selector_hover_selected_cb",
-      "_rmview_toolbar_clicked":"_rmview_toolbar_clicked"
+      "_rmview_toolbar_clicked":"_rmview_toolbar_clicked",
+      "_canvas_resize_cb":"_canvas_resize_cb"
     },
     "Edjes":
     {
@@ -1063,7 +1064,7 @@
         "Evas.Object.size_hint_align":[-1, -1],
         "Efl.Gfx.Base.visible":[true]
       },
-      "Contains":["left_panes", "right_panes"]
+      "Contains":["left_panes"]
     },
     "left_pane_layout":
     {
@@ -1096,11 +1097,13 @@
       {
         "Evas.Object.size_hint_weight":[1, 1],
         "Evas.Object.size_hint_align":[-1, -1],
+        "Elm.Panes.content_right_size":[0.83],
         "Efl.Gfx.Base.visible":[true]
       },
       "Contains":
       {
-        "left_pane_layout":["left"]
+        "left_pane_layout":["left"],
+        "right_panes":["right"]
       }
     },
     "left_pane_bg":
@@ -3073,7 +3076,7 @@
     {
       "Desc":
       {
-        "parent":"hor_box",
+        "parent":"left_panes",
         "class":"Elm.Panes",
         "public":true
       },
@@ -3081,11 +3084,54 @@
       {
         "Evas.Object.size_hint_weight":[1, 1],
         "Evas.Object.size_hint_align":[1, -1],
+        "Elm.Panes.content_right_size":[0.20],
         "Efl.Gfx.Base.visible":[true]
       },
       "Contains":
       {
-        "right_pane_layout":["right"]
+        "right_pane_layout":["right"],
+        "canvas_scroller":["left"]
+      }
+    },
+    "canvas_scroller":
+    {
+      "Desc":
+      {
+        "parent":"right_panes",
+        "class":"Elm.Scroller",
+        "public":true
+      },
+      "Properties":
+      {
+        "Evas.Object.size_hint_weight":[1, 1],
+        "Evas.Object.size_hint_align":[-1, -1],
+        "Elm_Interface_Scrollable.bounce_allow":[false, false],
+        "Efl.Gfx.Base.visible":[true]
+      },
+      "Callbacks":
+      {
+        "resize":["Invoke", "_canvas_resize_cb", null]
+      },
+      "Contains":
+      {
+         "canvas_grid":[null]
+      }
+    },
+    "canvas_grid":
+    {
+      "Desc":
+      {
+        "parent":"canvas_scroller",
+        "class":"Elm.Grid",
+        "public":true
+      },
+      "Properties":
+      {
+        "Evas.Object.size_hint_weight":[0, 0],
+        "Evas.Object.size_hint_align":[0, 0],
+        "Elm.Grid.size":[1,1],
+        "Evas.Object.size_hint_min":[1, 1],
+        "Efl.Gfx.Base.visible":[true]
       }
     },
     "right_pane_bg":
diff --git a/src/bin/gui/egui_logic.c b/src/bin/gui/egui_logic.c
index 8bf20a8..5b825fa 100644
--- a/src/bin/gui/egui_logic.c
+++ b/src/bin/gui/egui_logic.c
@@ -64,7 +64,8 @@ enum
 Eo *
 canvas_get()
 {
-   return g_main_wdgs->main_win->main_win;
+   //return g_main_wdgs->main_win->main_win;
+   return g_main_wdgs->main_win->canvas_grid;
 }
 
 static void
@@ -924,6 +925,8 @@ egui_start()
    eo_do(evas_object_smart_parent_get(g_main_wdgs->main_win->main_box), 
evas_obj_smart_member_add(g_main_wdgs->main_win->canvas_bg));
    eo_do(g_main_wdgs->main_win->canvas_bg, 
efl_gfx_stack_below(g_main_wdgs->main_win->main_box));
 
+   eo_do(g_main_wdgs->main_win->canvas_scroller, 
elm_interface_scrollable_movement_block_set(ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL
 |  ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL));
+
    /* hor box and toolbar are in the same main_box and he the same parent 
smart obj.
     * So stack hor_box under toolbar. */
    eo_do(g_main_wdgs->main_win->hor_box, 
efl_gfx_stack_below(g_main_wdgs->main_win->toolbar));

-- 


Reply via email to