[PyCharm] PY-74182 notebook cell spacing fixes

GitOrigin-RevId: 1adf368a2bbd54a0a73cc71eed1ac1087873d21e
This commit is contained in:
Bogdan.Kirilenko
2024-08-07 18:54:54 +02:00
committed by intellij-monorepo-bot
parent 6392989590
commit 19365eba18
4 changed files with 7 additions and 3 deletions

View File

@@ -42,6 +42,7 @@ object NewUINotebookDiffEditorAppearanceSizes: NotebookEditorAppearanceSizes {
override val CODE_AND_CODE_BOTTOM_GRAY_HEIGHT = 60
override val INNER_CELL_TOOLBAR_HEIGHT = 24
override val cellBorderHeight = JBUI.scale(20)
override val distanceBetweenCells: Int = JBUI.scale(16)
override val aboveFirstCellDelimiterHeight: Int = JBUI.scale(20)
override val SPACER_HEIGHT = cellBorderHeight / 2
override val EXECUTION_TIME_HEIGHT = 0 // not used in the jupyter diff viewer

View File

@@ -6,6 +6,7 @@ import com.intellij.openapi.actionSystem.ActionGroup
import com.intellij.openapi.components.Service
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.ui.scale.JBUIScale
import org.jetbrains.plugins.notebooks.ui.visualization.DefaultNotebookEditorAppearanceSizes
import java.awt.MouseInfo
import java.awt.Point
@@ -125,7 +126,7 @@ class JupyterAddCellToolbarService: Disposable {
fun getInstance(project: Project): JupyterAddCellToolbarService = project.getService(JupyterAddCellToolbarService::class.java)
private const val ACTION_GROUP_ID = "Jupyter.AboveCellPanelNew"
private const val TOOLBAR_HIDE_DELAY = 600
private val DELIMITER_SIZE = DefaultNotebookEditorAppearanceSizes.cellBorderHeight / 2
private val DELIMITER_SIZE = DefaultNotebookEditorAppearanceSizes.distanceBetweenCells
fun calculateToolbarBounds(
editor: Editor,
@@ -139,7 +140,7 @@ class JupyterAddCellToolbarService: Disposable {
val toolbarWidth = toolbar.preferredSize.width
val xOffset = (panelWidth - toolbarWidth) / 2
val yOffset = (panelHeight - (1.5 * DELIMITER_SIZE) - (toolbarHeight / 2)).toInt()
val yOffset = (panelHeight - DELIMITER_SIZE - (toolbarHeight / 2))
val editorComponent = editor.contentComponent
val panelLocationInEditor = SwingUtilities.convertPoint(panel, Point(0, 0), editorComponent)

View File

@@ -19,7 +19,7 @@ class NotebookAboveCellDelimiterPanel(
private val standardDelimiterHeight = editor.notebookAppearance.cellBorderHeight / 2
private val delimiterPanelHeight = when (isFirstCell) {
true -> editor.notebookAppearance.aboveFirstCellDelimiterHeight
false -> standardDelimiterHeight
false -> editor.notebookAppearance.distanceBetweenCells
}
val project get() = editor.project ?: ProjectManager.getInstance().defaultProject

View File

@@ -61,6 +61,7 @@ interface NotebookEditorAppearanceSizes {
val cellBorderHeight: Int
val aboveFirstCellDelimiterHeight: Int
val distanceBetweenCells: Int
fun getCellLeftLineWidth(editor: Editor): Int
fun getCellLeftLineHoverWidth(): Int
@@ -114,6 +115,7 @@ object DefaultNotebookEditorAppearanceSizes: NotebookEditorAppearanceSizes {
override val CODE_AND_CODE_TOP_GRAY_HEIGHT = JBUI.scale(6)
override val CODE_AND_CODE_BOTTOM_GRAY_HEIGHT = JBUI.scale(6)
override val INNER_CELL_TOOLBAR_HEIGHT = JBUI.scale(24)
override val distanceBetweenCells = JBUI.scale(16)
override val cellBorderHeight = JBUI.scale(16)
override val aboveFirstCellDelimiterHeight = JBUI.scale(24)
override val SPACER_HEIGHT = JBUI.scale(cellBorderHeight / 2)