()
| 695 | |
| 696 | /// <inheritdoc /> |
| 697 | public override void Draw() |
| 698 | { |
| 699 | // Cache data |
| 700 | var style = Style.Current; |
| 701 | var tree = ParentTree; |
| 702 | bool isSelected = tree.Selection.Contains(this); |
| 703 | bool isFocused = tree.ContainsFocus; |
| 704 | var left = _xOffset + 16; // offset + arrow |
| 705 | var textRect = new Rectangle(left, 0, Width - left, _headerHeight); |
| 706 | _margin.ShrinkRectangle(ref textRect); |
| 707 | |
| 708 | // Draw background |
| 709 | if (isSelected || _mouseOverHeader) |
| 710 | { |
| 711 | Render2D.FillRectangle(_headerRect, (isSelected && isFocused) ? BackgroundColorSelected : (_mouseOverHeader ? BackgroundColorHighlighted : BackgroundColorSelectedUnfocused)); |
| 712 | } |
| 713 | |
| 714 | // Draw arrow |
| 715 | if (HasAnyVisibleChild) |
| 716 | { |
| 717 | Render2D.DrawSprite(_opened ? style.ArrowDown : style.ArrowRight, ArrowRect, _mouseOverHeader ? style.Foreground : style.ForegroundGrey); |
| 718 | } |
| 719 | |
| 720 | // Draw icon |
| 721 | if (_iconCollaped.IsValid) |
| 722 | { |
| 723 | Render2D.DrawSprite(_opened ? _iconOpened : _iconCollaped, new Rectangle(textRect.Left, 0, 16, 16), IconColor); |
| 724 | textRect.X += 18.0f; |
| 725 | textRect.Width -= 18.0f; |
| 726 | } |
| 727 | |
| 728 | float textWidth = TextFont.GetFont().MeasureText(_text).X; |
| 729 | Rectangle trueTextRect = textRect; |
| 730 | trueTextRect.Width = textWidth; |
| 731 | trueTextRect.Scale(_highlightScale); |
| 732 | |
| 733 | if (_isHightlighted && _debounceHighlightTime > 0.1f) |
| 734 | { |
| 735 | Color highlightBackgroundColor = Editor.Instance.Options.Options.Visual.HighlightColor; |
| 736 | highlightBackgroundColor = highlightBackgroundColor.AlphaMultiplied(0.3f); |
| 737 | Render2D.FillRectangle(trueTextRect, highlightBackgroundColor); |
| 738 | } |
| 739 | |
| 740 | // Draw text |
| 741 | Color textColor = CacheTextColor(); |
| 742 | Render2D.DrawText(TextFont.GetFont(), _text, textRect, textColor, TextAlignment.Near, TextAlignment.Center); |
| 743 | |
| 744 | // Draw drag and drop effect |
| 745 | if (IsDragOver && _tree.DraggedOverNode == this) |
| 746 | { |
| 747 | switch (_dragOverMode) |
| 748 | { |
| 749 | case DragItemPositioning.At: |
| 750 | Render2D.FillRectangle(textRect, style.Selection); |
| 751 | Render2D.DrawRectangle(textRect, style.SelectionBorder); |
| 752 | break; |
| 753 | case DragItemPositioning.Above: |
| 754 | Render2D.DrawRectangle(new Rectangle(textRect.X, textRect.Top - DefaultDragInsertPositionMargin * 0.5f - DefaultNodeOffsetY - _margin.Top, textRect.Width, DefaultDragInsertPositionMargin), style.SelectionBorder); |
no test coverage detected