Ejemplo n.º 1
0
 public override void SetHorizontal(float x, float width)
 {
     if (!this.isVertical)
     {
         this.state.xOffset = x;
         if ((double)width != (double)this.state.lastTotalSize)
         {
             this.state.RelativeToRealSizes((int)width);
             this.state.lastTotalSize = (int)width;
             for (int i1 = 0; i1 < this.state.realSizes.Length - 1; ++i1)
             {
                 this.state.DoSplitter(i1, i1 + 1, 0);
             }
         }
         int index = 0;
         using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 GUILayoutEntry current  = enumerator.Current;
                 float          realSize = (float)this.state.realSizes[index];
                 current.SetHorizontal(Mathf.Round(x), Mathf.Round(realSize));
                 x += realSize + this.spacing;
                 ++index;
             }
         }
     }
     else
     {
         base.SetHorizontal(x, width);
     }
 }
Ejemplo n.º 2
0
 public override void SetHorizontal(float x, float width)
 {
     base.SetHorizontal(x, width);
     if (this.resetCoords)
     {
         x = 0.0f;
     }
     if (this.isVertical)
     {
         Debug.LogError((object)"Wordwrapped vertical group. Don't. Just Don't");
     }
     else
     {
         this.m_Lines = 0;
         float num = 0.0f;
         using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 GUILayoutEntry current = enumerator.Current;
                 if ((double)current.rect.xMax - (double)num > (double)x + (double)width)
                 {
                     num = current.rect.x - (float)current.margin.left;
                     ++this.m_Lines;
                 }
                 current.SetHorizontal(current.rect.x - num, current.rect.width);
                 current.rect.y = (float)this.m_Lines;
             }
         }
         ++this.m_Lines;
     }
 }
Ejemplo n.º 3
0
            public static bool Prefix(GUILayoutGroup __instance, ref GUILayoutEntry __result)
            {
                if (__instance.m_Cursor < __instance.entries.Count)
                {
                    __result = __instance.entries[__instance.m_Cursor];
                    __instance.m_Cursor++;
                    return(false);
                }

                throw new ArgumentException(string.Concat("Getting control ", __instance.m_Cursor, "'s position in a group with only ", __instance.entries.Count, " controls when doing ", Event.current.rawType, "\nAborting"));
            }
Ejemplo n.º 4
0
            public static bool Prefix(GUILayoutEntry __instance)
            {
                var cast = __instance?.TryCast <GUIWordWrapSizer>();

                if (cast != null)
                {
                    cast.CalcHeight();
                    return(false);
                }

                return(true);
            }
Ejemplo n.º 5
0
 public override void SetVertical(float y, float height)
 {
     if (this.entries.Count == 0)
     {
         base.SetVertical(y, height);
     }
     else if (this.isVertical)
     {
         base.SetVertical(y, height);
     }
     else
     {
         if (this.resetCoords)
         {
             y = 0.0f;
         }
         float num1 = y - (float)this.margin.top;
         float num2 = y + (float)this.margin.vertical - this.spacing * (float)(this.m_Lines - 1);
         float t    = 0.0f;
         if ((double)this.m_ChildMinHeight != (double)this.m_ChildMaxHeight)
         {
             t = Mathf.Clamp((float)(((double)num2 - (double)this.m_ChildMinHeight) / ((double)this.m_ChildMaxHeight - (double)this.m_ChildMinHeight)), 0.0f, 1f);
         }
         float num3 = num1;
         for (int index = 0; index < this.m_Lines; ++index)
         {
             if (index > 0)
             {
                 num3 += (float)Mathf.Max(this.m_LineInfo[index].topBorder, this.m_LineInfo[index - 1].bottomBorder);
             }
             this.m_LineInfo[index].start = num3;
             this.m_LineInfo[index].size  = Mathf.Lerp(this.m_LineInfo[index].minSize, this.m_LineInfo[index].maxSize, t);
             num3 += this.m_LineInfo[index].size + this.spacing;
         }
         using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 GUILayoutEntry      current  = enumerator.Current;
                 FlowLayout.LineInfo lineInfo = this.m_LineInfo[(int)current.rect.y];
                 if (current.stretchHeight != 0)
                 {
                     current.SetVertical(lineInfo.start + (float)current.margin.top, lineInfo.size - (float)current.margin.vertical);
                 }
                 else
                 {
                     current.SetVertical(lineInfo.start + (float)current.margin.top, Mathf.Clamp(lineInfo.size - (float)current.margin.vertical, current.minHeight, current.maxHeight));
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
            private void AddYRecursive(GUILayoutEntry e, float y)
            {
                e.rect.y += y;
                GUILayoutGroup group = e as GUILayoutGroup;

                if (group != null)
                {
                    for (int i = 0; i < group.entries.Count; i++)
                    {
                        this.AddYRecursive(group.entries[i], y);
                    }
                }
            }
Ejemplo n.º 7
0
            private void AddYRecursive(GUILayoutEntry e, float y)
            {
                e.rect.y += y;
                GUILayoutGroup guiLayoutGroup = e as GUILayoutGroup;

                if (guiLayoutGroup == null)
                {
                    return;
                }
                for (int index = 0; index < guiLayoutGroup.entries.Count; ++index)
                {
                    this.AddYRecursive(guiLayoutGroup.entries[index], y);
                }
            }
            private void AddYRecursive(GUILayoutEntry e, float y)
            {
                // this looks kind of bad, but in 99% of cases it would only be one level depth (e.g. few labels inside BeginHorizontal)
                e.rect.y += y;

                GUILayoutGroup g = e as GUILayoutGroup;

                if (g != null)
                {
                    for (int i = 0; i < g.entries.Count; i++)
                    {
                        AddYRecursive((GUILayoutEntry)g.entries[i], y);
                    }
                }
            }
Ejemplo n.º 9
0
        public static Rect Unstripped_GetLast(this GUILayoutGroup group)
        {
            Rect result;

            if (group.m_Cursor > 0 && group.m_Cursor <= group.entries.Count)
            {
                GUILayoutEntry guilayoutEntry = group.entries[group.m_Cursor - 1];
                result = guilayoutEntry.rect;
            }
            else
            {
                result = GUILayoutEntry.kDummyRect;
            }
            return(result);
        }
Ejemplo n.º 10
0
 public static bool Prefix(GUILayoutGroup __instance, GUILayoutEntry e)
 {
     __instance.entries.Add(e);
     return(false);
 }
Ejemplo n.º 11
0
            public override void SetVertical(float y, float height)
            {
                this.rect.y      = y;
                this.rect.height = height;
                RectOffset padding = this.style.padding;

                if (this.isVertical)
                {
                    if (this.style != GUIStyle.none)
                    {
                        float a1 = (float)padding.top;
                        float a2 = (float)padding.bottom;
                        if (this.entries.Count != 0)
                        {
                            a1 = Mathf.Max(a1, (float)this.entries[0].margin.top);
                            a2 = Mathf.Max(a2, (float)this.entries[this.entries.Count - 1].margin.bottom);
                        }
                        y      += a1;
                        height -= a2 + a1;
                    }
                    if ((double)height != (double)this.state.lastTotalSize)
                    {
                        this.state.RelativeToRealSizes((int)height);
                        this.state.lastTotalSize = (int)height;
                        for (int i1 = 0; i1 < this.state.realSizes.Length - 1; ++i1)
                        {
                            this.state.DoSplitter(i1, i1 + 1, 0);
                        }
                    }
                    int index = 0;
                    using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            GUILayoutEntry current  = enumerator.Current;
                            float          realSize = (float)this.state.realSizes[index];
                            current.SetVertical(Mathf.Round(y), Mathf.Round(realSize));
                            y += realSize + this.spacing;
                            ++index;
                        }
                    }
                }
                else if (this.style != GUIStyle.none)
                {
                    using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            GUILayoutEntry current = enumerator.Current;
                            float          num     = (float)Mathf.Max(current.margin.top, padding.top);
                            float          y1      = y + num;
                            float          height1 = height - (float)Mathf.Max(current.margin.bottom, padding.bottom) - num;
                            if (current.stretchHeight != 0)
                            {
                                current.SetVertical(y1, height1);
                            }
                            else
                            {
                                current.SetVertical(y1, Mathf.Clamp(height1, current.minHeight, current.maxHeight));
                            }
                        }
                    }
                }
                else
                {
                    float num1 = y - (float)this.margin.top;
                    float num2 = height + (float)this.margin.vertical;
                    using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            GUILayoutEntry current = enumerator.Current;
                            if (current.stretchHeight != 0)
                            {
                                current.SetVertical(num1 + (float)current.margin.top, num2 - (float)current.margin.vertical);
                            }
                            else
                            {
                                current.SetVertical(num1 + (float)current.margin.top, Mathf.Clamp(num2 - (float)current.margin.vertical, current.minHeight, current.maxHeight));
                            }
                        }
                    }
                }
            }
Ejemplo n.º 12
0
 public override void CalcHeight()
 {
     if (this.entries.Count == 0)
     {
         this.maxHeight = this.minHeight = 0.0f;
     }
     else
     {
         this.m_ChildMinHeight = this.m_ChildMaxHeight = 0.0f;
         int num1 = 0;
         int num2 = 0;
         this.m_StretchableCountY = 0;
         if (!this.isVertical)
         {
             this.m_LineInfo = new FlowLayout.LineInfo[this.m_Lines];
             for (int index = 0; index < this.m_Lines; ++index)
             {
                 this.m_LineInfo[index].topBorder    = 10000;
                 this.m_LineInfo[index].bottomBorder = 10000;
             }
             using (List <GUILayoutEntry> .Enumerator enumerator = this.entries.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     GUILayoutEntry current = enumerator.Current;
                     current.CalcHeight();
                     int y = (int)current.rect.y;
                     this.m_LineInfo[y].minSize      = Mathf.Max(current.minHeight, this.m_LineInfo[y].minSize);
                     this.m_LineInfo[y].maxSize      = Mathf.Max(current.maxHeight, this.m_LineInfo[y].maxSize);
                     this.m_LineInfo[y].topBorder    = Mathf.Min(current.margin.top, this.m_LineInfo[y].topBorder);
                     this.m_LineInfo[y].bottomBorder = Mathf.Min(current.margin.bottom, this.m_LineInfo[y].bottomBorder);
                 }
             }
             for (int index = 0; index < this.m_Lines; ++index)
             {
                 this.m_ChildMinHeight += (float)(double)this.m_LineInfo[index].minSize;
                 this.m_ChildMaxHeight += (float)(double)this.m_LineInfo[index].maxSize;
             }
             for (int index = 1; index < this.m_Lines; ++index)
             {
                 float num3 = (float)Mathf.Max(this.m_LineInfo[index - 1].bottomBorder, this.m_LineInfo[index].topBorder);
                 this.m_ChildMinHeight += (float)(double)num3;
                 this.m_ChildMaxHeight += (float)(double)num3;
             }
             num1 = this.m_LineInfo[0].topBorder;
             num2 = this.m_LineInfo[this.m_LineInfo.Length - 1].bottomBorder;
         }
         this.margin.top    = num1;
         this.margin.bottom = num2;
         float num4;
         float num5 = num4 = 0.0f;
         this.minHeight = Mathf.Max(this.minHeight, this.m_ChildMinHeight + num5 + num4);
         if ((double)this.maxHeight == 0.0)
         {
             this.stretchHeight += this.m_StretchableCountY + (!this.style.stretchHeight ? 0 : 1);
             this.maxHeight      = this.m_ChildMaxHeight + num5 + num4;
         }
         else
         {
             this.stretchHeight = 0;
         }
         this.maxHeight = Mathf.Max(this.maxHeight, this.minHeight);
     }
 }