diff --git a/core/api/core.api b/core/api/core.api index 9dae76767..ab0ce833b 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -1486,6 +1486,7 @@ public final class org/jetbrains/jewel/painter/CommonPainterHintsProvider : org/ public static final field $stable I public static final field INSTANCE Lorg/jetbrains/jewel/painter/CommonPainterHintsProvider; public fun hints (Ljava/lang/String;Landroidx/compose/runtime/Composer;I)Ljava/util/List; + public fun priorityHints (Ljava/lang/String;Landroidx/compose/runtime/Composer;I)Ljava/util/List; } public abstract interface class org/jetbrains/jewel/painter/PainterHint { @@ -1504,6 +1505,11 @@ public final class org/jetbrains/jewel/painter/PainterHint$None : org/jetbrains/ public abstract interface class org/jetbrains/jewel/painter/PainterHintsProvider { public abstract fun hints (Ljava/lang/String;Landroidx/compose/runtime/Composer;I)Ljava/util/List; + public abstract fun priorityHints (Ljava/lang/String;Landroidx/compose/runtime/Composer;I)Ljava/util/List; +} + +public final class org/jetbrains/jewel/painter/PainterHintsProvider$DefaultImpls { + public static fun priorityHints (Lorg/jetbrains/jewel/painter/PainterHintsProvider;Ljava/lang/String;Landroidx/compose/runtime/Composer;I)Ljava/util/List; } public final class org/jetbrains/jewel/painter/PainterHintsProviderKt { diff --git a/core/src/main/kotlin/org/jetbrains/jewel/painter/PainterHintsProvider.kt b/core/src/main/kotlin/org/jetbrains/jewel/painter/PainterHintsProvider.kt index a97fff26c..fb6b363ee 100644 --- a/core/src/main/kotlin/org/jetbrains/jewel/painter/PainterHintsProvider.kt +++ b/core/src/main/kotlin/org/jetbrains/jewel/painter/PainterHintsProvider.kt @@ -18,6 +18,15 @@ import org.jetbrains.jewel.painter.hints.HiDpi @Immutable interface PainterHintsProvider { + /** + * These hints will be consumed before the hints which are passed as a parameter to [PainterProvider.getPainter]. + */ + @Composable + fun priorityHints(path: String): List = emptyList() + + /** + * These hints will be consumed after the hints which are passed as a parameter to [PainterProvider.getPainter]. + */ @Composable fun hints(path: String): List } diff --git a/core/src/main/kotlin/org/jetbrains/jewel/painter/ResourcePainterProvider.kt b/core/src/main/kotlin/org/jetbrains/jewel/painter/ResourcePainterProvider.kt index aeee86d2c..857ba34fb 100644 --- a/core/src/main/kotlin/org/jetbrains/jewel/painter/ResourcePainterProvider.kt +++ b/core/src/main/kotlin/org/jetbrains/jewel/painter/ResourcePainterProvider.kt @@ -60,8 +60,10 @@ class ResourcePainterProvider( @Composable override fun getPainter(vararg hints: PainterHint): State { - val resolvedHints = (hints.toList() + LocalPainterHintsProvider.current.hints(basePath)) - .filter { it.canApplyTo(basePath) } + val currentHintsProvider = LocalPainterHintsProvider.current + val providedHints = + currentHintsProvider.priorityHints(basePath) + hints.toList() + currentHintsProvider.hints(basePath) + val resolvedHints = providedHints.filter { it.canApplyTo(basePath) } val cacheKey = resolvedHints.hashCode() @@ -81,22 +83,22 @@ class ResourcePainterProvider( @Composable private fun loadPainter(hints: List): Painter { - val pathStack = buildSet { - var path = basePath - - add(path) - - for (hint in hints) { - path = when (hint) { - is PainterResourcePathHint -> hint.patch(path, contextClassLoaders) - is PainterPathHint -> hint.patch(path) - else -> continue + var paths = setOf(basePath) + + for (hint in hints) { + if (hint !is PainterResourcePathHint && hint !is PainterPathHint) continue + paths = paths.flatMap { + val patched = when (hint) { + is PainterResourcePathHint -> hint.patch(it, contextClassLoaders) + is PainterPathHint -> hint.patch(it) + else -> return@flatMap listOf(it) } - add(path) - } - }.reversed() - val url = pathStack.firstNotNullOfOrNull { resolveResource(it) } + setOf(patched, it) + }.toSet() + } + + val url = paths.firstNotNullOfOrNull { resolveResource(it) } @Suppress("UrlHashCode") // It's ok when comparing a URL to null if (url == null) { diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IntUiBridge.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IntUiBridge.kt index 1dcb6a44f..860b0d62c 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IntUiBridge.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/IntUiBridge.kt @@ -388,7 +388,7 @@ private fun readDefaultDropdownStyle( borderWidth = DarculaUIUtil.BW.dp, ), icons = DropdownIcons( - chevronDown = bridgePainterProvider("${iconsBasePath}general/chevron-down.svg"), + chevronDown = bridgePainterProvider("general/chevron-down.svg"), ), textStyle = dropdownTextStyle, menuStyle = menuStyle, @@ -440,7 +440,7 @@ private fun readUndecoratedDropdownStyle( borderWidth = 0.dp, ), icons = DropdownIcons( - chevronDown = bridgePainterProvider("${iconsBasePath}general/chevron-down.svg"), + chevronDown = bridgePainterProvider("general/chevron-down.svg"), ), textStyle = dropdownTextStyle, menuStyle = menuStyle, @@ -547,11 +547,11 @@ private fun readLinkStyle( metrics = LinkMetrics( focusHaloCornerSize = CornerSize(Registry.intValue("ide.link.button.focus.round.arc", 4).dp), textIconGap = 4.dp, - iconSize = DpSize.Unspecified, + iconSize = DpSize(16.dp, 16.dp), ), icons = LinkIcons( - dropdownChevron = bridgePainterProvider("${iconsBasePath}general/chevron-down.svg"), - externalLink = bridgePainterProvider("${iconsBasePath}ide/external_link_arrow.svg"), + dropdownChevron = bridgePainterProvider("general/chevron-down.svg"), + externalLink = bridgePainterProvider("ide/external_link_arrow.svg"), ), textStyles = LinkTextStyles( normal = linkTextStyle, @@ -604,7 +604,7 @@ private fun readMenuStyle(): MenuStyle { itemMetrics = MenuItemMetrics( selectionCornerSize = CornerSize(JBUI.CurrentTheme.PopupMenu.Selection.ARC.dp), outerPadding = PaddingValues(horizontal = 6.dp), - contentPadding = PaddingValues(horizontal = 10.dp, vertical = 1.dp), + contentPadding = PaddingValues(horizontal = 10.dp, vertical = 4.dp), separatorPadding = PaddingValues( horizontal = retrieveIntAsDpOrUnspecified("PopupMenuSeparator.withToEdge").takeOrElse { 0.dp }, vertical = retrieveIntAsDpOrUnspecified("PopupMenuSeparator.stripeIndent").takeOrElse { 0.dp }, @@ -616,7 +616,7 @@ private fun readMenuStyle(): MenuStyle { ), ), icons = MenuIcons( - submenuChevron = bridgePainterProvider("${iconsBasePath}general/chevron-down.svg"), + submenuChevron = bridgePainterProvider("general/chevron-right.svg"), ), ) } @@ -766,8 +766,8 @@ private fun readLazyTreeStyle(): LazyTreeStyle { elementBackgroundSelectedFocused = selectedElementBackground, ) - val chevronCollapsed = bridgePainterProvider("${iconsBasePath}general/chevron-right.svg") - val chevronExpanded = bridgePainterProvider("${iconsBasePath}general/chevron-down.svg") + val chevronCollapsed = bridgePainterProvider("general/chevron-right.svg") + val chevronExpanded = bridgePainterProvider("general/chevron-down.svg") return LazyTreeStyle( colors = colors, @@ -826,7 +826,7 @@ private fun readDefaultTabStyle(): TabStyle { tabHeight = retrieveIntAsDpOrUnspecified("TabbedPane.tabHeight").takeOrElse { 24.dp }, ), icons = TabIcons( - close = bridgePainterProvider("${iconsBasePath}expui/general/closeSmall.svg"), + close = bridgePainterProvider("expui/general/closeSmall.svg"), ), contentAlpha = TabContentAlpha( iconNormal = 1f, @@ -881,7 +881,7 @@ private fun readEditorTabStyle(): TabStyle { tabHeight = retrieveIntAsDpOrUnspecified("TabbedPane.tabHeight").takeOrElse { 24.dp }, ), icons = TabIcons( - close = bridgePainterProvider("${iconsBasePath}expui/general/closeSmall.svg"), + close = bridgePainterProvider("expui/general/closeSmall.svg"), ), contentAlpha = TabContentAlpha( iconNormal = .7f, diff --git a/int-ui/int-ui-core/api/int-ui-core.api b/int-ui/int-ui-core/api/int-ui-core.api index bab021b3a..d153570ec 100644 --- a/int-ui/int-ui-core/api/int-ui-core.api +++ b/int-ui/int-ui-core/api/int-ui-core.api @@ -67,6 +67,7 @@ public abstract class org/jetbrains/jewel/intui/core/IntUiPainterHintsProvider : public static final field $stable I public fun (ZLjava/util/Map;Ljava/util/Map;Ljava/util/Map;)V protected final fun getPaletteHint (Ljava/lang/String;)Lorg/jetbrains/jewel/painter/PainterHint; + public fun priorityHints (Ljava/lang/String;Landroidx/compose/runtime/Composer;I)Ljava/util/List; } public abstract interface class org/jetbrains/jewel/intui/core/IntUiThemeColorPalette : org/jetbrains/jewel/IntelliJThemeColorPalette { diff --git a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTooltipStyling.kt b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTooltipStyling.kt index 22c78a469..a8c396637 100644 --- a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTooltipStyling.kt +++ b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTooltipStyling.kt @@ -36,19 +36,19 @@ fun TooltipStyle.Companion.dark( @Composable fun TooltipColors.Companion.light( - contentColor: Color = IntUiLightTheme.colors.grey(12), backgroundColor: Color = IntUiLightTheme.colors.grey(2), + contentColor: Color = IntUiLightTheme.colors.grey(12), borderColor: Color = backgroundColor, shadow: Color = Color(0x78919191), // Not a palette color -) = TooltipColors(contentColor, backgroundColor, borderColor, shadow) +) = TooltipColors(backgroundColor, contentColor, borderColor, shadow) @Composable fun TooltipColors.Companion.dark( - contentColor: Color = IntUiDarkTheme.colors.grey(12), backgroundColor: Color = IntUiDarkTheme.colors.grey(2), - shadow: Color = Color(0x66000000), // Not a palette color + contentColor: Color = IntUiDarkTheme.colors.grey(12), borderColor: Color = IntUiDarkTheme.colors.grey(3), -) = TooltipColors(contentColor, backgroundColor, borderColor, shadow) + shadow: Color = Color(0x66000000), // Not a palette color +) = TooltipColors(backgroundColor, contentColor, borderColor, shadow) fun TooltipMetrics.Companion.defaults( contentPadding: PaddingValues = PaddingValues(vertical = 9.dp, horizontal = 12.dp),