From 245594bfc19c4d5d2745296994717b01ff82168d Mon Sep 17 00:00:00 2001 From: "Vassiliy.Kudryashov" Date: Tue, 20 Oct 2020 21:06:01 +0300 Subject: [PATCH] IDEA-123086 Show pinned tabs in a separate row GitOrigin-RevId: f5ca8f9d1ae68e474728289a72c7ec1a22fe9ab4 --- .../src/com/intellij/ide/ui/UISettingsState.kt | 2 ++ .../resources/messages/ApplicationBundle.properties | 1 + .../com/intellij/ui/tabs/impl/table/TableLayout.java | 11 +++++++---- .../options/editor/EditorTabsConfigurable.kt | 5 +++++ .../options/editor/EditorTabsOptionsModel.kt | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsState.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsState.kt index f5b8a12a96eb..0b6a7d757f91 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsState.kt +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsState.kt @@ -94,6 +94,8 @@ class UISettingsState : BaseState() { var scrollTabLayoutInEditor by property(true) @get:OptionTag("HIDE_TABS_IF_NEED") var hideTabsIfNeeded by property(true) + @get:OptionTag("SHOW_PINNED_TABS_IN_A_SEPARATE_ROW") + var showPinnedTabsInASeparateRow by property(false) @get:OptionTag("SHOW_CLOSE_BUTTON") var showCloseButton by property(true) @get:OptionTag("CLOSE_TAB_BUTTON_ON_THE_RIGHT") diff --git a/platform/platform-api/resources/messages/ApplicationBundle.properties b/platform/platform-api/resources/messages/ApplicationBundle.properties index 0a8500536385..6cf1294ddd60 100644 --- a/platform/platform-api/resources/messages/ApplicationBundle.properties +++ b/platform/platform-api/resources/messages/ApplicationBundle.properties @@ -288,6 +288,7 @@ combobox.editor.tab.placement=Tab placement checkbox.editor.tabs.in.single.row=Show tabs in one row tabs.close.button.placement=Close button position checkbox.editor.scroll.if.need=Hide tabs if there is no space +checkbox.show.pinned.tabs.in.a.separate.row=Show pinned tabs in a separate row checkbox.show.file.icon.in.editor.tabs=Show file icon checkbox.show.file.extension.in.editor.tabs=Show file extension checkbox.show.directory.for.non.unique.files=Show directory for non-unique file names diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java index f302a14b7309..04e39937900d 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/table/TableLayout.java @@ -1,6 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui.tabs.impl.table; +import com.intellij.ide.ui.UISettings; import com.intellij.ui.tabs.TabInfo; import com.intellij.ui.tabs.TabsUtil; import com.intellij.ui.tabs.impl.JBTabsImpl; @@ -38,12 +39,13 @@ public class TableLayout extends TabLayout { final int maxX = data.toFitRec.x + data.toFitRec.width; int hGap = myTabs.getTabHGap(); + boolean showPinnedTabsSeparately = UISettings.getInstance().getState().getShowPinnedTabsInASeparateRow(); for (TabInfo eachInfo : data.myVisibleInfos) { final TabLabel eachLabel = myTabs.myInfo2Label.get(eachInfo); boolean pinned = eachLabel.isPinned(); final Dimension size = eachLabel.getNotStrictPreferredSize(); int width = size.width + hGap; - if (pinned) { + if (pinned && showPinnedTabsSeparately) { if (eachXPinned + width >= maxX) { requiredRowsPinned++; eachXPinned = data.toFitRec.x; @@ -75,7 +77,7 @@ public class TableLayout extends TabLayout { final Dimension size = eachLabel.getNotStrictPreferredSize(); boolean pinned = eachLabel.isPinned(); int width = size.width + hGap; - if (pinned) { + if (pinned && showPinnedTabsSeparately) { if (eachXPinned + width <= maxX) { eachTableRow.add(eachInfo, width); eachXPinned += width; @@ -86,7 +88,7 @@ public class TableLayout extends TabLayout { eachTableRow.add(eachInfo, width); } } else { - if (eachXUnpinned + size.width + hGap <= maxX && !eachLabel.isNextToLastPinned()) { + if (eachXUnpinned + size.width + hGap <= maxX && (!showPinnedTabsSeparately || !eachLabel.isNextToLastPinned())) { eachTableRow.add(eachInfo, width); eachXUnpinned += width; } else { @@ -118,6 +120,7 @@ public class TableLayout extends TabLayout { Insets insets = myTabs.getLayoutInsets(); int eachY = insets.top; TablePassInfo data = new TablePassInfo(myTabs, visibleInfos); + boolean showPinnedTabsSeparately = UISettings.getInstance().getState().getShowPinnedTabsInASeparateRow(); if (!myTabs.isHideTabs()) { data = computeLayoutTable(visibleInfos); @@ -142,7 +145,7 @@ public class TableLayout extends TabLayout { label.putClientProperty(JBTabsImpl.STRETCHED_BY_WIDTH, Boolean.valueOf(toAjust)); int width; - if (label.isPinned()) { + if (label.isPinned() && showPinnedTabsSeparately) { width = label.getNotStrictPreferredSize().width; } else if (i < eachRow.myColumns.size() - 1 || !toAjust) { diff --git a/platform/platform-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.kt b/platform/platform-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.kt index ec1477f6e160..dfb67e49c921 100644 --- a/platform/platform-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.kt +++ b/platform/platform-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.kt @@ -67,6 +67,11 @@ class EditorTabsConfigurable : BoundSearchableConfigurable( myEditorTabPlacement.selectedValueMatches { it == SwingConstants.TOP || it == SwingConstants.BOTTOM } and myScrollTabLayoutInEditorCheckBox.selected).component } + row { + checkBox(showPinnedTabsInASeparateRow).enableIf( + myEditorTabPlacement.selectedValueIs(SwingConstants.TOP) + and myScrollTabLayoutInEditorCheckBox.selected.not()).component + } } } row { checkBox(useSmallFont).enableIfTabsVisible() } diff --git a/platform/platform-impl/src/com/intellij/application/options/editor/EditorTabsOptionsModel.kt b/platform/platform-impl/src/com/intellij/application/options/editor/EditorTabsOptionsModel.kt index a5f2907e3279..34b0471e3dc8 100644 --- a/platform/platform-impl/src/com/intellij/application/options/editor/EditorTabsOptionsModel.kt +++ b/platform/platform-impl/src/com/intellij/application/options/editor/EditorTabsOptionsModel.kt @@ -16,6 +16,7 @@ internal val showTabsTooltips get() = CheckboxDescriptor(mess internal val showFileIcon get() = CheckboxDescriptor(message("checkbox.show.file.icon.in.editor.tabs"), ui::showFileIconInTabs) internal val showFileExtension get() = CheckboxDescriptor(message("checkbox.show.file.extension.in.editor.tabs"), PropertyBinding({ !ui.hideKnownExtensionInTabs }, { ui.hideKnownExtensionInTabs = !it })) internal val hideTabsIfNeeded get() = CheckboxDescriptor(message("checkbox.editor.scroll.if.need"), ui::hideTabsIfNeeded) +internal val showPinnedTabsInASeparateRow get() = CheckboxDescriptor(message("checkbox.show.pinned.tabs.in.a.separate.row"), ui::showPinnedTabsInASeparateRow) internal val sortTabsAlphabetically get() = CheckboxDescriptor(message("checkbox.sort.tabs.alphabetically"), ui::sortTabsAlphabetically) internal val openTabsAtTheEnd get() = CheckboxDescriptor(message("checkbox.open.new.tabs.at.the.end"), ui::openTabsAtTheEnd) internal val reuseNotModifiedTabs get() = CheckboxDescriptor(message("checkbox.smart.tab.reuse"), ui::reuseNotModifiedTabs, message("checkbox.smart.tab.reuse.inline.help"))