mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
[python] PY-79486: (WIP): Fix UI size and make it resizable.
`WindowManager` handles DPI issues. GitOrigin-RevId: 0f60b5a761bd7df6551209f4c4b1af89bfd7403e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
46a8fcb887
commit
1bed87261f
@@ -6,7 +6,6 @@ import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.intellij.icons.AllIcons
|
||||
@@ -31,8 +30,6 @@ import org.jetbrains.jewel.ui.icon.IntelliJIconKey
|
||||
*/
|
||||
@Composable
|
||||
internal fun ModuleList(
|
||||
screenWidthPx: Int,
|
||||
screenHeightPx: Int,
|
||||
viewModel: ModulesViewModel,
|
||||
) {
|
||||
LaunchedEffect(viewModel) {
|
||||
@@ -42,13 +39,9 @@ internal fun ModuleList(
|
||||
val projectStructureLabel = remember { message("python.sdk.configurator.frontend.choose.modules.project.structure") }
|
||||
val environmentLabel = remember { message("python.sdk.configurator.frontend.choose.modules.environment") }
|
||||
|
||||
val (width, height) = with(LocalDensity.current) {
|
||||
// width: 50% of screen, height: 65% of the screen (according to Lena)
|
||||
Pair(screenWidthPx.toDp() * 0.5f, screenHeightPx.toDp() * 0.65f)
|
||||
}
|
||||
val border = Modifier.border(Stroke.Alignment.Outside, 1.dp, JewelTheme.globalColors.borders.normal)
|
||||
val space = 5.dp
|
||||
VerticallyScrollableContainer(Modifier.padding(space).then(border).size(width = width, height = height)) {
|
||||
VerticallyScrollableContainer(Modifier.padding(space).then(border).fillMaxSize()) {
|
||||
val checkboxArrangement = Arrangement.spacedBy(space)
|
||||
Column(Modifier.fillMaxSize(), verticalArrangement = checkboxArrangement) {
|
||||
Text(text = topLabel, Modifier.padding(space))
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.python.sdkConfigurator.frontend
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.openapi.wm.WindowManager
|
||||
import com.intellij.python.sdkConfigurator.common.impl.ModuleName
|
||||
import com.intellij.python.sdkConfigurator.common.impl.ModulesDTO
|
||||
import com.intellij.python.sdkConfigurator.frontend.PySdkConfiguratorFrontendBundle.message
|
||||
@@ -12,7 +13,7 @@ import kotlinx.coroutines.withContext
|
||||
import org.jetbrains.jewel.bridge.compose
|
||||
import org.jetbrains.jewel.foundation.ExperimentalJewelApi
|
||||
import org.jetbrains.jewel.foundation.enableNewSwingCompositing
|
||||
import java.awt.GraphicsEnvironment
|
||||
import java.awt.Dimension
|
||||
import javax.swing.JComponent
|
||||
|
||||
internal suspend fun askUser(project: Project, modules: ModulesDTO, onResult: (Set<ModuleName>) -> Unit) {
|
||||
@@ -27,11 +28,10 @@ internal suspend fun askUser(project: Project, modules: ModulesDTO, onResult: (S
|
||||
}
|
||||
}
|
||||
|
||||
private class MyDialog(project: Project, private val viewModel: ModulesViewModel) : DialogWrapper(project) {
|
||||
private class MyDialog(private val project: Project, private val viewModel: ModulesViewModel) : DialogWrapper(project) {
|
||||
|
||||
init {
|
||||
title = message("python.sdk.configurator.frontend.choose.modules.title")
|
||||
isResizable = false
|
||||
setOKButtonText(message("python.sdk.configurator.frontend.choose.modules.configure"))
|
||||
init()
|
||||
}
|
||||
@@ -47,13 +47,12 @@ private class MyDialog(project: Project, private val viewModel: ModulesViewModel
|
||||
viewModel.okButtonEnabledListener = { enabled ->
|
||||
isOKActionEnabled = enabled // To enable/disable "OK" button
|
||||
}
|
||||
val screenSize = GraphicsEnvironment.getLocalGraphicsEnvironment().defaultScreenDevice.displayMode
|
||||
return compose(focusOnClickInside = true) {
|
||||
ModuleList(
|
||||
screenWidthPx = screenSize.width,
|
||||
screenHeightPx = screenSize.height,
|
||||
viewModel = viewModel
|
||||
)
|
||||
val screen = WindowManager.getInstance().getFrame(project)!! // Have no idea why could it be null
|
||||
return compose(focusOnClickInside = true, config = {
|
||||
// 65% according to Lena
|
||||
preferredSize = Dimension(screen.width / 2, (screen.height * 0.65f).toInt())
|
||||
}) {
|
||||
ModuleList(viewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user