Exemple #1
0
 private void AddGridItemChild(GridItem parent, GridItem child)
 {
     m_ItemDataSource.AddChildItem(parent, child);
     m_GridViewGroup.UpdateItemsBySearchText();
 }
 private bool ItemBeginRenameAction(GridItem item)
 {
     m_GridView.GetRenameOverlay().isRenamingFilename = true;
     return(true);
 }
Exemple #3
0
        protected int GetControlIdFromInstanceId(GridItem item)
        {
            int controlId = GUIUtility.GetControlID(item.GetHashCode() + m_Owner.GetHashCode(), FocusType.Passive);

            return(controlId);
        }
 public virtual bool HasChildren(GridItem item)
 {
     return(true);
 }
 public virtual bool AcceptRename(GridItem item)
 {
     return(true);
 }
Exemple #6
0
        private void HandleMouseWithoutDragging(int itmeId, int controlId, Rect rect, GridItem item)
        {
            Event current = Event.current;

            switch (current.GetTypeForControl(controlId))
            {
            case EventType.MouseDown:
                if (current.button != 0 || !rect.Contains(current.mousePosition))
                {
                    break;
                }
                m_Owner.Repaint();
                if (current.clickCount == 1)
                {
                    m_Owner.ScrollToPosition(GridView.AdjustRectForFraming(rect));
                }
                current.Use();
                m_Owner.SetSelection(GetNewSelection(itmeId, false, false).ToArray(), current.clickCount == 2);
                break;

            case EventType.ContextClick:
                if (!rect.Contains(current.mousePosition))
                {
                    break;
                }
                m_Owner.SetSelection(new int[1]
                {
                    itmeId
                }, false);

                if (!rect.Contains(current.mousePosition))
                {
                    break;
                }

                if (m_Owner.GirdItemPopupMenuAction != null)
                {
                    m_Owner.GirdItemPopupMenuAction(item);
                    current.Use();
                }
                break;
            }
        }
Exemple #7
0
        private void HandleMouseWithDragging(int itmeId, int controlId, Rect rect, GridItem item)
        {
            Event     current        = Event.current;
            EventType typeForControl = current.GetTypeForControl(controlId);

            switch (typeForControl)
            {
            case EventType.MouseDown:
                if (Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
                {
                    if (current.clickCount == 2)
                    {
                        m_Owner.SetSelection(new int[1]
                        {
                            itmeId
                        }, true);
                        if (m_Owner.ItemDoubleClickAction != null)
                        {
                            m_Owner.ItemDoubleClickAction(item);
                        }
                        m_DragSelection.Clear();
                    }
                    else
                    {
                        m_DragSelection       = GetNewSelection(itmeId, true, false);
                        GUIUtility.hotControl = controlId;
                        ((DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), controlId))
                        .mouseDownPosition = Event.current.mousePosition;
                        m_Owner.ScrollToPosition(GridView.AdjustRectForFraming(rect));
                    }
                    current.Use();
                    break;
                }
                if (Event.current.button != 1 || !rect.Contains(Event.current.mousePosition))
                {
                    break;
                }

                m_Owner.SetSelection(GetNewSelection(itmeId, true, false).ToArray(), false);
                Event.current.Use();
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl != controlId)
                {
                    break;
                }

                if (rect.Contains(current.mousePosition))
                {
                    bool flag;
                    if (ListMode)
                    {
                        rect.x     += 28f;
                        rect.width += 28f;
                        flag        = rect.Contains(current.mousePosition);
                    }
                    else
                    {
                        rect.y      = rect.y + rect.height - GridView.s_Styles.resultsGridLabel.fixedHeight;
                        rect.height = GridView.s_Styles.resultsGridLabel.fixedHeight;
                        flag        = rect.Contains(current.mousePosition);
                    }
                    List <int> selectedInstanceIds = m_Owner.ViewConfig.SelectedItemIdList;
                    if (flag && m_Owner.ViewConfig.AllowRenaming &&
                        (m_Owner.AllowRenameOnMouseUp && selectedInstanceIds.Count == 1) &&
                        (selectedInstanceIds[0] == itmeId &&
                         !EditorGUIUtilityWrap.HasHolddownKeyModifiers(current)))
                    {
                        m_Owner.BeginRename(0.5f);
                    }
                    else
                    {
                        m_Owner.SetSelection(GetNewSelection(itmeId, false, false).ToArray(), false);
                    }
                    GUIUtility.hotControl = 0;
                    current.Use();
                }
                m_DragSelection.Clear();
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl != controlId)
                {
                    break;
                }
                if (((DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), controlId))
                    .CanStartDrag())
                {
                    m_Owner.ViewHandler.StartDrag(itmeId, m_DragSelection);
                    GUIUtility.hotControl = 0;
                }
                current.Use();
                break;

            default:
                if (typeForControl != EventType.DragUpdated && typeForControl != EventType.DragPerform)
                {
                    if (typeForControl != EventType.DragExited)
                    {
                        if (typeForControl != EventType.ContextClick)
                        {
                            break;
                        }

                        if (!rect.Contains(current.mousePosition))
                        {
                            break;
                        }

                        if (m_Owner.GirdItemPopupMenuAction != null)
                        {
                            m_Owner.GirdItemPopupMenuAction(item);
                            current.Use();
                        }
                        break;
                    }
                    m_DragSelection.Clear();
                    break;
                }
                bool perform = current.type == EventType.DragPerform;
                if (rect.Contains(current.mousePosition))
                {
                    DragAndDropVisualMode andDropVisualMode = m_Owner.ViewHandler.DoDrag(itmeId, perform);
                    if (andDropVisualMode != DragAndDropVisualMode.None)
                    {
                        if (perform)
                        {
                            DragAndDrop.AcceptDrag();
                        }
                        m_DropTargetControlID  = controlId;
                        DragAndDrop.visualMode = andDropVisualMode;
                        current.Use();
                    }
                    if (perform)
                    {
                        m_DropTargetControlID = 0;
                    }
                }
                if (!perform)
                {
                    break;
                }
                m_DragSelection.Clear();
                break;
            }
        }