Exemplo n.º 1
0
    public override void UpdateHeaderContents(DirectorControlState state, Rect position, Rect headerBackground)
    {
        Rect   rect  = new Rect(position.x + 14f, position.y, 14f, position.height);
        Rect   rect2 = new Rect(rect.x + rect.width, position.y, position.width - 14f - 96f - 14f, 17f);
        string text  = base.TargetTrack.Behaviour.name;
        bool   flag  = EditorGUI.Foldout(rect, isExpanded, GUIContent.none, false);

        if (flag != this.isExpanded)
        {
            this.isExpanded = flag;
            EditorPrefs.SetBool(base.IsExpandedKey, this.isExpanded);
        }
        updateHeaderControl1(new Rect(position.width - 64f, position.y, 16f, 16f));
        this.updateHeaderControl2(new Rect(position.width - 48f, position.y, 16f, 16f));
        this.updateHeaderControl3(new Rect(position.width - 32f, position.y, 16f, 16f));
        this.updateHeaderControl4(new Rect(position.width - 16f, position.y, 16f, 16f));
        if (isExpanded)
        {
            Rect row = new Rect(rect2.x + 28f, position.y + 17f, headerBackground.width - rect2.x - 28f, 17f);
            if (focusedControl != null && focusedControl.Wrapper != null && focusedControl.Wrapper.Behaviour != null)
            {
                new Rect(row.x, row.y, row.width / 2f, row.height);
                Rect arg_26D_0         = new Rect(row.x + row.width / 2f, row.y, row.width / 2f, row.height);
                Rect controlHeaderArea = new Rect(row.x, row.y + row.height, row.width, position.height - 34f);
                focusedControl.UpdateHeaderArea(state, controlHeaderArea);
                if (GUI.Button(arg_26D_0, new GUIContent("Done")))
                {
                    focusedControl = null;
                    editItemControl(-1);
                    MINIMUM_ROWS_SHOWING = 3;
                    rowsShowing          = 5;
                }
            }
            else
            {
                updateEditPanel(row);
            }
        }
        if (isRenaming)
        {
            GUI.SetNextControlName("CurveTrackRename");
            text = EditorGUI.TextField(rect2, GUIContent.none, text);
            if (renameRequested)
            {
                EditorGUI.FocusTextInControl("CurveTrackRename");
                renameRequested = false;
            }
            if ((int)Event.current.keyCode == 13 || (Event.current.type == EventType.MouseDown && !rect2.Contains(Event.current.mousePosition)))
            {
                isRenaming                 = false;
                GUIUtility.hotControl      = (0);
                GUIUtility.keyboardControl = (0);
            }
        }
        if (base.TargetTrack.Behaviour.name != text)
        {
            Undo.RecordObject(base.TargetTrack.Behaviour.gameObject, string.Format("Renamed {0}", base.TargetTrack.Behaviour.name));
            base.TargetTrack.Behaviour.name = (text);
        }
        if (!this.isRenaming)
        {
            string  text2  = text;
            Vector2 vector = GUI.skin.label.CalcSize(new GUIContent(text2));
            while (vector.x > rect2.width && text2.Length > 5)
            {
                text2  = text2.Substring(0, text2.Length - 4) + "...";
                vector = GUI.skin.label.CalcSize(new GUIContent(text2));
            }
            if (Selection.Contains(base.TargetTrack.Behaviour.gameObject))
            {
                GUI.Label(rect2, text2, EditorStyles.whiteLabel);
            }
            else
            {
                GUI.Label(rect2, text2);
            }
            int controlID = GUIUtility.GetControlID(base.TargetTrack.Behaviour.GetInstanceID(), (FocusType)2, position);
            if (Event.current.GetTypeForControl(controlID) == EventType.MouseDown)
            {
                if (position.Contains(Event.current.mousePosition) && (int)Event.current.button == 1)
                {
                    if (!base.IsSelected)
                    {
                        base.RequestSelect();
                    }
                    base.showHeaderContextMenu();
                    Event.current.Use();
                    return;
                }
                if (position.Contains(Event.current.mousePosition) && (int)Event.current.button == 0)
                {
                    base.RequestSelect();
                    Event.current.Use();
                }
            }
        }
    }