示例#1
0
            protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
            {
                var comment = _comment.GetCurrentValue(obj, context);

                fiLateBindings.EditorGUI.HelpBox(rect, comment, _commentType);
                return(obj);
            }
        private fiGraphMetadata(fiGraphMetadata parentMetadata, string accessKey)
        {
            _childrenInt    = new CullableDictionary <int, fiGraphMetadata, IntDictionary <fiGraphMetadata> >();
            _childrenString = new CullableDictionary <string, fiGraphMetadata, Dictionary <string, fiGraphMetadata> >();
            _metadata       = new CullableDictionary <Type, object, Dictionary <Type, object> >();
            _parentMetadata = parentMetadata;

            if (_parentMetadata == null)
            {
                _precomputedData = new Dictionary <string, List <object> >();
            }
            else
            {
                _precomputedData = _parentMetadata._precomputedData;
            }

            RebuildAccessPath(accessKey);

            if (_precomputedData.ContainsKey(_accessPath))
            {
                foreach (var data in _precomputedData[_accessPath])
                {
                    _metadata[data.GetType()] = data;
                }
            }
        }
示例#3
0
            protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
            {
                DoLayout(rect, obj, context, metadata);

                for (int i = 0; i < _items.Count; ++i)
                {
                    var item = _items[i];
                    if (item.Rule.ShouldShow(obj, context, metadata) == false)
                    {
                        continue;
                    }

                    float width = item.Layout_Width;

                    Rect itemRect = rect;
                    itemRect.width = width;

                    // If we're not matching the parent height then manually trim the rects height
                    // so the layout gets a rect equal to the height it requests.
                    if (item.MatchParentHeight == false)
                    {
                        itemRect.height = item.Rule.GetHeight(obj, context, metadata);
                    }

                    obj = item.Rule.Edit(itemRect, obj, context, metadata);

                    rect.x += width;
                }

                return(obj);
            }
示例#4
0
 protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
 {
     _data.Push(obj);
     obj = _control.Edit(rect, obj, context, metadata);
     _data.Pop();
     return(obj);
 }
        /// <summary>
        /// Helper method that automates metadata migration for array based graph reorders.
        /// </summary>
        public static void MigrateMetadata <T>(fiGraphMetadata metadata, T[] previous, T[] updated)
        {
            var migrations = ComputeNeededMigrations(metadata, previous, updated);

            // migrate persistent data
            var fromKeys = new string[migrations.Count];
            var toKeys   = new string[migrations.Count];

            for (int i = 0; i < migrations.Count; ++i)
            {
                fromKeys[i] = metadata.Enter(migrations[i].OldIndex).Metadata._accessPath;
                toKeys[i]   = metadata.Enter(migrations[i].NewIndex).Metadata._accessPath;
            }
            // fiPersistentMetadata.Migrate(metadata.TargetObject, fromKeys, toKeys);

            // migrate the graph items
            List <fiGraphMetadata> copiedGraphs = new List <fiGraphMetadata>(migrations.Count);

            for (int i = 0; i < migrations.Count; ++i)
            {
                copiedGraphs.Add(metadata._childrenInt[i]);
            }

            for (int i = 0; i < migrations.Count; ++i)
            {
                metadata._childrenInt[migrations[i].NewIndex] = copiedGraphs[i];
            }
        }
示例#6
0
            protected override float DoGetHeight(T obj, TContext context, fiGraphMetadata metadata)
            {
                var top    = _top.GetCurrentValue(obj, context);
                var bottom = _bottom.GetCurrentValue(obj, context);

                return(_control.GetHeight(obj, context, metadata) + top + bottom);
            }
示例#7
0
            protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
            {
                if (_errorMessage != null)
                {
                    fiLateBindings.EditorGUI.HelpBox(rect, _errorMessage, CommentType.Error);
                    return(obj);
                }


                fiLateBindings.EditorGUI.BeginChangeCheck();

                fiLateBindings.EditorGUI.BeginDisabledGroup(_setValue == null);

                var val           = _getValue(obj, context);
                var childMetadata = new fiGraphMetadataChild {
                    Metadata = GetInstanceMetadata(metadata)
                };
                var label   = _label;
                var updated = fiLateBindings.PropertyEditor.Edit(_fieldType, _attributes, rect, label, val, childMetadata);

                fiLateBindings.EditorGUI.EndDisabledGroup();

                if (fiLateBindings.EditorGUI.EndChangeCheck())
                {
                    if (_setValue != null)
                    {
                        _setValue(obj, context, updated);
                    }
                }

                return(obj);
            }
示例#8
0
 protected override float DoGetHeight(T obj, TContext context, fiGraphMetadata metadata)
 {
     return(fiLateBindings.PropertyEditor.GetElementHeightSkipUntilNot(new[] {
         type_fitkControlPropertyEditor, type_IObjectPropertyEditor
     }, typeof(T), typeof(T).Resolve(), GUIContent.none, obj, new fiGraphMetadataChild {
         Metadata = metadata
     }));
 }
示例#9
0
 protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
 {
     return((T)fiLateBindings.PropertyEditor.EditSkipUntilNot(new [] {
         type_fitkControlPropertyEditor, type_IObjectPropertyEditor
     }, typeof(T), typeof(T).Resolve(), rect, GUIContent.none, obj, new fiGraphMetadataChild {
         Metadata = metadata
     }));
 }
示例#10
0
            protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
            {
                fiLateBindings.fiEditorGUI.PushHierarchyMode(false);
                var result = _childControl.Edit(rect, obj, context, metadata);

                fiLateBindings.fiEditorGUI.PopHierarchyMode();
                return(result);
            }
示例#11
0
            protected override float DoGetHeight(T obj, TContext context, fiGraphMetadata metadata)
            {
                _data.Push(obj);
                var height = _control.GetHeight(obj, context, metadata);

                _data.Pop();
                return(height);
            }
示例#12
0
            protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
            {
                var indent = _indent.GetCurrentValue(obj, context);

                rect.x     += indent;
                rect.width -= indent;
                return(_control.Edit(rect, obj, context, metadata));
            }
            protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
            {
                float padding = rect.height - _centered.GetHeight(obj, context, metadata);

                rect.y      += padding / 2;
                rect.height -= padding;

                return(_centered.Edit(rect, obj, context, metadata));
            }
示例#14
0
 protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
 {
     fiLateBindings.EditorGUI.BeginDisabledGroup(!_enabled);
     if (GUI.Button(rect, _label.GetCurrentValue(obj, context)))
     {
         _onClick(obj, context);
     }
     fiLateBindings.EditorGUI.EndDisabledGroup();
     return(obj);
 }
示例#15
0
        private tkControlEditor GetControlEditor(T element, fiGraphMetadata graphMetadata)
        {
            tkControlPropertyEditor.fiLayoutPropertyEditorMetadata metadata;
            if (graphMetadata.TryGetMetadata(out metadata) == false)
            {
                metadata        = graphMetadata.GetMetadata <tkControlPropertyEditor.fiLayoutPropertyEditorMetadata>();
                metadata.Layout = GetEditor(element);
            }

            return(metadata.Layout);
        }
示例#16
0
            private tkFoldoutMetadata GetMetadata(fiGraphMetadata metadata)
            {
                bool wasCreated;
                var  foldout = GetInstanceMetadata(metadata).GetPersistentMetadata <tkFoldoutMetadata>(out wasCreated);

                if (wasCreated)
                {
                    foldout.IsExpanded = _defaultToExpanded;
                }

                return(foldout);
            }
示例#17
0
            protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata) {
                var value = _getValue(obj, context);
                var min = _min.GetCurrentValue(obj, context);
                var max = _max.GetCurrentValue(obj, context);

                fiLateBindings.EditorGUI.BeginChangeCheck();
                value = fiLateBindings.EditorGUI.Slider(rect, _label.GetCurrentValue(obj, context), value, min, max);
                if (fiLateBindings.EditorGUI.EndChangeCheck()) {
                    _setValue(obj, context, value);
                }

                return obj;
            }
示例#18
0
            protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
            {
                var left   = _left.GetCurrentValue(obj, context);
                var right  = _right.GetCurrentValue(obj, context);
                var top    = _top.GetCurrentValue(obj, context);
                var bottom = _bottom.GetCurrentValue(obj, context);

                rect.x      += left;
                rect.width  -= left + right;
                rect.y      += top;
                rect.height -= top + bottom;
                return(_control.Edit(rect, obj, context, metadata));
            }
示例#19
0
            protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
            {
                var guiContent = GUIContent.GetCurrentValue(obj, context);

                Rect labelRect        = rect;
                Rect controlRect      = rect;
                bool pushedLabelWidth = false;

                if (_control != null && guiContent.IsEmpty == false)
                {
                    labelRect.height = fiLateBindings.EditorGUIUtility.singleLineHeight;

                    if (InlineControl)
                    {
                        labelRect.width    = fiGUI.PushLabelWidth(guiContent, labelRect.width);
                        pushedLabelWidth   = true;
                        controlRect.x     += labelRect.width;
                        controlRect.width -= labelRect.width;
                    }
                    else
                    {
                        var deltaY = labelRect.height + fiLateBindings.EditorGUIUtility.standardVerticalSpacing;
                        controlRect.x      += fiRectUtility.IndentHorizontal;
                        controlRect.width  -= fiRectUtility.IndentHorizontal;
                        controlRect.y      += deltaY;
                        controlRect.height -= deltaY;
                    }
                }

                if (guiContent.IsEmpty == false)
                {
                    var style          = fiLateBindings.EditorStyles.label;
                    var savedFontStyle = style.fontStyle;
                    style.fontStyle = _fontStyle;
                    GUI.Label(labelRect, guiContent, style);
                    style.fontStyle = savedFontStyle;
                }

                if (_control != null)
                {
                    _control.Edit(controlRect, obj, context, metadata);
                }

                if (pushedLabelWidth)
                {
                    fiGUI.PopLabelWidth();
                }

                return(obj);
            }
        /// <summary>
        /// Get a child metadata instance for the given identifier. This is useful for general
        /// classes and structs where an object has a set of discrete named fields or properties.
        /// </summary>
        public fiGraphMetadataChild Enter(string childIdentifier)
        {
            fiGraphMetadata metadata;

            if (_childrenString.TryGetValue(childIdentifier, out metadata) == false)
            {
                metadata = new fiGraphMetadata(this, childIdentifier);
                _childrenString[childIdentifier] = metadata;
            }

            return(new fiGraphMetadataChild {
                Metadata = metadata
            });
        }
示例#21
0
            protected override T DoEdit(Rect rect, T obj, TContext context, fiGraphMetadata metadata)
            {
                var label    = _label.GetCurrentValue(obj, context);
                int selected = _currentSelection.GetCurrentValue(obj, context);
                var options  = _options.GetCurrentValue(obj, context);
                int updated  = fiLateBindings.EditorGUI.Popup(rect, label.AsGUIContent, selected, options);

                if (selected != updated)
                {
                    obj = _onSelectionChanged(obj, context, updated);
                }

                return(obj);
            }
示例#22
0
            protected override float DoGetHeight(T obj, TContext context, fiGraphMetadata metadata)
            {
                var foldout = GetMetadata(metadata);

                float height = fiLateBindings.EditorGUIUtility.singleLineHeight;

                if (foldout.IsExpanded)
                {
                    height += fiLateBindings.EditorGUIUtility.standardVerticalSpacing;
                    height += _control.GetHeight(obj, context, metadata);
                }

                return(height);
            }
示例#23
0
        public override float GetElementHeight(GUIContent label, Facade <T> element, fiGraphMetadata metadata)
        {
            float height = 0;

            if (string.IsNullOrEmpty(label.text) == false || TypeOptions.Types.Length > 1)
            {
                height = LabelHeight;
            }

            var anim = metadata.GetMetadata <fiAnimationMetadata>();

            if (anim.IsAnimating)
            {
                return(height + anim.AnimationHeight);
            }

            if (element == null)
            {
                element = new Facade <T>();
            }


            if (element.InstanceType == null)
            {
                element.InstanceType = TypeOptions.Types[0];
            }

            InspectedType inspectedType = InspectedType.Get(element.InstanceType);

            var serializer        = (BaseSerializer)fiSingletons.Get(fiInstalledSerializerManager.DefaultMetadata.SerializerType);
            var deserializationOp = new ListSerializationOperator()
            {
                SerializedObjects = element.ObjectReferences
            };

            var properties = inspectedType.GetProperties(InspectedMemberFilters.InspectableMembers);

            for (int i = 0; i < properties.Count; ++i)
            {
                InspectedProperty property = properties[i];

                object propertyValue = DeserializeProperty(serializer, deserializationOp, property, element);

                height += fiEditorGUI.EditPropertyHeightDirect(property, propertyValue, metadata.Enter(property.Name));
                height += SplitterHeight;
            }

            return(height);
        }
示例#24
0
        /// <summary>
        /// Get a child metadata instance for the given identifier. This is
        /// useful for collections where each item maps to a unique index.
        /// </summary>
        public fiGraphMetadataChild Enter(int childIdentifier, object context)
        {
            fiGraphMetadata metadata;

            if (_childrenInt.TryGetValue(childIdentifier, out metadata) == false)
            {
                metadata = new fiGraphMetadata(this, childIdentifier.ToString());
                _childrenInt[childIdentifier] = metadata;
            }
            metadata.Context = context;

            return(new fiGraphMetadataChild {
                Metadata = metadata
            });
        }
示例#25
0
            protected override float DoGetHeight(T obj, TContext context, fiGraphMetadata metadata)
            {
                if (_errorMessage != null)
                {
                    return(fiCommentUtility.GetCommentHeight(_errorMessage, CommentType.Error));
                }

                var val           = _getValue(obj, context);
                var childMetadata = new fiGraphMetadataChild {
                    Metadata = GetInstanceMetadata(metadata)
                };
                var label = _label;

                return(fiLateBindings.PropertyEditor.GetElementHeight(_fieldType, _attributes, label, val, childMetadata));
            }
示例#26
0
            protected override float DoGetHeight(T obj, TContext context, fiGraphMetadata metadata)
            {
                float height = 0;

                for (int i = 0; i < _items.Count; ++i)
                {
                    var item = _items[i];
                    if (item.Rule.ShouldShow(obj, context, metadata) == false)
                    {
                        continue;
                    }

                    height = Math.Max(height, item.Rule.GetHeight(obj, context, metadata));
                }

                return(height);
            }
        protected override void OnEdit(Rect rect, UnityObject behavior, fiGraphMetadata metadata)
        {
            fiGraphMetadataChild childMetadata = metadata.Enter("DefaultBehaviorEditor");

            childMetadata.Metadata.GetPersistentMetadata <fiDropdownMetadata>().ForceDisable();

            // We don't want to get the IObjectPropertyEditor for the given target, which extends
            // UnityObject, so that we can actually edit the property instead of getting a Unity
            // reference field. We also don't want the AbstractTypePropertyEditor, which we will get
            // if the behavior has any derived types.
            PropertyEditorChain editorChain = PropertyEditor.Get(behavior.GetType(), null);
            IPropertyEditor     editor      = editorChain.SkipUntilNot(
                typeof(IObjectPropertyEditor),
                typeof(AbstractTypePropertyEditor));

            // Run the editor
            editor.Edit(rect, GUIContent.none, behavior, childMetadata);
        }
示例#28
0
        public static fiGraphMetadata GetMetadataFor(fiUnityObjectReference target)
        {
            fiGraphMetadata metadata;

            if (s_metadata.TryGetValue(target, out metadata) == false)
            {
                // Make sure that we update the s_metadata instance for target before initializing all of the providers,
                // as some of the providers may recurisvely call into this method to fetch the actual fiGraphMetadata
                // instance during initialization.
                metadata           = new fiGraphMetadata(target);
                s_metadata[target] = metadata;
                for (int i = 0; i < s_providers.Length; ++i)
                {
                    s_providers[i].RestoreData(target);
                }
            }
            return(metadata);
        }
        /// <summary>
        /// Helper method that automates metadata migration for array based graph reorders.
        /// </summary>
        private static List <MetadataMigration> ComputeNeededMigrations <T>(fiGraphMetadata metadata, T[] previous, T[] updated)
        {
            var migrations = new List <MetadataMigration>();

            for (int newIndex = 0; newIndex < updated.Length; ++newIndex)
            {
                int prevIndex = Array.IndexOf(previous, updated[newIndex]);

                if (prevIndex != -1 && prevIndex != newIndex)
                {
                    migrations.Add(new MetadataMigration {
                        NewIndex = newIndex,
                        OldIndex = prevIndex
                    });
                }
            }

            return(migrations);
        }
示例#30
0
            protected override float DoGetHeight(T obj, TContext context, fiGraphMetadata metadata)
            {
                float height = 0;

                if (GUIContent.GetCurrentValue(obj, context).IsEmpty == false)
                {
                    height += fiLateBindings.EditorGUIUtility.singleLineHeight;
                }

                if (_control != null)
                {
                    var controlHeight = _control.GetHeight(obj, context, metadata);
                    if (InlineControl == false)
                    {
                        height += fiLateBindings.EditorGUIUtility.standardVerticalSpacing + controlHeight;
                    }
                }

                return(height);
            }