[ui] IJPL-206578 Islands: text goes beyond the tab area while scrolling

GitOrigin-RevId: 24450d1bc63ab1415b64517a89dc8b9632a4ba8c
This commit is contained in:
Pavel Porvatov
2025-11-01 00:21:46 +00:00
committed by intellij-monorepo-bot
parent 9555a0588f
commit 205c4eb7a9
7 changed files with 39 additions and 15 deletions
@@ -16,4 +16,6 @@ open class IslandsPainterProvider {
open fun createCommonTabPainter(): TabPainterAdapter? = null
open fun useMacScrollBar(): Boolean = false
open fun isTabOccupiesWholeHeight(): Boolean = true
}
@@ -302,7 +302,8 @@ open class TabLabel @Internal constructor(
protected fun paintFadeout(g: Graphics) {
val g2d = g.create() as Graphics2D
try {
val tabBg = effectiveBackground
val isTabOccupiesWholeHeight = IslandsPainterProvider.getInstance()?.isTabOccupiesWholeHeight() != false
val tabBg = if (isTabOccupiesWholeHeight) effectiveBackground else tabs.tabPainter.getBackgroundColor()
val transparent = ColorUtil.withAlpha(tabBg, 0.0)
val borderThickness = tabs.borderThickness
val width = JBUI.scale(MathUtil.clamp(Registry.intValue("ide.editor.tabs.fadeout.width", 10), 1, 200))
@@ -318,8 +319,10 @@ open class TabLabel @Internal constructor(
val contentRect = labelPlaceholder.bounds
// Fadeout for right side before pin/close button (needed only in side placements and in squeezing layout)
if (contentRect.width < labelPlaceholder.preferredSize.width + tabs.tabHGap) {
val rightRect = Rectangle(contentRect.x + contentRect.width - width, borderThickness, width, rect.height - 2 * borderThickness)
paintGradientRect(g2d, rightRect, transparent, tabBg)
if (isTabOccupiesWholeHeight) { // Can be implemented later for isTabOccupiesWholeHeight
val rightRect = Rectangle(contentRect.x + contentRect.width - width, borderThickness, width, rect.height - 2 * borderThickness)
paintGradientRect(g2d, rightRect, transparent, tabBg)
}
}
else if (tabs.effectiveLayout.isScrollable && rect.width < preferredSize.width + tabs.tabHGap
) {
@@ -62,8 +62,6 @@ open class InternalUICustomization {
open val debuggerTabPainterAdapter: TabPainterAdapter? = null
open val shouldPaintEditorFadeout: Boolean = true
open val toolWindowUIDecorator: ToolWindowUIDecorator = ToolWindowUIDecorator()
open val toolWindowTabPainter: JBTabPainter = JBTabPainter.TOOL_WINDOW
@@ -77,6 +75,8 @@ open class InternalUICustomization {
open val isMainMenuBottomBorder: Boolean = true
open val isTabOccupiesWholeHeight: Boolean = true
internal open fun configureToolWindowPane(toolWindowPaneParent: JComponent, buttonManager: ToolWindowButtonManager) {}
/**
@@ -13,4 +13,9 @@ internal class IslandsInternalPainterProvider : IslandsPainterProvider() {
override fun useMacScrollBar(): Boolean {
return InternalUICustomization.getInstance()?.isMacScrollBar == true
}
override fun isTabOccupiesWholeHeight(): Boolean {
val customization = InternalUICustomization.getInstance()
return customization?.isTabOccupiesWholeHeight ?: super.isTabOccupiesWholeHeight()
}
}
@@ -43,7 +43,8 @@ internal class IslandsTabPainterAdapter(isDefault: Boolean, debugger: Boolean, v
val active = tabs.isActiveTabs(info)
val hovered = tabs.isHoveredTab(label)
val rect = Rectangle(label.size)
val tabLabelWidth = calcTabLabelWidth(label)
val rect = Rectangle(tabLabelWidth, label.height)
val g2 = g.create() as Graphics2D
try {
@@ -56,6 +57,24 @@ internal class IslandsTabPainterAdapter(isDefault: Boolean, debugger: Boolean, v
g2.dispose()
}
}
/**
* label.preferredSize doesn't work for squeeze mode
*/
private fun calcTabLabelWidth(label: TabLabel): Int {
var rect : Rectangle? = null
for (component in label.components) {
if (rect == null) {
rect = component.bounds
} else {
rect = rect.union(component.bounds)
}
}
val contentWidth = if (rect == null) 0 else rect.x + rect.width
return contentWidth + label.insets.right
}
}
private class IslandsTabTheme : TabTheme {
@@ -129,16 +129,14 @@ internal class IslandsUICustomization : InternalUICustomization() {
return !isManyIslandEnabled
}
override val shouldPaintEditorFadeout: Boolean
get() {
return !isManyIslandEnabled
}
override val isMainMenuBottomBorder: Boolean
get() {
return !isManyIslandEnabled
}
override val isTabOccupiesWholeHeight: Boolean
get() = !isManyIslandEnabled
override val toolWindowUIDecorator: ToolWindowUIDecorator = object : ToolWindowUIDecorator() {
override fun decorateAndReturnHolder(divider: JComponent, child: JComponent, toolWindow: ToolWindow, originalBorderBuilder: () -> Border): JComponent {
return XNextIslandHolder().apply {
@@ -43,7 +43,6 @@ import com.intellij.ui.docking.DockableContent
import com.intellij.ui.docking.DragSession
import com.intellij.ui.docking.impl.DockManagerImpl.Companion.isNorthPanelAvailable
import com.intellij.ui.tabs.*
import com.intellij.ui.tabs.JBTabPainter.Companion.DEFAULT
import com.intellij.ui.tabs.TabInfo.DragOutDelegate
import com.intellij.ui.tabs.UiDecorator.UiDecoration
import com.intellij.ui.tabs.impl.*
@@ -741,9 +740,7 @@ private class EditorTabLabel(info: TabInfo, tabs: JBTabsImpl) : TabLabel(tabs, i
get() = UISettings.getInstance().closeTabButtonOnTheRight
override fun shouldPaintFadeout(): Boolean {
val customization = InternalUICustomization.getInstance()
return super.shouldPaintFadeout() && Registry.`is`("ide.editor.tabs.show.fadeout", true) &&
(customization == null || customization.shouldPaintEditorFadeout)
return super.shouldPaintFadeout() && Registry.`is`("ide.editor.tabs.show.fadeout", true)
}
override fun editLabelForeground(baseForeground: Color?): Color? {