[gimp] Bug 597117 - impossible to drop a group as a sibling inside a group



commit e3b5c55ca2a832ad42c7f8744c607f48376166c9
Author: Michael Natterer <mitch gimp org>
Date:   Tue Feb 8 09:35:38 2011 +0100

    Bug 597117 - impossible to drop a group as a sibling inside a group
    
    Properly distinguish between dropping after a group and into it, by
    having three drop areas on a collapsed row. Still handle expanded rows
    as before, but indicate dropping into visually just as on a collapsed
    row.

 app/widgets/gimpcontainertreeview-dnd.c |   30 ++++++++++++++++++++++++------
 app/widgets/gimpdrawabletreeview.c      |    5 +----
 app/widgets/gimpitemtreeview.c          |    6 +++++-
 3 files changed, 30 insertions(+), 11 deletions(-)
---
diff --git a/app/widgets/gimpcontainertreeview-dnd.c b/app/widgets/gimpcontainertreeview-dnd.c
index d0cb716..8fdcab6 100644
--- a/app/widgets/gimpcontainertreeview-dnd.c
+++ b/app/widgets/gimpcontainertreeview-dnd.c
@@ -115,13 +115,31 @@ gimp_container_tree_view_drop_status (GimpContainerTreeView    *tree_view,
 
       gtk_tree_view_get_cell_area (tree_view->view, drop_path, NULL, &cell_area);
 
-      if (y >= (cell_area.y + cell_area.height / 2))
+      if (gimp_viewable_get_children (dest_viewable))
         {
-          drop_pos = GTK_TREE_VIEW_DROP_AFTER;
+          if (gtk_tree_view_row_expanded (tree_view->view, drop_path))
+            {
+              if (y >= (cell_area.y + cell_area.height / 2))
+                drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
+              else
+                drop_pos = GTK_TREE_VIEW_DROP_BEFORE;
+            }
+          else
+            {
+              if (y >= (cell_area.y + 2 * (cell_area.height / 3)))
+                drop_pos = GTK_TREE_VIEW_DROP_AFTER;
+              else if (y <= (cell_area.y + cell_area.height / 3))
+                drop_pos = GTK_TREE_VIEW_DROP_BEFORE;
+              else
+                drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
+            }
         }
       else
         {
-          drop_pos = GTK_TREE_VIEW_DROP_BEFORE;
+          if (y >= (cell_area.y + cell_area.height / 2))
+            drop_pos = GTK_TREE_VIEW_DROP_AFTER;
+          else
+            drop_pos = GTK_TREE_VIEW_DROP_BEFORE;
         }
     }
 
@@ -511,8 +529,8 @@ gimp_container_tree_view_real_drop_possible (GimpContainerTreeView   *tree_view,
     {
       GimpViewable *parent;
 
-      /*  dropping on the lower part of a group item drops into that group  */
-      if (drop_pos == GTK_TREE_VIEW_DROP_AFTER &&
+      /*  dropping on the lower third of a group item drops into that group  */
+      if (drop_pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER &&
           gimp_viewable_get_children (dest_viewable))
         {
           parent = dest_viewable;
@@ -556,7 +574,7 @@ gimp_container_tree_view_real_drop_possible (GimpContainerTreeView   *tree_view,
           if (dest_index == (src_index + 1))
             return FALSE;
         }
-      else
+      else if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
         {
           if (dest_index == (src_index - 1))
             return FALSE;
diff --git a/app/widgets/gimpdrawabletreeview.c b/app/widgets/gimpdrawabletreeview.c
index 29bcd94..5dc9935 100644
--- a/app/widgets/gimpdrawabletreeview.c
+++ b/app/widgets/gimpdrawabletreeview.c
@@ -217,10 +217,7 @@ gimp_drawable_tree_view_drop_possible (GimpContainerTreeView   *tree_view,
 
           if (return_drop_pos)
             {
-              if (drop_pos == GTK_TREE_VIEW_DROP_BEFORE)
-                *return_drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE;
-              else
-                *return_drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
+              *return_drop_pos = GTK_TREE_VIEW_DROP_INTO_OR_AFTER;
             }
         }
 
diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c
index 07cc594..4c1c08d 100644
--- a/app/widgets/gimpitemtreeview.c
+++ b/app/widgets/gimpitemtreeview.c
@@ -737,7 +737,7 @@ gimp_item_tree_view_get_drop_index (GimpItemTreeView         *view,
       *parent = gimp_viewable_get_parent (dest_viewable);
       index   = gimp_item_get_index (GIMP_ITEM (dest_viewable));
 
-      if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
+      if (drop_pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER)
         {
           GimpContainer *children = gimp_viewable_get_children (dest_viewable);
 
@@ -751,6 +751,10 @@ gimp_item_tree_view_get_drop_index (GimpItemTreeView         *view,
               index++;
             }
         }
+      else if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
+        {
+          index++;
+        }
     }
 
   return index;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]