correct highlighting of hidden tabs in single-row layout

This commit is contained in:
Dmitry Jemerov
2012-02-24 12:05:21 +01:00
parent 92ff49d782
commit fe726c3795
4 changed files with 25 additions and 1 deletions
@@ -544,7 +544,7 @@ public class JBTabsImpl extends JComponent
final JCheckBoxMenuItem item = new JCheckBoxMenuItem(each.getText());
Color color = UIManager.getColor("MenuItem.background");
if (color != null) {
if (lastLayout.toDrop.contains(each)) {
if (mySingleRowLayout.isTabHidden(each)) {
color = new Color((int) (color.getRed() * 0.85f), (int) (color.getGreen() * 0.85f), (int) (color.getBlue() * 0.85f));
}
@@ -19,6 +19,7 @@ import com.intellij.ui.tabs.TabInfo;
import com.intellij.ui.tabs.impl.JBTabsImpl;
import com.intellij.ui.tabs.impl.TabLabel;
import java.awt.*;
import java.util.List;
/**
@@ -112,4 +113,11 @@ public class ScrollableSingleRowLayout extends SingleRowLayout {
label.setActionPanelVisible(true);
return super.applyTabLayout(data, label, length, deltaToFit);
}
@Override
public boolean isTabHidden(TabInfo tabInfo) {
final TabLabel label = myTabs.myInfo2Label.get(tabInfo);
final Rectangle bounds = label.getBounds();
return getStrategy().getMinPosition(bounds) < 0 || bounds.isEmpty();
}
}
@@ -339,6 +339,10 @@ public class SingleRowLayout extends TabLayout {
}
public boolean isTabHidden(TabInfo tabInfo) {
return myLastSingRowLayout.toDrop.contains(tabInfo);
}
public class GhostComponent extends JLabel {
private TabInfo myInfo;
@@ -41,6 +41,8 @@ public abstract class SingleRowLayoutStrategy {
public abstract int getLengthIncrement(final Dimension dimension);
public abstract int getMinPosition(final Rectangle bounds);
public abstract int getMaxPosition(final Rectangle bounds);
protected abstract int getFixedFitLength(final SingleRowPassInfo data);
@@ -106,6 +108,11 @@ public abstract class SingleRowLayoutStrategy {
return myTabs.isEditorTabs() ? labelPrefSize.width < MIN_TAB_WIDTH ? MIN_TAB_WIDTH : labelPrefSize.width : labelPrefSize.width;
}
@Override
public int getMinPosition(Rectangle bounds) {
return (int)bounds.getX();
}
public int getMaxPosition(final Rectangle bounds) {
return (int)bounds.getMaxX();
}
@@ -266,6 +273,11 @@ public abstract class SingleRowLayoutStrategy {
return labelPrefSize.height;
}
@Override
public int getMinPosition(Rectangle bounds) {
return (int) bounds.getMinY();
}
public int getMaxPosition(final Rectangle bounds) {
int maxY = (int)bounds.getMaxY();
return myTabs.isEditorTabs() ? maxY - 1 : maxY;