diff --git a/platform/platform-impl/src/com/intellij/ui/layout/Row.kt b/platform/platform-impl/src/com/intellij/ui/layout/Row.kt index 229ac7095978..bc18ce3f1a83 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/Row.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/Row.kt @@ -33,9 +33,7 @@ interface RowBuilder : BaseBuilder { return createChildRow(label?.let { Label(it) }, isSeparated = separated).apply(init) } - fun titledRow(title: String, init: Row.() -> Unit): Row { - return createChildRow(isSeparated = true, title = title).apply(init) - } + fun titledRow(title: String, init: Row.() -> Unit): Row /** * Creates row with hideable decorator. diff --git a/platform/platform-impl/src/com/intellij/ui/layout/SpacingConfiguration.kt b/platform/platform-impl/src/com/intellij/ui/layout/SpacingConfiguration.kt index de4d46af71e6..a36ee75e2f3c 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/SpacingConfiguration.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/SpacingConfiguration.kt @@ -2,7 +2,6 @@ package com.intellij.ui.layout import com.intellij.util.ui.JBUI -import com.intellij.util.ui.UIUtil interface SpacingConfiguration { /** @@ -47,10 +46,10 @@ interface SpacingConfiguration { // https://jetbrains.github.io/ui/controls/input_field/#spacing fun createIntelliJSpacingConfiguration(): SpacingConfiguration { return object : SpacingConfiguration { - override val horizontalGap = JBUI.scale(8) - override val verticalGap = JBUI.scale(5 * 2) + override val horizontalGap = JBUI.scale(6) + override val verticalGap = JBUI.scale(6 * 2) override val labelColumnHorizontalGap = JBUI.scale(6) - override val largeVerticalGap = JBUI.scale(UIUtil.LARGE_VGAP) + override val largeVerticalGap = JBUI.scale(20) override val shortTextWidth = JBUI.scale(250) override val maxShortTextWidth = JBUI.scale(350) @@ -61,7 +60,7 @@ fun createIntelliJSpacingConfiguration(): SpacingConfiguration { override val dialogLeftRight = JBUI.scale(12) override val commentVerticalTopGap = JBUI.scale(6) - override val indentLevel: Int get() = horizontalGap * 3 + override val indentLevel: Int get() = JBUI.scale(20) } } diff --git a/platform/platform-impl/src/com/intellij/ui/layout/migLayout/MigLayoutRow.kt b/platform/platform-impl/src/com/intellij/ui/layout/migLayout/MigLayoutRow.kt index a75f95f86e5c..6f1dbdecef39 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/migLayout/MigLayoutRow.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/migLayout/MigLayoutRow.kt @@ -17,6 +17,7 @@ import com.intellij.util.SmartList import net.miginfocom.layout.BoundSize import net.miginfocom.layout.CC import net.miginfocom.layout.LayoutUtil +import java.awt.Dimension import javax.swing.* import javax.swing.border.LineBorder import kotlin.reflect.KMutableProperty0 @@ -158,14 +159,15 @@ internal class MigLayoutRow(private val parent: MigLayoutRow?, noGrid: Boolean = false, title: String? = null): MigLayoutRow { val subRows = getOrCreateSubRowsList() + val newIndent = if (parent == null) indent else indent + spacing.indentLevel val row = MigLayoutRow(this, builder, labeled = label != null, noGrid = noGrid, - indent = if (subRowIndent >= 0) subRowIndent * spacing.indentLevel else indent + computeChildRowIndent(isSeparated)) + indent = if (subRowIndent >= 0) subRowIndent * spacing.indentLevel else newIndent) if (isSeparated) { - val separatorRow = MigLayoutRow(this, builder, indent = indent, noGrid = true) + val separatorRow = MigLayoutRow(this, builder, indent = newIndent, noGrid = true) configureSeparatorRow(separatorRow, title) separatorRow.enabled = subRowsEnabled separatorRow.visible = subRowsVisible @@ -193,13 +195,11 @@ internal class MigLayoutRow(private val parent: MigLayoutRow?, private fun addTitleComponent(titleComponent: T, isEmpty: Boolean) { val cc = CC().apply { - vertical.gapBefore = gapToBoundSize(spacing.largeVerticalGap, false) if (isEmpty) { vertical.gapAfter = gapToBoundSize(spacing.verticalGap * 2, false) isTrailingSeparator = true } else { - vertical.gapAfter = gapToBoundSize(spacing.verticalGap, false) // TitledSeparator doesn't grow by default opposite to SeparatorComponent growX() } @@ -207,6 +207,18 @@ internal class MigLayoutRow(private val parent: MigLayoutRow?, addComponent(titleComponent, lazyOf(cc)) } + override fun titledRow(title: String, init: Row.() -> Unit): Row { + return createChildRow(isSeparated = true, title = title).apply(init).apply { + createChildRow().apply { + JPanel().apply { + maximumSize = Dimension(0, 0) + preferredSize = Dimension(0, 0) + }() + largeGapAfter() + } + } + } + override fun hideableRow(title: String, init: Row.() -> Unit): Row { val titledSeparator = HideableTitledSeparator(title) val separatorRow = createChildRow() @@ -259,19 +271,6 @@ internal class MigLayoutRow(private val parent: MigLayoutRow?, } } - private fun computeChildRowIndent(isSeparated: Boolean): Int { - if (isSeparated) { - return spacing.indentLevel - } - val firstComponent = components.firstOrNull() ?: return 0 - if (firstComponent is JRadioButton || firstComponent is JCheckBox) { - return getCommentLeftInset(firstComponent) - } - else { - return spacing.indentLevel - } - } - override operator fun T.invoke(vararg constraints: CCFlags, gapLeft: Int, growPolicy: GrowPolicy?, comment: String?): CellBuilder { addComponent(this, constraints.create()?.let { lazyOf(it) } ?: lazy { CC() }, gapLeft, growPolicy, comment) return CellBuilderImpl(builder, this@MigLayoutRow, this) @@ -389,7 +388,7 @@ internal class MigLayoutRow(private val parent: MigLayoutRow?, } override fun largeGapAfter() { - gapAfter = "${spacing.largeVerticalGap * 2}px!" + gapAfter = "${spacing.largeVerticalGap}px!" } override fun createRow(label: String?): Row {