Example #1
0
        private static Rect DoGetRect(GUIContent content, GUIStyle style, GUILayoutOption[] options)
        {
            GUIUtility.CheckOnGUI();
            EventType type      = Event.current.type;
            EventType eventType = type;
            Rect      rect;

            if (eventType != EventType.Layout)
            {
                if (eventType != EventType.Used)
                {
                    GUILayoutEntry next = GUILayoutUtility.current.topLevel.GetNext();
                    GUIDebugger.LogLayoutEntry(next.rect, next.marginLeft, next.marginRight, next.marginTop, next.marginBottom, next.style);
                    rect = next.rect;
                }
                else
                {
                    rect = GUILayoutUtility.kDummyRect;
                }
            }
            else
            {
                bool isHeightDependantOnWidth = style.isHeightDependantOnWidth;
                if (isHeightDependantOnWidth)
                {
                    GUILayoutUtility.current.topLevel.Add(new GUIWordWrapSizer(style, content, options));
                }
                else
                {
                    Vector2 constraints = new Vector2(0f, 0f);
                    bool    flag        = options != null;
                    if (flag)
                    {
                        for (int i = 0; i < options.Length; i++)
                        {
                            GUILayoutOption      gUILayoutOption = options[i];
                            GUILayoutOption.Type type2           = gUILayoutOption.type;
                            GUILayoutOption.Type type3           = type2;
                            if (type3 != GUILayoutOption.Type.maxWidth)
                            {
                                if (type3 == GUILayoutOption.Type.maxHeight)
                                {
                                    constraints.y = (float)gUILayoutOption.value;
                                }
                            }
                            else
                            {
                                constraints.x = (float)gUILayoutOption.value;
                            }
                        }
                    }
                    Vector2 vector = style.CalcSizeWithConstraints(content, constraints);
                    vector.x = Mathf.Ceil(vector.x);
                    vector.y = Mathf.Ceil(vector.y);
                    GUILayoutUtility.current.topLevel.Add(new GUILayoutEntry(vector.x, vector.x, vector.y, vector.y, style, options));
                }
                rect = GUILayoutUtility.kDummyRect;
            }
            return(rect);
        }
Example #2
0
        private static Rect DoGetRect(GUIContent content, GUIStyle style, GUILayoutOption[] options)
        {
            GUIUtility.CheckOnGUI();
            EventType type = Event.current.type;
            Rect      rect;

            if (type != EventType.Layout)
            {
                if (type != EventType.Used)
                {
                    GUILayoutEntry next = GUILayoutUtility.current.topLevel.GetNext();
                    rect = next.rect;
                }
                else
                {
                    rect = GUILayoutUtility.kDummyRect;
                }
            }
            else
            {
                if (style.isHeightDependantOnWidth)
                {
                    GUILayoutUtility.current.topLevel.Add(new GUIWordWrapSizer(style, content, options));
                }
                else
                {
                    Vector2 constraints = new Vector2(0f, 0f);
                    if (options != null)
                    {
                        foreach (GUILayoutOption guilayoutOption in options)
                        {
                            GUILayoutOption.Type type2 = guilayoutOption.type;
                            if (type2 != GUILayoutOption.Type.maxHeight)
                            {
                                if (type2 == GUILayoutOption.Type.maxWidth)
                                {
                                    constraints.x = (float)guilayoutOption.value;
                                }
                            }
                            else
                            {
                                constraints.y = (float)guilayoutOption.value;
                            }
                        }
                    }
                    Vector2 vector = style.CalcSizeWithConstraints(content, constraints);
                    GUILayoutUtility.current.topLevel.Add(new GUILayoutEntry(vector.x, vector.x, vector.y, vector.y, style, options));
                }
                rect = GUILayoutUtility.kDummyRect;
            }
            return(rect);
        }
Example #3
0
        public override void ApplyOptions(GUILayoutOption[] options)
        {
            bool flag = options == null;

            if (!flag)
            {
                base.ApplyOptions(options);
                for (int i = 0; i < options.Length; i++)
                {
                    GUILayoutOption      gUILayoutOption = options[i];
                    GUILayoutOption.Type type            = gUILayoutOption.type;
                    GUILayoutOption.Type type2           = type;
                    switch (type2)
                    {
                    case GUILayoutOption.Type.fixedWidth:
                    case GUILayoutOption.Type.minWidth:
                    case GUILayoutOption.Type.maxWidth:
                        this.m_UserSpecifiedHeight = true;
                        break;

                    case GUILayoutOption.Type.fixedHeight:
                    case GUILayoutOption.Type.minHeight:
                    case GUILayoutOption.Type.maxHeight:
                        this.m_UserSpecifiedWidth = true;
                        break;

                    default:
                        if (type2 == GUILayoutOption.Type.spacing)
                        {
                            this.spacing = (float)((int)gUILayoutOption.value);
                        }
                        break;
                    }
                }
            }
        }
Example #4
0
 internal GUILayoutOption(GUILayoutOption.Type type, object value)
 {
     this.type  = type;
     this.value = value;
 }
		internal GUILayoutOption(GUILayoutOption.Type type, object value)
		{
			this.type = type;
			this.value = value;
		}