|
18 | 18 | package org.eclipse.e4.ui.workbench.renderers.swt; |
19 | 19 |
|
20 | 20 | import java.lang.reflect.Field; |
| 21 | +import java.util.Arrays; |
21 | 22 | import java.util.Objects; |
22 | 23 | import org.eclipse.core.runtime.Platform; |
23 | 24 | import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
@@ -619,19 +620,44 @@ void drawSelectedTab(int itemIndex, GC gc, Rectangle bounds) { |
619 | 620 | } else if (!onBottom) { |
620 | 621 | gc.drawLine(startX, 0, endX, 0); |
621 | 622 | } |
622 | | - |
| 623 | + onBottom = true; |
623 | 624 | if (selectedTabHighlightColor != null) { |
| 625 | + gc.setForeground(selectedTabHighlightColor); |
624 | 626 | gc.setBackground(selectedTabHighlightColor); |
| 627 | + int originalLineWidth = gc.getLineWidth(); |
| 628 | + int highlightHeight = 2; |
625 | 629 | boolean highlightOnTop = drawTabHighlightOnTop; |
626 | 630 | if (onBottom) { |
627 | 631 | highlightOnTop = !highlightOnTop; |
628 | 632 | } |
629 | | - int highlightHeight = 2; |
630 | | - int verticalOffset = highlightOnTop ? 0 : bounds.height - (highlightHeight - 1); |
631 | | - int horizontalOffset = itemIndex == 0 || cornerSize == SQUARE_CORNER ? 0 : 1; |
632 | | - int widthAdjustment = cornerSize == SQUARE_CORNER ? 0 : 1; |
633 | | - gc.fillRectangle(bounds.x + horizontalOffset, bounds.y + verticalOffset, bounds.width - widthAdjustment, |
634 | | - highlightHeight); |
| 633 | + |
| 634 | + if (highlightOnTop && cornerSize != SQUARE_CORNER) { |
| 635 | + // When using round tabs, extract the part of the outline that covers the |
| 636 | + // highlight and draw it with adapted height |
| 637 | + int[] highlightShape = Arrays.copyOfRange(tabOutlinePoints, 12, tabOutlinePoints.length - 12); |
| 638 | + int yEnd = !highlightOnTop |
| 639 | + ? outlineBoundsForOutline.y + outlineBoundsForOutline.height - highlightHeight + 1 |
| 640 | + : highlightHeight; |
| 641 | + highlightShape[1] = highlightShape[highlightShape.length - 1] = yEnd; |
| 642 | + boolean gcAdvanced = gc.getAdvanced(); |
| 643 | + gc.setAdvanced(false); |
| 644 | + gc.fillPolygon(highlightShape); |
| 645 | + gc.setAdvanced(gcAdvanced); |
| 646 | + } else { |
| 647 | + // When using square tab or drawing the highlight at the bottom, simply draw a |
| 648 | + // line |
| 649 | + int highlightY = highlightOnTop ? outlineBoundsForOutline.y |
| 650 | + : bounds.y + bounds.height - highlightHeight + 1; |
| 651 | + gc.fillRectangle(outlineBoundsForOutline.x, highlightY, outlineBoundsForOutline.width, highlightHeight); |
| 652 | + if (highlightOnTop) { |
| 653 | + // Compensate for the outline being draw on top of the filled region by |
| 654 | + // extending the highlight with an equally wide line next to the filled region |
| 655 | + gc.setLineWidth(1); |
| 656 | + gc.drawLine(outlineBoundsForOutline.x, highlightY + highlightHeight, |
| 657 | + outlineBoundsForOutline.x + outlineBoundsForOutline.width, highlightY + highlightHeight); |
| 658 | + } |
| 659 | + } |
| 660 | + gc.setLineWidth(originalLineWidth); |
635 | 661 | } |
636 | 662 |
|
637 | 663 | if (backgroundPattern != null) { |
|
0 commit comments