示例#1
0
        protected override bool OnDragMotion(Gdk.DragContext context, int x, int y, uint time)
        {
            TreePath             path;
            TreeViewDropPosition pos;
            Source active_source = ServiceManager.SourceManager.ActiveSource;

            if (active_source.SupportedMergeTypes == SourceMergeType.None)
            {
                Gdk.Drag.Status(context, 0, time);
                return(false);
            }
            else if (!GetDestRowAtPos(x, y, out path, out pos))
            {
                Gdk.Drag.Status(context, 0, time);
                return(false);
            }

            Source drop_source   = store.GetSource(path);
            Source parent_source = (drop_source as LibrarySource) ?? (drop_source.Parent as LibrarySource);

            // Scroll if within 20 pixels of the top or bottom
            if (y < 20)
            {
                Vadjustment.Value -= 30;
            }
            else if ((Allocation.Height - y) < 20)
            {
                Vadjustment.Value += 30;
            }

            ShowNewPlaylistUnder(parent_source, active_source);

            if (!drop_source.AcceptsUserInputFromSource(active_source))
            {
                Gdk.Drag.Status(context, 0, time);
                return(true);
            }

            SetDragDestRow(path, TreeViewDropPosition.IntoOrAfter);

            bool move = (active_source is LibrarySource) && (drop_source is LibrarySource);

            Gdk.Drag.Status(context, move ? Gdk.DragAction.Move : Gdk.DragAction.Copy, time);

            return(true);
        }