Ejemplo n.º 1
0
        private void LayoutException(ITextMeasure measure, StackTraceLine[] stackLines, float maxWidth)
        {
            float nextX       = 0.0f;
            float totalHeight = measure.CalcHeight(value, maxWidth);

            if (stackLines != null)
            {
                for (int i = 0; i < stackLines.Length; ++i)
                {
                    float lineHeight = measure.CalcHeight(stackLines[i].line, maxWidth);
                    stackLines[i].frame = new Rect(nextX, totalHeight, maxWidth, lineHeight);

                    if (stackLines[i].sourcePathStart != -1)
                    {
                        GUIStyleTextMeasure styleMeasure = measure as GUIStyleTextMeasure;
                        if (styleMeasure != null)
                        {
                            ResolveSourceLink(styleMeasure, ref stackLines[i]);
                        }
                    }

                    totalHeight += lineHeight;
                }
            }

            this.width  = maxWidth;
            this.height = totalHeight;
        }
Ejemplo n.º 2
0
        internal void Layout(ITextMeasure measure, float contentWidth, float maxWidth)
        {
            if (this.IsPlain)
            {
                if (this.level == LogLevel.Exception)
                {
                    StackTraceLine[] stackLines = this.data as StackTraceLine[];
                    if (stackLines == null && this.stackTrace != null)
                    {
                        stackLines = EditorStackTrace.ParseStackTrace(this.stackTrace);
                        this.data  = stackLines;
                    }

                    LayoutException(measure, stackLines, maxWidth);
                }
                else
                {
                    LayoutPlain(measure, maxWidth);
                }
            }
            else if (this.IsTable)
            {
                string[] table = this.Table;
                Assert.IsNotNull(table);

                LayoutTable(measure, table, contentWidth, maxWidth);
            }
            else
            {
                throw new NotImplementedException("Unexpected entry type");
            }
        }
Ejemplo n.º 3
0
        public TwoLineTextBlockControl()
        {
            _fontOptions                  = new FontOptions();
            _fontObserverDisposer         = _fontOptions.Observe(this);
            _fontOptions.PropertyChanged += FontOptionsOnPropertyChanged;
            _textMeasure                  = TextMeasureHelper.GetTextMeasure(new FontOptionsStruct(_fontOptions));

            _panel = new TwoLineTextBlockPanel(CreateTextBlock(), CreateTextBlock());

            ChildInternal = _panel;
        }
Ejemplo n.º 4
0
        public ConsoleView(AbstractConsole console, float width, float height)
            : base(console.Capacity, width, height)
        {
            m_console = console;

            this.ConsoleDelegate = this;
            this.DataSource = this;
            this.Delegate = this;

            m_textMeasure = CreateTextMeasure();

            m_filteredDelegate = new ConsoleFilteredDelegate(this);

            ReloadData();
        }
Ejemplo n.º 5
0
        public ConsoleView(AbstractConsole console, float width, float height)
            : base(console.Capacity, width, height)
        {
            m_console = console;

            this.ConsoleDelegate = this;
            this.DataSource      = this;
            this.Delegate        = this;

            m_textMeasure = CreateTextMeasure();

            m_filteredDelegate = new ConsoleFilteredDelegate(this);

            ReloadData();
        }
Ejemplo n.º 6
0
        private void LayoutTable(ITextMeasure measure, string[] table, float contentWidth, float maxWidth)
        {
            int    maxLength     = 0;
            string longestString = null;

            for (int i = 0; i < table.Length; ++i)
            {
                string str = table[i];
                int    len = StringUtils.Strlen(str);
                if (len > maxLength)
                {
                    maxLength     = len;
                    longestString = str;
                }
            }

            int colLength = maxLength + kColSeparator.Length;

            Vector2 colSize  = measure.CalcSize(kColSeparator + longestString);
            float   colWidth = colSize.x;

            int numCols = Mathf.Max(1, (int)(contentWidth / colWidth));
            int numRows = table.Length / numCols + (table.Length % numCols != 0 ? 1 : 0);

            StringBuilder buffer = new StringBuilder(colLength * table.Length);

            for (int row = 0; row < numRows; ++row)
            {
                int appendSpacing = 0;
                for (int col = 0; col < numCols; ++col)
                {
                    int index = col * numRows + row;

                    if (index > table.Length - 1)
                    {
                        break;
                    }

                    buffer.Append(' ', appendSpacing);
                    if (col > 0)
                    {
                        buffer.Append(kColSeparator);
                    }

                    string str = table[index];
                    if (str != null)
                    {
                        buffer.Append(str);
                        appendSpacing = maxLength - str.Length;
                    }
                    else
                    {
                        appendSpacing = maxLength;
                    }
                }

                if (row < numRows - 1)
                {
                    buffer.Append('\n');
                }
            }

            this.value = buffer.ToString();

            Vector2 size = measure.CalcSize(this.value);

            this.width  = maxWidth;
            this.height = size.y;
        }
Ejemplo n.º 7
0
 private void LayoutPlain(ITextMeasure measure, float maxWidth)
 {
     this.width  = maxWidth;
     this.height = measure.CalcHeight(value, maxWidth);
 }
Ejemplo n.º 8
0
 internal void Layout(ITextMeasure measure, float maxWidth)
 {
     Layout(measure, maxWidth, maxWidth);
 }
Ejemplo n.º 9
0
        private void LayoutTable(ITextMeasure measure, string[] table, float contentWidth, float maxWidth)
        {
            int maxLength = 0;
            string longestString = null;

            for (int i = 0; i < table.Length; ++i)
            {
                string str = table[i];
                int len = StringUtils.Strlen(str);
                if (len > maxLength)
                {
                    maxLength = len;
                    longestString = str;
                }
            }

            int colLength = maxLength + kColSeparator.Length;

            Vector2 colSize = measure.CalcSize(kColSeparator + longestString);
            float colWidth = colSize.x;

            int numCols = Mathf.Max(1, (int)(contentWidth / colWidth));
            int numRows = table.Length / numCols + (table.Length % numCols != 0 ? 1 : 0);

            StringBuilder buffer = new StringBuilder(colLength * table.Length);

            for (int row = 0; row < numRows; ++row)
            {
                int appendSpacing = 0;
                for (int col = 0; col < numCols; ++col)
                {
                    int index = col * numRows + row;

                    if (index > table.Length - 1)
                    {
                        break;
                    }

                    buffer.Append(' ', appendSpacing);
                    if (col > 0)
                    {
                        buffer.Append(kColSeparator);
                    }

                    string str = table[index];
                    if (str != null)
                    {
                        buffer.Append(str);
                        appendSpacing = maxLength - str.Length;
                    }
                    else
                    {
                        appendSpacing = maxLength;
                    }
                }

                if (row < numRows - 1)
                {
                    buffer.Append('\n');
                }
            }

            this.value = buffer.ToString();

            Vector2 size = measure.CalcSize(this.value);
            this.width = maxWidth;
            this.height = size.y;
        }
Ejemplo n.º 10
0
 private void LayoutPlain(ITextMeasure measure, float maxWidth)
 {
     this.width = maxWidth;
     this.height = measure.CalcHeight(value, maxWidth);
 }
Ejemplo n.º 11
0
        private void LayoutException(ITextMeasure measure, StackTraceLine[] stackLines, float maxWidth)
        {
            float nextX = 0.0f;
            float totalHeight = measure.CalcHeight(value, maxWidth);

            if (stackLines != null)
            {
                for (int i = 0; i < stackLines.Length; ++i)
                {
                    float lineHeight = measure.CalcHeight(stackLines[i].line, maxWidth);
                    stackLines[i].frame = new Rect(nextX, totalHeight, maxWidth, lineHeight);

                    if (stackLines[i].sourcePathStart != -1)
                    {
                        GUIStyleTextMeasure styleMeasure = measure as GUIStyleTextMeasure;
                        if (styleMeasure != null)
                        {
                            ResolveSourceLink(styleMeasure, ref stackLines[i]);
                        }
                    }

                    totalHeight += lineHeight;
                }
            }

            this.width = maxWidth;
            this.height = totalHeight;
        }
Ejemplo n.º 12
0
        internal void Layout(ITextMeasure measure, float contentWidth, float maxWidth)
        {
            if (this.IsPlain)
            {
                if (this.level == LogLevel.Exception)
                {
                    StackTraceLine[] stackLines = this.data as StackTraceLine[];
                    if (stackLines == null && this.stackTrace != null)
                    {
                        stackLines = EditorStackTrace.ParseStackTrace(this.stackTrace);
                        this.data = stackLines;
                    }

                    LayoutException(measure, stackLines, maxWidth);
                }
                else
                {
                    LayoutPlain(measure, maxWidth);
                }
            }
            else if (this.IsTable)
            {
                string[] table = this.Table;
                Assert.IsNotNull(table);

                LayoutTable(measure, table, contentWidth, maxWidth);
            }
            else
            {
                throw new NotImplementedException("Unexpected entry type");
            }
        }
Ejemplo n.º 13
0
 internal void Layout(ITextMeasure measure, float maxWidth)
 {
     Layout(measure, maxWidth, maxWidth);
 }