mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
ui: update UI DSL gaps to new guidelines
GitOrigin-RevId: cea406fb9326b68629f0e1922e1b6e265befaffd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7a3e121327
commit
cb2edf7f2e
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <T : JComponent> 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 : JComponent> T.invoke(vararg constraints: CCFlags, gapLeft: Int, growPolicy: GrowPolicy?, comment: String?): CellBuilder<T> {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user