*/
package com.intellij.ui.tabs.impl;
-import com.intellij.ui.Gray;
-import com.intellij.util.ui.UIUtil;
+import com.intellij.ui.ColorUtil;
import java.awt.*;
/**
* @author Konstantin Bulenkov
*/
-class DarculaEditorTabsPainter extends JBEditorTabsPainter {
- @Override
- public void doPaintInactive(Graphics2D g2d,
- Rectangle effectiveBounds,
- int x,
- int y,
- int w,
- int h,
- Color tabColor,
- int row,
- int column,
- boolean vertical) {
- if (tabColor != null) {
- g2d.setColor(tabColor);
- g2d.fillRect(x, y, w, h);
- } else {
- g2d.setPaint(UIUtil.getControlColor());
- g2d.fillRect(x, y, w, h);
- }
+@SuppressWarnings("UseJBColor")
+class DarculaEditorTabsPainter extends DefaultEditorTabsPainter {
- g2d.setColor(Gray._0.withAlpha(10));
- g2d.drawRect(x, y, w - 1, h - 1);
+ @Override
+ protected Color getDefaultTabColor() {
+ return new Color(0x515658);
}
@Override
- public void doPaintBackground(Graphics2D g, Rectangle clip, boolean vertical, Rectangle rectangle) {
- g.setColor(UIUtil.getPanelBackground());
- g.fill(clip);
-
- g.setColor(Gray._0.withAlpha(80));
- g.fill(clip);
-
- final int x = rectangle.x;
- final int y = rectangle.y;
- final int h = rectangle.height;
- g.setPaint(UIUtil.getGradientPaint(x, y, Gray._78.withAlpha(160), x, y + h, Gray._78.withAlpha(120)));
- final int w = rectangle.width;
- g.fillRect(x, rectangle.y, w, h + (vertical ? 1 : 0));
-
- if (!vertical) {
- g.setColor(Gray._78);
- g.drawLine(x, rectangle.y, x + w, rectangle.y);
- }
+ public Color getBackgroundColor() {
+ return new Color(0x353536);
}
-
- public void fillSelectionAndBorder(Graphics2D g, JBTabsImpl.ShapeInfo selectedShape, Color tabColor, int x, int y, int height) {
- if (tabColor != null) {
- g.setColor(tabColor);
- g.fill(selectedShape.fillPath.getShape());
-
- g.setPaint(UIUtil.getGradientPaint(x, y, Gray._255.withAlpha(50), x, y + height, Gray._255.withAlpha(0)));
- } else {
- g.setPaint(UIUtil.getGradientPaint(x, y, Gray._85, x, y + height, Gray._60));
- }
-
- g.fill(selectedShape.fillPath.getShape());
-
- g.setColor(Gray._135.withAlpha(90));
- g.draw(selectedShape.fillPath.getShape());
-
- // fix right side due to swing stupidity (fill & draw will occupy different shapes)
- g.draw(selectedShape.labelPath
- .transformLine(selectedShape.labelPath.getMaxX() - selectedShape.labelPath.deltaX(1), selectedShape.labelPath.getY() +
- selectedShape.labelPath.deltaY(1),
- selectedShape.labelPath.getMaxX() - selectedShape.labelPath.deltaX(1), selectedShape.labelPath.getMaxY() -
- selectedShape.labelPath.deltaY(4)));
+ @Override
+ protected Color getInactiveMaskColor() {
+ return ColorUtil.withAlpha(new Color(0x262626), .5);
}
@Override
- public Color getBackgroundColor() {
- //noinspection UseJBColor
- return new Color(0x3C3F41);
+ protected Color getShadowBaseColor() {
+ return new Color(0x242627);
}
}
*/
package com.intellij.ui.tabs.impl;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.ui.ColorUtil;
import com.intellij.ui.Gray;
-import com.intellij.util.ui.UIUtil;
import java.awt.*;
/**
* @author Konstantin Bulenkov
*/
+@SuppressWarnings("UseJBColor")
public class DefaultEditorTabsPainter extends JBEditorTabsPainter {
- private static final int ACTIVE_TAB_SHADOW_HEIGHT = 3;
-
@Override
public void doPaintInactive(Graphics2D g2d,
Rectangle effectiveBounds,
int row,
int column,
boolean vertical) {
- if (tabColor != null) {
- g2d.setPaint(UIUtil.getGradientPaint(x, y, Gray._200, x, y + effectiveBounds.height, Gray._130));
- g2d.fillRect(x, y, w, h);
-
- g2d.setColor(ColorUtil.toAlpha(tabColor, 150));
- g2d.fillRect(x, y, w, h);
- } else {
- g2d.setPaint(UIUtil.getGradientPaint(x, y, Gray._255.withAlpha(180), x, y + effectiveBounds.height, Gray._255.withAlpha(100)));
- g2d.fillRect(x, y, w, h);
- }
-
-
- // Push top row under the navbar or toolbar and have a blink over previous row shadow for 2nd and subsequent rows.
- if (row == 0) {
- g2d.setColor(Gray._200.withAlpha(200));
- }
- else {
- g2d.setColor(Gray._255.withAlpha(100));
- }
-
- g2d.drawLine(x, y, x + w - 1, y);
+ ;
+ g2d.setColor(tabColor != null ? tabColor : getDefaultTabColor());
+ g2d.fillRect(x, y, w, h);
+ g2d.setColor(getInactiveMaskColor());
+ g2d.fillRect(x, y, w, h);
if (!vertical) {
- drawShadow(g2d, x, w, y + h);
+ drawShadowLines(g2d, x, y, w);
}
}
- private static void drawShadow(Graphics2D g, int x, int w, int shadowBottom) {
- int shadowTop = shadowBottom - ACTIVE_TAB_SHADOW_HEIGHT;
- g.setPaint(UIUtil.getGradientPaint(x, shadowTop, Gray.TRANSPARENT,
- x, shadowBottom, Gray._0.withAlpha(30)));
- g.fillRect(x, shadowTop, w, ACTIVE_TAB_SHADOW_HEIGHT);
- }
-
@Override
public void doPaintBackground(Graphics2D g, Rectangle clip, boolean vertical, Rectangle rectangle) {
- g.setColor(UIUtil.getPanelBackground());
+ g.setColor(getBackgroundColor());
g.fill(clip);
-
- g.setColor(Gray._0.withAlpha(80));
- g.fill(clip);
-
- final int x = rectangle.x;
- final int y = rectangle.y;
- g.setPaint(UIUtil.getGradientPaint(x, y, Gray._255.withAlpha(160),
- x, rectangle.y + rectangle.height, Gray._255.withAlpha(120)));
- g.fillRect(x, rectangle.y, rectangle.width, rectangle.height + (vertical ? 1 : 0));
-
if (!vertical) {
- g.setColor(Gray._210);
- g.drawLine(x, rectangle.y, x + rectangle.width, rectangle.y);
-
- drawShadow(g, rectangle.x, rectangle.width, rectangle.y + rectangle.height);
+ drawShadowLines(g, rectangle.x, rectangle.y, rectangle.width);
}
}
- private static Color multiplyColor(Color c) {
- //noinspection UseJBColor
- return new Color(c.getRed() * c.getRed() / 255, c.getGreen() * c.getGreen() / 255, c.getBlue() * c.getBlue() / 255);
+ private void drawShadowLines(Graphics g, int x, int y, int width) {
+ g.setColor(ColorUtil.withAlpha(getShadowBaseColor(), .5));
+ g.drawLine(x, y, x + width, y);
+ g.setColor(ColorUtil.withAlpha(getShadowBaseColor(), .2));
+ g.drawLine(x, y+1, x + width, y+1);
}
public void fillSelectionAndBorder(Graphics2D g, JBTabsImpl.ShapeInfo selectedShape, Color tabColor, int x, int y, int height) {
- if (tabColor != null) {
- g.setColor(multiplyColor(tabColor));
- g.fill(selectedShape.fillPath.getShape());
-
- g.setPaint(UIUtil.getGradientPaint(x, y, Gray._255.withAlpha(150), x, y + height, Gray._255.withAlpha(0)));
- } else {
- g.setPaint(UIUtil.getGradientPaint(x, y, Gray._255, x, y + height, Gray._230));
- }
-
+ g.setColor(tabColor != null ? tabColor : getDefaultTabColor());
g.fill(selectedShape.fillPath.getShape());
-
- g.setColor(Gray._255.withAlpha(180));
g.draw(selectedShape.fillPath.getShape());
-
- // fix right side due to swing stupidity (fill & draw will occupy different shapes)
- g.draw(selectedShape.labelPath
- .transformLine(selectedShape.labelPath.getMaxX() - selectedShape.labelPath.deltaX(1), selectedShape.labelPath.getY() +
- selectedShape.labelPath.deltaY(1),
- selectedShape.labelPath.getMaxX() - selectedShape.labelPath.deltaX(1), selectedShape.labelPath.getMaxY() -
- selectedShape.labelPath.deltaY(4)));
}
@Override
public Color getBackgroundColor() {
- return Gray._142;
+ return Gray._177;
+ }
+
+ protected Color getDefaultTabColor() {
+ return EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground();
+ }
+
+ protected Color getInactiveMaskColor() {
+ return ColorUtil.withAlpha(new Color(0x262626), .2);
+ }
+
+ protected Color getShadowBaseColor() {
+ return new Color(0xbababa);
}
}
super.doPaint(g);
return;
}
- int dimSize = 20;
- int dimStep = 1;
+ int dimSize = 30;
+ int dimStep = 2;
Composite oldComposite = g.getComposite();
Shape oldClip = g.getClip();
try {
for (int x = clip.x + clip.width - dimSize; x < clip.x + clip.width; x+=dimStep) {
g.setClip(x, clip.y, dimStep, clip.height);
- float linear = 1 - ((float)x - (clip.x + clip.width - dimSize)) / dimSize;
- g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(1 - Math.cos(Math.PI * linear)) / 2));
+ g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1 - ((float)x - (clip.x + clip.width - dimSize)) / dimSize));
super.doPaint(g);
}
} finally {
public Insets getInsets() {
Insets insets = super.getInsets();
if (myTabs.isEditorTabs()) {
- int right = insets.right;
if (!Registry.is("editor.use.compressible.tabs")) {
- if (UISettings.getInstance().SHOW_CLOSE_BUTTON) right = 3;
+ if (UISettings.getInstance().SHOW_CLOSE_BUTTON) insets.right = 3;
}
else {
- right = (UISettings.getInstance().SHOW_CLOSE_BUTTON || !UISettings.getInstance().MARK_MODIFIED_TABS_WITH_ASTERISK) ? 3 : 6;
+ insets.right = (UISettings.getInstance().SHOW_CLOSE_BUTTON || !UISettings.getInstance().MARK_MODIFIED_TABS_WITH_ASTERISK) ? 3 : 6;
+ insets.left = 5;
}
- return new Insets(insets.top, insets.left, insets.bottom, right);
+ return new Insets(insets.top, insets.left, insets.bottom, insets.right);
}
return insets;
import com.intellij.ui.tabs.impl.JBTabsImpl;
import com.intellij.ui.tabs.impl.LayoutPassInfo;
import com.intellij.ui.tabs.impl.TabLabel;
+import com.intellij.util.ui.GraphicsUtil;
import java.awt.*;
import java.util.Iterator;
if (firstLabel != null && lastLabel != null) {
data.tabRectangle.x = firstLabel.getBounds().x;
data.tabRectangle.y = firstLabel.getBounds().y;
- data.tabRectangle.width = data.requiredLength;//(int)lastLabel.getBounds().getMaxX() - data.tabRectangle.x;
+ data.tabRectangle.width = data.requiredLength;
data.tabRectangle.height = (int)lastLabel.getBounds().getMaxY() - data.tabRectangle.y;
}
}
@Override
protected void layoutLabelsAndGhosts(SingleRowPassInfo data) {
+ if (myTabs.getPresentation().getTabsPosition() != JBTabsPosition.top
+ && myTabs.getPresentation().getTabsPosition() != JBTabsPosition.bottom) {
+ super.layoutLabelsAndGhosts(data);
+ return;
+ }
+
+ int tabWidth = 0;
boolean layoutStopped = false;
int lengthEstimation = 0;
- boolean needCompression = false;
- if (myTabs.getPresentation().getTabsPosition() == JBTabsPosition.top
- || myTabs.getPresentation().getTabsPosition() == JBTabsPosition.bottom) {
- for (TabInfo eachInfo : data.toLayout) {
- final TabLabel label = myTabs.myInfo2Label.get(eachInfo);
- lengthEstimation += getStrategy().getLengthIncrement(label.getPreferredSize());
+ for (TabInfo eachInfo : data.toLayout) {
+ final TabLabel label = myTabs.myInfo2Label.get(eachInfo);
+ if (tabWidth == 0) {
+ tabWidth = GraphicsUtil.stringWidth("m", label.getLabelComponent().getFont()) * 15;
}
- needCompression = lengthEstimation > data.toFitLength;
+ lengthEstimation += tabWidth;
}
+ double compressionFactor = (double)lengthEstimation / data.toFitLength;
+
int spentLength = 0;
for (Iterator<TabInfo> iterator = data.toLayout.iterator(); iterator.hasNext(); ) {
TabInfo eachInfo = iterator.next();
}
label.setActionPanelVisible(true);
- final Dimension eachSize = label.getPreferredSize();
int length;
- if (needCompression) {
- length = iterator.hasNext() ? (int)(getStrategy().getLengthIncrement(label.getPreferredSize()) * (float)data.toFitLength / lengthEstimation)
+ if (compressionFactor > 1) {
+ length = iterator.hasNext() ? (int)(tabWidth * (float)data.toFitLength / lengthEstimation)
: data.toFitLength - spentLength - data.toLayout.size() / 2;
spentLength += length;
}
else {
- length = getStrategy().getLengthIncrement(eachSize);
+ length = tabWidth;
}
boolean continueLayout = applyTabLayout(data, label, length, 0);
JBTabsImpl.resetLayout(myTabs.myInfo2Label.get(eachInfo));
}
}
+
+ @Override
+ protected boolean applyTabLayout(SingleRowPassInfo data, TabLabel label, int length, int deltaToFit) {
+ boolean result = super.applyTabLayout(data, label, length, deltaToFit);
+ label.setAlignmentToCenter(false);
+ return result;
+ }
}
}
final Icon modifiedIcon;
- if (UISettings.getInstance().MARK_MODIFIED_TABS_WITH_ASTERISK) {
+ if (UISettings.getInstance().MARK_MODIFIED_TABS_WITH_ASTERISK || Registry.is("editor.use.compressible.tabs")) {
modifiedIcon = composite != null && composite.isModified() ? MODIFIED_ICON : GAP_ICON;
count++;
}