VerticalListInlayPresentation: simplify size tracking

GitOrigin-RevId: 31eee7ab77e90e5a51fc20dcadcd43fa64f74de1
This commit is contained in:
Nikolay Plyusnin
2024-06-03 11:42:01 +03:00
committed by intellij-monorepo-bot
parent 46b202f267
commit c44130e554

View File

@@ -1,7 +1,6 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.hints.presentation
import com.intellij.codeInsight.hints.dimension
import com.intellij.openapi.editor.markup.TextAttributes
import java.awt.Dimension
import java.awt.Graphics2D
@@ -20,14 +19,15 @@ class VerticalListInlayPresentation(
val presentations: List<InlayPresentation>
) : BasePresentation() {
override var width: Int = 0
get() = presentations.maxByOrNull { it.width }!!.width
private set
override var height: Int = 0
get() = presentations.sumOf { it.height }
private set
private var presentationUnderCursor: InlayPresentation? = null
init {
calcDimensions()
for (presentation in presentations) {
presentation.addListener(InternalListener(presentation))
}
@@ -63,13 +63,6 @@ class VerticalListInlayPresentation(
changePresentationUnderCursor(null)
}
fun calcDimensions() {
width = presentations.maxByOrNull { it.width }!!.width
height = presentations.sumOf { it.height }
}
private fun handleMouse(
original: Point,
action: (InlayPresentation, Point) -> Unit
@@ -111,10 +104,7 @@ class VerticalListInlayPresentation(
}
override fun sizeChanged(previous: Dimension, current: Dimension) {
val old = dimension()
calcDimensions()
val new = dimension()
this@VerticalListInlayPresentation.fireSizeChanged(old, new)
this@VerticalListInlayPresentation.fireSizeChanged(previous, current)
}
private fun shiftOfCurrent(): Int {