From d802a00a64f89782311dfb0cb9c2d00d54d8189f Mon Sep 17 00:00:00 2001 From: Sebastiano Poggi Date: Fri, 22 Sep 2023 18:10:29 +0200 Subject: [PATCH] No indication by default in Jewel (#130) Indication is not compatible with how Int UI handles state, so we need to disable it by default. --- .../jewel/intui/core/BaseIntUiTheme.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/int-ui/int-ui-core/src/main/kotlin/org/jetbrains/jewel/intui/core/BaseIntUiTheme.kt b/int-ui/int-ui-core/src/main/kotlin/org/jetbrains/jewel/intui/core/BaseIntUiTheme.kt index 9c00c2434..1d3d569ca 100644 --- a/int-ui/int-ui-core/src/main/kotlin/org/jetbrains/jewel/intui/core/BaseIntUiTheme.kt +++ b/int-ui/int-ui-core/src/main/kotlin/org/jetbrains/jewel/intui/core/BaseIntUiTheme.kt @@ -1,10 +1,15 @@ package org.jetbrains.jewel.intui.core +import androidx.compose.foundation.Indication +import androidx.compose.foundation.IndicationInstance import androidx.compose.foundation.LocalContextMenuRepresentation +import androidx.compose.foundation.LocalIndication +import androidx.compose.foundation.interaction.InteractionSource import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.drawscope.ContentDrawScope import androidx.compose.ui.text.TextStyle import org.jetbrains.jewel.GlobalColors import org.jetbrains.jewel.GlobalMetrics @@ -215,7 +220,22 @@ fun BaseIntUiTheme( LocalTextFieldStyle provides componentStyling.textFieldStyle, LocalDefaultTabStyle provides componentStyling.defaultTabStyle, LocalEditorTabStyle provides componentStyling.editorTabStyle, + LocalIndication provides NoIndication, ) { IntelliJTheme(theme, swingCompatMode, content) } } + +private object NoIndication : Indication { + + private object NoIndicationInstance : IndicationInstance { + + override fun ContentDrawScope.drawIndication() { + drawContent() + } + } + + @Composable + override fun rememberUpdatedInstance(interactionSource: InteractionSource): IndicationInstance = + NoIndicationInstance +}