private void drawCustomBackground(GC gc, Rectangle bounds, int state) { boolean selected = (state & SWT.SELECTED) != 0; Color defaultBackground = selected ? parent.getSelectionBackground() : parent.getBackground(); boolean vertical = selected ? parentWrapper.isSelectionGradientVertical() : parentWrapper.isGradientVertical(); Rectangle partHeaderBounds = computeTrim(PART_HEADER, state, bounds.x, bounds.y, bounds.width, bounds.height); drawUnselectedTabBackground(gc, partHeaderBounds, state, vertical, defaultBackground); drawTabBackground(gc, partHeaderBounds, state, vertical, defaultBackground); }
int[] ltt = drawCircle(circX, circY, radius, CirclePart.LEFT_TOP); System.arraycopy(ltt, 0, points, index, ltt.length); index += ltt.length; int[] lbb = drawCircle(circX, circY + height - (radius * 2), radius, CirclePart.LEFT_BOTTOM); System.arraycopy(lbb, 0, points, index, lbb.length); index += lbb.length; int[] rb = drawCircle(circX + width - (radius * 2), circY + height - (radius * 2), radius, CirclePart.RIGHT_BOTTOM); System.arraycopy(rb, 0, points, index, rb.length); index += rb.length; int[] rt = drawCircle(circX + width - (radius * 2), circY, radius, CirclePart.RIGHT_TOP); System.arraycopy(rt, 0, points, index, rt.length); index += rt.length; drawShadow(display, bounds, gc);
this.drawCustomBackground(gc, bounds, state); return; case PART_BODY: this.drawTabBody(gc, bounds); return; case PART_HEADER: this.drawTabHeader(gc, bounds, state); this.drawCorners(gc, bounds); return; default: return; if ((state & SWT.SELECTED) != 0) { drawSelectedTab(part, gc, bounds); state &= ~SWT.BACKGROUND; super.draw(part, state, bounds, gc); } else { drawUnselectedTab(part, gc, bounds, state); if ((state & SWT.HOT) == 0 && !active) { gc.setAlpha(0x7f);
this.drawTabBody(gc, bounds, state); return; case PART_HEADER: this.drawTabHeader(gc, bounds, state); return; default: return; if ((state & SWT.SELECTED) != 0) { drawSelectedTab(part, gc, bounds, state); state &= ~SWT.BACKGROUND; super.draw(part, state, bounds, gc); } else { drawUnselectedTab(part, gc, bounds, state); if ((state & SWT.HOT) == 0 && !active) { gc.setAlpha(0x7f);
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; int[] ltt = drawCircle(circX, circY, radius, CirclePart.left(onBottom)); int startX = ltt[6]; if (!onBottom) { mirrorCirclePoints(ltt); int[] rt = drawCircle(circX + width - (radius * 2), circY, radius, CirclePart.right(onBottom)); int endX = rt[rt.length - 4]; if (!onBottom) { mirrorCirclePoints(rt); setSelectedTabFill(gc.getDevice().getSystemColor(SWT.COLOR_WHITE)); if (!active && !onBottom) { 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,
Rectangle trim = computeTrim(PART_HEADER, state, 0, 0, 0, 0); trim.width = bounds.width - trim.width; draw(PART_BACKGROUND, SWT.NONE, trim, gc); int[] ltt = drawCircle(circX + 1, circY + 1, radius, CirclePart.LEFT_TOP); System.arraycopy(ltt, 0, points, index, ltt.length); index += ltt.length; int[] lbb = drawCircle(circX + 1, circY + height - (radius * 2) - 2, radius, CirclePart.LEFT_BOTTOM); System.arraycopy(lbb, 0, points, index, lbb.length); index += lbb.length; int[] rb = drawCircle(circX + width - (radius * 2) - 2, circY + height - (radius * 2) - 2, radius, CirclePart.RIGHT_BOTTOM); System.arraycopy(rb, 0, points, index, rb.length); index += rb.length; int[] rt = drawCircle(circX + width - (radius * 2) - 2, circY + 1, radius, CirclePart.RIGHT_TOP); System.arraycopy(rt, 0, points, index, rt.length); index += rt.length;
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; int[] ltt = drawCircle(circX, circY, radius, LEFT_TOP); startX = ltt[6]; for (int i = 0; i < ltt.length / 2; i += 2) { int[] rt = drawCircle(circX + width - (radius * 2), circY, radius, RIGHT_TOP); endX = rt[rt.length - 4]; 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]; RGB blendColor = gc.getDevice() .getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW).getRGB(); RGB topGradient = blend(blendColor, parent.getParent() .getBackground().getRGB(), 40);
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)); 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); convolve(kernel, inPixels, outPixels, width, height, true); convolve(kernel, outPixels, inPixels, height, width, true);
@Override public void setShadowColor(Color color) { this.shadowColor = color; createShadow(parent.getDisplay()); parent.redraw(); }
int[] ltt = drawCircle(leftIndex, circY, radius, CirclePart.left(onBottom)); if (!onBottom) { mirrorCirclePoints(ltt); int[] rt = drawCircle(rightIndex + width - (radius * 2), circY, radius, CirclePart.right(onBottom)); if (!onBottom) { mirrorCirclePoints(rt);
private void drawCutout(GC gc, int x, int y, int radius, CirclePart side) { int centerX = x + (side.isLeft() ? radius : -radius); int centerY = y + (side.isTop() ? radius : -radius); int[] circle = drawCircle(centerX, centerY, radius, side); int[] result = new int[circle.length + 2]; result[0] = x; result[1] = y; int count = circle.length / 2; for (int idx = 0; idx < count; idx++) { int destIdx = idx * 2 + 2; int srcIdx = (count - 1 - idx) * 2; result[destIdx] = circle[srcIdx]; result[destIdx + 1] = circle[srcIdx + 1]; } gc.fillPolygon(result); }
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 = onBottom ? bounds.height - parent.getTabHeight() - 1 - header : -trim.y; draw(PART_BACKGROUND, SWT.NONE, trim, gc); region.dispose(); int[] ltt = drawCircle(circX + 1, circY + 1, radius, LEFT_TOP); System.arraycopy(ltt, 0, points, index, ltt.length); index += ltt.length; int[] lbb = drawCircle(circX + 1, circY + height - (radius * 2) - 2, radius, LEFT_BOTTOM); System.arraycopy(lbb, 0, points, index, lbb.length); index += lbb.length; int[] rb = drawCircle(circX + width - (radius * 2) - 2, circY + height - (radius * 2) - 2, radius, RIGHT_BOTTOM); System.arraycopy(rb, 0, points, index, rb.length); index += rb.length; int[] rt = drawCircle(circX + width - (radius * 2) - 2, circY + 1, radius, RIGHT_TOP); System.arraycopy(rt, 0, points, index, rt.length);
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); convolve(kernel, inPixels, outPixels, width, height, true); convolve(kernel, outPixels, inPixels, height, width, true);
int[] ltt = drawCircle(circX, circY, radius, LEFT_TOP); System.arraycopy(ltt, 0, points, index, ltt.length); index += ltt.length; int[] lbb = drawCircle(circX, circY + height - (radius * 2), radius, LEFT_BOTTOM); System.arraycopy(lbb, 0, points, index, lbb.length); index += lbb.length; int[] rb = drawCircle(circX + width - (radius * 2), circY + height - (radius * 2), radius, RIGHT_BOTTOM); System.arraycopy(rb, 0, points, index, rb.length); index += rb.length; int[] rt = drawCircle(circX + width - (radius * 2), circY, radius, RIGHT_TOP); System.arraycopy(rt, 0, points, index, rt.length); drawShadow(display, bounds, gc);
public void setShadowColor(Color color) { this.shadowColor = color; createShadow(parent.getDisplay()); parent.redraw(); }
int[] ltt = drawCircle(leftIndex, circY, radius, LEFT_TOP); for (int i = 0; i < ltt.length / 2; i += 2) { int tmp = ltt[i]; int[] rt = drawCircle(rightIndex + width - (radius * 2), circY, radius, RIGHT_TOP); for (int i = 0; i < rt.length / 2; i += 2) { int[] ltt = drawCircle(leftIndex, circY, radius, LEFT_BOTTOM); System.arraycopy(ltt, 0, points, index, ltt.length); index += ltt.length; int[] rt = drawCircle(rightIndex + width - (radius * 2), circY, radius, RIGHT_BOTTOM); System.arraycopy(rt, 0, points, index, rt.length);