mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[PyCharm] PY-80553 Returning DefaultNotebookEditorAppearance.kt instead of Diff appearance for jupyter notebooks + minor cosmetics
GitOrigin-RevId: 1cad41478121c0c2dfdc0842efe41c77c2b1a0d3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a87c6df75c
commit
1a97b0035d
@@ -25,8 +25,9 @@ import com.intellij.ui.JBColor
|
||||
import java.awt.Color
|
||||
import kotlin.sequences.generateSequence
|
||||
|
||||
open class DefaultNotebookEditorAppearance(private val editor: Editor) : NotebookEditorAppearance,
|
||||
NotebookEditorAppearanceSizes by DefaultNotebookEditorAppearanceSizes {
|
||||
open class DefaultNotebookEditorAppearance(
|
||||
private val editor: Editor
|
||||
) : NotebookEditorAppearance, NotebookEditorAppearanceSizes by DefaultNotebookEditorAppearanceSizes {
|
||||
|
||||
private val swapCellAndEditorBackgroundColor = AtomicBooleanProperty(
|
||||
Registry.`is`("jupyter.editor.swap.cell.and.editor.background", false)
|
||||
@@ -130,12 +131,11 @@ open class DefaultNotebookEditorAppearance(private val editor: Editor) : Noteboo
|
||||
|
||||
override fun getCellLeftLineWidth(editor: Editor): Int =
|
||||
when (editor.currentMode) {
|
||||
NotebookEditorMode.EDIT -> EDIT_MODE_CELL_LEFT_LINE_WIDTH
|
||||
NotebookEditorMode.COMMAND -> COMMAND_MODE_CELL_LEFT_LINE_WIDTH
|
||||
NotebookEditorMode.EDIT -> editModeCellLeftLineWidth
|
||||
NotebookEditorMode.COMMAND -> commandModeCellLeftLineWidth
|
||||
}
|
||||
|
||||
override fun getCellLeftLineHoverWidth(): Int =
|
||||
COMMAND_MODE_CELL_LEFT_LINE_WIDTH
|
||||
override fun getCellLeftLineHoverWidth(): Int = commandModeCellLeftLineWidth
|
||||
|
||||
override fun shouldShowCellLineNumbers(): Boolean = true
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.intellij.notebooks.ui.editor
|
||||
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.util.ui.JBUI
|
||||
|
||||
class NewUINotebookDiffEditorAppearance(editor: Editor): DefaultNotebookEditorAppearance(editor){
|
||||
|
||||
override fun shouldShowCellLineNumbers(): Boolean = false
|
||||
override fun shouldShowExecutionCounts(): Boolean = false // not needed for DIFF -> execution does not reach it
|
||||
override fun shouldShowOutExecutionCounts(): Boolean = false
|
||||
override fun shouldShowRunButtonInGutter(): Boolean = true
|
||||
// see comments in org.jetbrains.plugins.notebooks.ui.visualization.DefaultNotebookEditorAppearanceSizes
|
||||
override val CODE_CELL_LEFT_LINE_PADDING: Int = 5
|
||||
override val LINE_NUMBERS_MARGIN: Int = 10
|
||||
|
||||
override val COMMAND_MODE_CELL_LEFT_LINE_WIDTH: Int = 4
|
||||
override val EDIT_MODE_CELL_LEFT_LINE_WIDTH: Int = 2
|
||||
override val CODE_AND_CODE_TOP_GRAY_HEIGHT: Int = 60
|
||||
override val CODE_AND_CODE_BOTTOM_GRAY_HEIGHT: Int = 60
|
||||
override val INNER_CELL_TOOLBAR_HEIGHT: Int = 24
|
||||
override val cellBorderHeight: Int = JBUI.scale(20)
|
||||
override val distanceBetweenCells: Int = JBUI.scale(16)
|
||||
override val aboveFirstCellDelimiterHeight: Int = JBUI.scale(20)
|
||||
override val SPACER_HEIGHT: Int = cellBorderHeight / 2
|
||||
override val EXECUTION_TIME_HEIGHT: Int = 0 // not used in the jupyter diff viewer
|
||||
override val SPACE_BELOW_CELL_TOOLBAR: Int = 10
|
||||
override val CELL_TOOLBAR_TOTAL_HEIGHT: Int = INNER_CELL_TOOLBAR_HEIGHT + SPACE_BELOW_CELL_TOOLBAR
|
||||
override val PROGRESS_STATUS_HEIGHT: Int = 2
|
||||
|
||||
|
||||
override val EXTRA_PADDING_EXECUTION_COUNT: Int = 0
|
||||
|
||||
override fun getCellLeftLineWidth(editor: Editor): 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
|
||||
}
|
||||
@@ -15,7 +15,7 @@ internal class NotebookEditorAppearanceManager {
|
||||
|
||||
private val connection: MessageBusConnection = ApplicationManager.getApplication().getMessageBus().connect(NotebookPluginDisposable.getInstance() as Disposable)
|
||||
|
||||
private val eventDispatcher = EventDispatcher.create<EditorColorsListener>(EditorColorsListener::class.java)
|
||||
private val eventDispatcher = EventDispatcher.create(EditorColorsListener::class.java)
|
||||
|
||||
init {
|
||||
connection.subscribe(EditorColorsManager.TOPIC, EditorColorsListener { scheme ->
|
||||
|
||||
@@ -6,32 +6,30 @@ import com.intellij.util.ui.JBUI
|
||||
|
||||
object DefaultNotebookEditorAppearanceSizes : NotebookEditorAppearanceSizes {
|
||||
// TODO it's hardcoded, but it should be equal to distance between a folding line and an editor.
|
||||
override val CODE_CELL_LEFT_LINE_PADDING: Int = 5
|
||||
override val codeCellLeftLinePadding: Int = JBUI.scale(5)
|
||||
|
||||
// TODO it's hardcoded, but it should be EditorGutterComponentImpl.getLineNumberAreaWidth()
|
||||
override val LINE_NUMBERS_MARGIN: Int = 10
|
||||
override val lineNumbersMargin: Int = JBUI.scale(10)
|
||||
|
||||
// TODO Do the pixel constants need JBUI.scale?
|
||||
override val COMMAND_MODE_CELL_LEFT_LINE_WIDTH: Int = JBUI.scale(4)
|
||||
override val EDIT_MODE_CELL_LEFT_LINE_WIDTH: Int = JBUI.scale(2)
|
||||
override val CODE_AND_CODE_TOP_GRAY_HEIGHT: Int = JBUI.scale(6)
|
||||
override val CODE_AND_CODE_BOTTOM_GRAY_HEIGHT: Int = JBUI.scale(6)
|
||||
override val INNER_CELL_TOOLBAR_HEIGHT: Int = JBUI.scale(24)
|
||||
override val commandModeCellLeftLineWidth: Int = JBUI.scale(4)
|
||||
override val editModeCellLeftLineWidth: Int = JBUI.scale(2)
|
||||
override val codeAndCodeTopGrayHeight: Int = JBUI.scale(6)
|
||||
override val codeAndCodeBottomGrayHeight: Int = JBUI.scale(6)
|
||||
override val innerCellToolbarHeight: Int = JBUI.scale(24)
|
||||
override val distanceBetweenCells: Int = JBUI.scale(16)
|
||||
override val cellBorderHeight: Int = JBUI.scale(16)
|
||||
override val aboveFirstCellDelimiterHeight: Int = JBUI.scale(42)
|
||||
override val SPACER_HEIGHT: Int = JBUI.scale(cellBorderHeight / 2)
|
||||
override val EXECUTION_TIME_HEIGHT: Int = JBUI.scale(SPACER_HEIGHT + 14)
|
||||
override val SPACE_BELOW_CELL_TOOLBAR: Int = JBUI.scale(4)
|
||||
override val CELL_TOOLBAR_TOTAL_HEIGHT: Int = JBUI.scale(INNER_CELL_TOOLBAR_HEIGHT + SPACE_BELOW_CELL_TOOLBAR)
|
||||
override val PROGRESS_STATUS_HEIGHT: Int = JBUI.scale(2)
|
||||
override val spacerHeight: Int = JBUI.scale(cellBorderHeight / 2)
|
||||
override val executionTimeHeight: Int = JBUI.scale(spacerHeight + 14)
|
||||
override val spaceBelowCellToolbar: Int = JBUI.scale(4)
|
||||
override val cellToolbarTotalHeight: Int = JBUI.scale(innerCellToolbarHeight + spaceBelowCellToolbar)
|
||||
override val progressStatusHeight: Int = JBUI.scale(2)
|
||||
|
||||
override val extraPaddingExecutionCount: Int = JBUI.scale(20)
|
||||
|
||||
override val EXTRA_PADDING_EXECUTION_COUNT: Int = JBUI.scale(20)
|
||||
|
||||
override fun getCellLeftLineWidth(editor: Editor): Int = EDIT_MODE_CELL_LEFT_LINE_WIDTH
|
||||
override fun getCellLeftLineHoverWidth(): Int = COMMAND_MODE_CELL_LEFT_LINE_WIDTH
|
||||
override fun getCellLeftLineWidth(editor: Editor): Int = editModeCellLeftLineWidth
|
||||
override fun getCellLeftLineHoverWidth(): Int = commandModeCellLeftLineWidth
|
||||
|
||||
override fun getLeftBorderWidth(): Int =
|
||||
Integer.max(COMMAND_MODE_CELL_LEFT_LINE_WIDTH, EDIT_MODE_CELL_LEFT_LINE_WIDTH) + CODE_CELL_LEFT_LINE_PADDING
|
||||
Integer.max(commandModeCellLeftLineWidth, editModeCellLeftLineWidth) + codeCellLeftLinePadding
|
||||
}
|
||||
@@ -27,6 +27,5 @@ interface NotebookEditorAppearanceColors {
|
||||
fun getGutterInputExecutionCountForegroundColor(scheme: EditorColorsScheme): Color? = null
|
||||
fun getGutterOutputExecutionCountForegroundColor(scheme: EditorColorsScheme): Color? = null
|
||||
fun getProgressStatusRunningColor(scheme: EditorColorsScheme): Color = JBColor.BLUE
|
||||
fun getInlayBackgroundColor(scheme: EditorColorsScheme): Color? = null
|
||||
fun getTextOutputBackground(scheme: EditorColorsScheme): Color = scheme.defaultBackground
|
||||
}
|
||||
@@ -19,24 +19,20 @@ interface NotebookEditorAppearanceSizes {
|
||||
val cellOutputToolbarInlayPriority: Int
|
||||
get() = 5
|
||||
|
||||
val codeCellLeftLinePadding: Int
|
||||
val lineNumbersMargin: Int
|
||||
val commandModeCellLeftLineWidth: Int
|
||||
val editModeCellLeftLineWidth: Int
|
||||
val codeAndCodeTopGrayHeight: Int
|
||||
val codeAndCodeBottomGrayHeight: Int
|
||||
val innerCellToolbarHeight: Int
|
||||
val spacerHeight: Int
|
||||
val executionTimeHeight: Int
|
||||
val spaceBelowCellToolbar: Int
|
||||
val cellToolbarTotalHeight: Int
|
||||
val progressStatusHeight: Int
|
||||
|
||||
val CODE_CELL_LEFT_LINE_PADDING: Int
|
||||
val LINE_NUMBERS_MARGIN: Int
|
||||
|
||||
// TODO Do the pixel constants need JBUI.scale?
|
||||
val COMMAND_MODE_CELL_LEFT_LINE_WIDTH: Int
|
||||
val EDIT_MODE_CELL_LEFT_LINE_WIDTH: Int
|
||||
val CODE_AND_CODE_TOP_GRAY_HEIGHT: Int
|
||||
val CODE_AND_CODE_BOTTOM_GRAY_HEIGHT: Int
|
||||
val INNER_CELL_TOOLBAR_HEIGHT: Int
|
||||
val SPACER_HEIGHT: Int
|
||||
val EXECUTION_TIME_HEIGHT: Int
|
||||
val SPACE_BELOW_CELL_TOOLBAR: Int
|
||||
val CELL_TOOLBAR_TOTAL_HEIGHT: Int
|
||||
val PROGRESS_STATUS_HEIGHT: Int
|
||||
|
||||
|
||||
val EXTRA_PADDING_EXECUTION_COUNT: Int
|
||||
val extraPaddingExecutionCount: Int
|
||||
val cellBorderHeight: Int
|
||||
val aboveFirstCellDelimiterHeight: Int
|
||||
val distanceBetweenCells: Int
|
||||
|
||||
Reference in New Issue
Block a user