* 2016-05-04 GiWoong Kim giwoong.kim@samsung.com
* Modifications by S-Core Co., Ltd.
* 1. Give a Tizen identity (based on CTabRendering.java)
+ * 2. Remove unnecessary lines
*/
package org.eclipse.e4.ui.workbench.renderers.swt;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.graphics.Pattern;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ToolBar;
/**
// keylines
final static int OUTER_KEYLINE = 1;
- final static int INNER_KEYLINE = 0;
- final static int TOP_KEYLINE = 0;
// Item Constants
static final int ITEM_TOP_MARGIN = 2;
int[] shape;
- Image shadowImage;
-
int cornerSize = 14;
- Color shadowColor;
Color outerKeyline, innerKeyline;
Color[] activeToolbar;
int[] activePercents;
@Override
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;
+ int borderTop = OUTER_KEYLINE;
+ int borderBottom = OUTER_KEYLINE;
int marginWidth = parent.marginWidth;
int marginHeight = parent.marginHeight;
switch (part) {
height += tabHeight + (cornerSize / 4) + borderBottom
+ borderTop;
} else {
- x = x - marginWidth - OUTER_KEYLINE - INNER_KEYLINE - (cornerSize / 2);
- width = width + 2 * OUTER_KEYLINE + 2 * INNER_KEYLINE + 2
+ x = x - marginWidth - OUTER_KEYLINE - (cornerSize / 2);
+ width = width + 2 * OUTER_KEYLINE + 2
* marginWidth + cornerSize;
int tabHeight = parent.getTabHeight() + 1; // TODO: Figure out
// what
}
break;
case PART_HEADER:
- x = x - (INNER_KEYLINE + OUTER_KEYLINE);
- width = width + 2 * (INNER_KEYLINE + OUTER_KEYLINE);
+ x = x - OUTER_KEYLINE;
+ width = width + 2 * OUTER_KEYLINE;
break;
case PART_BORDER:
- x = x - INNER_KEYLINE - OUTER_KEYLINE - (cornerSize / 4);
- width = width + 2 * (INNER_KEYLINE + OUTER_KEYLINE)
- + cornerSize / 2;
+ x = x - OUTER_KEYLINE - (cornerSize / 4);
+ width = width + 2 * OUTER_KEYLINE + cornerSize / 2;
height = height + borderTop + borderBottom;
y = y - borderTop;
@Override
protected void dispose() {
- if (shadowImage != null && !shadowImage.isDisposed()) {
- shadowImage.dispose();
- shadowImage = null;
- }
super.dispose();
}
}
void drawTabHeader(GC gc, Rectangle bounds, int state) {
- // gc.setClipping(bounds.x, bounds.y, bounds.width,
- // parent.getTabHeight() + 1);
-
int[] points = new int[1024];
int index = 0;
int radius = cornerSize / 2;
int marginWidth = parent.marginWidth;
int marginHeight = parent.marginHeight;
- int delta = INNER_KEYLINE + OUTER_KEYLINE + 2 * marginWidth;
+ int delta = OUTER_KEYLINE + 2 * marginWidth;
int width = bounds.width - delta;
- int height = bounds.height - INNER_KEYLINE - OUTER_KEYLINE - 2 * marginHeight;
+ int height = bounds.height - OUTER_KEYLINE - 2 * marginHeight;
int circX = bounds.x + delta / 2 + radius;
int circY = bounds.y + radius;
int[] tempPoints = new int[index];
System.arraycopy(points, 0, tempPoints, 0, index);
- if (outerKeyline == null)
+ /* draw outerlines */
+ if (outerKeyline == null) {
outerKeyline = gc.getDevice().getSystemColor(SWT.COLOR_BLACK);
+ }
gc.setForeground(outerKeyline);
/* Tizen */
- // gc.drawPolyline(shape);
-
/*
* FIXME: This polyline is related to 'swt-outer-keyline-color' CSS
* property. Condition should be set based on pseudo-state. But,
int radius = cornerSize / 2;
int marginWidth = parent.marginWidth;
int marginHeight = parent.marginHeight;
- int delta = INNER_KEYLINE + OUTER_KEYLINE + 2 * marginWidth;
+ int delta = OUTER_KEYLINE + 2 * marginWidth;
int width = bounds.width - delta;
- int height = Math.max(parent.getTabHeight() + INNER_KEYLINE + OUTER_KEYLINE,
- bounds.height - INNER_KEYLINE - OUTER_KEYLINE - 2 * marginHeight);
+ int height = Math.max(parent.getTabHeight() + OUTER_KEYLINE, bounds.height - OUTER_KEYLINE - 2 * marginHeight);
int circX = bounds.x + delta / 2 + radius;
int circY = bounds.y + radius;
System.arraycopy(ltt, 0, points, index, ltt.length);
index += ltt.length;
- int[] lbb = drawCircle(circX, circY + height - (radius * 2), radius,
- LEFT_BOTTOM);
+ int[] lbb = drawCircle(circX, circY + height - (radius * 2), radius, LEFT_BOTTOM);
System.arraycopy(lbb, 0, points, index, lbb.length);
index += lbb.length;
System.arraycopy(rb, 0, points, index, rb.length);
index += rb.length;
- int[] rt = drawCircle(circX + width - (radius * 2), circY, radius,
- RIGHT_TOP);
+ int[] rt = drawCircle(circX + width - (radius * 2), circY, radius, RIGHT_TOP);
System.arraycopy(rt, 0, points, index, rt.length);
index += rt.length;
points[index++] = circX;
}
void drawSelectedTab(int itemIndex, GC gc, Rectangle bounds, int state) {
- if (parent.getSingle() && parent.getItem(itemIndex).isShowing())
+ if (parent.getSingle() && parent.getItem(itemIndex).isShowing()) {
return;
+ }
int width = bounds.width;
int[] points = new int[1024];
int circY = bounds.y - 1 + radius;
int selectionX1, selectionY1, selectionX2, selectionY2;
int bottomY = bounds.y + bounds.height;
- if (itemIndex == 0
- && bounds.x == -computeTrim(CTabFolderRenderer.PART_HEADER,
- SWT.NONE, 0, 0, 0, 0).x) {
+ if (itemIndex == 0 && bounds.x == -computeTrim(CTabFolderRenderer.PART_HEADER, SWT.NONE, 0, 0, 0, 0).x) {
circX -= 1;
points[index++] = circX - radius;
points[index++] = bottomY;
points[index++] = selectionY1 = bottomY;
} else {
if (active) {
- points[index++] = INNER_KEYLINE + OUTER_KEYLINE;
+ points[index++] = OUTER_KEYLINE;
points[index++] = bottomY;
}
points[index++] = selectionX1 = bounds.x;
points[index++] = selectionY2 = bounds.y + bounds.height;
if (active) {
- points[index++] = parent.getSize().x - (INNER_KEYLINE + OUTER_KEYLINE);
+ points[index++] = parent.getSize().x - OUTER_KEYLINE;
points[index++] = bottomY;
}
- gc.setClipping(0, bounds.y,
- parent.getSize().x - (INNER_KEYLINE + OUTER_KEYLINE),
- bounds.y + bounds.height);// bounds.height
+ gc.setClipping(0, bounds.y, parent.getSize().x - OUTER_KEYLINE, bounds.y + bounds.height);
- Pattern backgroundPattern = null;
if (selectedTabFillColors == null) {
setSelectedTabFill(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
}
- if (selectedTabFillColors.length == 1) {
- gc.setBackground(selectedTabFillColors[0]);
- gc.setForeground(selectedTabFillColors[0]);
- } else if (selectedTabFillColors.length == 2) {
- // for now we support the 2-colors gradient for selected tab
- backgroundPattern = new Pattern(gc.getDevice(), 0, 0, 0,
- bounds.height + 1, selectedTabFillColors[0],
- selectedTabFillColors[1]);
- gc.setBackgroundPattern(backgroundPattern);
- gc.setForeground(selectedTabFillColors[1]);
- }
+ gc.setBackground(selectedTabFillColors[0]);
+ gc.setForeground(selectedTabFillColors[0]);
int[] tmpPoints = new int[index];
System.arraycopy(points, 0, tmpPoints, 0, index);
gc.fillPolygon(tmpPoints);
/* Tizen */
- Color prevColor = gc.getForeground();
-
gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WHITE));
gc.fillRectangle(selectionX1, 0, selectionX2 - selectionX1, selectionY1);
- gc.setForeground(prevColor);
+ gc.setForeground(selectedTabFillColors[0]);
/* ===== */
gc.drawLine(selectionX1, selectionY1, selectionX2, selectionY2);
if (tabOutlineColor == null)
tabOutlineColor = gc.getDevice().getSystemColor(SWT.COLOR_BLACK);
gc.setForeground(tabOutlineColor);
- Color gradientLineTop = null;
- Pattern foregroundPattern = null;
- if (!active) {
- RGB blendColor = gc.getDevice()
- .getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW).getRGB();
- RGB topGradient = blend(blendColor, tabOutlineColor.getRGB(), 40);
- gradientLineTop = new Color(gc.getDevice(), topGradient);
- foregroundPattern = new Pattern(gc.getDevice(), 0, 0, 0,
- bounds.height + 1, gradientLineTop, gc.getDevice()
- .getSystemColor(SWT.COLOR_WHITE));
- gc.setForegroundPattern(foregroundPattern);
- }
+
/* Tizen */
// gc.drawPolyline(tmpPoints);
if (unselectedTabSeparator) {
gc.setClipping(rect);
if (active) {
- if (outerKeyline == null)
+ if (outerKeyline == null) {
outerKeyline = gc.getDevice().getSystemColor(SWT.COLOR_RED);
+ }
gc.setForeground(outerKeyline);
/* Tizen */
- // gc.drawPolyline(shape);
-
/*
* FIXME: This polyline is related to 'swt-outer-keyline-color' CSS
* property. Condition should be set based on pseudo-state. But,
/* Tizen */
if (selectedTabUnderline) {
// draw a underline
- prevColor = gc.getForeground();
+ Color prevColor = gc.getForeground();
int prevLineWidth = gc.getLineWidth();
gc.setForeground(JFaceResources.getColorRegistry().get(TIZEN_POINT_COLOR_1_KEY));
gc.setForeground(prevColor);
}
/* ===== */
-
- if (backgroundPattern != null) {
- backgroundPattern.dispose();
- }
- if (gradientLineTop != null) {
- gradientLineTop.dispose();
- }
- if (foregroundPattern != null) {
- foregroundPattern.dispose();
- }
}
void drawUnselectedTab(int itemIndex, GC gc, Rectangle bounds, int state) {
inactive_index += 2;
}
gc.setClipping(points[0], bounds.y,
- parent.getSize().x - (INNER_KEYLINE + OUTER_KEYLINE), bounds.y + bounds.height);
+ parent.getSize().x - OUTER_KEYLINE, bounds.y + bounds.height);
Color color = hotUnselectedTabsColorBackground;
if (color == null) {
Rectangle rect = null;
gc.setClipping(rect);
- if (outerKeyline == null)
+ if (outerKeyline == null) {
outerKeyline = gc.getDevice().getSystemColor(SWT.COLOR_BLACK);
+ }
// gc.setForeground(outerKeyline);
// gc.drawPolyline(shape);
}
return Math.min(255, b);
}
- void createShadow(final Display display) {
- if (shadowImage != null) {
- shadowImage.dispose();
- shadowImage = null;
- }
- ImageData data = new ImageData(60, 60, 32, new PaletteData(0xFF0000,
- 0xFF00, 0xFF));
- Image tmpImage = shadowImage = new Image(display, data);
- GC gc = new GC(tmpImage);
- if (shadowColor == null)
- shadowColor = gc.getDevice().getSystemColor(SWT.COLOR_GRAY);
- gc.setBackground(shadowColor);
- drawTabBody(gc, new Rectangle(0, 0, 60, 60), SWT.None);
- ImageData blured = blur(tmpImage, 5, 25);
- shadowImage = new Image(display, blured);
- tmpImage.dispose();
- }
-
public ImageData blur(Image src, int radius, int sigma) {
float[] kernel = create1DKernel(radius, sigma);
@Override
public void setShadowColor(Color color) {
- this.shadowColor = color;
- createShadow(parent.getDisplay());
+ /* do nothing */
parent.redraw();
}