Support full-width cells (experimental)

GitOrigin-RevId: 5d682277d9fbf3c5e301529093b34df90fcc9a5e
This commit is contained in:
Dmitry Jemerov
2019-07-03 18:50:15 +03:00
committed by intellij-monorepo-bot
parent 8186241993
commit d8189f98ce
2 changed files with 11 additions and 5 deletions
@@ -81,18 +81,20 @@ abstract class Row : Cell(), RowBuilder {
/**
* Shares cell between components.
*
* @param isFullWidth If true, the cell occupies the full width of the enclosing component.
*/
inline fun cell(isVerticalFlow: Boolean = false, init: Cell.() -> Unit) {
setCellMode(true, isVerticalFlow)
inline fun cell(isVerticalFlow: Boolean = false, isFullWidth: Boolean = false, init: Cell.() -> Unit) {
setCellMode(true, isVerticalFlow, isFullWidth)
init()
setCellMode(false, isVerticalFlow)
setCellMode(false, isVerticalFlow, isFullWidth)
}
@PublishedApi
internal abstract fun createRow(label: String?, buttonGroup: ButtonGroup?): Row
@PublishedApi
internal abstract fun setCellMode(value: Boolean, isVerticalFlow: Boolean)
internal abstract fun setCellMode(value: Boolean, isVerticalFlow: Boolean, fullWidth: Boolean)
// backward compatibility
@Deprecated(level = DeprecationLevel.HIDDEN, message = "deprecated")
@@ -14,6 +14,7 @@ import com.intellij.ui.layout.*
import com.intellij.util.SmartList
import net.miginfocom.layout.BoundSize
import net.miginfocom.layout.CC
import net.miginfocom.layout.LayoutUtil
import java.awt.Component
import javax.swing.*
import javax.swing.border.LineBorder
@@ -185,7 +186,7 @@ internal class MigLayoutRow(private val parent: MigLayoutRow?,
}
// cell mode not tested with "gear" button, wait first user request
override fun setCellMode(value: Boolean, isVerticalFlow: Boolean) {
override fun setCellMode(value: Boolean, isVerticalFlow: Boolean, fullWidth: Boolean) {
if (value) {
assert(componentIndexWhenCellModeWasEnabled == -1)
componentIndexWhenCellModeWasEnabled = components.size
@@ -198,6 +199,9 @@ internal class MigLayoutRow(private val parent: MigLayoutRow?,
val component = components.get(firstComponentIndex)
val cc = componentConstraints.getOrPut(component) { CC() }
cc.split(components.size - firstComponentIndex)
if (fullWidth) {
cc.spanX(LayoutUtil.INF)
}
if (isVerticalFlow) {
cc.flowY()
// because when vertical buttons placed near scroll pane, it wil be centered by baseline (and baseline not applicable for grow elements, so, will be centered)