IDEA-326402 Fix scrolling tab issues and add delay 5 sec for relayout tabs (move to selected tab)

GitOrigin-RevId: e625d1bd9eab3eac5e60b932e9e7865bbe1d38c2
This commit is contained in:
Vera Petrenkova
2024-03-26 16:57:29 +00:00
committed by intellij-monorepo-bot
parent 807fa8bed3
commit 75d6d70526
4 changed files with 12 additions and 6 deletions
@@ -460,6 +460,7 @@ class DefaultScrollBarUI extends ScrollBarUI {
public void mouseReleased(MouseEvent event) {
if (isDragging) updateMouse(event.getX(), event.getY());
if (myScrollBar == null || !myScrollBar.isEnabled()) return;
myScrollBar.setValueIsAdjusting(false);
if (redispatchIfTrackNotClickable(event)) return;
if (SwingUtilities.isRightMouseButton(event)) return;
isDragging = false;
@@ -467,7 +468,6 @@ class DefaultScrollBarUI extends ScrollBarUI {
myScrollTimer.stop();
isValueCached = true;
myCachedValue = myScrollBar.getValue();
myScrollBar.setValueIsAdjusting(false);
repaint();
}
@@ -154,6 +154,8 @@ open class JBTabsImpl(
}
}
private final val RELAYOUT_DELAY = 5000
private val visibleInfos = ArrayList<TabInfo>()
private val infoToPage = HashMap<TabInfo, AccessibleTabPage>()
private val hiddenInfos = HashMap<TabInfo, Int>()
@@ -393,6 +395,8 @@ open class JBTabsImpl(
scrollBarChangeListener = ChangeListener { updateTabsOffsetFromScrollBar() }
}
fun isScrollBarAdjusting(): Boolean = scrollBar.valueIsAdjusting
private fun addMouseMotionAwtListener(parentDisposable: Disposable) {
StartupUiUtil.addAwtListener(object : AWTEventListener {
val afterScroll = Alarm(parentDisposable)
@@ -419,7 +423,7 @@ open class JBTabsImpl(
if (!isMouseInsideTabsArea) {
relayout(false, false)
}
}, 500)
}, RELAYOUT_DELAY)
}
}
}, AWTEvent.MOUSE_MOTION_EVENT_MASK, parentDisposable)
@@ -539,8 +543,10 @@ open class JBTabsImpl(
fun unHover(label: TabLabel) {
if (tabLabelAtMouse === label) {
tabLabelAtMouse = null
label.revalidate()
label.repaint()
Alarm().addRequest({
label.revalidate()
label.repaint()
}, RELAYOUT_DELAY)
}
}
@@ -11,7 +11,7 @@ class ScrollableMultiRowLayout(tabs: JBTabsImpl,
private var scrollOffset: Int = 0
override fun layoutTable(visibleInfos: List<TabInfo>): LayoutPassInfo {
if (!tabs.isMouseInsideTabsArea && !tabs.isHideTabs) {
if (!tabs.isMouseInsideTabsArea && !tabs.isHideTabs && !tabs.isScrollBarAdjusting()) {
scrollToSelectedTab()
}
return super.layoutTable(visibleInfos)
@@ -62,7 +62,7 @@ public final class ScrollableSingleRowLayout extends SingleRowLayout {
}
private void doScrollToSelectedTab(SingleRowPassInfo passInfo) {
if (myTabs.isMouseInsideTabsArea()) {
if (myTabs.isMouseInsideTabsArea() || myTabs.isScrollBarAdjusting()) {
return;
}
int offset = -myScrollOffset;