public static float GetHeight(ValueDefinition definition, VariableInitializerType initializerType, TagList tags, bool isExpanded) { var height = EditorGUIUtility.singleLineHeight; if (HasConstraint(definition.Type, definition.Constraint, definition.IsConstraintLocked)) { height += GetConstraintHeight(definition.Type, definition.Constraint); } if (HasInitializer(definition.Type, initializerType)) { if (initializerType == VariableInitializerType.Expression && definition.Initializer != null) { height += ExpressionControl.GetFoldoutHeight(definition.Initializer, isExpanded, true, 2, 3) + RectHelper.VerticalSpace; } else { height += RectHelper.LineHeight; } } if (HasTags(tags)) { height += RectHelper.LineHeight; } return(height); }
public static ValueDefinition Draw(Rect position, GUIContent label, ValueDefinition definition, VariableInitializerType initializer, TagList tags, bool showConstraintLabel, ref bool isExpanded) { var tag = definition.Tag; var constraint = definition.Constraint; var hasInitializer = HasInitializer(definition.Type, initializer); var hasConstraint = HasConstraint(definition.Type, definition.Constraint, definition.IsConstraintLocked); var hasTag = HasTags(tags); var typeRect = RectHelper.TakeLine(ref position); if (label != GUIContent.none) { var labelRect = RectHelper.TakeWidth(ref typeRect, RectHelper.CurrentLabelWidth); EditorGUI.LabelField(labelRect, label); } var type = DrawType(typeRect, definition.IsTypeLocked, definition.Type); if (hasConstraint) { var constraintHeight = GetConstraintHeight(definition.Type, definition.Constraint); var constraintRect = RectHelper.TakeHeight(ref position, constraintHeight); DrawConstraint(constraintRect, type, definition.IsConstraintLocked, ref constraint, showConstraintLabel); } if (hasInitializer && definition.Initializer != null) { if (initializer == VariableInitializerType.Expression) { var initializerHeight = ExpressionControl.GetFoldoutHeight(definition.Initializer, isExpanded, true, 2, 3); var initializerRect = RectHelper.TakeHeight(ref position, initializerHeight); RectHelper.TakeVerticalSpace(ref position); DrawInitializer(initializerRect, ref definition, ref isExpanded); } else if (initializer == VariableInitializerType.DefaultValue) { var initializerRect = RectHelper.TakeLine(ref position); DrawDefaultValue(initializerRect, ref definition); } } if (hasTag) { var tagRect = RectHelper.TakeLine(ref position); tag = DrawTag(tagRect, tag, tags); } return(ValueDefinition.Create(type, constraint, tag, definition.Initializer, definition.IsTypeLocked, definition.IsConstraintLocked)); }
private void Draw(Rect rect, IList list, int index) { var command = _composition.CustomCommands[index]; var labelRect = RectHelper.TakeWidth(ref rect, _labelWidth); EditorGUI.LabelField(labelRect, command.Name); using (var changes = new EditorGUI.ChangeCheckScope()) { ExpressionControl.DrawFoldout(rect, command.Expression, GUIContent.none); if (changes.changed) { _composition.SetExpression(index, command.Expression); } } }
private static void DrawInitializer(Rect rect, ref ValueDefinition definition, ref bool isExpanded) { ExpressionControl.DrawFoldout(rect, definition.Initializer, _initializerLabel, ref isExpanded, true); }
private float GetCommandHeight(int index) { var command = _composition.CustomCommands[index]; return(ExpressionControl.GetHeight(command.Expression, true)); }