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 19021742755b..229ac7095978 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/Row.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/Row.kt @@ -92,6 +92,12 @@ abstract class Row : Cell(), RowBuilder { abstract var subRowsVisible: Boolean + /** + * Indent for child rows of this row, expressed in steps (multiples of [SpacingConfiguration.indentLevel]). Replaces indent + * calculated from row nesting. + */ + abstract var subRowIndent: Int + protected abstract val builder: LayoutBuilderImpl /** diff --git a/platform/platform-impl/src/com/intellij/ui/layout/ShowcaseUiDslAction.kt b/platform/platform-impl/src/com/intellij/ui/layout/ShowcaseUiDslAction.kt index 789215044555..3018a2b2ea44 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/ShowcaseUiDslAction.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/ShowcaseUiDslAction.kt @@ -16,6 +16,7 @@ internal class ShowcaseUiDslAction : DumbAwareAction() { tabs.presentation.setAlphabeticalMode(false) tabs.addTab(TabInfo(secondColumnSmallerPanel()).setText("Second Column Smaller")) + tabs.addTab(TabInfo(rowWithIndent()).setText("Row with Indent")) val dialog = dialog("UI DSL Showcase", tabs.component) Disposer.register(dialog.disposable, disposable) 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 1d0356126686..a75f95f86e5c 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 @@ -140,6 +140,8 @@ internal class MigLayoutRow(private val parent: MigLayoutRow?, } } + override var subRowIndent: Int = -1 + internal val isLabeledIncludingSubRows: Boolean get() = labeled || (subRows?.any { it.isLabeledIncludingSubRows } ?: false) @@ -160,7 +162,7 @@ internal class MigLayoutRow(private val parent: MigLayoutRow?, val row = MigLayoutRow(this, builder, labeled = label != null, noGrid = noGrid, - indent = indent + computeChildRowIndent(isSeparated)) + indent = if (subRowIndent >= 0) subRowIndent * spacing.indentLevel else indent + computeChildRowIndent(isSeparated)) if (isSeparated) { val separatorRow = MigLayoutRow(this, builder, indent = indent, noGrid = true) diff --git a/platform/platform-impl/src/com/intellij/ui/layout/testPanels.kt b/platform/platform-impl/src/com/intellij/ui/layout/testPanels.kt index 4d41cbd9f9d2..9dcd07b1f6fc 100644 --- a/platform/platform-impl/src/com/intellij/ui/layout/testPanels.kt +++ b/platform/platform-impl/src/com/intellij/ui/layout/testPanels.kt @@ -308,3 +308,25 @@ fun separatorAndComment() : JPanel { } } } + +fun rowWithIndent(): JPanel { + return panel { + row("Zero") { + subRowIndent = 0 + row("Bar 0") { + } + } + row("One") { + subRowIndent = 1 + + row("Bar 1") { + } + } + row("Two") { + subRowIndent = 2 + + row("Bar 2") { + } + } + } +} \ No newline at end of file diff --git a/platform/platform-tests/testData/ui/layout/subRowsIndent.yml b/platform/platform-tests/testData/ui/layout/subRowsIndent.yml new file mode 100644 index 000000000000..5718afb796ac --- /dev/null +++ b/platform/platform-tests/testData/ui/layout/subRowsIndent.yml @@ -0,0 +1,51 @@ +layoutConstraints: + fillX: true + gridGapX: + min: &id001 {horizontal: true, unit: 0, value: 0.0} + preferred: *id001 + gridGapY: + min: &id002 {horizontal: false, value: 10.0} + preferred: *id002 + hideMode: 2 + insets: + - {horizontal: false, unit: 0, value: 0.0} + - {horizontal: true, unit: 0, value: 0.0} + - {horizontal: false, unit: 0, value: 0.0} + - {horizontal: true, unit: 0, value: 0.0} +rowConstraints: + constraints: + - align: &id003 {horizontal: false, unit: -1, value: 0.0} + - align: *id003 + - align: *id003 + - align: *id003 + - align: *id003 + - align: *id003 + count: 6 +columnConstraints: + constraints: + - gapAfter: + max: &id004 {horizontal: true, value: 6.0} + min: *id004 + preferred: *id004 + grow: 0.0 + - {} + count: 2 +componentConstrains: + Zero [label]: {spanX: INF, wrap: true} + Bar 0 [label]: {spanX: INF, wrap: true} + One [label]: {spanX: INF, wrap: true} + Bar 1 [label]: + horizontal: + gapBefore: + min: &id005 {horizontal: true, value: 24.0} + preferred: *id005 + spanX: INF + wrap: true + Two [label]: {spanX: INF, wrap: true} + Bar 2 [label]: + horizontal: + gapBefore: + min: &id006 {horizontal: true, value: 48.0} + preferred: *id006 + spanX: INF + wrap: true \ No newline at end of file diff --git a/platform/platform-tests/testSrc/com/intellij/ui/layout/UiDslTest.kt b/platform/platform-tests/testSrc/com/intellij/ui/layout/UiDslTest.kt index b8f89d965965..7a15ffbff82c 100644 --- a/platform/platform-tests/testSrc/com/intellij/ui/layout/UiDslTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/ui/layout/UiDslTest.kt @@ -113,5 +113,10 @@ abstract class UiDslTest { } } + @Test + fun subRowsIndent() { + doTest { rowWithIndent() } + } + protected abstract fun doTest(panelCreator: () -> JPanel) } \ No newline at end of file