[tabs] Edit insets of editor tabs in Compact mode in left/right position

Fix IDEA-314809 and IDEA-314774.

GitOrigin-RevId: e29cf599d0056ccc89c63abe3cdb1cf340aec63d
This commit is contained in:
Konstantin Hudyakov
2023-03-10 14:03:35 +02:00
committed by intellij-monorepo-bot
parent cbf4fc9bd5
commit c3a41caf4a
6 changed files with 26 additions and 12 deletions

View File

@@ -3531,6 +3531,7 @@ public class JBTabsImpl extends JComponent
remove(divider);
}
applyDecoration();
relayout(true, false);
return this;
}

View File

@@ -804,18 +804,10 @@ public class TabLabel extends JPanel implements Accessible, DataProvider {
private int layoutComponent(int xOffset, Component component, int spaceTop, int spaceHeight) {
if (component != null) {
int prefWestWidth = component.getPreferredSize().width;
setBoundsWithVAlign(component, xOffset, prefWestWidth, spaceTop, spaceHeight);
component.setBounds(xOffset, spaceTop, prefWestWidth, spaceHeight);
xOffset += prefWestWidth + getHgap();
}
return xOffset;
}
private void setBoundsWithVAlign(Component component, int left, int width, int spaceTop, int spaceHeight) {
if (component == null) return;
int height = component.getPreferredSize().height;
int top = spaceTop + (spaceHeight - height) / 2 + (spaceHeight - height) % 2;
component.setBounds(left, top, width, height);
}
}
}

View File

@@ -702,7 +702,8 @@ class LafManagerImpl : LafManager(), PersistentStateComponent<Element>, Disposab
// separate navbar
defaults.put(JBUI.CurrentTheme.NavBar.itemInsetsKey(), cmInsets(2))
// editor tabs
defaults.put("EditorTabs.tabInsets", cmInsets(-2, 4, -2, 4))
defaults.put(JBUI.CurrentTheme.EditorTabs.tabInsetsKey(), cmInsets(-2, 4, -2, 4))
defaults.put(JBUI.CurrentTheme.EditorTabs.verticalTabInsetsKey(), cmInsets(2, 8, 1, 8))
defaults.put(JBUI.CurrentTheme.EditorTabs.tabActionsInsetKey(), 0)
defaults.put(JBUI.CurrentTheme.EditorTabs.fontKey(), Supplier { JBFont.medium() })
// toolwindows

View File

@@ -551,7 +551,10 @@ private class EditorTabs(
Toolkit.getDefaultToolkit().removeAWTEventListener(listener)
}
setUiDecorator { UiDecoration(null, JBUI.CurrentTheme.EditorTabs.tabInsets()) }
setUiDecorator {
val insets = if (isHorizontalTabs) JBUI.CurrentTheme.EditorTabs.tabInsets() else JBUI.CurrentTheme.EditorTabs.verticalTabInsets()
UiDecoration(null, insets)
}
val source = ActionManager.getInstance().getAction("EditorTabsEntryPoint")
source.templatePresentation.putClientProperty(ActionButton.HIDE_DROPDOWN_ICON, true)
entryPointActionGroup = DefaultActionGroup(source)

View File

@@ -393,6 +393,11 @@
"key": "EditorTabs.tabInsets",
"description": "Inner insets around each editor tab"
},
{
"key": "EditorTabs.verticalTabInsets",
"description": "Inner insets around each editor tab when tabs placed left or right",
"since": "2023.1"
},
{
"key": "EditorTabs.unselectedAlpha",
"description": "The alpha coefficient (0..1) that is used to paint file icon if the tab is not selected and not hovered",

View File

@@ -600,7 +600,19 @@ public final class JBUI {
}
public static Insets tabInsets() {
return insets("EditorTabs.tabInsets", isNewUI() ? insets(-7, 12, -7, 8) : insets(0, 8));
return insets(tabInsetsKey(), isNewUI() ? insets(-7, 12, -7, 8) : insets(0, 8));
}
public static String tabInsetsKey() {
return "EditorTabs.tabInsets";
}
public static Insets verticalTabInsets() {
return insets(verticalTabInsetsKey(), JBInsets.create(tabInsets()));
}
public static String verticalTabInsetsKey() {
return "EditorTabs.verticalTabInsets";
}
public static int tabActionsInset() {