()
| 223 | |
| 224 | /// <inheritdoc /> |
| 225 | public override void DrawSelf() |
| 226 | { |
| 227 | // Cache data |
| 228 | var rect = new Rectangle(Float2.Zero, Size); |
| 229 | bool enabled = EnabledInHierarchy; |
| 230 | var font = GetFont(); |
| 231 | if (!font) |
| 232 | return; |
| 233 | |
| 234 | // Background |
| 235 | Color backColor = BackgroundColor; |
| 236 | if (IsMouseOver || IsNavFocused) |
| 237 | backColor = BackgroundSelectedColor; |
| 238 | Render2D.FillRectangle(rect, backColor); |
| 239 | if (HasBorder) |
| 240 | Render2D.DrawRectangle(rect, IsFocused ? BorderSelectedColor : BorderColor, BorderThickness); |
| 241 | |
| 242 | // Apply view offset and clip mask |
| 243 | if (ClipText) |
| 244 | Render2D.PushClip(TextClipRectangle); |
| 245 | bool useViewOffset = !_viewOffset.IsZero; |
| 246 | if (useViewOffset) |
| 247 | Render2D.PushTransform(Matrix3x3.Translation2D(-_viewOffset)); |
| 248 | |
| 249 | var text = ConvertedText(); |
| 250 | |
| 251 | // Check if sth is selected to draw selection |
| 252 | if (HasSelection && IsFocused) |
| 253 | { |
| 254 | var leftEdge = font.GetCharPosition(text, SelectionLeft, ref _layout); |
| 255 | var rightEdge = font.GetCharPosition(text, SelectionRight, ref _layout); |
| 256 | float fontHeight = font.Height; |
| 257 | #if PLATFORM_MAC && !PLATFORM_SDL |
| 258 | fontHeight /= (float)Platform.Dpi / 96.0f; // TODO: refactor DPI support on macOS to skip such hacks |
| 259 | #endif |
| 260 | float textHeight = fontHeight / DpiScale; |
| 261 | |
| 262 | // Draw selection background |
| 263 | float alpha = Mathf.Min(1.0f, Mathf.Cos(_animateTime * BackgroundSelectedFlashSpeed) * 0.5f + 1.3f); |
| 264 | alpha *= alpha; |
| 265 | Color selectionColor = SelectionColor * alpha; |
| 266 | // |
| 267 | int selectedLinesCount = 1 + Mathf.FloorToInt((rightEdge.Y - leftEdge.Y) / textHeight); |
| 268 | if (selectedLinesCount == 1) |
| 269 | { |
| 270 | // Selected is part of single line |
| 271 | Rectangle r1 = new Rectangle(leftEdge.X, leftEdge.Y, rightEdge.X - leftEdge.X, fontHeight); |
| 272 | Render2D.FillRectangle(r1, selectionColor); |
| 273 | } |
| 274 | else |
| 275 | { |
| 276 | float leftMargin = _layout.Bounds.Location.X; |
| 277 | |
| 278 | // Selected is more than one line |
| 279 | Rectangle r1 = new Rectangle(leftEdge.X, leftEdge.Y, 1000000000, fontHeight); |
| 280 | Render2D.FillRectangle(r1, selectionColor); |
| 281 | // |
| 282 | for (int i = 3; i <= selectedLinesCount; i++) |
nothing calls this directly
no test coverage detected