Example #1
0
        public override void Draw()
        {
            base.Draw();

            if (verticalScrollMode == VerticalScrollModes.EntryWise)
            {
                float x = 0, y = 0;
                float currentLine = 0;
                for (int i = 0; i < listItems.Count; i++)
                {
                    TextLabel label = listItems[i].textLabel;

                    if (currentLine < scrollIndex || currentLine >= scrollIndex + rowsDisplayed)
                    {
                        currentLine += label.NumTextLines;
                        continue;
                    }

                    currentLine += label.NumTextLines;
                    label.StartCharacterIndex = horizontalScrollIndex;
                    label.RefreshClassicLayout();

                    DecideTextColor(label, i);

                    label.Position = new Vector2(x, y);
                    label.Draw();

                    y += label.TextHeight + rowSpacing;
                }
            }
            else if (verticalScrollMode == VerticalScrollModes.PixelWise)
            {
                int x = 0;
                int y = -scrollIndex;
                for (int i = 0; i < listItems.Count; i++)
                {
                    TextLabel label = listItems[i].textLabel;

                    if (y + label.TextHeight < 0 || y >= this.Size.y)
                    {
                        y += label.TextHeight + rowSpacing;
                        continue;
                    }

                    if (horizontalScrollMode == HorizontalScrollModes.CharWise)
                    {
                        label.StartCharacterIndex = horizontalScrollIndex;
                    }
                    else if (horizontalScrollMode == HorizontalScrollModes.PixelWise)
                    {
                        x = -horizontalScrollIndex;
                    }
                    label.RefreshClassicLayout();

                    DecideTextColor(label, i);

                    label.HorzPixelScrollOffset = x;
                    label.Position = new Vector2(x, y);
                    label.Draw();

                    y += label.TextHeight + rowSpacing;
                }
            }
        }