Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogdan Gheorghe2013-05-09 21:50:18 +0000
committerBogdan Gheorghe2013-05-09 21:51:29 +0000
commit5586b4276a8bad64ed208b81521e93368db16cf9 (patch)
treeeac6256b00b4a4f9320d221c96d8c56a05899006
parent847520d8d759b373e537eb8799e1b1714084c90e (diff)
downloadeclipse.platform.ui-I20130509-2000.tar.gz
eclipse.platform.ui-I20130509-2000.tar.xz
eclipse.platform.ui-I20130509-2000.zip
[Bug 396780] CTabRendering doesn't draw bottom tabs correctlyI20130509-2000
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java241
1 files changed, 150 insertions, 91 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java
index c63ff98c301..71fadf480e4 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/CTabRendering.java
@@ -11,6 +11,7 @@
package org.eclipse.e4.ui.workbench.renderers.swt;
import javax.inject.Inject;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabFolderRenderer;
@@ -79,8 +80,9 @@ public class CTabRendering extends CTabFolderRenderer {
protected Rectangle computeTrim(int part, int state, int x, int y,
int width, int height) {
- int borderTop = TOP_KEYLINE + OUTER_KEYLINE;
- int borderBottom = INNER_KEYLINE + OUTER_KEYLINE;
+ boolean onBottom = parent.getTabPosition() == SWT.BOTTOM;
+ int borderTop = onBottom ? INNER_KEYLINE + OUTER_KEYLINE : TOP_KEYLINE + OUTER_KEYLINE ;
+ int borderBottom = onBottom ? TOP_KEYLINE + OUTER_KEYLINE : INNER_KEYLINE + OUTER_KEYLINE;
int marginWidth = parent.marginWidth;
int marginHeight = parent.marginHeight;
int sideDropWidth = shadowEnabled ? SIDE_DROP_WIDTH : 0;
@@ -89,7 +91,8 @@ public class CTabRendering extends CTabFolderRenderer {
if (state == SWT.FILL) {
x = -1 - paddingLeft;
int tabHeight = parent.getTabHeight() + 1;
- y = y - paddingTop - marginHeight - tabHeight - borderTop
+ y = onBottom ? y - paddingTop - marginHeight - borderTop
+ - (cornerSize / 4) : y - paddingTop - marginHeight - tabHeight - borderTop
- (cornerSize / 4);
width = 2 + paddingLeft + paddingRight;
height += paddingTop + paddingBottom;
@@ -106,7 +109,7 @@ public class CTabRendering extends CTabFolderRenderer {
// +1
// TODO: Fix
if (parent.getMinimized()) {
- y = /* parent.onBottom ? y - borderTop : */y - tabHeight
+ y = onBottom ? y - borderTop - 5 : y - tabHeight
- borderTop - 5;
height = borderTop + borderBottom + tabHeight;
} else {
@@ -115,8 +118,9 @@ public class CTabRendering extends CTabFolderRenderer {
// - borderTop: y - marginHeight - highlight_header -
// tabHeight
// - borderTop;
- y = y - marginHeight - tabHeight - borderTop
- - (cornerSize / 4);
+ y = onBottom ? y - marginHeight - borderTop
+ - (cornerSize / 4) : y - marginHeight - tabHeight - borderTop
+ - (cornerSize / 4);
height = height + borderBottom + borderTop + 2
* marginHeight + tabHeight + cornerSize / 2
+ cornerSize / 4
@@ -127,14 +131,21 @@ public class CTabRendering extends CTabFolderRenderer {
case PART_HEADER:
x = x - (INNER_KEYLINE + OUTER_KEYLINE) - sideDropWidth;
width = width + 2 * (INNER_KEYLINE + OUTER_KEYLINE + sideDropWidth);
+
break;
case PART_BORDER:
x = x - INNER_KEYLINE - OUTER_KEYLINE - sideDropWidth
- (cornerSize / 4);
width = width + 2 * (INNER_KEYLINE + OUTER_KEYLINE + sideDropWidth)
+ cornerSize / 2;
- y = y - borderTop;
height = height + borderTop + borderBottom;
+ y = y - borderTop;
+ if (onBottom) {
+ if (shadowEnabled) {
+ height += 3;
+ }
+ }
+
break;
default:
if (0 <= part && part < parent.getItemCount()) {
@@ -207,6 +218,7 @@ public class CTabRendering extends CTabFolderRenderer {
// gc.setClipping(bounds.x, bounds.y, bounds.width,
// parent.getTabHeight() + 1);
+ boolean onBottom = parent.getTabPosition() == SWT.BOTTOM;
int[] points = new int[1024];
int index = 0;
int radius = cornerSize / 2;
@@ -228,14 +240,13 @@ public class CTabRendering extends CTabFolderRenderer {
region.intersect(clipping);
gc.setClipping(region);
- int header = 3; // TODO: this needs to be added to computeTrim for
+ int header = shadowEnabled ? onBottom ? 6 : 3 : 0; // TODO: this needs to be added to computeTrim for
// HEADER
Rectangle trim = computeTrim(PART_HEADER, state, 0, 0, 0, 0);
trim.width = bounds.width - trim.width;
trim.height = (parent.getTabHeight() + 1 + header) - trim.height;
trim.x = -trim.x;
- trim.y = -trim.y;
-
+ trim.y = onBottom ? bounds.height - parent.getTabHeight() - 1 - header : -trim.y;
draw(PART_BACKGROUND, SWT.NONE, trim, gc);
gc.setClipping(clipping);
@@ -348,68 +359,89 @@ public class CTabRendering extends CTabFolderRenderer {
if (parent.getSingle() && parent.getItem(itemIndex).isShowing())
return;
+ boolean onBottom = parent.getTabPosition() == SWT.BOTTOM;
+ int header = shadowEnabled? 2 : 0;
int width = bounds.width;
int[] points = new int[1024];
int index = 0;
int radius = cornerSize / 2;
int circX = bounds.x + radius;
- int circY = bounds.y - 1 + radius;
+ int circY = onBottom ? bounds.y + bounds.height + 1 - header - radius : bounds.y - 1 + radius;
int selectionX1, selectionY1, selectionX2, selectionY2;
+ int bottomY = onBottom ? bounds.y - header : bounds.y + bounds.height;
if (itemIndex == 0
&& bounds.x == -computeTrim(CTabFolderRenderer.PART_HEADER,
SWT.NONE, 0, 0, 0, 0).x) {
circX -= 1;
points[index++] = circX - radius;
- points[index++] = bounds.y + bounds.height;
+ points[index++] = bottomY;
points[index++] = selectionX1 = circX - radius;
- points[index++] = selectionY1 = bounds.y + bounds.height;
+ points[index++] = selectionY1 = bottomY;
} else {
if (active) {
points[index++] = shadowEnabled ? SIDE_DROP_WIDTH : 0
+ INNER_KEYLINE + OUTER_KEYLINE;
- points[index++] = bounds.y + bounds.height;
+ points[index++] = bottomY;
}
points[index++] = selectionX1 = bounds.x;
- points[index++] = selectionY1 = bounds.y + bounds.height;
+ points[index++] = selectionY1 = bottomY;
}
- int[] ltt = drawCircle(circX, circY, radius, LEFT_TOP);
- int startX = ltt[6];
- for (int i = 0; i < ltt.length / 2; i += 2) {
- int tmp = ltt[i];
- ltt[i] = ltt[ltt.length - i - 2];
- ltt[ltt.length - i - 2] = tmp;
- tmp = ltt[i + 1];
- ltt[i + 1] = ltt[ltt.length - i - 1];
- ltt[ltt.length - i - 1] = tmp;
- }
- System.arraycopy(ltt, 0, points, index, ltt.length);
- index += ltt.length;
- int[] rt = drawCircle(circX + width - (radius * 2), circY, radius,
- RIGHT_TOP);
- int endX = rt[rt.length - 4];
- for (int i = 0; i < rt.length / 2; i += 2) {
- int tmp = rt[i];
- rt[i] = rt[rt.length - i - 2];
- rt[rt.length - i - 2] = tmp;
- tmp = rt[i + 1];
- rt[i + 1] = rt[rt.length - i - 1];
- rt[rt.length - i - 1] = tmp;
- }
- System.arraycopy(rt, 0, points, index, rt.length);
- index += rt.length;
+ int startX = -1, endX = -1;
+ if (!onBottom) {
+ int[] ltt = drawCircle(circX, circY, radius, LEFT_TOP);
+ startX = ltt[6];
+ for (int i = 0; i < ltt.length / 2; i += 2) {
+ int tmp = ltt[i];
+ ltt[i] = ltt[ltt.length - i - 2];
+ ltt[ltt.length - i - 2] = tmp;
+ tmp = ltt[i + 1];
+ ltt[i + 1] = ltt[ltt.length - i - 1];
+ ltt[ltt.length - i - 1] = tmp;
+ }
+ System.arraycopy(ltt, 0, points, index, ltt.length);
+ index += ltt.length;
- points[index++] = selectionX2 = bounds.width + circX - radius;
- points[index++] = selectionY2 = bounds.y + bounds.height;
+ int[] rt = drawCircle(circX + width - (radius * 2), circY, radius,
+ RIGHT_TOP);
+ endX = rt[rt.length - 4];
+ for (int i = 0; i < rt.length / 2; i += 2) {
+ int tmp = rt[i];
+ rt[i] = rt[rt.length - i - 2];
+ rt[rt.length - i - 2] = tmp;
+ tmp = rt[i + 1];
+ rt[i + 1] = rt[rt.length - i - 1];
+ rt[rt.length - i - 1] = tmp;
+ }
+ System.arraycopy(rt, 0, points, index, rt.length);
+ index += rt.length;
+
+ points[index++] = selectionX2 = bounds.width + circX - radius;
+ points[index++] = selectionY2 = bounds.y + bounds.height;
+ } else {
+ int[] ltt = drawCircle(circX, circY, radius, LEFT_BOTTOM);
+ startX = ltt[6];
+ System.arraycopy(ltt, 0, points, index, ltt.length);
+ index += ltt.length;
+
+ int[] rt = drawCircle(circX + width - (radius * 2), circY, radius,
+ RIGHT_BOTTOM);
+ endX = rt[rt.length - 4];
+ System.arraycopy(rt, 0, points, index, rt.length);
+ index += rt.length;
+
+ points[index++] = selectionX2 = bounds.width + circX - radius;
+ points[index++] = selectionY2 = bottomY;
+ }
if (active) {
points[index++] = parent.getSize().x
- (shadowEnabled ? SIDE_DROP_WIDTH : 0 + INNER_KEYLINE
+ OUTER_KEYLINE);
- points[index++] = bounds.y + bounds.height;
+ points[index++] = bottomY;
}
- gc.setClipping(0, bounds.y, parent.getSize().x
+ gc.setClipping(0, onBottom ? bounds.y - header : bounds.y, parent.getSize().x
- (shadowEnabled ? SIDE_DROP_WIDTH : 0 + INNER_KEYLINE
+ OUTER_KEYLINE), bounds.y + bounds.height);// bounds.height
// + 4);
@@ -420,7 +452,7 @@ public class CTabRendering extends CTabFolderRenderer {
gc.setForeground(selectedTabFillColor);
Color gradientTop = null;
Pattern backgroundPattern = null;
- if (!active) {
+ if (!active && !onBottom) {
RGB blendColor = gc.getDevice()
.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW).getRGB();
RGB topGradient = blend(blendColor, parent.getParent()
@@ -440,7 +472,7 @@ public class CTabRendering extends CTabFolderRenderer {
gc.setForeground(tabOutlineColor);
Color gradientLineTop = null;
Pattern foregroundPattern = null;
- if (!active) {
+ if (!active && !onBottom) {
RGB blendColor = gc.getDevice()
.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW).getRGB();
RGB topGradient = blend(blendColor, tabOutlineColor.getRGB(), 40);
@@ -460,7 +492,9 @@ public class CTabRendering extends CTabFolderRenderer {
gc.setForeground(outerKeyline);
gc.drawPolyline(shape);
} else {
- gc.drawLine(startX, 0, endX, 0);
+ if (!onBottom) {
+ gc.drawLine(startX, 0, endX, 0);
+ }
if (gradientTop != null)
gradientTop.dispose();
if (backgroundPattern != null)
@@ -475,79 +509,103 @@ public class CTabRendering extends CTabFolderRenderer {
void drawUnselectedTab(int itemIndex, GC gc, Rectangle bounds, int state) {
if ((state & SWT.HOT) != 0) {
+ int header = shadowEnabled ? 2 : 0;
int width = bounds.width;
+ boolean onBottom = parent.getTabPosition() == SWT.BOTTOM;
int[] points = new int[1024];
int[] inactive = new int[8];
int index = 0, inactive_index = 0;
int radius = cornerSize / 2;
int circX = bounds.x + radius;
- int circY = bounds.y - 1 + radius;
-
+ int circY = onBottom ? bounds.y + bounds.height + 1 - header - radius : bounds.y - 1 + radius;
+ int bottomY = onBottom ? bounds.y - header : bounds.y + bounds.height;
+
int leftIndex = circX;
if (itemIndex == 0) {
if (parent.getSelectionIndex() != 0)
leftIndex -= 1;
points[index++] = leftIndex - radius;
- points[index++] = bounds.y + bounds.height;
+ points[index++] = bottomY;
} else {
points[index++] = bounds.x;
- points[index++] = bounds.y + bounds.height;
+ points[index++] = bottomY;
}
-
+
if (!active) {
System.arraycopy(points, 0, inactive, 0, index);
inactive_index += 2;
}
-
- int[] ltt = drawCircle(leftIndex, circY, radius, LEFT_TOP);
- for (int i = 0; i < ltt.length / 2; i += 2) {
- int tmp = ltt[i];
- ltt[i] = ltt[ltt.length - i - 2];
- ltt[ltt.length - i - 2] = tmp;
- tmp = ltt[i + 1];
- ltt[i + 1] = ltt[ltt.length - i - 1];
- ltt[ltt.length - i - 1] = tmp;
- }
- System.arraycopy(ltt, 0, points, index, ltt.length);
- index += ltt.length;
-
- if (!active) {
- System.arraycopy(ltt, 0, inactive, inactive_index, 2);
- inactive_index += 2;
- }
-
+
int rightIndex = circX - 1;
- int[] rt = drawCircle(rightIndex + width - (radius * 2), circY,
- radius, RIGHT_TOP);
- for (int i = 0; i < rt.length / 2; i += 2) {
- int tmp = rt[i];
- rt[i] = rt[rt.length - i - 2];
- rt[rt.length - i - 2] = tmp;
- tmp = rt[i + 1];
- rt[i + 1] = rt[rt.length - i - 1];
- rt[rt.length - i - 1] = tmp;
- }
- System.arraycopy(rt, 0, points, index, rt.length);
- index += rt.length;
- if (!active) {
- System.arraycopy(rt, rt.length - 4, inactive, inactive_index, 2);
- inactive[inactive_index] -= 1;
- inactive_index += 2;
+ if (!onBottom) {
+ int[] ltt = drawCircle(leftIndex, circY, radius, LEFT_TOP);
+ for (int i = 0; i < ltt.length / 2; i += 2) {
+ int tmp = ltt[i];
+ ltt[i] = ltt[ltt.length - i - 2];
+ ltt[ltt.length - i - 2] = tmp;
+ tmp = ltt[i + 1];
+ ltt[i + 1] = ltt[ltt.length - i - 1];
+ ltt[ltt.length - i - 1] = tmp;
+ }
+ System.arraycopy(ltt, 0, points, index, ltt.length);
+ index += ltt.length;
+
+ if (!active) {
+ System.arraycopy(ltt, 0, inactive, inactive_index, 2);
+ inactive_index += 2;
+ }
+
+ int[] rt = drawCircle(rightIndex + width - (radius * 2), circY,
+ radius, RIGHT_TOP);
+ for (int i = 0; i < rt.length / 2; i += 2) {
+ int tmp = rt[i];
+ rt[i] = rt[rt.length - i - 2];
+ rt[rt.length - i - 2] = tmp;
+ tmp = rt[i + 1];
+ rt[i + 1] = rt[rt.length - i - 1];
+ rt[rt.length - i - 1] = tmp;
+ }
+ System.arraycopy(rt, 0, points, index, rt.length);
+ index += rt.length;
+ if (!active) {
+ System.arraycopy(rt, rt.length - 4, inactive, inactive_index, 2);
+ inactive[inactive_index] -= 1;
+ inactive_index += 2;
+ }
+ } else {
+ int[] ltt = drawCircle(leftIndex, circY, radius, LEFT_BOTTOM);
+ System.arraycopy(ltt, 0, points, index, ltt.length);
+ index += ltt.length;
+
+ if (!active) {
+ System.arraycopy(ltt, 0, inactive, inactive_index, 2);
+ inactive_index += 2;
+ }
+
+ int[] rt = drawCircle(rightIndex + width - (radius * 2), circY,
+ radius, RIGHT_BOTTOM);
+ System.arraycopy(rt, 0, points, index, rt.length);
+ index += rt.length;
+ if (!active) {
+ System.arraycopy(rt, rt.length - 4, inactive, inactive_index, 2);
+ inactive[inactive_index] -= 1;
+ inactive_index += 2;
+ }
+
}
points[index++] = bounds.width + rightIndex - radius;
- points[index++] = bounds.y + bounds.height;
+ points[index++] = bottomY;
if (!active) {
System.arraycopy(points, index - 2, inactive, inactive_index, 2);
inactive[inactive_index] -= 1;
inactive_index += 2;
}
-
- gc.setClipping(points[0], bounds.y, parent.getSize().x
+ gc.setClipping(points[0], onBottom ? bounds.y - header : bounds.y, parent.getSize().x
- (shadowEnabled ? SIDE_DROP_WIDTH : 0 + INNER_KEYLINE
- + OUTER_KEYLINE), bounds.y + bounds.height);// bounds.height
- // + 4);
+ + OUTER_KEYLINE), bounds.y + bounds.height);
+
gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
int[] tmpPoints = new int[index];
System.arraycopy(points, 0, tmpPoints, 0, index);
@@ -913,3 +971,4 @@ public class CTabRendering extends CTabFolderRenderer {
this.active = active;
}
}
+

Back to the top