mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[command-completion] IDEA-381061 Command and postfix completion previews shouldn't show documentation UI elements
GitOrigin-RevId: 759e4942c791f46f4963f73c8cad0749bee45f10
This commit is contained in:
committed by
intellij-monorepo-bot
parent
55765566c8
commit
9abbc55f0f
+7
-1
@@ -88,10 +88,16 @@ internal class DocumentationPopupUI(
|
||||
gearActions.addAll(secondaryActions)
|
||||
gearActions.addSeparator()
|
||||
gearActions.addAll(primaryActions)
|
||||
|
||||
val corner = toolbarComponent(DefaultActionGroup(editSourceAction, gearActions), editorPane).apply {
|
||||
border = JBUI.Borders.empty(0, 0, contentOuterPadding - 3, settingsButtonPadding - 5)
|
||||
}
|
||||
|
||||
ui.trackDocumentationCustomStyleChange(this){
|
||||
if (it != null) {
|
||||
corner.isVisible = !it.customEnabled
|
||||
}
|
||||
}
|
||||
|
||||
ui.trackDocumentationBackgroundChange(this) {
|
||||
corner.background = it
|
||||
}
|
||||
|
||||
@@ -42,16 +42,12 @@ import com.intellij.util.ui.UIUtil
|
||||
import com.intellij.util.ui.accessibility.ScreenReader
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
import kotlinx.coroutines.flow.asSharedFlow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.jetbrains.annotations.Nls
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import java.awt.Color
|
||||
import java.awt.Font
|
||||
import java.awt.Graphics
|
||||
import java.awt.Rectangle
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JLabel
|
||||
@@ -90,6 +86,8 @@ internal class DocumentationUI(
|
||||
private val switcher: DefinitionSwitcher<DocumentationRequest>
|
||||
private var contentKind: ContentKind? = null
|
||||
|
||||
private val customStyleFlow: MutableStateFlow<CustomStyle?> = MutableStateFlow(null)
|
||||
|
||||
init {
|
||||
scrollPane = DocumentationScrollPane()
|
||||
editorPane = DocumentationHintEditorPane(project, DocumentationScrollPane.keyboardActions(scrollPane)) {
|
||||
@@ -206,6 +204,25 @@ internal class DocumentationUI(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tracks changes to a custom style and invokes the provided callback when the style changes.
|
||||
*
|
||||
* @param disposable A disposable object to manage the lifecycle of style change tracking. The tracking will stop when this disposable is disposed.
|
||||
* @param onChange A callback function that is invoked whenever the custom style changes. The function receives the updated `CustomStyle` or `null` if no style is available.
|
||||
*/
|
||||
fun trackDocumentationCustomStyleChange(disposable: Disposable, onChange: (CustomStyle?) -> Unit) {
|
||||
val job = cs.launch {
|
||||
customStyleFlow.collectLatest {
|
||||
withContext(Dispatchers.EDT) {
|
||||
onChange(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
Disposer.register(disposable) {
|
||||
job.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearImages() {
|
||||
imageResolver = null
|
||||
}
|
||||
@@ -285,6 +302,9 @@ internal class DocumentationUI(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal data class CustomStyle(val backgroundColor: Color, val customEnabled: Boolean)
|
||||
|
||||
private data class DecoratedData(@NlsSafe val html: String, val decoratedStyle: DecoratedStyle?)
|
||||
private data class DecoratedStyle(val fontSize: Float, val backgroundColor: Color)
|
||||
private data class PreviousDecoratedStyle(val fontSize: FontSize, val backgroundColor: Color)
|
||||
@@ -378,6 +398,7 @@ internal class DocumentationUI(
|
||||
editorPane.isCustomSettingsEnabled = true
|
||||
editorPane.setFont(UIUtil.getFontWithFallback(editorPane.getFontName(), Font.PLAIN, JBUIScale.scale(decoratedStyle.fontSize).toInt()))
|
||||
editorPane.background = decoratedStyle.backgroundColor
|
||||
customStyleFlow.value = CustomStyle(decoratedStyle.backgroundColor, true)
|
||||
}
|
||||
else {
|
||||
val localInitialDecoratedData = initialDecoratedData
|
||||
@@ -385,6 +406,7 @@ internal class DocumentationUI(
|
||||
editorPane.isCustomSettingsEnabled = false
|
||||
editorPane.background = localInitialDecoratedData.backgroundColor
|
||||
editorPane.applyFontProps(localInitialDecoratedData.fontSize)
|
||||
customStyleFlow.value = CustomStyle(localInitialDecoratedData.backgroundColor, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user