protected bool SvgInputAssetsDraw(SVGBasicAtlas atlas, Event currentEvent, out Rect scollRect)
    {
        bool isDirty = false;

        // keep track of drawn rows
        if (currentEvent.type != EventType.Layout)
        {
            this.m_InputAssetsRects = new List <Rect>();
        }

        Vector2 scrollPos = EditorGUILayout.BeginScrollView(this.m_SvgListScrollPos, GUILayout.ExpandWidth(true), GUILayout.MaxHeight(102), GUILayout.Height(102));

        // perform backward loop because we could even remove entries without issues
        for (int i = 0; i < atlas.SvgAssetsCount(); ++i)
        {
            Rect rowRect;
            isDirty |= this.SvgInputAssetDraw(atlas, i, out rowRect);
            // keep track of row rectangle
            if (currentEvent.type != EventType.Layout)
            {
                this.m_InputAssetsRects.Add(rowRect);
            }
        }
        EditorGUILayout.EndScrollView();
        // keep track of the scrollview area
        scollRect = GUILayoutUtility.GetLastRect();
        if (this.m_SvgListScrollPos != scrollPos)
        {
            this.m_SvgListScrollPos = scrollPos;
        }
        return(isDirty);
    }
    protected bool HandleDragEvents(SVGBasicAtlas atlas, Event currentEvent, Rect scollRect)
    {
        int  i;
        bool isDirty = false;

        // events handler
        if (currentEvent.type != EventType.Layout)
        {
            bool needRepaint = false;
            // get mouse position relative to scollRect
            Vector2 mousePos = currentEvent.mousePosition - new Vector2(scollRect.xMin, scollRect.yMin);

            if (scollRect.Contains(currentEvent.mousePosition))
            {
                bool separatorInserted = false;

                for (i = 0; i < atlas.SvgAssetsCount(); ++i)
                {
                    // get the row rectangle relative to atlas.SvgList[i]
                    Rect rowRect = this.m_InputAssetsRects[i];
                    // expand the rectangle height
                    rowRect.yMin -= 3;
                    rowRect.yMax += 3;

                    if (rowRect.Contains(mousePos))
                    {
                        // a mousedown on a row, will stop an already started drag operation
                        if (currentEvent.type == EventType.MouseDown)
                        {
                            this.m_DragInfo.StopDrag();
                        }
                        // check if we are already dragging an object
                        if (this.m_DragInfo.Dragging)
                        {
                            if (!separatorInserted)
                            {
                                bool ok         = true;
                                bool dragBefore = (mousePos.y <= rowRect.yMin + rowRect.height / 2) ? true : false;
                                // if we are dragging a text (asset) file, all positions are ok
                                // if we are dragging an already present SVG row, we must perform additional checks
                                if (!(this.m_DragInfo.DraggedObject is TextAsset))
                                {
                                    if (this.m_DragInfo.DraggedObject == atlas.SvgAsset(i))
                                    {
                                        ok = false;
                                    }
                                    else
                                    {
                                        if (dragBefore)
                                        {
                                            if (i > 0 && this.m_DragInfo.DraggedObject == atlas.SvgAsset(i - 1))
                                            {
                                                ok = false;
                                            }
                                        }
                                        else
                                        {
                                            if (i < (atlas.SvgAssetsCount() - 1) && this.m_DragInfo.DraggedObject == atlas.SvgAsset(i + 1))
                                            {
                                                ok = false;
                                            }
                                        }
                                    }
                                }

                                if (ok)
                                {
                                    if (dragBefore)
                                    {
                                        this.m_DragInfo.InsertIdx    = i;
                                        this.m_DragInfo.InsertBefore = true;
                                        separatorInserted            = true;
                                    }
                                    else
                                    {
                                        this.m_DragInfo.InsertIdx    = i;
                                        this.m_DragInfo.InsertBefore = false;
                                        separatorInserted            = true;
                                    }
                                    needRepaint = true;
                                }
                            }
                        }
                        else
                        {
                            // initialize the drag of an already present SVG document
                            if (currentEvent.type == EventType.MouseDrag)
                            {
                                DragAndDrop.PrepareStartDrag();
                                DragAndDrop.StartDrag("Start drag");
                                this.m_DragInfo.StartDrag(atlas.SvgAsset(i));
                                needRepaint = true;
                            }
                        }
                    }
                }

                // mouse is dragging inside the drop box, but not under an already present row; insertion point is inside the last element
                if (this.m_DragInfo.Dragging && !separatorInserted && atlas.SvgAssetsCount() > 0 && mousePos.y > this.m_InputAssetsRects[atlas.SvgAssetsCount() - 1].yMax)
                {
                    bool ok = true;

                    if (!(this.m_DragInfo.DraggedObject is TextAsset))
                    {
                        if (this.m_DragInfo.DraggedObject == atlas.SvgAsset(atlas.SvgAssetsCount() - 1))
                        {
                            ok = false;
                        }
                    }

                    if (ok)
                    {
                        this.m_DragInfo.InsertIdx    = atlas.SvgAssetsCount() - 1;
                        this.m_DragInfo.InsertBefore = false;
                        needRepaint = true;
                    }
                }
            }
            else
            {
                this.m_DragInfo.InsertIdx = -1;
            }

            if (needRepaint)
            {
                Repaint();
            }
        }

        if (currentEvent.type == EventType.DragExited)
        {
            this.m_DragInfo.StopDrag();
            DragAndDrop.objectReferences = new UnityEngine.Object[0];
        }
        else
        {
            switch (currentEvent.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (this.m_DragInfo.Dragging)
                {
                    bool dragValid = true;

                    if (scollRect.Contains(currentEvent.mousePosition) && dragValid)
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Link;
                        if (currentEvent.type == EventType.DragPerform)
                        {
                            int index;

                            // accept drag&drop operation
                            DragAndDrop.AcceptDrag();
                            // check if we are dropping a text asset
                            if (this.m_DragInfo.DraggedObject is TextAsset)
                            {
                                // if a valid inter-position has not been selected, append the new asset at the end of list
                                if (this.m_DragInfo.InsertIdx < 0)
                                {
                                    index = atlas.SvgAssetsCount();
                                }
                                else
                                {
                                    index = (this.m_DragInfo.InsertBefore) ? this.m_DragInfo.InsertIdx : (this.m_DragInfo.InsertIdx + 1);
                                }
                                // add the text asset to the SVG list
                                if (atlas.SvgAssetAdd(this.m_DragInfo.DraggedObject as TextAsset, index))
                                {
                                    isDirty = true;
                                }
                            }
                            else
                            {
                                // we are dropping an already present SVG row
                                index = (this.m_DragInfo.InsertBefore) ? this.m_DragInfo.InsertIdx : (this.m_DragInfo.InsertIdx + 1);
                                if (atlas.SvgAssetMove(this.m_DragInfo.DraggedObject as SVGAssetInput, index))
                                {
                                    isDirty = true;
                                }
                            }
                            // now we can close the drag operation
                            this.m_DragInfo.StopDrag();
                        }
                    }
                    else
                    {
                        // if we are dragging outside of the allowed drop region, simply reject the drag&drop
                        DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                    }
                }
                else
                {
                    if (scollRect.Contains(currentEvent.mousePosition))
                    {
                        if (DragAndDrop.objectReferences != null && DragAndDrop.objectReferences.Length > 0)
                        {
                            UnityEngine.Object draggedObject = DragAndDrop.objectReferences[0];
                            // check object type, only TextAssets are allowed
                            if (draggedObject is TextAsset)
                            {
                                this.m_DragInfo.StartDrag(DragAndDrop.objectReferences[0]);
                                Repaint();
                            }
                            else
                            {
                                // acceptance is not confirmed (e.g. we are dragging a binary file)
                                DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
                            }
                        }
                    }
                }
                break;

            default:
                break;
            }
        }

        return(isDirty);
    }