diff --git a/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/ListComboBox.kt b/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/ListComboBox.kt index a3943cec918a0..87ab377467394 100644 --- a/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/ListComboBox.kt +++ b/platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/ListComboBox.kt @@ -6,7 +6,6 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.heightIn -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.text.input.rememberTextFieldState import androidx.compose.runtime.Composable @@ -874,17 +873,15 @@ private fun PopupContent( VerticallyScrollableContainer(scrollState = listState.lazyListState as ScrollableState) { SelectableLazyColumn( modifier = - Modifier.fillMaxWidth() - .testTag("Jewel.ComboBox.List") - .thenIf(items.isNotEmpty()) { padding(contentPadding) } - .thenIf(items.isEmpty()) { - heightIn( - min = - comboBoxSize.height + - contentPadding.calculateTopPadding() + - contentPadding.calculateBottomPadding() - ) - }, + Modifier.fillMaxWidth().testTag("Jewel.ComboBox.List").thenIf(items.isEmpty()) { + heightIn( + min = + comboBoxSize.height + + contentPadding.calculateTopPadding() + + contentPadding.calculateBottomPadding() + ) + }, + contentPadding = if (items.isNotEmpty()) contentPadding else PaddingValues(), selectionMode = SelectionMode.Single, state = listState, onSelectedIndexesChange = { selectedItemsIndexes -> diff --git a/plugins/devkit/intellij.devkit.compose/resources/messages/DevkitComposeBundle.properties b/plugins/devkit/intellij.devkit.compose/resources/messages/DevkitComposeBundle.properties index a224211fce716..ece339b37ea2b 100644 --- a/plugins/devkit/intellij.devkit.compose/resources/messages/DevkitComposeBundle.properties +++ b/plugins/devkit/intellij.devkit.compose/resources/messages/DevkitComposeBundle.properties @@ -44,6 +44,8 @@ jewel.swing.not.editable.disabled=Not editable + disabled jewel.swing.editable=Editable jewel.swing.editable.disabled=Editable + Disabled jewel.swing.text.areas=Text areas: +jewel.swing.label=Swing +jewel.compose.label=Compose compose.sandbox=Compose Sandbox compose.sandbox.show.automatically.on.project.open=Show automatically on project open diff --git a/plugins/devkit/intellij.devkit.compose/src/demo/SwingComparisonTabPanel.kt b/plugins/devkit/intellij.devkit.compose/src/demo/SwingComparisonTabPanel.kt index a4efdbfe21aee..b96e86de49ae2 100644 --- a/plugins/devkit/intellij.devkit.compose/src/demo/SwingComparisonTabPanel.kt +++ b/plugins/devkit/intellij.devkit.compose/src/demo/SwingComparisonTabPanel.kt @@ -294,7 +294,11 @@ internal class SwingComparisonTabPanel : BorderLayoutPanel() { private fun Panel.comboBoxesRow() { row(DevkitComposeBundle.message("jewel.swing.combo.boxes")) { - // Swing ComboBoxes + label(DevkitComposeBundle.message("jewel.swing.label")).bold() + } + .layout(RowLayout.PARENT_GRID) + + row("") { val zoomLevels = arrayOf("100%", "125%", "150%", "175%", "200%", "300%") JPanel() @@ -323,7 +327,7 @@ internal class SwingComparisonTabPanel : BorderLayoutPanel() { } .run { cell(this).align(AlignY.TOP) } - val itemsComboBox = arrayOf("Cat", "Elephant", "Sun", "Book", "Laughter") + val itemsComboBox = arrayOf("Cat", "Elephant", "Sun", "Book", "Laughter", "Whisper", "Ocean", "Serendipity lorem ipsum", "Umbrella") JPanel() .apply { layout = BoxLayout(this, BoxLayout.Y_AXIS) @@ -350,7 +354,15 @@ internal class SwingComparisonTabPanel : BorderLayoutPanel() { ) } .run { cell(this).align(AlignY.TOP) } + } + .layout(RowLayout.PARENT_GRID) + row("") { + label(DevkitComposeBundle.message("jewel.compose.label")).bold() + } + .layout(RowLayout.PARENT_GRID) + + row("") { compose(modifier = Modifier.padding(horizontal = 8.dp)) { val comboBoxItems = remember { listOf( @@ -366,17 +378,20 @@ internal class SwingComparisonTabPanel : BorderLayoutPanel() { "Joy", ) } + val zoomLevels = remember { + listOf("100%", "125%", "150%", "175%", "200%", "300%") + } Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { Column { var selectedIndex by remember { mutableIntStateOf(0) } - val selectedText: String = comboBoxItems[selectedIndex] + val selectedText: String = zoomLevels[selectedIndex] Text("Not editable") Text(text = "Selected item: $selectedText") ListComboBox( - items = comboBoxItems, + items = zoomLevels, selectedIndex = selectedIndex, onSelectedItemChange = { selectedIndex = it }, modifier = Modifier.width(200.dp), @@ -385,13 +400,13 @@ internal class SwingComparisonTabPanel : BorderLayoutPanel() { Column { var selectedIndex by remember { mutableIntStateOf(0) } - val selectedText: String = comboBoxItems[selectedIndex] + val selectedText: String = zoomLevels[selectedIndex] Text("Not editable + disabled") Text(text = "Selected item: $selectedText") ListComboBox( - items = comboBoxItems, + items = zoomLevels, selectedIndex = selectedIndex, onSelectedItemChange = { selectedIndex = it }, modifier = Modifier.width(200.dp),