diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java index 4925d3b63d81..8debcab2ad4f 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java @@ -235,7 +235,7 @@ public class JBTabsImpl extends JComponent @Override public void mouseWheelMoved(MouseWheelEvent e) { if (mySingleRowLayout.myLastSingRowLayout != null) { - mySingleRowLayout.scroll(e.getUnitsToScroll() * 10); + mySingleRowLayout.scroll(e.getUnitsToScroll() * mySingleRowLayout.getScrollUnitIncrement()); revalidateAndRepaint(false); } } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/ScrollableSingleRowLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/ScrollableSingleRowLayout.java index afc6a014f825..20ef48854089 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/ScrollableSingleRowLayout.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/ScrollableSingleRowLayout.java @@ -60,6 +60,17 @@ public class ScrollableSingleRowLayout extends SingleRowLayout { myScrollSelectionInViewPending = true; } + public int getScrollUnitIncrement() { + if (myLastSingRowLayout != null) { + final List visibleInfos = myLastSingRowLayout.myVisibleInfos; + if (visibleInfos.size() > 0) { + final TabInfo info = visibleInfos.get(0); + return getStrategy().getScrollUnitIncrement(myTabs.myInfo2Label.get(info)); + } + } + return 0; + } + private void doScrollSelectionInView(SingleRowPassInfo passInfo) { int offset = -myScrollOffset; for (TabInfo info : passInfo.myVisibleInfos) { @@ -68,8 +79,11 @@ public class ScrollableSingleRowLayout extends SingleRowLayout { if (offset < 0) { scroll(offset); } - else if (offset + length > passInfo.toFitLength - getStrategy().getMoreRectAxisSize()) { - scroll(offset + length - passInfo.toFitLength + getStrategy().getMoreRectAxisSize()); + else { + final int maxLength = passInfo.toFitLength - getStrategy().getMoreRectAxisSize(); + if (offset + length > maxLength) { + scroll(offset + length - maxLength); + } } break; } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java index b3f430022255..02e751d09718 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayout.java @@ -132,6 +132,10 @@ public class SingleRowLayout extends TabLayout { public void scroll(int units) { } + public int getScrollUnitIncrement() { + return 0; + } + public void scrollSelectionInView(List visibleInfos) { } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayoutStrategy.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayoutStrategy.java index d5a0abf41418..eef01235bbf2 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayoutStrategy.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/singleRow/SingleRowLayoutStrategy.java @@ -80,6 +80,14 @@ public abstract class SingleRowLayoutStrategy { */ public abstract boolean drawPartialOverflowTabs(); + /** + * Return the change of scroll offset for every unit of mouse wheel scrolling. + * + * @param label the first visible tab label + * @return the scroll amount + */ + public abstract int getScrollUnitIncrement(TabLabel label); + abstract static class Horizontal extends SingleRowLayoutStrategy { protected Horizontal(final SingleRowLayout layout) { super(layout); @@ -140,6 +148,11 @@ public abstract class SingleRowLayoutStrategy { public boolean drawPartialOverflowTabs() { return true; } + + @Override + public int getScrollUnitIncrement(TabLabel label) { + return 10; + } } static class Top extends Horizontal { @@ -302,6 +315,11 @@ public abstract class SingleRowLayoutStrategy { public boolean drawPartialOverflowTabs() { return false; } + + @Override + public int getScrollUnitIncrement(TabLabel label) { + return label.getPreferredSize().height; + } } static class Left extends Vertical {