private string GetCroppedText(string fullText, float cropWidth, GUIStyle style)
        {
            int thatFitWithinWidth = style.GetNumCharactersThatFitWithinWidth(fullText, cropWidth);

            if (thatFitWithinWidth == -1 || thatFitWithinWidth <= 1 || thatFitWithinWidth == fullText.Length)
            {
                return(fullText);
            }
            return(fullText.Substring(0, thatFitWithinWidth - 1) + "…");
        }
Example #2
0
        private string LimitStringWidth(string content, float width, GUIStyle style)
        {
            int numCharactersThatFitWithinWidth = style.GetNumCharactersThatFitWithinWidth(content, width);

            if (content.Length > numCharactersThatFitWithinWidth)
            {
                return(content.Substring(0, Mathf.Min(numCharactersThatFitWithinWidth - 3, content.Length)) + "...");
            }
            return(content);
        }
Example #3
0
        private string GetCroppedText(string fullText, float cropWidth, GUIStyle style)
        {
            int numCharactersThatFitWithinWidth = style.GetNumCharactersThatFitWithinWidth(fullText, cropWidth);

            if ((numCharactersThatFitWithinWidth != -1) && ((numCharactersThatFitWithinWidth > 1) && (numCharactersThatFitWithinWidth != fullText.Length)))
            {
                return(fullText.Substring(0, numCharactersThatFitWithinWidth - 1) + "…");
            }
            return(fullText);
        }
Example #4
0
        // When the given 'text' exceeds the given 'width', out-of-bound characters
        // are removed as well as a few more to display a trailing ellipsis.
        // If 'text' does not exceed width, text is returned.
        private string FitTextToWidth(string text, float width, GUIStyle style)
        {
            int characterCountVisible = style.GetNumCharactersThatFitWithinWidth(text, width);

            if (characterCountVisible > 1 && characterCountVisible != text.Length)
            {
                string ellipsedText;
                int    characterLength = (characterCountVisible - 1);
                if (!Instance.m_Cache.TryGetEllipsedNames(text, characterLength, out ellipsedText))
                {
                    ellipsedText = text.Substring(0, characterLength) + (" \u2026");    // 'horizontal ellipsis' (U+2026) is: ...
                    Instance.m_Cache.StoreEllipsedNames(text, ellipsedText, characterLength);
                }
                return(ellipsedText);
            }
            return(text);
        }
Example #5
0
        private string GetCroppedText(string fullText, float cropWidth, GUIStyle style)
        {
            int    numCharactersThatFitWithinWidth = style.GetNumCharactersThatFitWithinWidth(fullText, cropWidth);
            string result;

            if (numCharactersThatFitWithinWidth == -1)
            {
                result = fullText;
            }
            else if (numCharactersThatFitWithinWidth > 1 && numCharactersThatFitWithinWidth != fullText.Length)
            {
                result = fullText.Substring(0, numCharactersThatFitWithinWidth - 1) + "…";
            }
            else
            {
                result = fullText;
            }
            return(result);
        }
        string GetCroppedText(string fullText, float cropWidth, GUIStyle style)
        {
            // Check if we need to crop
            int characterCountVisible = style.GetNumCharactersThatFitWithinWidth(fullText, cropWidth);

            if (characterCountVisible == -1)
            {
                return(fullText);
            }

            if (characterCountVisible > 1 && characterCountVisible != fullText.Length)
            {
                return(fullText.Substring(0, characterCountVisible - 1) + ("\u2026")); // 'horizontal ellipsis' (U+2026) is: ...
            }
            else
            {
                return(fullText);
            }
        }
        private string FitTextToWidth(string text, float width, GUIStyle style)
        {
            int    numCharactersThatFitWithinWidth = style.GetNumCharactersThatFitWithinWidth(text, width);
            string result;

            if (numCharactersThatFitWithinWidth > 1 && numCharactersThatFitWithinWidth != text.Length)
            {
                int    num = numCharactersThatFitWithinWidth - 1;
                string text2;
                if (!SoftlockViewController.Instance.m_Cache.TryGetEllipsedNames(text, num, out text2))
                {
                    text2 = text.Substring(0, num) + " …";
                    SoftlockViewController.Instance.m_Cache.StoreEllipsedNames(text, text2, num);
                }
                result = text2;
            }
            else
            {
                result = text;
            }
            return(result);
        }
Example #8
0
        private GUIContent GetTruncatedTabContent(int tabIndex)
        {
            var tabContent = m_Panes[tabIndex].titleContent;

            if (tabContent.text.Length > 10)
            {
                var        text = tabContent.text;
                GUIContent gc   = (GUIContent)s_GUIContents[text];
                if (gc != null)
                {
                    return(gc);
                }

                int cappedMaxChars = tabStyle.GetNumCharactersThatFitWithinWidth(text, Styles.tabMaxWidth);
                if (text.Length > cappedMaxChars)
                {
                    gc = new GUIContent(text.Substring(0, Mathf.Max(3, Mathf.Min(cappedMaxChars - 2, text.Length))) + "\u2026", tabContent.image,
                                        String.IsNullOrEmpty(tabContent.tooltip) ? text : tabContent.tooltip);
                    s_GUIContents[text] = gc;
                    return(gc);
                }
            }
            return(tabContent);
        }
Example #9
0
 internal static int GetNumCharactersThatFitWithinWidth(GUIStyle style, string text, float width)
 {
     return(style.GetNumCharactersThatFitWithinWidth(text, width));
 }