Ejemplo n.º 1
0
        private void DrawPreviewRows(Rect previewRowsRect, PreviewPanelContents previewContents, bool showSecondColumn, bool showThirdColumn)
        {
            for (int i = 0; i < previewContents.NumVisibleRows; ++i)
            {
                var content         = previewContents[i];
                var previewRowStyle = new PreviewRowStyle();
                previewRowStyle.IconStyle = this.guiStyles.Icon;

                previewRowStyle.FirstColumnStyle = content.NameChangedThisStep ?
                                                   this.guiStyles.OriginalNameLabelWhenModified :
                                                   this.guiStyles.OriginalNameLabelUnModified;
                previewRowStyle.FirstColumnWidth = previewContents.LongestOriginalNameWidth;

                previewRowStyle.SecondColumnStyle = content.NameChangedThisStep ?
                                                    this.guiStyles.NewNameLabelModified :
                                                    this.guiStyles.NewNameLabelUnModified;

                previewRowStyle.SecondColumnWidth = showSecondColumn ? previewContents.LongestNewNameWidth : 0.0f;

                previewRowStyle.ThirdColumnStyle = content.NameChangedThisStep ?
                                                   this.guiStyles.FinalNameLabelWhenModified :
                                                   this.guiStyles.FinalNameLabelUnModified;

                previewRowStyle.ThirdColumnWidth = showThirdColumn ? previewContents.LongestFinalNameWidth : 0.0f;

                previewRowStyle.BackgroundColor = i % 2 == 0 ? this.guiStyles.PreviewRowBackgroundEven : this.guiStyles.PreviewRowBackgroundOdd;

                var rowRect = new Rect(previewRowsRect);
                rowRect.height = PreviewRowHeight;
                rowRect.y      = previewRowsRect.y + (content.IndexInPreview * rowRect.height);
                if (DrawPreviewRow(rowRect, content, previewRowStyle))
                {
                    if (this.ObjectRemovedAtIndex != null)
                    {
                        this.ObjectRemovedAtIndex.Invoke(i);
                    }

                    break;
                }
            }
        }
        private void DrawPreviewRows(int stepIndex, PreviewPanelContents previewContents, bool showSecondColumn, bool showThirdColumn)
        {
            for (int i = 0; i < previewContents.NumRows; ++i)
            {
                var content         = previewContents[i];
                var previewRowStyle = new PreviewRowStyle();
                previewRowStyle.IconStyle = this.guiStyles.Icon;

                previewRowStyle.FirstColumnStyle = content.NamesAreDifferent ?
                                                   this.guiStyles.OriginalNameLabelWhenModified :
                                                   this.guiStyles.OriginalNameLabelUnModified;
                previewRowStyle.FirstColumnWidth = previewContents.LongestOriginalNameWidth;

                previewRowStyle.SecondColumnStyle = content.NamesAreDifferent ?
                                                    this.guiStyles.NewNameLabelModified :
                                                    this.guiStyles.NewNameLabelUnModified;

                previewRowStyle.SecondColumnWidth = showSecondColumn ? previewContents.LongestNewNameWidth : 0.0f;

                previewRowStyle.ThirdColumnStyle = content.NamesAreDifferent ?
                                                   this.guiStyles.FinalNameLabelWhenModified :
                                                   this.guiStyles.FinalNameLabelUnModified;

                previewRowStyle.ThirdColumnWidth = showThirdColumn ? previewContents.LongestFinalNameWidth : 0.0f;

                previewRowStyle.BackgroundColor = i % 2 == 0 ? this.guiStyles.PreviewRowBackgroundEven : this.guiStyles.PreviewRowBackgroundOdd;

                previewRowStyle.InsertionColor = this.guiStyles.InsertionTextColor;
                previewRowStyle.DeletionColor  = this.guiStyles.DeletionTextColor;

                if (DrawPreviewRow(stepIndex, content, previewRowStyle))
                {
                    this.ObjectsToRename.Remove(this.ObjectsToRename[i]);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        private static bool DrawPreviewRow(Rect rowRect, PreviewRowModel info, PreviewRowStyle style)
        {
            bool isDeleteClicked = false;

            var oldColor = GUI.color;

            GUI.color = style.BackgroundColor;
            GUI.DrawTexture(rowRect, Texture2D.whiteTexture);
            GUI.color = oldColor;

            // Space gives us a bit of padding or else we're just too bunched up to the side
            var deleteButtonRect = new Rect(rowRect);

            deleteButtonRect.x     += 4.0f;
            deleteButtonRect.width  = 16.0f;
            deleteButtonRect.height = 16.0f;
            deleteButtonRect.y     += Mathf.Max(0, (rowRect.height - deleteButtonRect.height) / 2.0f);
            if (GUI.Button(deleteButtonRect, "x", EditorStyles.miniButton))
            {
                isDeleteClicked = true;
            }

            var warningRect = new Rect(deleteButtonRect);

            warningRect.y      = rowRect.y;
            warningRect.x     += deleteButtonRect.width;
            warningRect.width  = 16.0f;
            warningRect.height = 16.0f;
            if (info.WarningIcon != null)
            {
                var content = new GUIContent(info.WarningIcon, info.WarningMessage);
                GUI.Box(warningRect, content, style.IconStyle);
            }

            var iconRect = new Rect(warningRect);

            iconRect.x     += warningRect.width;
            iconRect.width  = 16.0f;
            iconRect.height = 16.0f;
            GUI.Box(iconRect, info.Icon, style.IconStyle);

            var firstColumnRect = new Rect(iconRect);

            firstColumnRect.x     += iconRect.width;
            firstColumnRect.width  = style.FirstColumnWidth;
            firstColumnRect.height = rowRect.height;
            if (style.FirstColumnWidth > 0)
            {
                EditorGUI.LabelField(firstColumnRect, info.NameBeforeStep, style.FirstColumnStyle);
            }

            var secondColumnRect = new Rect(firstColumnRect);

            secondColumnRect.x     += firstColumnRect.width;
            secondColumnRect.width  = style.SecondColumnWidth;
            secondColumnRect.height = rowRect.height;
            if (style.SecondColumnWidth > 0)
            {
                EditorGUI.LabelField(secondColumnRect, info.NameAtStep, style.SecondColumnStyle);
            }

            var thirdColumnRect = new Rect(secondColumnRect);

            thirdColumnRect.x     += secondColumnRect.width;
            thirdColumnRect.width  = style.ThirdColumnWidth;
            thirdColumnRect.height = rowRect.height;
            if (style.ThirdColumnWidth > 0)
            {
                EditorGUI.LabelField(thirdColumnRect, info.FinalName, style.ThirdColumnStyle);
            }

            return(isDeleteClicked);
        }
        private static bool DrawPreviewRow(int previewStepIndex, PreviewRowModel info, PreviewRowStyle style)
        {
            bool isDeleteClicked = false;

            var horizontalRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(18.0f));

            var oldColor = GUI.color;

            GUI.color = style.BackgroundColor;
            GUI.DrawTexture(horizontalRect, Texture2D.whiteTexture);
            GUI.color = oldColor;

            // Space gives us a bit of padding or else we're just too bunched up to the side
            GUILayout.Space(4.0f);

            if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(16.0f)))
            {
                isDeleteClicked = true;
            }

            GUILayout.Box(info.Icon, style.IconStyle, GUILayout.Width(16.0f), GUILayout.Height(16.0f));

            if (style.FirstColumnWidth > 0)
            {
                var originalName = previewStepIndex >= 0 && previewStepIndex < info.RenameResultSequence.NumSteps ?
                                   info.RenameResultSequence.GetOriginalNameAtStep(previewStepIndex, style.DeletionColor) :
                                   info.RenameResultSequence.OriginalName;
                EditorGUILayout.LabelField(originalName, style.FirstColumnStyle, GUILayout.Width(style.FirstColumnWidth));
            }

            if (style.SecondColumnWidth > 0)
            {
                var newName = previewStepIndex >= 0 && previewStepIndex < info.RenameResultSequence.NumSteps ?
                              info.RenameResultSequence.GetNewNameAtStep(previewStepIndex, style.InsertionColor) :
                              info.RenameResultSequence.NewName;
                EditorGUILayout.LabelField(newName, style.SecondColumnStyle, GUILayout.Width(style.SecondColumnWidth));
            }

            if (style.ThirdColumnWidth > 0)
            {
                EditorGUILayout.LabelField(info.RenameResultSequence.NewName, style.ThirdColumnStyle, GUILayout.Width(style.ThirdColumnWidth));
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();

            return(isDeleteClicked);
        }