From 4a07e7311cf0b10d57b679a56eb75cdaaa147225 Mon Sep 17 00:00:00 2001 From: Bogdan Kirilenko Date: Mon, 18 Dec 2023 14:40:08 +0100 Subject: [PATCH] [jupyter] PY-20132 excluding some inlays for better UI in the jupyter diff viewer GitOrigin-RevId: dd9086774280d1efb9fa7171f781b66b2c17c314 --- .../NewUINotebookDiffEditorAppearance.kt | 53 +++++++++++++++++++ .../visualization/ui/NotebookEditorUiUtil.kt | 5 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/editor/NewUINotebookDiffEditorAppearance.kt diff --git a/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/editor/NewUINotebookDiffEditorAppearance.kt b/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/editor/NewUINotebookDiffEditorAppearance.kt new file mode 100644 index 000000000000..0124e036e612 --- /dev/null +++ b/notebooks/notebook-ui/src/org/jetbrains/plugins/notebooks/ui/editor/NewUINotebookDiffEditorAppearance.kt @@ -0,0 +1,53 @@ +package org.jetbrains.plugins.notebooks.ui.editor + +import com.intellij.openapi.editor.colors.ColorKey +import com.intellij.openapi.editor.colors.EditorColorsScheme +import org.jetbrains.plugins.notebooks.ui.visualization.NotebookEditorAppearance +import org.jetbrains.plugins.notebooks.ui.visualization.NotebookEditorAppearanceSizes +import java.awt.Color + +object NewUINotebookDiffEditorAppearance: NotebookEditorAppearance, + NotebookEditorAppearanceSizes by NewUINotebookDiffEditorAppearanceSizes +{ + private val CARET_ROW_COLOR_NEW_UI = ColorKey.createColorKey("JUPYTER.CARET_ROW_COLOR_NEW_UI") + + override fun getCodeCellBackground(scheme: EditorColorsScheme): Color? = // Color.orange + scheme.getColor(NotebookEditorAppearance.CODE_CELL_BACKGROUND_NEW_UI) + + override fun getCaretRowColor(scheme: EditorColorsScheme): Color? = scheme.getColor(CARET_ROW_COLOR_NEW_UI) + override fun shouldShowCellLineNumbers(): Boolean = false + override fun shouldShowExecutionCounts(): Boolean = false // not needed for DIFF -> execution does not reach it +} + + +object NewUINotebookDiffEditorAppearanceSizes: NotebookEditorAppearanceSizes { + // see comments in org.jetbrains.plugins.notebooks.ui.visualization.DefaultNotebookEditorAppearanceSizes + override val CODE_CELL_LEFT_LINE_PADDING = 5 + override val LINE_NUMBERS_MARGIN = 10 + + override val COMMAND_MODE_CELL_LEFT_LINE_WIDTH = 4 + override val EDIT_MODE_CELL_LEFT_LINE_WIDTH = 2 + override val CODE_AND_CODE_TOP_GRAY_HEIGHT = 60 + override val CODE_AND_CODE_BOTTOM_GRAY_HEIGHT = 60 + override val INNER_CELL_TOOLBAR_HEIGHT = 24 + override val CELL_BORDER_HEIGHT = 20 + override val SPACER_HEIGHT = CELL_BORDER_HEIGHT / 2 + override val EXECUTION_TIME_HEIGHT = 0 // not used in the jupyter diff viewer + override val SPACE_BELOW_CELL_TOOLBAR = 10 + override val CELL_TOOLBAR_TOTAL_HEIGHT = INNER_CELL_TOOLBAR_HEIGHT + SPACE_BELOW_CELL_TOOLBAR + override val PROGRESS_STATUS_HEIGHT = 2 + + override val JUPYTER_CELL_SPACERS_INLAY_PRIORITY = 10 + override val JUPYTER_BELOW_OUTPUT_CELL_SPACERS_INLAY_PRIORITY = -10 + override val JUPYTER_CELL_TOOLBAR_INLAY_PRIORITY = JUPYTER_CELL_SPACERS_INLAY_PRIORITY + 10 + override val NOTEBOOK_OUTPUT_INLAY_PRIORITY: Int = 5 + + override val EXTRA_PADDING_EXECUTION_COUNT = 0 + override val EXTRA_GUTTER_AREA_WIDTH_EXECUTION_COUNT = 0 // not needed, see JupyterEditorGutterExtraSpaceManager + + override fun getCellLeftLineWidth(): Int = 10 + override fun getCellLeftLineHoverWidth(): Int = 10 + + override fun getLeftBorderWidth(): Int = + Integer.max(COMMAND_MODE_CELL_LEFT_LINE_WIDTH, EDIT_MODE_CELL_LEFT_LINE_WIDTH) + CODE_CELL_LEFT_LINE_PADDING +} diff --git a/notebooks/visualization/src/org/jetbrains/plugins/notebooks/visualization/ui/NotebookEditorUiUtil.kt b/notebooks/visualization/src/org/jetbrains/plugins/notebooks/visualization/ui/NotebookEditorUiUtil.kt index ff4ef14023dd..552abdac7bee 100644 --- a/notebooks/visualization/src/org/jetbrains/plugins/notebooks/visualization/ui/NotebookEditorUiUtil.kt +++ b/notebooks/visualization/src/org/jetbrains/plugins/notebooks/visualization/ui/NotebookEditorUiUtil.kt @@ -1,6 +1,7 @@ package org.jetbrains.plugins.notebooks.visualization.ui import com.intellij.openapi.editor.Editor +import com.intellij.openapi.editor.EditorKind import com.intellij.openapi.editor.Inlay import com.intellij.openapi.editor.ex.EditorEx import com.intellij.openapi.editor.impl.EditorComponentImpl @@ -21,6 +22,8 @@ fun EditorEx.addComponentInlay( priority: Int, offset: Int, ): Inlay<*> { + // see DS-5614 + val fullWidthArg: Boolean = this.editorKind != EditorKind.DIFF val inlay = EditorEmbeddedComponentManager.getInstance().addComponent( this, component, @@ -30,7 +33,7 @@ fun EditorEx.addComponentInlay( isRelatedToPrecedingText, showAbove, showWhenFolded, - true, + fullWidthArg, priority, offset, )