Exemplo n.º 1
0
        /// <summary> Creates a new instance of the drawer or returns a reusable instance from the pool. </summary>
        /// <param name="value"> The starting cached value of the drawer. </param>
        /// <param name="memberInfo"> LinkedMemberInfo for the field, property or parameter that the drawer represents. Can be null. </param>
        /// <param name="parent"> The parent drawer of the created drawer. Can be null. </param>
        /// <param name="label"> The prefix label. </param>
        /// <param name="readOnly"> True if control should be read only. </param>
        /// <param name="textArea"> True if text field has the TextArea attribute and should be shown in expanded mode. </param>
        /// <returns> The instance, ready to be used. </returns>
        public static TextDrawer Create(string value, [CanBeNull] LinkedMemberInfo memberInfo, [CanBeNull] IParentDrawer parent, [CanBeNull] GUIContent label, bool readOnly = false, bool textArea = false, bool setDelayed = false)
        {
            TextDrawer result;

            if (!DrawerPool.TryGet(out result))
            {
                result = new TextDrawer();
            }
            result.Setup(value, memberInfo, parent, label, readOnly, textArea, setDelayed);
            result.LateSetup();
            return(result);
        }
Exemplo n.º 2
0
        protected override void DoBuildMembers()
        {
            Array.Resize(ref members, 26);

            var first = Value;

            bool readOnly = ReadOnly;

            //NOTE: This didn't have a LinkedMemberInfo earlier for some reason. Did it cause problems?
            members[0] = TextDrawer.Create(first.name, memberBuildList[0], this, GUIContentPool.Create("Name"), readOnly, false);

            members[1] = GUIStyleStateDrawer.Create(first.normal, memberBuildList[1], this, GUIContentPool.Create("Normal"), readOnly);
            members[2] = GUIStyleStateDrawer.Create(first.hover, memberBuildList[2], this, GUIContentPool.Create("Hover"), readOnly);
            members[3] = GUIStyleStateDrawer.Create(first.active, memberBuildList[3], this, GUIContentPool.Create("Active"), readOnly);
            members[4] = GUIStyleStateDrawer.Create(first.focused, memberBuildList[4], this, GUIContentPool.Create("Focused"), readOnly);

            members[5] = GUIStyleStateDrawer.Create(first.onNormal, memberBuildList[5], this, GUIContentPool.Create("On Normal"), readOnly);
            members[6] = GUIStyleStateDrawer.Create(first.onHover, memberBuildList[6], this, GUIContentPool.Create("On Hover"), readOnly);
            members[7] = GUIStyleStateDrawer.Create(first.onActive, memberBuildList[7], this, GUIContentPool.Create("On Active"), readOnly);
            members[8] = GUIStyleStateDrawer.Create(first.onFocused, memberBuildList[8], this, GUIContentPool.Create("On Focused"), readOnly);

            members[9]  = RectOffsetDrawer.Create(first.border, memberBuildList[9], this, GUIContentPool.Create("Border"), readOnly);
            members[10] = RectOffsetDrawer.Create(first.margin, memberBuildList[10], this, GUIContentPool.Create("Margin"), readOnly);
            members[11] = RectOffsetDrawer.Create(first.padding, memberBuildList[11], this, GUIContentPool.Create("Padding"), readOnly);
            members[12] = RectOffsetDrawer.Create(first.overflow, memberBuildList[12], this, GUIContentPool.Create("Overflow"), readOnly);

            members[13] = ObjectReferenceDrawer.Create(first.font, memberBuildList[13], this, GUIContentPool.Create("Font"), true, false, readOnly);
            members[14] = IntDrawer.Create(first.fontSize, memberBuildList[14], this, GUIContentPool.Create("Font Size"), readOnly);
            members[15] = EnumDrawer.Create(first.fontStyle, memberBuildList[15], this, GUIContentPool.Create("Font Style"), readOnly);

            members[16] = EnumDrawer.Create(first.alignment, memberBuildList[16], this, GUIContentPool.Create("Alignment"), readOnly);
            members[17] = ToggleDrawer.Create(first.wordWrap, memberBuildList[17], this, GUIContentPool.Create("Word Wrap"), readOnly);
            members[18] = ToggleDrawer.Create(first.richText, memberBuildList[18], this, GUIContentPool.Create("Rich Text"), readOnly);
            members[19] = EnumDrawer.Create(first.clipping, memberBuildList[19], this, GUIContentPool.Create("Text Clipping"), readOnly);

            members[20] = EnumDrawer.Create(first.imagePosition, memberBuildList[20], this, GUIContentPool.Create("Image Position"), readOnly);
            members[21] = Vector2Drawer.Create(first.contentOffset, memberBuildList[21], this, GUIContentPool.Create("Content Offset"), readOnly);
            members[22] = FloatDrawer.Create(first.fixedWidth, memberBuildList[22], this, GUIContentPool.Create("Fixed Width"), readOnly);
            members[23] = FloatDrawer.Create(first.fixedHeight, memberBuildList[23], this, GUIContentPool.Create("Fixed Height"), readOnly);
            members[24] = ToggleDrawer.Create(first.stretchWidth, memberBuildList[24], this, GUIContentPool.Create("Strech Width"), readOnly);
            members[25] = ToggleDrawer.Create(first.stretchHeight, memberBuildList[25], this, GUIContentPool.Create("Strech Height"), readOnly);

                        #if DEV_MODE
            Debug.Assert(memberBuildList.Count == members.Length);
                        #endif
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        protected override void DoBuildMembers()
        {
            if (DebugMode)
            {
                base.DoBuildMembers();
                return;
            }

                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(memberBuildList.Count == 3);
                        #endif

            var first = Value;
            Array.Resize(ref members, 3);
            var readOnly = ReadOnly;
            members[0] = TextDrawer.Create(first.text, memberBuildList[0], this, GUIContentPool.Create("Text"), readOnly, false);
            members[1] = ObjectReferenceDrawer.Create(first.image, memberBuildList[1], this, GUIContentPool.Create("Image"), false, false, readOnly);
            members[2] = TextDrawer.Create(first.tooltip, memberBuildList[2], this, GUIContentPool.Create("Tooltip"), readOnly, false);
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        protected override void DoBuildMembers()
        {
            DrawerArrayPool.Resize(ref members, 2);

            // Making key be read-only for now until code has been added to handle on-the-fly changing of keys gracefully.
            // E.g. all keys should use delayed text fields and be marked with NotNull (e.g. using a custom DrawerProvider).
            var keyInfo = memberBuildList[0];

            IDrawer keyMember;
            var     keyValue = keyInfo.GetValue(0);
            var     keyLabel = GUIContentPool.Create("K");
            //var keyIsReadOnly = ReadOnly;
            const bool keyIsReadOnly = true;

            if (keyType == Types.Int)
            {
                keyMember = DelayedIntDrawer.Create((int)keyValue, keyInfo, this, keyLabel, keyIsReadOnly);
            }
            else if (keyType == Types.String)
            {
                keyMember = TextDrawer.Create((string)keyValue, keyInfo, this, keyLabel, keyIsReadOnly, false, true);
            }
            else if (keyType == Types.Float)
            {
                keyMember = DelayedFloatDrawer.Create((float)keyValue, keyInfo, this, keyLabel, keyIsReadOnly);
            }
            else
            {
                keyMember = DrawerProvider.GetForField(keyValue, keyType, keyInfo, this, keyLabel, keyIsReadOnly);
            }

            keyMember.OverrideValidateValue = ValidateKey;

            members[0] = keyMember;
            var valueInfo   = memberBuildList[1];
            var valueMember = DrawerProvider.GetForField(valueInfo.GetValue(0), valueType, valueInfo, this, GUIContentPool.Create("V"), ReadOnly);

            members[1] = valueMember;
        }