Example #1
0
 /// <inheritdoc/>
 public override void Draw(Rect position, SearchFilter filter, string fullClassName, FilterTestType passedTestMethod)
 {
 }
Example #2
0
        /// <inheritdoc/>
        public override void Draw(Rect position, SearchFilter filter, string fullClassName, FilterTestType passedTestMethod)
        {
            var highlightRect = GetTextHighlightRectForFilter(label.text, position, style, filter, fullClassName, passedTestMethod, -4f, 0f, -17f);

            if (highlightRect.HasValue)
            {
                if (clipping)
                {
                    bool drawBackgroundBehindFoldoutsWas = DrawGUI.drawBackgroundBehindFoldouts;
                    DrawGUI.drawBackgroundBehindFoldouts = false;
                    DrawGUI.Active.Foldout(position, label, unfolded, style, highlightRect);
                    DrawGUI.drawBackgroundBehindFoldouts = drawBackgroundBehindFoldoutsWas;
                }
                else
                {
                    DrawGUI.Active.Foldout(position, label, unfolded, style, highlightRect);
                }
                return;
            }
            Draw(position);
        }
Example #3
0
        public static bool TryGetTextHighlightRectsForFilter(string text, Rect position, GUIStyle style, SearchFilter filter, string fullClassName, FilterTestType passedTestMethod, float offsetX, float offsetY, float adjustWidth, List <Rect> results)
        {
            var genericFilters      = filter.FiltersGeneric;
            int genericFiltersCount = genericFilters.Count;
            int genericFilterIndex  = 0;

            string filterText = filter.FilterFieldLabel;

            do
            {
                if (filterText.Length > 0)
                {
                    int highlightStart;
                    int highlightCount;
                    switch (passedTestMethod)
                    {
                    case FilterTestType.Label:
                        if (TryGetHighlightStartIndexAndCharCount(text, filterText, out highlightStart, out highlightCount))
                        {
                            results.Add(GetTextHighlightRectForFilter(text, position, style, highlightStart, highlightCount, offsetX, offsetY, adjustWidth));
                        }
                        break;

                    case FilterTestType.FullClassName:
                    case FilterTestType.Indetermined:
                        if (fullClassName.Length > text.Length && filterText.IndexOf('.') != -1)
                        {
                            highlightStart = GetHighlightStartIndex(text, filterText, out filterText);
                            if (highlightStart != -1)
                            {
                                highlightCount = filterText.Length;
                                results.Add(GetTextHighlightRectForFilter(text, position, style, highlightStart, highlightCount, offsetX, offsetY, adjustWidth));
                            }
                        }
                        else if (TryGetHighlightStartIndexAndCharCount(text, filterText, out highlightStart, out highlightCount))
                        {
                            results.Add(GetTextHighlightRectForFilter(text, position, style, highlightStart, highlightCount, offsetX, offsetY, adjustWidth));
                        }
                        break;
                    }
                }

                if (genericFilterIndex >= genericFiltersCount)
                {
                    break;
                }

                filterText = genericFilters[genericFilterIndex];
                genericFilterIndex++;
            }while(true);

            return(results.Count > 0);
        }
Example #4
0
        public static Rect?GetTextHighlightRectForFilter(string text, Rect position, GUIStyle style, SearchFilter filter, string fullClassName, FilterTestType passedTestMethod, float offsetX, float offsetY, float adjustWidth)
        {
                        #if ENABLE_PREFIX_HIGHLIGHTING
                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(filter.HasFilter, "!HasFilter");
            Debug.Assert(passedTestMethod != FilterTestType.None, passedTestMethod.ToString());
            Debug.Assert(fullClassName.Length >= text.Length, "\"" + fullClassName + "\"");
                        #endif

            string filterText = filter.FilterFieldLabel;
            if (filterText.Length == 0)
            {
                filterText = filter.FilterGeneric;
                if (filterText.Length == 0)
                {
                    return(null);
                }
            }

            int highlightStart;
            int highlightCount;
            switch (passedTestMethod)
            {
            case FilterTestType.Label:
                if (!TryGetHighlightStartIndexAndCharCount(text, filterText, out highlightStart, out highlightCount))
                {
                    return(null);
                }
                break;

            case FilterTestType.FullClassName:
            case FilterTestType.Indetermined:
                if (fullClassName.Length > text.Length && filterText.IndexOf('.') != -1)
                {
                    highlightStart = GetHighlightStartIndex(text, filterText, out filterText);
                    highlightCount = filterText.Length;
                }
                else
                {
                    if (!TryGetHighlightStartIndexAndCharCount(text, filterText, out highlightStart, out highlightCount))
                    {
                        return(null);
                    }
                }
                break;

            default:
                return(null);
            }

            if (highlightStart == -1)
            {
                return(null);
            }

            var highlightRect = position;
            highlightRect.x += style.contentOffset.x + style.margin.left - 2f;

            var size = style.CalcSize(GUIContentPool.Temp(text.Substring(0, highlightStart)));
            highlightRect.x += size.x;

            size = style.CalcSize(GUIContentPool.Temp(text.Substring(highlightStart, highlightCount)));
            highlightRect.width = size.x;

            highlightRect.x     += offsetX;
            highlightRect.y     += offsetY;
            highlightRect.width += adjustWidth;

                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(highlightRect.x >= 0f);
            Debug.Assert(highlightRect.width > 0f);
            Debug.Assert(highlightRect.height > 0f);
                        #endif

            return(highlightRect);
                        #else
            return(null);
                        #endif
        }
Example #5
0
 public void HighlightTextForFilter(Rect position, SearchFilter filter, string fullClassName, FilterTestType passedTestMethod, float offsetX, float adjustWidth)
 {
     if (TryGetTextHighlightRectsForFilter(label.text, position, DrawGUI.prefixLabel, filter, fullClassName, passedTestMethod, offsetX, 0f, adjustWidth, highlightRects))
     {
         var color = InspectorUtility.Preferences.theme.FilterHighlight;
         for (int n = highlightRects.Count - 1; n >= 0; n--)
         {
             Platform.Active.GUI.ColorRect(highlightRects[n], color);
         }
         highlightRects.Clear();
     }
                 #if DEV_MODE && DEBUG_NOT_HIGHLIGHTING
     else
     {
         Debug.LogWarning("HighlightTextForFilter(\"" + label.text + "\" / \"" + fullClassName + ") with passedTestMethod=" + passedTestMethod + " Highlighting: " + StringUtils.False);
     }
                 #endif
 }
Example #6
0
 /// <summary>
 /// Draw the prefix GUI at the given position.
 ///
 /// This variant of the Draw method should be called when there's a filter present.
 /// It handles highlighting characters in the prefix label based on the filter.
 /// </summary>
 public virtual void Draw(Rect position, [CanBeNull] SearchFilter filter, string fullClassName, FilterTestType passedTestMethod)
 {
     HighlightTextForFilter(position, filter, fullClassName, passedTestMethod, -3f, -6f);
     Draw(position);
 }