Exemplo n.º 1
0
        public override void    DrawRow(RowsDrawer rowsDrawer, Rect r, int i, bool?collapse)
        {
            if (this.instanceIDs == null)
            {
                this.ParseCondition();
            }

            LogSettings log         = HQ.Settings.Get <LogSettings>();
            float       originWidth = RowUtility.drawingWindow.position.width - rowsDrawer.verticalScrollbarWidth;

            // Draw highlight.
            r.x      = 0F;
            r.width  = originWidth;
            r.height = log.height;

            this.DrawBackground(rowsDrawer, r, i);

            if (Event.current.type == EventType.MouseDrag &&
                Utility.position2D != Vector2.zero &&
                DragAndDrop.GetGenericData(Utility.DragObjectDataName) != null &&
                (Utility.position2D - Event.current.mousePosition).sqrMagnitude >= Constants.MinStartDragDistance)
            {
                DragAndDrop.StartDrag("Drag Object");
                Event.current.Use();
            }

            r.width = 16F;
            EditorGUI.DrawRect(r, Color.cyan);
            bool lastValue = this.isOpened;

            this.isOpened = EditorGUI.Foldout(r, this.isOpened, "");
            if (lastValue != this.isOpened)
            {
                rowsDrawer.InvalidateViewHeight();
            }
            r.x     = r.width;
            r.width = originWidth - r.x;

            r       = this.DrawPreLogData(rowsDrawer, r);
            r.width = originWidth - r.x;

            // Draw contexts.
            for (int j = 0; j < this.instanceIDs.Length; j++)
            {
                Texture2D icon = null;

                r.width = log.height;
                if (this.instanceIDs[j] != 0)
                {
                    icon = Utility.GetIcon(this.instanceIDs[j]);

                    if (Event.current.type == EventType.MouseDown &&
                        r.Contains(Event.current.mousePosition) == true)
                    {
                        if (Event.current.button == 0)
                        {
                            Utility.position2D = Event.current.mousePosition;

                            DragAndDrop.PrepareStartDrag();
                            DragAndDrop.objectReferences = new Object[] { EditorUtility.InstanceIDToObject(this.instanceIDs[j]) };
                            DragAndDrop.SetGenericData(Utility.DragObjectDataName, this.instanceIDs[j]);

                            if (RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup ||
                                (Event.current.modifiers & log.selectObjectOnModifier) != 0)
                            {
                                Selection.activeInstanceID = this.instanceIDs[j];
                            }
                            else
                            {
                                EditorGUIUtility.PingObject(this.instanceIDs[j]);
                            }

                            RowUtility.LastClickTime = EditorApplication.timeSinceStartup;
                        }
                        else if (Event.current.button == 1)
                        {
                            Selection.activeInstanceID = this.instanceIDs[j];
                        }
                    }
                }

                if (icon != null)
                {
                    GUI.DrawTexture(r, icon);
                }
                else
                {
                    EditorGUI.DrawRect(r, Color.black);
                }

                if (r.Contains(Event.current.mousePosition) == true)
                {
                    r.x    += r.width;
                    r.width = originWidth - r.x;

                    Object context = null;

                    if (this.instanceIDs[j] != 0)
                    {
                        context = EditorUtility.InstanceIDToObject(this.instanceIDs[j]);
                    }

                    if (context != null)
                    {
                        EditorGUI.LabelField(r, context.ToString());
                    }
                    else
                    {
                        EditorGUI.LabelField(r, LC.G("MultiContextsRow_ObjectNotAvailable"));
                    }

                    RowUtility.drawingWindow.Repaint();
                }

                r.x += r.width + MultiContextsRow.Spacing;
            }

            r.x     = 0F;
            r.width = originWidth;
            this.HandleDefaultSelection(rowsDrawer, r, i);

            if (this.isOpened == true)
            {
                r.x     = 0F;
                r.y    += r.height;
                r.width = originWidth;
                r       = RowUtility.DrawStackTrace(this, rowsDrawer, r, i, this);
            }
        }