mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[ui] IJPL-210503 Islands: Increase height and insets of tabs in vertical compact mode
GitOrigin-RevId: c2f212381cc153ba57eb1a0a60fb540a2c5955a1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c87eaf147c
commit
f7e71265d1
@@ -3,7 +3,9 @@ package com.intellij.ui.tabs.impl
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.serviceOrNull
|
||||
import com.intellij.ui.tabs.JBTabsPosition
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.awt.Insets
|
||||
|
||||
@ApiStatus.Experimental
|
||||
@ApiStatus.Internal
|
||||
@@ -18,4 +20,6 @@ open class IslandsPainterProvider {
|
||||
open fun useMacScrollBar(): Boolean = false
|
||||
|
||||
open fun isTabOccupiesWholeHeight(): Boolean = true
|
||||
|
||||
open fun getSingleRowTabInsets(tabsPosition: JBTabsPosition): Insets? = null
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.intellij.ui.tabs.TabInfo;
|
||||
import com.intellij.ui.tabs.TabsUtil;
|
||||
import com.intellij.ui.tabs.impl.*;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -151,6 +152,12 @@ public abstract class SingleRowLayout extends TabLayout {
|
||||
data.insets.left += tabs.getFirstTabOffset();
|
||||
}
|
||||
|
||||
IslandsPainterProvider provider = IslandsPainterProvider.getInstance();
|
||||
var additionalInsets = provider == null ? null : provider.getSingleRowTabInsets(tabs.getTabsPosition());
|
||||
if (additionalInsets != null) {
|
||||
data.insets = JBInsets.addInsets(data.insets, additionalInsets);
|
||||
}
|
||||
|
||||
JBTabsImpl.Toolbar selectedForeToolbar = tabs.infoToForeToolbar.get(selected);
|
||||
data.hfToolbar =
|
||||
new WeakReference<>(
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@ import com.intellij.openapi.application.impl.InternalUICustomization;
|
||||
import com.intellij.openapi.ui.JBPopupMenu;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.JBTabsPaneImpl;
|
||||
import com.intellij.ui.RelativeFont;
|
||||
import com.intellij.ui.paint.LinePainter2D;
|
||||
import com.intellij.ui.paint.RectanglePainter2D;
|
||||
@@ -300,7 +301,8 @@ public class DarculaTabbedPaneUI extends BasicTabbedPaneUI {
|
||||
@Override
|
||||
protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) {
|
||||
InternalUICustomization customization = InternalUICustomization.getInstance();
|
||||
if (customization != null && customization.paintTab(g, new Rectangle(x, y, w, h), tabIndex == hoverTab, isSelected)) {
|
||||
if (customization != null && customization.paintTab(g, JBTabsPaneImpl.swingConstantToEnum(tabPlacement), new Rectangle(x, y, w, h),
|
||||
tabIndex == hoverTab, isSelected)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -21,6 +21,7 @@ import com.intellij.ui.BorderPainter
|
||||
import com.intellij.ui.JBColor
|
||||
import com.intellij.ui.mac.WindowTabsComponent
|
||||
import com.intellij.ui.tabs.JBTabPainter
|
||||
import com.intellij.ui.tabs.JBTabsPosition
|
||||
import com.intellij.ui.tabs.impl.JBTabsImpl
|
||||
import com.intellij.ui.tabs.impl.TabLabel
|
||||
import com.intellij.ui.tabs.impl.TabPainterAdapter
|
||||
@@ -167,11 +168,13 @@ open class InternalUICustomization {
|
||||
|
||||
open fun paintProjectTab(frame: JFrame, label: TabLabel, g: Graphics, tabs: JBTabsImpl, selected: Boolean, index: Int, lastIndex: Int): Boolean = false
|
||||
|
||||
open fun paintTab(g: Graphics, rect: Rectangle, hovered: Boolean, selected: Boolean): Boolean = false
|
||||
open fun paintTab(g: Graphics, position: JBTabsPosition, rect: Rectangle, hovered: Boolean, selected: Boolean): Boolean = false
|
||||
|
||||
open fun paintTabBorder(g: Graphics, tabPlacement: Int, tabIndex: Int, x: Int, y: Int, w: Int, h: Int, isSelected: Boolean): Boolean = false
|
||||
|
||||
open fun getTabLayoutStart(layout: ContentLayout): Int = 0
|
||||
|
||||
open fun getSingleRowTabInsets(tabsPosition: JBTabsPosition): Insets? = null
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
|
||||
+7
@@ -2,8 +2,10 @@
|
||||
package com.intellij.openapi.application.impl.islands
|
||||
|
||||
import com.intellij.openapi.application.impl.InternalUICustomization
|
||||
import com.intellij.ui.tabs.JBTabsPosition
|
||||
import com.intellij.ui.tabs.impl.IslandsPainterProvider
|
||||
import com.intellij.ui.tabs.impl.TabPainterAdapter
|
||||
import java.awt.Insets
|
||||
|
||||
internal class IslandsInternalPainterProvider : IslandsPainterProvider() {
|
||||
override fun createCommonTabPainter(): TabPainterAdapter? {
|
||||
@@ -18,4 +20,9 @@ internal class IslandsInternalPainterProvider : IslandsPainterProvider() {
|
||||
val customization = InternalUICustomization.getInstance()
|
||||
return customization?.isTabOccupiesWholeHeight ?: super.isTabOccupiesWholeHeight()
|
||||
}
|
||||
|
||||
override fun getSingleRowTabInsets(tabsPosition: JBTabsPosition): Insets? {
|
||||
val customization = InternalUICustomization.getInstance()
|
||||
return if (customization == null) super.getSingleRowTabInsets(tabsPosition) else customization.getSingleRowTabInsets(tabsPosition)
|
||||
}
|
||||
}
|
||||
+14
-6
@@ -52,7 +52,7 @@ internal class IslandsTabPainterAdapter(isDefault: Boolean, debugger: Boolean, v
|
||||
GraphicsUtil.setupAAPainting(g2)
|
||||
|
||||
tabs.setFirstTabOffset(JBUI.scale(3))
|
||||
(tabPainter as IslandsTabPainter).paintTab(g2, rect, info.tabColor, active, hovered, selected)
|
||||
(tabPainter as IslandsTabPainter).paintTab(g2, tabs.tabsPosition, rect, info.tabColor, active, hovered, selected)
|
||||
}
|
||||
finally {
|
||||
g2.dispose()
|
||||
@@ -128,11 +128,11 @@ internal open class IslandsTabPainter(isDefault: Boolean, isToolWindow: Boolean)
|
||||
override fun getBackgroundColor(): Color = myTheme.background!!
|
||||
|
||||
override fun paintTab(position: JBTabsPosition, g: Graphics2D, rect: Rectangle, borderThickness: Int, tabColor: Color?, active: Boolean, hovered: Boolean) {
|
||||
paintTab(g, rect, tabColor, active, hovered, false)
|
||||
paintTab(g, position, rect, tabColor, active, hovered, false)
|
||||
}
|
||||
|
||||
override fun paintSelectedTab(position: JBTabsPosition, g: Graphics2D, rect: Rectangle, borderThickness: Int, tabColor: Color?, active: Boolean, hovered: Boolean) {
|
||||
paintTab(g, rect, tabColor, active, hovered, true)
|
||||
paintTab(g, position, rect, tabColor, active, hovered, true)
|
||||
}
|
||||
|
||||
override fun paintBorderLine(g: Graphics2D, thickness: Int, from: Point, to: Point) {
|
||||
@@ -157,14 +157,15 @@ internal open class IslandsTabPainter(isDefault: Boolean, isToolWindow: Boolean)
|
||||
RectanglePainter2D.FILL.paint(g, rect.x.toDouble(), rect.y.toDouble(), rect.width.toDouble(), rect.height.toDouble())
|
||||
}
|
||||
|
||||
open fun paintTab(g: Graphics2D, rect: Rectangle, tabColor: Color?, active: Boolean, hovered: Boolean, selected: Boolean) {
|
||||
open fun paintTab(g: Graphics2D, position: JBTabsPosition, rect: Rectangle, tabColor: Color?, active: Boolean, hovered: Boolean, selected: Boolean) {
|
||||
val arc = JBUI.CurrentTheme.MainToolbar.Button.hoverArc().float.toDouble()
|
||||
val compactMode = UISettings.getInstance().compactMode
|
||||
|
||||
val hOffset = JBUIScale.scale(if (compactMode) 2f else 4f).toDouble()
|
||||
val hOffset = JBUIScale.scale(getHOffsetUnscaled(compactMode, position).toFloat()).toDouble()
|
||||
val minVOffset = JBUIScale.scale(if (compactMode) 4f else 8f).toDouble()
|
||||
|
||||
val fullHeight = JBUIScale.scale(if (compactMode) 24f else 28f).toDouble()
|
||||
val vOffset = (rect.height - fullHeight).coerceAtLeast(JBUIScale.scale(8f).toDouble())
|
||||
val vOffset = (rect.height - fullHeight).coerceAtLeast(minVOffset)
|
||||
|
||||
val x = rect.x + hOffset
|
||||
val y = floor(rect.y + vOffset / 2.0)
|
||||
@@ -185,6 +186,13 @@ internal open class IslandsTabPainter(isDefault: Boolean, isToolWindow: Boolean)
|
||||
RectanglePainter2D.DRAW.paint(g, x, y, width, height, arc)
|
||||
}
|
||||
|
||||
private fun getHOffsetUnscaled(compactMode: Boolean, position: JBTabsPosition): Int {
|
||||
return when (position.isSide) {
|
||||
true -> 6
|
||||
false -> if (compactMode) 2 else 4
|
||||
}
|
||||
}
|
||||
|
||||
private val hoverBackground = JBColor("EditorTabs.hoverBackground", JBColor(Color(0xE5, 0xEE, 0xFF, 0x80), Color(0x34, 0x3E, 0x51, 0x80)))
|
||||
|
||||
private val inactiveBorderColor = JBColor("EditorTabs.inactiveUnderlinedTabBorderColor", JBColor(Color(0x7F, 0x99, 0xC3, 0x80), Color(0x7F, 0x99, 0xC3, 0x80)))
|
||||
|
||||
+10
-4
@@ -811,9 +811,9 @@ internal class IslandsUICustomization : InternalUICustomization() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun paintTab(g: Graphics2D, rect: Rectangle, tabColor: Color?, active: Boolean, hovered: Boolean, selected: Boolean) {
|
||||
override fun paintTab(g: Graphics2D, position: JBTabsPosition, rect: Rectangle, tabColor: Color?, active: Boolean, hovered: Boolean, selected: Boolean) {
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)
|
||||
super.paintTab(g, rect, tabColor, active, hovered, selected)
|
||||
super.paintTab(g, position, rect, tabColor, active, hovered, selected)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -821,9 +821,9 @@ internal class IslandsUICustomization : InternalUICustomization() {
|
||||
|
||||
override val debuggerTabPainterAdapter: IslandsTabPainterAdapter = IslandsTabPainterAdapter(true, true, isManyIslandEnabled)
|
||||
|
||||
override fun paintTab(g: Graphics, rect: Rectangle, hovered: Boolean, selected: Boolean): Boolean {
|
||||
override fun paintTab(g: Graphics, position: JBTabsPosition, rect: Rectangle, hovered: Boolean, selected: Boolean): Boolean {
|
||||
if (isManyIslandEnabled) {
|
||||
toolWindowTabPainter.paintTab(g as Graphics2D, rect, null, true, hovered, selected)
|
||||
toolWindowTabPainter.paintTab(g as Graphics2D, position, rect, null, true, hovered, selected)
|
||||
return true
|
||||
}
|
||||
return true
|
||||
@@ -840,6 +840,12 @@ internal class IslandsUICustomization : InternalUICustomization() {
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun getSingleRowTabInsets(tabsPosition: JBTabsPosition): Insets? {
|
||||
val compactMode = UISettings.getInstance().compactMode
|
||||
|
||||
return if (isManyIslandEnabled && tabsPosition.isSide && compactMode) JBUI.insetsTop(3) else null
|
||||
}
|
||||
|
||||
private fun getMainBackgroundColor(): Color {
|
||||
return JBColor.namedColor("MainWindow.background", JBColor.PanelBackground)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.ui.tabs.JBTabsPosition;
|
||||
import com.intellij.ui.tabs.TabInfo;
|
||||
import com.intellij.ui.tabs.TabsListener;
|
||||
import com.intellij.ui.tabs.impl.JBEditorTabs;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -84,7 +85,8 @@ public class JBTabsPaneImpl implements TabbedPane {
|
||||
tabs.setTabsPosition(position);
|
||||
}
|
||||
|
||||
private static @NotNull JBTabsPosition swingConstantToEnum(int tabPlacement) {
|
||||
@ApiStatus.Internal
|
||||
public static @NotNull JBTabsPosition swingConstantToEnum(int tabPlacement) {
|
||||
return switch (tabPlacement) {
|
||||
case SwingConstants.TOP -> JBTabsPosition.top;
|
||||
case SwingConstants.BOTTOM -> JBTabsPosition.bottom;
|
||||
|
||||
@@ -166,6 +166,8 @@
|
||||
|
||||
"tabInsets": "-7,8,-7,8",
|
||||
"tabInsets.compact": "-2,6,-2,4",
|
||||
"verticalTabInsets": "-2,10,-2,10",
|
||||
"verticalTabInsets.compact": "0,10,0,10",
|
||||
"tabContentActionsRightInsets": "0,4,0,2"
|
||||
},
|
||||
|
||||
|
||||
@@ -121,6 +121,8 @@
|
||||
|
||||
"tabInsets": "-6,8,-6,8",
|
||||
"tabInsets.compact": "-2,6,-2,4",
|
||||
"verticalTabInsets": "-2,10,-2,10",
|
||||
"verticalTabInsets.compact": "0,10,0,10",
|
||||
"tabContentActionsRightInsets": "0,2,0,2"
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user