Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement/fix/complete implementation of scrollbars #554

Merged
merged 14 commits into from
Aug 26, 2024
13 changes: 11 additions & 2 deletions ide-laf-bridge/api/ide-laf-bridge.api
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public final class org/jetbrains/jewel/bridge/BridgeUtilsKt {
public static final fun retrieveArcAsCornerSize (Ljava/lang/String;)Landroidx/compose/foundation/shape/CornerSize;
public static final fun retrieveArcAsCornerSizeOrDefault (Ljava/lang/String;Landroidx/compose/foundation/shape/CornerSize;)Landroidx/compose/foundation/shape/CornerSize;
public static final fun retrieveArcAsCornerSizeWithFallbacks ([Ljava/lang/String;)Landroidx/compose/foundation/shape/CornerSize;
public static final fun retrieveColor-0YGnOg8 (Ljava/lang/String;ZJJ)J
public static final fun retrieveColor-4WTKRHQ (Ljava/lang/String;J)J
public static final fun retrieveColorOrNull (Ljava/lang/String;)Landroidx/compose/ui/graphics/Color;
public static final fun retrieveColorOrUnspecified (Ljava/lang/String;)J
Expand Down Expand Up @@ -139,8 +140,16 @@ public final class org/jetbrains/jewel/bridge/theme/IntUiBridgeKt {
}

public final class org/jetbrains/jewel/bridge/theme/ScrollbarBridgeKt {
public static final fun defaults-6ksGUsA (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling$Companion;JJJJ)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling;
public static synthetic fun defaults-6ksGUsA$default (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling$Companion;JJJJILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling;
public static final fun default (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$AlwaysVisible$Companion;)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$AlwaysVisible;
public static final fun default (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling$Companion;)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling;
public static final fun macOs-TZvXluI (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling$Companion;FFLandroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/foundation/layout/PaddingValues;JJJJ)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling;
public static synthetic fun macOs-TZvXluI$default (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling$Companion;FFLandroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/foundation/layout/PaddingValues;JJJJILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling;
public static final fun macOs-fYp4AQw (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$AlwaysVisible$Companion;FLandroidx/compose/foundation/layout/PaddingValues;JJJ)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$AlwaysVisible;
public static synthetic fun macOs-fYp4AQw$default (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$AlwaysVisible$Companion;FLandroidx/compose/foundation/layout/PaddingValues;JJJILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$AlwaysVisible;
public static final fun windowsAndLinux-TZvXluI (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling$Companion;FFLandroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/foundation/layout/PaddingValues;JJJJ)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling;
public static synthetic fun windowsAndLinux-TZvXluI$default (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling$Companion;FFLandroidx/compose/foundation/layout/PaddingValues;Landroidx/compose/foundation/layout/PaddingValues;JJJJILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$WhenScrolling;
public static final fun windowsAndLinux-tYhzLtE (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$AlwaysVisible$Companion;FLandroidx/compose/foundation/layout/PaddingValues;JJ)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$AlwaysVisible;
public static synthetic fun windowsAndLinux-tYhzLtE$default (Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$AlwaysVisible$Companion;FLandroidx/compose/foundation/layout/PaddingValues;JJILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/ScrollbarVisibility$AlwaysVisible;
}

public final class org/jetbrains/jewel/bridge/theme/SwingBridgeThemeKt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@ public fun retrieveColor(
default: Color,
): Color = retrieveColorOrNull(key) ?: default

public fun retrieveColor(
key: String,
isDark: Boolean,
default: Color,
defaultDark: Color,
): Color = retrieveColorOrNull(key) ?: if (isDark) defaultDark else default

public fun retrieveColorOrNull(key: String): Color? = JBColor.namedColorOrNull(key)?.toComposeColor()

public fun retrieveColorOrUnspecified(key: String): Color {
val color = retrieveColorOrNull(key)
if (color == null) {
logger.warn("Color with key \"$key\" not found, fallback to 'Color.Unspecified'")
logger.debug("Color with key \"$key\" not found, fallback to 'Color.Unspecified'")
}
return color ?: Color.Unspecified
}
Expand Down Expand Up @@ -98,9 +105,8 @@ public fun retrieveInsetsAsPaddingValues(
): PaddingValues = UIManager.getInsets(key)?.toPaddingValues() ?: default ?: keyNotFound(key, "Insets")

/**
* Converts a [Insets] to [PaddingValues]. If the receiver is a [JBInsets]
* instance, this function delegates to the specific [toPaddingValues] for
* it, which is scaling-aware.
* Converts a [Insets] to [PaddingValues]. If the receiver is a [JBInsets] instance, this function delegates to the
* specific [toPaddingValues] for it, which is scaling-aware.
*/
public fun Insets.toPaddingValues(): PaddingValues =
if (this is JBInsets) {
Expand All @@ -110,26 +116,22 @@ public fun Insets.toPaddingValues(): PaddingValues =
}

/**
* Converts a [JBInsets] to [PaddingValues], in a scaling-aware way. This
* means that the resulting [PaddingValues] will be constructed from the
* [JBInsets.getUnscaled] values, treated as [Dp]. This avoids double
* scaling.
* Converts a [JBInsets] to [PaddingValues], in a scaling-aware way. This means that the resulting [PaddingValues] will
* be constructed from the [JBInsets.getUnscaled] values, treated as [Dp]. This avoids double scaling.
*/
@Suppress("ktlint:standard:function-signature") // False positive
public fun JBInsets.toPaddingValues(): PaddingValues =
PaddingValues(unscaled.left.dp, unscaled.top.dp, unscaled.right.dp, unscaled.bottom.dp)

/**
* Converts a [Dimension] to [DpSize]. If the receiver is a [JBDimension]
* instance, this function delegates to the specific [toDpSize] for it,
* which is scaling-aware.
* Converts a [Dimension] to [DpSize]. If the receiver is a [JBDimension] instance, this function delegates to the
* specific [toDpSize] for it, which is scaling-aware.
*/
public fun Dimension.toDpSize(): DpSize = if (this is JBDimension) toDpSize() else DpSize(width.dp, height.dp)

/**
* Converts a [JBDimension] to [DpSize], in a scaling-aware way. This means
* that the resulting [DpSize] will be constructed by first obtaining the
* unscaled values. This avoids double scaling.
* Converts a [JBDimension] to [DpSize], in a scaling-aware way. This means that the resulting [DpSize] will be
* constructed by first obtaining the unscaled values. This avoids double scaling.
*/
public fun JBDimension.toDpSize(): DpSize {
val scaleFactor = scale(1f)
Expand Down Expand Up @@ -182,7 +184,8 @@ public fun retrieveTextStyle(
val jbFont = JBFont.create(lafFont, false)

val derivedFont =
jbFont.let { if (bold) it.asBold() else it.asPlain() }
jbFont
.let { if (bold) it.asBold() else it.asPlain() }
.let { if (fontStyle == FontStyle.Italic) it.asItalic() else it }

return TextStyle(
Expand Down

This file was deleted.

Loading