protected virtual bool DrawFoldout(string foldoutLabel, string key, string editableLabel, string editFieldKey, DoRenameDelgate doRename)
    {
        bool currentFoldoutState = entryFoldoutState.Contains(key);

        GUIContent content         = new GUIContent(foldoutLabel);
        float      width           = foldoutStyle.CalcSize(content).x;
        bool       newFoldoutState = EditorGUI.Foldout(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), currentFoldoutState,
                                                       foldoutLabel.HighlightSubstring(filterText, highlightColor), true, foldoutStyle);

        currentLinePosition += (width + 2);

        DrawEditableLabel(editableLabel, editFieldKey, doRename);

        SetFoldout(newFoldoutState, key);

        NewLine();

        return(newFoldoutState);
    }
    protected virtual void DrawEditableLabel(string editableLabel, string editFieldKey, DoRenameDelgate doRename, Dictionary <string, object> data)
    {
        float width;

        if (!editingFields.Contains(editFieldKey))
        {
            width = 120;
            if (GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), editableLabel.HighlightSubstring(filterText, highlightColor), labelStyle))
            {
                if (EditorApplication.timeSinceStartup - lastClickTime < GDEConstants.DoubleClickTime && lastClickedKey.Equals(editFieldKey))
                {
                    lastClickedKey = "";
                    editingFields.Add(editFieldKey);
                }
                else
                {
                    lastClickedKey = editFieldKey;
                    editingFields.Remove(editFieldKey);
                }

                lastClickTime = EditorApplication.timeSinceStartup;
            }
            currentLinePosition += (width + 2);
        }
        else
        {
            string editFieldText;
            if (!editFieldTextDict.TryGetValue(editFieldKey, out editFieldText))
            {
                editFieldText = editableLabel;
            }

            string newValue = DrawResizableTextBox(editFieldText);
            editFieldTextDict.TryAddOrUpdateValue(editFieldKey, newValue);

            if (!newValue.Equals(editableLabel))
            {
                GUIContent content = new GUIContent(GDEStrings.RenameBtn);
                width = GUI.skin.button.CalcSize(content).x;
                if (GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content) && doRename != null)
                {
                    string error;
                    if (doRename(editableLabel, newValue, data, out error))
                    {
                        editingFields.Remove(editFieldKey);
                        editFieldTextDict.Remove(editFieldKey);
                        GUI.FocusControl("");
                    }
                    else
                    {
                        EditorUtility.DisplayDialog(GDEStrings.ErrorLbl, string.Format("Couldn't rename {0} to {1}: {2}", editableLabel, newValue, error), GDEStrings.OkLbl);
                    }
                }
                currentLinePosition += (width + 2);

                content.text = GDEStrings.CancelBtn;
                width        = GUI.skin.button.CalcSize(content).x;
                if (GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content))
                {
                    editingFields.Remove(editFieldKey);
                    editFieldTextDict.Remove(editFieldKey);
                    GUI.FocusControl("");
                }
                currentLinePosition += (width + 2);
            }
            else
            {
                GUIContent content = new GUIContent(GDEStrings.CancelBtn);
                width = GUI.skin.button.CalcSize(content).x;
                if (GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content))
                {
                    editingFields.Remove(editFieldKey);
                    editFieldTextDict.Remove(editFieldKey);
                    GUI.FocusControl("");
                }
                currentLinePosition += (width + 2);
            }
        }
    }
 protected virtual void DrawEditableLabel(string editableLabel, string editFieldKey, DoRenameDelgate doRename)
 {
     DrawEditableLabel(editableLabel, editFieldKey, doRename, null);
 }
    protected virtual bool DrawFoldout(string foldoutLabel, string key, string editableLabel, string editFieldKey, DoRenameDelgate doRename)
    {
        bool currentFoldoutState = entryFoldoutState.Contains(key);

        GUIContent content = new GUIContent(foldoutLabel);
        float width = foldoutStyle.CalcSize(content).x;
        bool newFoldoutState = EditorGUI.Foldout(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), currentFoldoutState,
                                                 foldoutLabel.HighlightSubstring(filterText, highlightColor), true, foldoutStyle);
        currentLinePosition += (width + 2);

        DrawEditableLabel(editableLabel, editFieldKey, doRename);

        SetFoldout(newFoldoutState, key);

        NewLine();

        return newFoldoutState;
    }
    protected virtual void DrawEditableLabel(string editableLabel, string editFieldKey, DoRenameDelgate doRename, Dictionary<string, object> data)
    {
        float width;

        if (!editingFields.Contains(editFieldKey))
        {
            width = 120;
            if (GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), editableLabel.HighlightSubstring(filterText, highlightColor), labelStyle))
            {
                if (EditorApplication.timeSinceStartup - lastClickTime < GDEConstants.DoubleClickTime && lastClickedKey.Equals(editFieldKey))
                {
                    lastClickedKey = "";
                    editingFields.Add(editFieldKey);
                }
                else
                {
                    lastClickedKey = editFieldKey;
                    editingFields.Remove(editFieldKey);
                }

                lastClickTime = EditorApplication.timeSinceStartup;
            }
            currentLinePosition += (width + 2);
        }
        else
        {
            string editFieldText;
            if (!editFieldTextDict.TryGetValue(editFieldKey, out editFieldText))
                editFieldText = editableLabel;

            string newValue = DrawResizableTextBox(editFieldText);
            editFieldTextDict.TryAddOrUpdateValue(editFieldKey, newValue);

            if (!newValue.Equals(editableLabel))
            {
                GUIContent content = new GUIContent(GDEStrings.RenameBtn);
                width = GUI.skin.button.CalcSize(content).x;
                if (GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content) && doRename != null)
                {
                    string error;
                    if (doRename(editableLabel, newValue, data, out error))
                    {
                        editingFields.Remove(editFieldKey);
                        editFieldTextDict.Remove(editFieldKey);
                        GUI.FocusControl("");
                    }
                    else
                        EditorUtility.DisplayDialog(GDEStrings.ErrorLbl, string.Format("Couldn't rename {0} to {1}: {2}", editableLabel, newValue, error), GDEStrings.OkLbl);
                }
                currentLinePosition += (width + 2);

                content.text = GDEStrings.CancelBtn;
                width = GUI.skin.button.CalcSize(content).x;
                if (GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content))
                {
                    editingFields.Remove(editFieldKey);
                    editFieldTextDict.Remove(editFieldKey);
                    GUI.FocusControl("");
                }
                currentLinePosition += (width + 2);
            }
            else
            {
                GUIContent content = new GUIContent(GDEStrings.CancelBtn);
                width = GUI.skin.button.CalcSize(content).x;
                if (GUI.Button(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), content))
                {
                    editingFields.Remove(editFieldKey);
                    editFieldTextDict.Remove(editFieldKey);
                    GUI.FocusControl("");
                }
                currentLinePosition += (width + 2);
            }
        }
    }
 protected virtual void DrawEditableLabel(string editableLabel, string editFieldKey, DoRenameDelgate doRename)
 {
     DrawEditableLabel(editableLabel, editFieldKey, doRename, null);
 }