Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*******************************************************************************/
package org.eclipse.swt.custom;

import java.util.*;

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
Expand Down Expand Up @@ -93,8 +95,8 @@ public class CTabFolderRenderer {
static final int BUTTON_FILL = SWT.COLOR_LIST_BACKGROUND;
static final int BORDER1_COLOR = SWT.COLOR_WIDGET_NORMAL_SHADOW;

static final int ITEM_TOP_MARGIN = 2;
static final int ITEM_BOTTOM_MARGIN = 2;
static final int ITEM_TOP_MARGIN = 3;
static final int ITEM_BOTTOM_MARGIN = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be sufficient to only have a higher top margin but keep the bottom one as is? Or do we want to increase the padding consistently or even also have issues there?

static final int ITEM_LEFT_MARGIN = 4;
static final int ITEM_RIGHT_MARGIN = 4;
static final int INTERNAL_SPACING = 4;
Expand Down Expand Up @@ -1380,10 +1382,23 @@ void drawSelected(int itemIndex, GC gc, Rectangle bounds, int state ) {

// draw highlight marker of selected tab
if (parent.selectionHighlightBarThickness > 0 && parent.simple) {
Color previousColor = gc.getBackground();
gc.setBackground(item.getDisplay().getSystemColor(parent.shouldHighlight() ? SWT.COLOR_LIST_SELECTION : SWT.COLOR_WIDGET_DISABLED_FOREGROUND));
gc.fillRectangle(x + 1 /* outline */, parent.onBottom ? y + height - 1 - parent.selectionHighlightBarThickness : y + 1, width - 2 /*outline*/, parent.selectionHighlightBarThickness);
gc.setBackground(previousColor);
int thickness = parent.selectionHighlightBarThickness;
boolean onBottom = parent.onBottom;
Comment on lines +1385 to +1386
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be easier to read if the variables are corehently defines where they are used. Currently, you define some variable for the layout here in the beginning, then some coloring stuff is done, then again some layouting variables are calculated.

boolean highlight = parent.shouldHighlight();

Color oldBackground = gc.getBackground();
Color highlightColor = item.getDisplay().getSystemColor(
highlight ? SWT.COLOR_LIST_SELECTION : SWT.COLOR_WIDGET_DISABLED_FOREGROUND);
gc.setBackground(highlightColor);
Comment on lines +1387 to +1392
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: couldn't we just keep this part of the code as is?


int bottomY = y + height - 1;
int highlightY = onBottom ? bottomY - thickness : thickness + 1;

int[] shape2 = Arrays.copyOf(shape, shape.length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please us more self-explaining names such as highlightShape instead of shape2.

// Update Y coordinates in shape to apply highlight thickness
shape2[1] = shape2[3] = shape2[shape2.length - 1] = shape2[shape2.length - 3] = highlightY;
gc.fillPolygon(shape2);
gc.setBackground(oldBackground);
}

// draw outline
Expand Down
Loading