mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
IJPL-159801 Fix for issue with overlapping sticky lines panel and toolwindows
GitOrigin-RevId: 988b412199ffb1e508fac7a2818dceec27563554
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6fd41cc041
commit
5825091eb1
@@ -88,8 +88,7 @@ internal class StickyLineComponent(private val editor: EditorEx) : JComponent()
|
||||
assert(!isEmpty()) { "sticky panel should mark this line as not visible" }
|
||||
val editorY = editorY()
|
||||
val lineHeight = lineHeight()
|
||||
val gutterWidth = editor.gutterComponentEx.width
|
||||
val textWidth = lineWidth() - gutterWidth
|
||||
val (gutterWidth, textWidth) = gutterAndTextWidth()
|
||||
val editorBackground = editor.backgroundColor
|
||||
var isBackgroundChanged = false
|
||||
(editor as EditorImpl).isStickyLinePainting = true
|
||||
@@ -111,6 +110,16 @@ internal class StickyLineComponent(private val editor: EditorEx) : JComponent()
|
||||
}
|
||||
}
|
||||
|
||||
private fun gutterAndTextWidth(): Pair<Int, Int> {
|
||||
val lineWidth = lineWidth()
|
||||
val gutterWidth = editor.gutterComponentEx.width
|
||||
if (gutterWidth > lineWidth) {
|
||||
// IJPL-159801
|
||||
return lineWidth to 0
|
||||
}
|
||||
return gutterWidth to lineWidth - gutterWidth
|
||||
}
|
||||
|
||||
private fun setStickyLineBackgroundColor(): Boolean {
|
||||
val backgroundColorKey = if (isHovered) {
|
||||
EditorColors.STICKY_LINES_HOVERED_COLOR
|
||||
|
||||
@@ -4,7 +4,6 @@ package com.intellij.openapi.editor.impl.stickyLines.ui
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import java.awt.Color
|
||||
import java.awt.GradientPaint
|
||||
import java.awt.Graphics
|
||||
import java.awt.Graphics2D
|
||||
|
||||
@Suppress("UseJBColor") // JBColor does not work properly if IDE theme differs from editor's color scheme
|
||||
@@ -19,20 +18,10 @@ internal class StickyLineShadowPainter(var isDarkColorScheme: Boolean = false) {
|
||||
private val SHADOW_COLOR_DARK = Color(0, 0, 0, SHADOW_COLOR_ALPHA_DARK)
|
||||
private val SHADOW_COLOR_TRANSPARENT = Color(0, 0, 0, 0)
|
||||
|
||||
private var panelWidth: Int = 0
|
||||
private var panelHeight: Int = 0
|
||||
private var lineHeight: Int = 0
|
||||
|
||||
fun updateShadow(newPanelWidth: Int, newPanelHeight: Int, newLineHeight: Int) {
|
||||
panelWidth = newPanelWidth
|
||||
panelHeight = newPanelHeight
|
||||
lineHeight = newLineHeight
|
||||
}
|
||||
|
||||
@Suppress("GraphicsSetClipInspection")
|
||||
fun paintShadow(g: Graphics?) {
|
||||
if (isEnabled() && isPanelPresent() && g is Graphics2D) {
|
||||
val shadowHeight = shadowHeight()
|
||||
fun paintShadow(g: Graphics2D, panelHeight: Int, panelWidth: Int, lineHeight: Int) {
|
||||
if (isEnabled()) {
|
||||
val shadowHeight = shadowHeight(lineHeight)
|
||||
val prevPaint = g.paint
|
||||
g.setClip(0, 0, panelWidth, panelHeight + shadowHeight)
|
||||
g.translate(0, panelHeight)
|
||||
@@ -51,7 +40,7 @@ internal class StickyLineShadowPainter(var isDarkColorScheme: Boolean = false) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun shadowHeight(): Int {
|
||||
private fun shadowHeight(lineHeight: Int): Int {
|
||||
val factor = if (isDarkColorScheme) SHADOW_HEIGHT_FACTOR_DARK else SHADOW_HEIGHT_FACTOR_LIGHT
|
||||
return (lineHeight * factor).toInt()
|
||||
}
|
||||
@@ -60,10 +49,6 @@ internal class StickyLineShadowPainter(var isDarkColorScheme: Boolean = false) {
|
||||
return if (isDarkColorScheme) SHADOW_COLOR_DARK else SHADOW_COLOR_LIGHT
|
||||
}
|
||||
|
||||
private fun isPanelPresent(): Boolean {
|
||||
return panelWidth > 0 && panelHeight > 0 && lineHeight > 0
|
||||
}
|
||||
|
||||
private fun isEnabled(): Boolean {
|
||||
return Registry.`is`("editor.show.sticky.lines.shadow", true)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.intellij.ui.components.JBLayeredPane
|
||||
import com.intellij.ui.components.JBPanel
|
||||
import java.awt.Color
|
||||
import java.awt.Graphics
|
||||
import java.awt.Graphics2D
|
||||
import javax.swing.BoxLayout
|
||||
|
||||
internal class StickyLinesPanel(
|
||||
@@ -59,7 +60,7 @@ internal class StickyLinesPanel(
|
||||
// ------------------------------------------- Impl -------------------------------------------
|
||||
|
||||
private fun repaintLinesImpl() {
|
||||
val panelWidth: Int = (editor as EditorImpl).stickyLinesPanelWidth
|
||||
val panelWidth: Int = stickyLinesPanelWidth()
|
||||
val lineHeight: Int = editor.lineHeight
|
||||
var index = 0
|
||||
val components: Iterator<StickyLineComponent> = stickyComponents.unboundComponents().iterator()
|
||||
@@ -88,14 +89,14 @@ internal class StickyLinesPanel(
|
||||
repaint()
|
||||
}
|
||||
|
||||
override fun setBounds(x: Int, y: Int, width: Int, height: Int) {
|
||||
super.setBounds(x, y, width, height)
|
||||
shadowPainter.updateShadow(width, height, editor.lineHeight)
|
||||
}
|
||||
|
||||
override fun paintComponent(g: Graphics?) {
|
||||
super.paintComponent(g)
|
||||
shadowPainter.paintShadow(g)
|
||||
val panelHeight = panelH
|
||||
val panelWidth = stickyLinesPanelWidth() // panelW can be outdated here
|
||||
val lineHeight = editor.lineHeight
|
||||
if (g is Graphics2D && panelHeight > 0 && panelWidth > 0 && lineHeight > 0) {
|
||||
shadowPainter.paintShadow(g, panelHeight, panelWidth, lineHeight)
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------- Utils -------------------------------------------
|
||||
@@ -104,6 +105,10 @@ internal class StickyLinesPanel(
|
||||
return this.panelW != panelWidth || this.panelH != panelHeight
|
||||
}
|
||||
|
||||
private fun stickyLinesPanelWidth(): Int {
|
||||
return (editor as EditorImpl).stickyLinesPanelWidth
|
||||
}
|
||||
|
||||
private fun isPanelEnabled(): Boolean {
|
||||
val isEnabled = editor.settings.areStickyLinesShown()
|
||||
if (!isEnabled && stickyComponents.clear()) {
|
||||
|
||||
Reference in New Issue
Block a user