Skip to content

Commit

Permalink
https://github.com/jeeeyul/eclipse-themes/issues/121
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeeyul committed Mar 13, 2014
1 parent d88f098 commit 2220093
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ class JeeeyulsTabRenderer extends CTabFolderRenderer {
result.width = result.width + settings.margins.x + settings.paddings.x + settings.paddings.width + settings.margins.width

if(tabFolder.onBottom) {
result.y = result.y - settings.paddings.y
result.height = result.height + tabFolder.tabHeight + settings.paddings.y + settings.margins.height + settings.paddings.height
throw new UnsupportedOperationException
} else {
result.y = result.y - tabFolder.tabHeight - settings.paddings.y - 2
result.height = result.height + tabFolder.tabHeight + settings.paddings.y + settings.margins.height + settings.paddings.height + 2
Expand Down Expand Up @@ -348,17 +347,16 @@ class JeeeyulsTabRenderer extends CTabFolderRenderer {
}
]


var repair = newRectangle(settings.margins.x + settings.borderRadius, 0, 0, 0)
repair.union(parent.size.x, parent.tabHeight + 1)

draw(PART_BODY, SWT.FOREGROUND, repair, gc)
}

protected def drawTabBody(int part, int state, Rectangle bounds, GC gc) {
var oldClipping = gc.clipping
gc.clipping = bounds

// Fill Background
if(state.hasFlags(SWT.BACKGROUND)) {
gc.background = tabFolder.parent.background
Expand All @@ -371,13 +369,14 @@ class JeeeyulsTabRenderer extends CTabFolderRenderer {
val path = newTemporaryPath[
if(settings.borderRadius > 0) {
if(parent.onTop) {
val offset = tabArea.getResized(0, -1)
var box = newRectangleWithSize(settings.borderRadius * 2)
moveTo(tabArea.x, parent.tabHeight)
lineTo(tabArea.x + tabArea.width, parent.tabHeight)
box.relocateBottomRightWith(tabArea)
moveTo(offset.x, parent.tabHeight)
lineTo(offset.x + offset.width, parent.tabHeight)
box.relocateBottomRightWith(offset)
lineTo(box.right)
addArc(box, 0, -90)
box.relocateBottomLeftWith(tabArea)
box.relocateBottomLeftWith(offset)
lineTo(box.bottom)
addArc(box, 270, -90)
close()
Expand All @@ -398,10 +397,10 @@ class JeeeyulsTabRenderer extends CTabFolderRenderer {

// Draw Border
if(state.hasFlags(SWT.FOREGROUND) && settings.borderWidth > 0 && settings.borderColors != null && settings.borderPercents != null) {
if(isLinux){
if(isLinux) {
gc.antialias = SWT.OFF
}

val offset = tabArea.getResized(-1, -1).shrink(settings.borderWidth / 2)
val headerOffset = headerArea.getResized(-1, 1)
gc.lineWidth = settings.borderWidth
Expand Down Expand Up @@ -440,7 +439,7 @@ class JeeeyulsTabRenderer extends CTabFolderRenderer {
gc.foreground = settings.borderColors.last.toAutoReleaseColor
gc.draw(bodyPath)
}

gc.clipping = oldClipping
}

Expand Down Expand Up @@ -472,7 +471,7 @@ class JeeeyulsTabRenderer extends CTabFolderRenderer {
val item = tabFolder.getItem(part)

val itemBounds = if(tabFolder.onBottom)
item.bounds.getTranslated(-Math.max(settings.tabSpacing, 0) - settings.borderWidth, -1).getResized(-settings.tabSpacing, 0)
throw new UnsupportedOperationException
else
item.bounds.getResized(-Math.max(settings.tabSpacing, 0), 1)

Expand Down Expand Up @@ -584,50 +583,14 @@ class JeeeyulsTabRenderer extends CTabFolderRenderer {
addArc(corner, 0, 90)
corner.relocateTopLeftWith(outlineOffset)
lineTo(corner.top)
addArc(corner, 90, 90)
lineTo(outlineOffset.x, keyLineY)
if(state.hasFlags(SWT.SELECTED)) {
lineTo(settings.margins.x, keyLineY)
}
} else {
if(state.hasFlags(SWT.SELECTED)) {
moveTo(tabFolder.size.x - settings.margins.width - settings.borderWidth, keyLineY)
lineTo(itemOutlineBounds.bottomRight.x, keyLineY)
} else {
moveTo(outlineOffset.bottomRight.x, keyLineY)
}
lineTo(itemOutlineBounds.topRight)
lineTo(itemOutlineBounds.topLeft)
lineTo(itemOutlineBounds.bottomLeft.x, keyLineY)
if(state.hasFlags(SWT.SELECTED)) {
lineTo(settings.margins.x, keyLineY)
}
}
]
} else {
outline = newTemporaryPath[
var keyLineY = item.bounds.y - 1
if(settings.borderRadius > 0) {
var corner = newRectangle(outlineOffset.topLeft, new Point(settings.borderRadius * 2, settings.borderRadius * 2))
corner.relocateBottomRightWith(outlineOffset)
if(state.hasFlags(SWT.SELECTED)) {
moveTo(tabFolder.size.x - settings.margins.width - settings.borderWidth, keyLineY)
lineTo(itemOutlineBounds.topRight.x, keyLineY)
} else {
moveTo(outlineOffset.topRight.x, keyLineY)
}
lineTo(corner.right)
addArc(corner, 0, -90)

corner.relocateBottomLeftWith(itemOutlineBounds)
lineTo(corner.bottom)
addArc(corner, 270, -90)

lineTo(itemOutlineBounds.x, keyLineY)
if(state.hasFlags(SWT.SELECTED)) {
lineTo(settings.margins.x, keyLineY)
if(settings.borderColors != null && item != parent.firstVisibleItem) {
addArc(corner, 90, 90)
lineTo(outlineOffset.x, keyLineY)
if(state.hasFlags(SWT.SELECTED)) {
lineTo(settings.margins.x, keyLineY)
}
}

} else {
if(state.hasFlags(SWT.SELECTED)) {
moveTo(tabFolder.size.x - settings.margins.width - settings.borderWidth, keyLineY)
Expand All @@ -643,6 +606,8 @@ class JeeeyulsTabRenderer extends CTabFolderRenderer {
}
}
]
} else {
throw new UnsupportedOperationException
}

gc.lineWidth = settings.borderWidth
Expand Down Expand Up @@ -719,7 +684,7 @@ class JeeeyulsTabRenderer extends CTabFolderRenderer {

def protected getShadow() {
if(shadowNinePatch == null || shadowNinePatch.disposed) {
shadowNinePatch = Shadow9PatchFactory.createShadowPatch(settings.shadowColor.toRGB, settings.borderRadius, settings.shadowRadius);
shadowNinePatch = Shadow9PatchFactory.createShadowPatch(settings.shadowColor.toRGB, settings.borderRadius + 3, settings.shadowRadius);
}
return shadowNinePatch;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,27 @@ public int compare(CTabItem o1, CTabItem o2) {

return visibles.get(visibles.size() - 1);
}

public CTabItem getFirstVisibleItem(CTabFolder me) {
List<CTabItem> visibles = new ArrayList<CTabItem>();
for (CTabItem each : me.getItems()) {
if (each.isShowing()) {
visibles.add(each);
}
}

if (visibles.size() == 0) {
return null;
}
Collections.sort(visibles, new Comparator<CTabItem>() {
@Override
public int compare(CTabItem o1, CTabItem o2) {
return o1.getBounds().x - o2.getBounds().x;
}
});

return visibles.get(0);
}

public String setShortenText(CTabItem me, String shortenText) {
return _CTabItem.shortenedText.set(me, shortenText);
Expand Down

0 comments on commit 2220093

Please sign in to comment.