mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
scroll by full tab height when tabs are on the right
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-2
@@ -60,6 +60,17 @@ public class ScrollableSingleRowLayout extends SingleRowLayout {
|
||||
myScrollSelectionInViewPending = true;
|
||||
}
|
||||
|
||||
public int getScrollUnitIncrement() {
|
||||
if (myLastSingRowLayout != null) {
|
||||
final List<TabInfo> 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;
|
||||
}
|
||||
|
||||
@@ -132,6 +132,10 @@ public class SingleRowLayout extends TabLayout {
|
||||
public void scroll(int units) {
|
||||
}
|
||||
|
||||
public int getScrollUnitIncrement() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void scrollSelectionInView(List<TabInfo> visibleInfos) {
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user