From 75fa039a4cfdd3f1c13271c81a319ea06c0f5614 Mon Sep 17 00:00:00 2001 From: Ivan Morgillo Date: Mon, 2 Dec 2024 17:23:20 +0100 Subject: [PATCH 1/5] move styles to proper files Signed-off-by: Ivan Morgillo --- .../jewel/bridge/theme/BridgeSliderStyling.kt | 90 ------------ .../jewel/bridge/theme/IntUiBridgeButton.kt | 135 ------------------ .../theme/IntUiBridgeCircularProgress.kt | 16 +++ .../bridge/theme/IntUiBridgeEditorTab.kt | 70 +++++++++ ...kt => IntUiBridgeHorizontalProgressBar.kt} | 14 +- .../bridge/theme/IntUiBridgeIconButton.kt | 42 ++++++ .../bridge/theme/IntUiBridgeOutlinedButton.kt | 71 +++++++++ ...llbarBridge.kt => IntUiBridgeScrollbar.kt} | 4 +- .../IntUiBridgeSegmentedControlButton.kt | 64 +++++++++ .../jewel/bridge/theme/IntUiBridgeSlider.kt | 86 +++++++++++ .../jewel/bridge/theme/IntUiBridgeTab.kt | 52 ------- 11 files changed, 352 insertions(+), 292 deletions(-) delete mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/BridgeSliderStyling.kt create mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeCircularProgress.kt create mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt rename ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/{IntUiBridgeProgress.kt => IntUiBridgeHorizontalProgressBar.kt} (77%) create mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeIconButton.kt create mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt rename ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/{ScrollbarBridge.kt => IntUiBridgeScrollbar.kt} (100%) create mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSegmentedControlButton.kt diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/BridgeSliderStyling.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/BridgeSliderStyling.kt deleted file mode 100644 index c4e23906de..0000000000 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/BridgeSliderStyling.kt +++ /dev/null @@ -1,90 +0,0 @@ -package org.jetbrains.jewel.bridge.theme - -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.takeOrElse -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.DpSize -import androidx.compose.ui.unit.dp -import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified -import org.jetbrains.jewel.ui.component.styling.SliderColors -import org.jetbrains.jewel.ui.component.styling.SliderMetrics - -public fun SliderColors.Companion.light( - track: Color = retrieveColorOrUnspecified("ColorPalette.Gray10").takeOrElse { Color(0xFFD3D5DB) }, - trackFilled: Color = retrieveColorOrUnspecified("ColorPalette.Blue6").takeOrElse { Color(0xFF588CF3) }, - trackDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray12").takeOrElse { Color(0xFFEBECF0) }, - trackFilledDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray11").takeOrElse { Color(0xFFDFE1E5) }, - stepMarker: Color = track, - thumbFill: Color = retrieveColorOrUnspecified("ColorPalette.Gray14").takeOrElse { Color(0xFFFFFFFF) }, - thumbFillDisabled: Color = thumbFill, - thumbFillFocused: Color = thumbFill, - thumbFillPressed: Color = thumbFill, - thumbFillHovered: Color = thumbFill, - thumbBorder: Color = retrieveColorOrUnspecified("ColorPalette.Gray8").takeOrElse { Color(0xFFA8ADBD) }, - thumbBorderFocused: Color = retrieveColorOrUnspecified("ColorPalette.Blue4").takeOrElse { Color(0xFF3574F0) }, - thumbBorderDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray11").takeOrElse { Color(0xFFDFE1E5) }, - thumbBorderPressed: Color = retrieveColorOrUnspecified("ColorPalette.Gray7").takeOrElse { Color(0xFF818594) }, - thumbBorderHovered: Color = retrieveColorOrUnspecified("ColorPalette.Gray9").takeOrElse { Color(0xFFC9CCD6) }, -): SliderColors = - SliderColors( - track, - trackFilled, - trackDisabled, - trackFilledDisabled, - stepMarker, - thumbFill, - thumbFillDisabled, - thumbFillFocused, - thumbFillPressed, - thumbFillHovered, - thumbBorder, - thumbBorderFocused, - thumbBorderDisabled, - thumbBorderPressed, - thumbBorderHovered, - ) - -public fun SliderColors.Companion.dark( - track: Color = retrieveColorOrUnspecified("ColorPalette.Gray4").takeOrElse { Color(0xFF43454A) }, - trackFilled: Color = retrieveColorOrUnspecified("ColorPalette.Blue7").takeOrElse { Color(0xFF467FF2) }, - trackDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray3").takeOrElse { Color(0xFF393B40) }, - trackFilledDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray4").takeOrElse { Color(0xFF43454A) }, - stepMarker: Color = track, - thumbFill: Color = retrieveColorOrUnspecified("ColorPalette.Gray2").takeOrElse { Color(0xFF2B2D30) }, - thumbFillDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray3").takeOrElse { Color(0xFF393B40) }, - thumbFillFocused: Color = thumbFill, - thumbFillPressed: Color = thumbFill, - thumbFillHovered: Color = thumbFill, - thumbBorder: Color = retrieveColorOrUnspecified("ColorPalette.Gray7").takeOrElse { Color(0xFF6F737A) }, - thumbBorderFocused: Color = retrieveColorOrUnspecified("ColorPalette.Blue6").takeOrElse { Color(0xFF3574F0) }, - thumbBorderDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray5").takeOrElse { Color(0xFF4E5157) }, - thumbBorderPressed: Color = retrieveColorOrUnspecified("ColorPalette.Gray8").takeOrElse { Color(0xFF868A91) }, - thumbBorderHovered: Color = retrieveColorOrUnspecified("ColorPalette.Gray9").takeOrElse { Color(0xFF9DA0A8) }, -): SliderColors = - SliderColors( - track, - trackFilled, - trackDisabled, - trackFilledDisabled, - stepMarker, - thumbFill, - thumbFillDisabled, - thumbFillFocused, - thumbFillPressed, - thumbFillHovered, - thumbBorder, - thumbBorderFocused, - thumbBorderDisabled, - thumbBorderPressed, - thumbBorderHovered, - ) - -public fun SliderMetrics.Companion.defaults( - trackHeight: Dp = 4.dp, - thumbSize: DpSize = DpSize(14.dp, 14.dp), - thumbBorderWidth: Dp = 1.dp, - stepLineHeight: Dp = 8.dp, - stepLineWidth: Dp = 1.dp, - trackToStepSpacing: Dp = thumbSize.height / 2 + 4.dp, -): SliderMetrics = - SliderMetrics(trackHeight, thumbSize, thumbBorderWidth, stepLineHeight, stepLineWidth, trackToStepSpacing) diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt index 2a5e6f6813..8971a2aedf 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt @@ -1,16 +1,12 @@ package org.jetbrains.jewel.bridge.theme import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.shape.CornerSize import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor -import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp -import com.intellij.ide.ui.laf.darcula.DarculaUIUtil import com.intellij.util.ui.JBUI import org.jetbrains.jewel.bridge.createVerticalBrush -import org.jetbrains.jewel.bridge.dp import org.jetbrains.jewel.bridge.retrieveArcAsCornerSizeWithFallbacks import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified import org.jetbrains.jewel.bridge.toComposeColor @@ -19,12 +15,6 @@ import org.jetbrains.jewel.foundation.Stroke import org.jetbrains.jewel.ui.component.styling.ButtonColors import org.jetbrains.jewel.ui.component.styling.ButtonMetrics import org.jetbrains.jewel.ui.component.styling.ButtonStyle -import org.jetbrains.jewel.ui.component.styling.IconButtonColors -import org.jetbrains.jewel.ui.component.styling.IconButtonMetrics -import org.jetbrains.jewel.ui.component.styling.IconButtonStyle -import org.jetbrains.jewel.ui.component.styling.SegmentedControlButtonColors -import org.jetbrains.jewel.ui.component.styling.SegmentedControlButtonMetrics -import org.jetbrains.jewel.ui.component.styling.SegmentedControlButtonStyle internal fun readDefaultButtonStyle(): ButtonStyle { val normalBackground = @@ -77,128 +67,3 @@ internal fun readDefaultButtonStyle(): ButtonStyle { ) } -internal fun readOutlinedButtonStyle(): ButtonStyle { - val normalBackground = - listOf( - JBUI.CurrentTheme.Button.buttonColorStart().toComposeColor(), - JBUI.CurrentTheme.Button.buttonColorEnd().toComposeColor(), - ) - .createVerticalBrush() - - val normalContent = retrieveColorOrUnspecified("Button.foreground") - - val normalBorder = - listOf( - JBUI.CurrentTheme.Button.buttonOutlineColorStart(false).toComposeColor(), - JBUI.CurrentTheme.Button.buttonOutlineColorEnd(false).toComposeColor(), - ) - .createVerticalBrush() - - val colors = - ButtonColors( - background = normalBackground, - backgroundDisabled = SolidColor(Color.Transparent), - backgroundFocused = normalBackground, - backgroundPressed = normalBackground, - backgroundHovered = normalBackground, - content = normalContent, - contentDisabled = retrieveColorOrUnspecified("Button.disabledText"), - contentFocused = normalContent, - contentPressed = normalContent, - contentHovered = normalContent, - border = normalBorder, - borderDisabled = SolidColor(JBUI.CurrentTheme.Button.disabledOutlineColor().toComposeColor()), - borderFocused = SolidColor(JBUI.CurrentTheme.Button.focusBorderColor(false).toComposeColor()), - borderPressed = normalBorder, - borderHovered = normalBorder, - ) - - val minimumSize = JBUI.CurrentTheme.Button.minimumSize().toDpSize() - return ButtonStyle( - colors = colors, - metrics = - ButtonMetrics( - cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), - padding = PaddingValues(horizontal = 14.dp), // see DarculaButtonUI.HORIZONTAL_PADDING - minSize = DpSize(minimumSize.width, minimumSize.height), - borderWidth = DarculaUIUtil.LW.dp, - focusOutlineExpand = Dp.Unspecified, - ), - focusOutlineAlignment = Stroke.Alignment.Center, - ) -} - -internal fun readSegmentedControlButtonStyle(): SegmentedControlButtonStyle { - val selectedBackground = SolidColor(JBUI.CurrentTheme.SegmentedButton.SELECTED_BUTTON_COLOR.toComposeColor()) - - val normalBorder = - listOf( - JBUI.CurrentTheme.SegmentedButton.SELECTED_START_BORDER_COLOR.toComposeColor(), - JBUI.CurrentTheme.SegmentedButton.SELECTED_END_BORDER_COLOR.toComposeColor(), - ) - .createVerticalBrush() - - val selectedDisabledBorder = - listOf( - JBUI.CurrentTheme.Button.buttonOutlineColorStart(false).toComposeColor(), - JBUI.CurrentTheme.Button.buttonOutlineColorEnd(false).toComposeColor(), - ) - .createVerticalBrush() - - val colors = - SegmentedControlButtonColors( - background = SolidColor(Color.Transparent), - backgroundPressed = selectedBackground, - backgroundHovered = SolidColor(JBUI.CurrentTheme.ActionButton.hoverBackground().toComposeColor()), - backgroundSelected = selectedBackground, - backgroundSelectedFocused = - SolidColor(JBUI.CurrentTheme.SegmentedButton.FOCUSED_SELECTED_BUTTON_COLOR.toComposeColor()), - content = retrieveColorOrUnspecified("Button.foreground"), - contentDisabled = retrieveColorOrUnspecified("Label.disabledForeground"), - border = normalBorder, - borderSelected = normalBorder, - borderSelectedDisabled = selectedDisabledBorder, - borderSelectedFocused = SolidColor(JBUI.CurrentTheme.Button.focusBorderColor(false).toComposeColor()), - ) - - val minimumSize = JBUI.CurrentTheme.Button.minimumSize().toDpSize() - return SegmentedControlButtonStyle( - colors = colors, - metrics = - SegmentedControlButtonMetrics( - cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), - segmentedButtonPadding = PaddingValues(horizontal = 14.dp), - minSize = DpSize(minimumSize.width, minimumSize.height), - borderWidth = DarculaUIUtil.LW.dp, - ), - ) -} - -internal fun readIconButtonStyle(): IconButtonStyle = - IconButtonStyle( - metrics = - IconButtonMetrics( - cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), - borderWidth = 1.dp, - padding = PaddingValues(0.dp), - minSize = DpSize(24.dp, 24.dp), - ), - colors = - IconButtonColors( - foregroundSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedForeground"), - background = Color.Unspecified, - backgroundDisabled = Color.Unspecified, - backgroundSelected = retrieveColorOrUnspecified("ActionButton.pressedBackground"), - backgroundSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedBackground"), - backgroundPressed = retrieveColorOrUnspecified("ActionButton.pressedBackground"), - backgroundHovered = retrieveColorOrUnspecified("ActionButton.hoverBackground"), - backgroundFocused = retrieveColorOrUnspecified("ActionButton.hoverBackground"), - border = Color.Unspecified, - borderDisabled = Color.Unspecified, - borderSelected = retrieveColorOrUnspecified("ActionButton.pressedBackground"), - borderSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedBackground"), - borderFocused = Color.Unspecified, - borderPressed = retrieveColorOrUnspecified("ActionButton.pressedBorderColor"), - borderHovered = retrieveColorOrUnspecified("ActionButton.hoverBorderColor"), - ), - ) diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeCircularProgress.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeCircularProgress.kt new file mode 100644 index 0000000000..ada2482613 --- /dev/null +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeCircularProgress.kt @@ -0,0 +1,16 @@ +package org.jetbrains.jewel.bridge.theme + +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.takeOrElse +import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified +import org.jetbrains.jewel.ui.component.styling.CircularProgressStyle +import kotlin.time.Duration.Companion.milliseconds + +internal fun readCircularProgressStyle(isDark: Boolean) = + CircularProgressStyle( + frameTime = 125.milliseconds, + color = + retrieveColorOrUnspecified("ProgressIcon.color").takeOrElse { + if (isDark) Color(0xFF6F737A) else Color(0xFFA8ADBD) + }, + ) diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt new file mode 100644 index 0000000000..b4ff47799a --- /dev/null +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt @@ -0,0 +1,70 @@ +package org.jetbrains.jewel.bridge.theme + +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.takeOrElse +import com.intellij.util.ui.JBUI +import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified +import org.jetbrains.jewel.bridge.retrieveInsetsAsPaddingValues +import org.jetbrains.jewel.bridge.retrieveIntAsDpOrUnspecified +import org.jetbrains.jewel.bridge.toComposeColor +import org.jetbrains.jewel.bridge.toComposeColorOrUnspecified +import org.jetbrains.jewel.ui.component.styling.TabColors +import org.jetbrains.jewel.ui.component.styling.TabContentAlpha +import org.jetbrains.jewel.ui.component.styling.TabIcons +import org.jetbrains.jewel.ui.component.styling.TabMetrics +import org.jetbrains.jewel.ui.component.styling.TabStyle +import org.jetbrains.jewel.ui.icons.AllIconsKeys + +internal fun readEditorTabStyle(): TabStyle { + val normalBackground = JBUI.CurrentTheme.EditorTabs.background().toComposeColor() + val selectedBackground = JBUI.CurrentTheme.EditorTabs.underlinedTabBackground().toComposeColorOrUnspecified() + val normalContent = retrieveColorOrUnspecified("TabbedPane.foreground") + val selectedUnderline = retrieveColorOrUnspecified("TabbedPane.underlineColor") + + val colors = + TabColors( + background = normalBackground, + backgroundDisabled = normalBackground, + backgroundPressed = selectedBackground, + backgroundHovered = JBUI.CurrentTheme.EditorTabs.hoverBackground().toComposeColor(), + backgroundSelected = selectedBackground, + content = normalContent, + contentDisabled = retrieveColorOrUnspecified("TabbedPane.disabledForeground"), + contentPressed = normalContent, + contentHovered = normalContent, + contentSelected = normalContent, + underline = Color.Unspecified, + underlineDisabled = retrieveColorOrUnspecified("TabbedPane.disabledUnderlineColor"), + underlinePressed = selectedUnderline, + underlineHovered = Color.Unspecified, + underlineSelected = selectedUnderline, + ) + + return TabStyle( + colors = colors, + metrics = + TabMetrics( + underlineThickness = retrieveIntAsDpOrUnspecified("TabbedPane.tabSelectionHeight").takeOrElse { 2.dp }, + tabPadding = retrieveInsetsAsPaddingValues("TabbedPane.tabInsets"), + closeContentGap = 4.dp, + tabContentSpacing = 4.dp, + tabHeight = retrieveIntAsDpOrUnspecified("TabbedPane.tabHeight").takeOrElse { 24.dp }, + ), + icons = TabIcons(close = AllIconsKeys.General.CloseSmall), + contentAlpha = + TabContentAlpha( + iconNormal = .7f, + iconDisabled = .7f, + iconPressed = 1f, + iconHovered = 1f, + iconSelected = 1f, + contentNormal = .7f, + contentDisabled = .7f, + contentPressed = 1f, + contentHovered = 1f, + contentSelected = 1f, + ), + scrollbarStyle = readScrollbarStyle(isDark), + ) +} diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeProgress.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeHorizontalProgressBar.kt similarity index 77% rename from ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeProgress.kt rename to ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeHorizontalProgressBar.kt index e888084893..083199d5fd 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeProgress.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeHorizontalProgressBar.kt @@ -1,24 +1,12 @@ package org.jetbrains.jewel.bridge.theme import androidx.compose.foundation.shape.CornerSize -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.takeOrElse import androidx.compose.ui.unit.dp -import kotlin.time.Duration.Companion.milliseconds import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified -import org.jetbrains.jewel.ui.component.styling.CircularProgressStyle import org.jetbrains.jewel.ui.component.styling.HorizontalProgressBarColors import org.jetbrains.jewel.ui.component.styling.HorizontalProgressBarMetrics import org.jetbrains.jewel.ui.component.styling.HorizontalProgressBarStyle - -internal fun readCircularProgressStyle(isDark: Boolean) = - CircularProgressStyle( - frameTime = 125.milliseconds, - color = - retrieveColorOrUnspecified("ProgressIcon.color").takeOrElse { - if (isDark) Color(0xFF6F737A) else Color(0xFFA8ADBD) - }, - ) +import kotlin.time.Duration.Companion.milliseconds internal fun readHorizontalProgressBarStyle() = HorizontalProgressBarStyle( diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeIconButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeIconButton.kt new file mode 100644 index 0000000000..ba719b7b97 --- /dev/null +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeIconButton.kt @@ -0,0 +1,42 @@ +package org.jetbrains.jewel.bridge.theme + +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.shape.CornerSize +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.DpSize +import androidx.compose.ui.unit.dp +import com.intellij.ide.ui.laf.darcula.DarculaUIUtil +import org.jetbrains.jewel.bridge.dp +import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified +import org.jetbrains.jewel.ui.component.styling.IconButtonColors +import org.jetbrains.jewel.ui.component.styling.IconButtonMetrics +import org.jetbrains.jewel.ui.component.styling.IconButtonStyle + +internal fun readIconButtonStyle(): IconButtonStyle = + IconButtonStyle( + metrics = + IconButtonMetrics( + cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), + borderWidth = 1.dp, + padding = PaddingValues(0.dp), + minSize = DpSize(24.dp, 24.dp), + ), + colors = + IconButtonColors( + foregroundSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedForeground"), + background = Color.Unspecified, + backgroundDisabled = Color.Unspecified, + backgroundSelected = retrieveColorOrUnspecified("ActionButton.pressedBackground"), + backgroundSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedBackground"), + backgroundPressed = retrieveColorOrUnspecified("ActionButton.pressedBackground"), + backgroundHovered = retrieveColorOrUnspecified("ActionButton.hoverBackground"), + backgroundFocused = retrieveColorOrUnspecified("ActionButton.hoverBackground"), + border = Color.Unspecified, + borderDisabled = Color.Unspecified, + borderSelected = retrieveColorOrUnspecified("ActionButton.pressedBackground"), + borderSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedBackground"), + borderFocused = Color.Unspecified, + borderPressed = retrieveColorOrUnspecified("ActionButton.pressedBorderColor"), + borderHovered = retrieveColorOrUnspecified("ActionButton.hoverBorderColor"), + ), + ) diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt new file mode 100644 index 0000000000..72fd83a11a --- /dev/null +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt @@ -0,0 +1,71 @@ +package org.jetbrains.jewel.bridge.theme + +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.shape.CornerSize +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.SolidColor +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.DpSize +import androidx.compose.ui.unit.dp +import com.intellij.ide.ui.laf.darcula.DarculaUIUtil +import com.intellij.util.ui.JBUI +import org.jetbrains.jewel.bridge.createVerticalBrush +import org.jetbrains.jewel.bridge.dp +import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified +import org.jetbrains.jewel.bridge.toComposeColor +import org.jetbrains.jewel.bridge.toDpSize +import org.jetbrains.jewel.foundation.Stroke +import org.jetbrains.jewel.ui.component.styling.ButtonColors +import org.jetbrains.jewel.ui.component.styling.ButtonMetrics +import org.jetbrains.jewel.ui.component.styling.ButtonStyle + +internal fun readOutlinedButtonStyle(): ButtonStyle { + val normalBackground = + listOf( + JBUI.CurrentTheme.Button.buttonColorStart().toComposeColor(), + JBUI.CurrentTheme.Button.buttonColorEnd().toComposeColor(), + ) + .createVerticalBrush() + + val normalContent = retrieveColorOrUnspecified("Button.foreground") + + val normalBorder = + listOf( + JBUI.CurrentTheme.Button.buttonOutlineColorStart(false).toComposeColor(), + JBUI.CurrentTheme.Button.buttonOutlineColorEnd(false).toComposeColor(), + ) + .createVerticalBrush() + + val colors = + ButtonColors( + background = normalBackground, + backgroundDisabled = SolidColor(Color.Transparent), + backgroundFocused = normalBackground, + backgroundPressed = normalBackground, + backgroundHovered = normalBackground, + content = normalContent, + contentDisabled = retrieveColorOrUnspecified("Button.disabledText"), + contentFocused = normalContent, + contentPressed = normalContent, + contentHovered = normalContent, + border = normalBorder, + borderDisabled = SolidColor(JBUI.CurrentTheme.Button.disabledOutlineColor().toComposeColor()), + borderFocused = SolidColor(JBUI.CurrentTheme.Button.focusBorderColor(false).toComposeColor()), + borderPressed = normalBorder, + borderHovered = normalBorder, + ) + + val minimumSize = JBUI.CurrentTheme.Button.minimumSize().toDpSize() + return ButtonStyle( + colors = colors, + metrics = + ButtonMetrics( + cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), + padding = PaddingValues(horizontal = 14.dp), // see DarculaButtonUI.HORIZONTAL_PADDING + minSize = DpSize(minimumSize.width, minimumSize.height), + borderWidth = DarculaUIUtil.LW.dp, + focusOutlineExpand = Dp.Unspecified, + ), + focusOutlineAlignment = Stroke.Alignment.Center, + ) +} diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/ScrollbarBridge.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeScrollbar.kt similarity index 100% rename from ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/ScrollbarBridge.kt rename to ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeScrollbar.kt index 5892bc5d4c..ee37429217 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/ScrollbarBridge.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeScrollbar.kt @@ -5,8 +5,6 @@ import androidx.compose.foundation.shape.CornerSize import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import kotlin.time.Duration -import kotlin.time.Duration.Companion.milliseconds import org.jetbrains.jewel.bridge.ScrollbarHelper import org.jetbrains.jewel.bridge.retrieveColor import org.jetbrains.jewel.ui.component.styling.ScrollbarColors @@ -15,6 +13,8 @@ import org.jetbrains.jewel.ui.component.styling.ScrollbarStyle import org.jetbrains.jewel.ui.component.styling.ScrollbarVisibility import org.jetbrains.jewel.ui.component.styling.TrackClickBehavior import org.jetbrains.skiko.hostOs +import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds internal fun readScrollbarStyle(isDark: Boolean): ScrollbarStyle = ScrollbarStyle( diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSegmentedControlButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSegmentedControlButton.kt new file mode 100644 index 0000000000..7fe5abe53c --- /dev/null +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSegmentedControlButton.kt @@ -0,0 +1,64 @@ +package org.jetbrains.jewel.bridge.theme + +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.shape.CornerSize +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.SolidColor +import androidx.compose.ui.unit.DpSize +import androidx.compose.ui.unit.dp +import com.intellij.ide.ui.laf.darcula.DarculaUIUtil +import com.intellij.util.ui.JBUI +import org.jetbrains.jewel.bridge.createVerticalBrush +import org.jetbrains.jewel.bridge.dp +import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified +import org.jetbrains.jewel.bridge.toComposeColor +import org.jetbrains.jewel.bridge.toDpSize +import org.jetbrains.jewel.ui.component.styling.SegmentedControlButtonColors +import org.jetbrains.jewel.ui.component.styling.SegmentedControlButtonMetrics +import org.jetbrains.jewel.ui.component.styling.SegmentedControlButtonStyle + +internal fun readSegmentedControlButtonStyle(): SegmentedControlButtonStyle { + val selectedBackground = SolidColor(JBUI.CurrentTheme.SegmentedButton.SELECTED_BUTTON_COLOR.toComposeColor()) + + val normalBorder = + listOf( + JBUI.CurrentTheme.SegmentedButton.SELECTED_START_BORDER_COLOR.toComposeColor(), + JBUI.CurrentTheme.SegmentedButton.SELECTED_END_BORDER_COLOR.toComposeColor(), + ) + .createVerticalBrush() + + val selectedDisabledBorder = + listOf( + JBUI.CurrentTheme.Button.buttonOutlineColorStart(false).toComposeColor(), + JBUI.CurrentTheme.Button.buttonOutlineColorEnd(false).toComposeColor(), + ) + .createVerticalBrush() + + val colors = + SegmentedControlButtonColors( + background = SolidColor(Color.Transparent), + backgroundPressed = selectedBackground, + backgroundHovered = SolidColor(JBUI.CurrentTheme.ActionButton.hoverBackground().toComposeColor()), + backgroundSelected = selectedBackground, + backgroundSelectedFocused = + SolidColor(JBUI.CurrentTheme.SegmentedButton.FOCUSED_SELECTED_BUTTON_COLOR.toComposeColor()), + content = retrieveColorOrUnspecified("Button.foreground"), + contentDisabled = retrieveColorOrUnspecified("Label.disabledForeground"), + border = normalBorder, + borderSelected = normalBorder, + borderSelectedDisabled = selectedDisabledBorder, + borderSelectedFocused = SolidColor(JBUI.CurrentTheme.Button.focusBorderColor(false).toComposeColor()), + ) + + val minimumSize = JBUI.CurrentTheme.Button.minimumSize().toDpSize() + return SegmentedControlButtonStyle( + colors = colors, + metrics = + SegmentedControlButtonMetrics( + cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), + segmentedButtonPadding = PaddingValues(horizontal = 14.dp), + minSize = DpSize(minimumSize.width, minimumSize.height), + borderWidth = DarculaUIUtil.LW.dp, + ), + ) +} diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSlider.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSlider.kt index ee2379b3ba..0c55c32f36 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSlider.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSlider.kt @@ -1,6 +1,12 @@ package org.jetbrains.jewel.bridge.theme import androidx.compose.foundation.shape.CircleShape +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.takeOrElse +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.DpSize +import androidx.compose.ui.unit.dp +import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified import org.jetbrains.jewel.ui.component.styling.SliderColors import org.jetbrains.jewel.ui.component.styling.SliderMetrics import org.jetbrains.jewel.ui.component.styling.SliderStyle @@ -12,3 +18,83 @@ internal fun readSliderStyle(dark: Boolean): SliderStyle { val colors = if (dark) SliderColors.dark() else SliderColors.light() return SliderStyle(colors, SliderMetrics.defaults(), CircleShape) } + +public fun SliderColors.Companion.light( + track: Color = retrieveColorOrUnspecified("ColorPalette.Gray10").takeOrElse { Color(0xFFD3D5DB) }, + trackFilled: Color = retrieveColorOrUnspecified("ColorPalette.Blue6").takeOrElse { Color(0xFF588CF3) }, + trackDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray12").takeOrElse { Color(0xFFEBECF0) }, + trackFilledDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray11").takeOrElse { Color(0xFFDFE1E5) }, + stepMarker: Color = track, + thumbFill: Color = retrieveColorOrUnspecified("ColorPalette.Gray14").takeOrElse { Color(0xFFFFFFFF) }, + thumbFillDisabled: Color = thumbFill, + thumbFillFocused: Color = thumbFill, + thumbFillPressed: Color = thumbFill, + thumbFillHovered: Color = thumbFill, + thumbBorder: Color = retrieveColorOrUnspecified("ColorPalette.Gray8").takeOrElse { Color(0xFFA8ADBD) }, + thumbBorderFocused: Color = retrieveColorOrUnspecified("ColorPalette.Blue4").takeOrElse { Color(0xFF3574F0) }, + thumbBorderDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray11").takeOrElse { Color(0xFFDFE1E5) }, + thumbBorderPressed: Color = retrieveColorOrUnspecified("ColorPalette.Gray7").takeOrElse { Color(0xFF818594) }, + thumbBorderHovered: Color = retrieveColorOrUnspecified("ColorPalette.Gray9").takeOrElse { Color(0xFFC9CCD6) }, +): SliderColors = + SliderColors( + track, + trackFilled, + trackDisabled, + trackFilledDisabled, + stepMarker, + thumbFill, + thumbFillDisabled, + thumbFillFocused, + thumbFillPressed, + thumbFillHovered, + thumbBorder, + thumbBorderFocused, + thumbBorderDisabled, + thumbBorderPressed, + thumbBorderHovered, + ) + +public fun SliderColors.Companion.dark( + track: Color = retrieveColorOrUnspecified("ColorPalette.Gray4").takeOrElse { Color(0xFF43454A) }, + trackFilled: Color = retrieveColorOrUnspecified("ColorPalette.Blue7").takeOrElse { Color(0xFF467FF2) }, + trackDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray3").takeOrElse { Color(0xFF393B40) }, + trackFilledDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray4").takeOrElse { Color(0xFF43454A) }, + stepMarker: Color = track, + thumbFill: Color = retrieveColorOrUnspecified("ColorPalette.Gray2").takeOrElse { Color(0xFF2B2D30) }, + thumbFillDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray3").takeOrElse { Color(0xFF393B40) }, + thumbFillFocused: Color = thumbFill, + thumbFillPressed: Color = thumbFill, + thumbFillHovered: Color = thumbFill, + thumbBorder: Color = retrieveColorOrUnspecified("ColorPalette.Gray7").takeOrElse { Color(0xFF6F737A) }, + thumbBorderFocused: Color = retrieveColorOrUnspecified("ColorPalette.Blue6").takeOrElse { Color(0xFF3574F0) }, + thumbBorderDisabled: Color = retrieveColorOrUnspecified("ColorPalette.Gray5").takeOrElse { Color(0xFF4E5157) }, + thumbBorderPressed: Color = retrieveColorOrUnspecified("ColorPalette.Gray8").takeOrElse { Color(0xFF868A91) }, + thumbBorderHovered: Color = retrieveColorOrUnspecified("ColorPalette.Gray9").takeOrElse { Color(0xFF9DA0A8) }, +): SliderColors = + SliderColors( + track, + trackFilled, + trackDisabled, + trackFilledDisabled, + stepMarker, + thumbFill, + thumbFillDisabled, + thumbFillFocused, + thumbFillPressed, + thumbFillHovered, + thumbBorder, + thumbBorderFocused, + thumbBorderDisabled, + thumbBorderPressed, + thumbBorderHovered, + ) + +public fun SliderMetrics.Companion.defaults( + trackHeight: Dp = 4.dp, + thumbSize: DpSize = DpSize(14.dp, 14.dp), + thumbBorderWidth: Dp = 1.dp, + stepLineHeight: Dp = 8.dp, + stepLineWidth: Dp = 1.dp, + trackToStepSpacing: Dp = thumbSize.height / 2 + 4.dp, +): SliderMetrics = + SliderMetrics(trackHeight, thumbSize, thumbBorderWidth, stepLineHeight, stepLineWidth, trackToStepSpacing) diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt index 351c6a04de..677447fedd 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt @@ -70,55 +70,3 @@ internal fun readDefaultTabStyle(): TabStyle { ) } -internal fun readEditorTabStyle(): TabStyle { - val normalBackground = JBUI.CurrentTheme.EditorTabs.background().toComposeColor() - val selectedBackground = JBUI.CurrentTheme.EditorTabs.underlinedTabBackground().toComposeColorOrUnspecified() - val normalContent = retrieveColorOrUnspecified("TabbedPane.foreground") - val selectedUnderline = retrieveColorOrUnspecified("TabbedPane.underlineColor") - - val colors = - TabColors( - background = normalBackground, - backgroundDisabled = normalBackground, - backgroundPressed = selectedBackground, - backgroundHovered = JBUI.CurrentTheme.EditorTabs.hoverBackground().toComposeColor(), - backgroundSelected = selectedBackground, - content = normalContent, - contentDisabled = retrieveColorOrUnspecified("TabbedPane.disabledForeground"), - contentPressed = normalContent, - contentHovered = normalContent, - contentSelected = normalContent, - underline = Color.Unspecified, - underlineDisabled = retrieveColorOrUnspecified("TabbedPane.disabledUnderlineColor"), - underlinePressed = selectedUnderline, - underlineHovered = Color.Unspecified, - underlineSelected = selectedUnderline, - ) - - return TabStyle( - colors = colors, - metrics = - TabMetrics( - underlineThickness = retrieveIntAsDpOrUnspecified("TabbedPane.tabSelectionHeight").takeOrElse { 2.dp }, - tabPadding = retrieveInsetsAsPaddingValues("TabbedPane.tabInsets"), - closeContentGap = 4.dp, - tabContentSpacing = 4.dp, - tabHeight = retrieveIntAsDpOrUnspecified("TabbedPane.tabHeight").takeOrElse { 24.dp }, - ), - icons = TabIcons(close = AllIconsKeys.General.CloseSmall), - contentAlpha = - TabContentAlpha( - iconNormal = .7f, - iconDisabled = .7f, - iconPressed = 1f, - iconHovered = 1f, - iconSelected = 1f, - contentNormal = .7f, - contentDisabled = .7f, - contentPressed = 1f, - contentHovered = 1f, - contentSelected = 1f, - ), - scrollbarStyle = readScrollbarStyle(isDark), - ) -} From fd4cbb988b838d5811d640a99d619f0b0df6aab5 Mon Sep 17 00:00:00 2001 From: Ivan Morgillo Date: Mon, 2 Dec 2024 17:27:17 +0100 Subject: [PATCH 2/5] make formatter and linter happy --- ide-laf-bridge/api/ide-laf-bridge.api | 32 ++++++------- .../jewel/bridge/theme/IntUiBridgeButton.kt | 1 - .../theme/IntUiBridgeCircularProgress.kt | 8 ++-- .../bridge/theme/IntUiBridgeEditorTab.kt | 38 +++++++-------- .../theme/IntUiBridgeHorizontalProgressBar.kt | 2 +- .../bridge/theme/IntUiBridgeIconButton.kt | 46 +++++++++---------- .../bridge/theme/IntUiBridgeOutlinedButton.kt | 14 +++--- .../bridge/theme/IntUiBridgeScrollbar.kt | 4 +- .../IntUiBridgeSegmentedControlButton.kt | 26 +++++------ .../jewel/bridge/theme/IntUiBridgeTab.kt | 1 - 10 files changed, 85 insertions(+), 87 deletions(-) diff --git a/ide-laf-bridge/api/ide-laf-bridge.api b/ide-laf-bridge/api/ide-laf-bridge.api index 5b09ac9fe2..20785f6c9e 100644 --- a/ide-laf-bridge/api/ide-laf-bridge.api +++ b/ide-laf-bridge/api/ide-laf-bridge.api @@ -136,27 +136,12 @@ public final class org/jetbrains/jewel/bridge/theme/BridgeGlobalMetricsKt { public static final fun readFromLaF (Lorg/jetbrains/jewel/foundation/GlobalMetrics$Companion;)Lorg/jetbrains/jewel/foundation/GlobalMetrics; } -public final class org/jetbrains/jewel/bridge/theme/BridgeSliderStylingKt { - public static final fun dark-7HESe_I (Lorg/jetbrains/jewel/ui/component/styling/SliderColors$Companion;JJJJJJJJJJJJJJJ)Lorg/jetbrains/jewel/ui/component/styling/SliderColors; - public static synthetic fun dark-7HESe_I$default (Lorg/jetbrains/jewel/ui/component/styling/SliderColors$Companion;JJJJJJJJJJJJJJJILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/SliderColors; - public static final fun defaults-IDSuZpE (Lorg/jetbrains/jewel/ui/component/styling/SliderMetrics$Companion;FJFFFF)Lorg/jetbrains/jewel/ui/component/styling/SliderMetrics; - public static synthetic fun defaults-IDSuZpE$default (Lorg/jetbrains/jewel/ui/component/styling/SliderMetrics$Companion;FJFFFFILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/SliderMetrics; - public static final fun light-7HESe_I (Lorg/jetbrains/jewel/ui/component/styling/SliderColors$Companion;JJJJJJJJJJJJJJJ)Lorg/jetbrains/jewel/ui/component/styling/SliderColors; - public static synthetic fun light-7HESe_I$default (Lorg/jetbrains/jewel/ui/component/styling/SliderColors$Companion;JJJJJJJJJJJJJJJILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/SliderColors; -} - public final class org/jetbrains/jewel/bridge/theme/BridgeThemeColorPaletteKt { public static final fun getWindowsPopupBorder (Lorg/jetbrains/jewel/foundation/theme/ThemeColorPalette;)Landroidx/compose/ui/graphics/Color; public static final fun readFromLaF (Lorg/jetbrains/jewel/foundation/theme/ThemeColorPalette$Companion;)Lorg/jetbrains/jewel/foundation/theme/ThemeColorPalette; } -public final class org/jetbrains/jewel/bridge/theme/IntUiBridgeTextKt { - public static final fun retrieveConsoleTextStyle ()Landroidx/compose/ui/text/TextStyle; - public static final fun retrieveDefaultTextStyle ()Landroidx/compose/ui/text/TextStyle; - public static final fun retrieveEditorTextStyle ()Landroidx/compose/ui/text/TextStyle; -} - -public final class org/jetbrains/jewel/bridge/theme/ScrollbarBridgeKt { +public final class org/jetbrains/jewel/bridge/theme/IntUiBridgeScrollbarKt { 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; @@ -169,6 +154,21 @@ public final class org/jetbrains/jewel/bridge/theme/ScrollbarBridgeKt { 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/IntUiBridgeSliderKt { + public static final fun dark-7HESe_I (Lorg/jetbrains/jewel/ui/component/styling/SliderColors$Companion;JJJJJJJJJJJJJJJ)Lorg/jetbrains/jewel/ui/component/styling/SliderColors; + public static synthetic fun dark-7HESe_I$default (Lorg/jetbrains/jewel/ui/component/styling/SliderColors$Companion;JJJJJJJJJJJJJJJILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/SliderColors; + public static final fun defaults-IDSuZpE (Lorg/jetbrains/jewel/ui/component/styling/SliderMetrics$Companion;FJFFFF)Lorg/jetbrains/jewel/ui/component/styling/SliderMetrics; + public static synthetic fun defaults-IDSuZpE$default (Lorg/jetbrains/jewel/ui/component/styling/SliderMetrics$Companion;FJFFFFILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/SliderMetrics; + public static final fun light-7HESe_I (Lorg/jetbrains/jewel/ui/component/styling/SliderColors$Companion;JJJJJJJJJJJJJJJ)Lorg/jetbrains/jewel/ui/component/styling/SliderColors; + public static synthetic fun light-7HESe_I$default (Lorg/jetbrains/jewel/ui/component/styling/SliderColors$Companion;JJJJJJJJJJJJJJJILjava/lang/Object;)Lorg/jetbrains/jewel/ui/component/styling/SliderColors; +} + +public final class org/jetbrains/jewel/bridge/theme/IntUiBridgeTextKt { + public static final fun retrieveConsoleTextStyle ()Landroidx/compose/ui/text/TextStyle; + public static final fun retrieveDefaultTextStyle ()Landroidx/compose/ui/text/TextStyle; + public static final fun retrieveEditorTextStyle ()Landroidx/compose/ui/text/TextStyle; +} + public final class org/jetbrains/jewel/bridge/theme/SwingBridgeThemeKt { public static final fun SwingBridgeTheme (Lkotlin/jvm/functions/Function2;Landroidx/compose/runtime/Composer;I)V } diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt index 8971a2aedf..b194802e14 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt @@ -66,4 +66,3 @@ internal fun readDefaultButtonStyle(): ButtonStyle { focusOutlineAlignment = Stroke.Alignment.Center, ) } - diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeCircularProgress.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeCircularProgress.kt index ada2482613..6d9b8f763f 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeCircularProgress.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeCircularProgress.kt @@ -2,15 +2,15 @@ package org.jetbrains.jewel.bridge.theme import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.takeOrElse +import kotlin.time.Duration.Companion.milliseconds import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified import org.jetbrains.jewel.ui.component.styling.CircularProgressStyle -import kotlin.time.Duration.Companion.milliseconds internal fun readCircularProgressStyle(isDark: Boolean) = CircularProgressStyle( frameTime = 125.milliseconds, color = - retrieveColorOrUnspecified("ProgressIcon.color").takeOrElse { - if (isDark) Color(0xFF6F737A) else Color(0xFFA8ADBD) - }, + retrieveColorOrUnspecified("ProgressIcon.color").takeOrElse { + if (isDark) Color(0xFF6F737A) else Color(0xFFA8ADBD) + }, ) diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt index b4ff47799a..a1c1f7477e 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt @@ -44,27 +44,27 @@ internal fun readEditorTabStyle(): TabStyle { return TabStyle( colors = colors, metrics = - TabMetrics( - underlineThickness = retrieveIntAsDpOrUnspecified("TabbedPane.tabSelectionHeight").takeOrElse { 2.dp }, - tabPadding = retrieveInsetsAsPaddingValues("TabbedPane.tabInsets"), - closeContentGap = 4.dp, - tabContentSpacing = 4.dp, - tabHeight = retrieveIntAsDpOrUnspecified("TabbedPane.tabHeight").takeOrElse { 24.dp }, - ), + TabMetrics( + underlineThickness = retrieveIntAsDpOrUnspecified("TabbedPane.tabSelectionHeight").takeOrElse { 2.dp }, + tabPadding = retrieveInsetsAsPaddingValues("TabbedPane.tabInsets"), + closeContentGap = 4.dp, + tabContentSpacing = 4.dp, + tabHeight = retrieveIntAsDpOrUnspecified("TabbedPane.tabHeight").takeOrElse { 24.dp }, + ), icons = TabIcons(close = AllIconsKeys.General.CloseSmall), contentAlpha = - TabContentAlpha( - iconNormal = .7f, - iconDisabled = .7f, - iconPressed = 1f, - iconHovered = 1f, - iconSelected = 1f, - contentNormal = .7f, - contentDisabled = .7f, - contentPressed = 1f, - contentHovered = 1f, - contentSelected = 1f, - ), + TabContentAlpha( + iconNormal = .7f, + iconDisabled = .7f, + iconPressed = 1f, + iconHovered = 1f, + iconSelected = 1f, + contentNormal = .7f, + contentDisabled = .7f, + contentPressed = 1f, + contentHovered = 1f, + contentSelected = 1f, + ), scrollbarStyle = readScrollbarStyle(isDark), ) } diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeHorizontalProgressBar.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeHorizontalProgressBar.kt index 083199d5fd..a8231a6699 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeHorizontalProgressBar.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeHorizontalProgressBar.kt @@ -2,11 +2,11 @@ package org.jetbrains.jewel.bridge.theme import androidx.compose.foundation.shape.CornerSize import androidx.compose.ui.unit.dp +import kotlin.time.Duration.Companion.milliseconds import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified import org.jetbrains.jewel.ui.component.styling.HorizontalProgressBarColors import org.jetbrains.jewel.ui.component.styling.HorizontalProgressBarMetrics import org.jetbrains.jewel.ui.component.styling.HorizontalProgressBarStyle -import kotlin.time.Duration.Companion.milliseconds internal fun readHorizontalProgressBarStyle() = HorizontalProgressBarStyle( diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeIconButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeIconButton.kt index ba719b7b97..e88d43a364 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeIconButton.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeIconButton.kt @@ -15,28 +15,28 @@ import org.jetbrains.jewel.ui.component.styling.IconButtonStyle internal fun readIconButtonStyle(): IconButtonStyle = IconButtonStyle( metrics = - IconButtonMetrics( - cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), - borderWidth = 1.dp, - padding = PaddingValues(0.dp), - minSize = DpSize(24.dp, 24.dp), - ), + IconButtonMetrics( + cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), + borderWidth = 1.dp, + padding = PaddingValues(0.dp), + minSize = DpSize(24.dp, 24.dp), + ), colors = - IconButtonColors( - foregroundSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedForeground"), - background = Color.Unspecified, - backgroundDisabled = Color.Unspecified, - backgroundSelected = retrieveColorOrUnspecified("ActionButton.pressedBackground"), - backgroundSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedBackground"), - backgroundPressed = retrieveColorOrUnspecified("ActionButton.pressedBackground"), - backgroundHovered = retrieveColorOrUnspecified("ActionButton.hoverBackground"), - backgroundFocused = retrieveColorOrUnspecified("ActionButton.hoverBackground"), - border = Color.Unspecified, - borderDisabled = Color.Unspecified, - borderSelected = retrieveColorOrUnspecified("ActionButton.pressedBackground"), - borderSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedBackground"), - borderFocused = Color.Unspecified, - borderPressed = retrieveColorOrUnspecified("ActionButton.pressedBorderColor"), - borderHovered = retrieveColorOrUnspecified("ActionButton.hoverBorderColor"), - ), + IconButtonColors( + foregroundSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedForeground"), + background = Color.Unspecified, + backgroundDisabled = Color.Unspecified, + backgroundSelected = retrieveColorOrUnspecified("ActionButton.pressedBackground"), + backgroundSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedBackground"), + backgroundPressed = retrieveColorOrUnspecified("ActionButton.pressedBackground"), + backgroundHovered = retrieveColorOrUnspecified("ActionButton.hoverBackground"), + backgroundFocused = retrieveColorOrUnspecified("ActionButton.hoverBackground"), + border = Color.Unspecified, + borderDisabled = Color.Unspecified, + borderSelected = retrieveColorOrUnspecified("ActionButton.pressedBackground"), + borderSelectedActivated = retrieveColorOrUnspecified("ToolWindow.Button.selectedBackground"), + borderFocused = Color.Unspecified, + borderPressed = retrieveColorOrUnspecified("ActionButton.pressedBorderColor"), + borderHovered = retrieveColorOrUnspecified("ActionButton.hoverBorderColor"), + ), ) diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt index 72fd83a11a..925eb900ea 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt @@ -59,13 +59,13 @@ internal fun readOutlinedButtonStyle(): ButtonStyle { return ButtonStyle( colors = colors, metrics = - ButtonMetrics( - cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), - padding = PaddingValues(horizontal = 14.dp), // see DarculaButtonUI.HORIZONTAL_PADDING - minSize = DpSize(minimumSize.width, minimumSize.height), - borderWidth = DarculaUIUtil.LW.dp, - focusOutlineExpand = Dp.Unspecified, - ), + ButtonMetrics( + cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), + padding = PaddingValues(horizontal = 14.dp), // see DarculaButtonUI.HORIZONTAL_PADDING + minSize = DpSize(minimumSize.width, minimumSize.height), + borderWidth = DarculaUIUtil.LW.dp, + focusOutlineExpand = Dp.Unspecified, + ), focusOutlineAlignment = Stroke.Alignment.Center, ) } diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeScrollbar.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeScrollbar.kt index ee37429217..5892bc5d4c 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeScrollbar.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeScrollbar.kt @@ -5,6 +5,8 @@ import androidx.compose.foundation.shape.CornerSize import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import kotlin.time.Duration +import kotlin.time.Duration.Companion.milliseconds import org.jetbrains.jewel.bridge.ScrollbarHelper import org.jetbrains.jewel.bridge.retrieveColor import org.jetbrains.jewel.ui.component.styling.ScrollbarColors @@ -13,8 +15,6 @@ import org.jetbrains.jewel.ui.component.styling.ScrollbarStyle import org.jetbrains.jewel.ui.component.styling.ScrollbarVisibility import org.jetbrains.jewel.ui.component.styling.TrackClickBehavior import org.jetbrains.skiko.hostOs -import kotlin.time.Duration -import kotlin.time.Duration.Companion.milliseconds internal fun readScrollbarStyle(isDark: Boolean): ScrollbarStyle = ScrollbarStyle( diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSegmentedControlButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSegmentedControlButton.kt index 7fe5abe53c..d33cd95795 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSegmentedControlButton.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeSegmentedControlButton.kt @@ -22,16 +22,16 @@ internal fun readSegmentedControlButtonStyle(): SegmentedControlButtonStyle { val normalBorder = listOf( - JBUI.CurrentTheme.SegmentedButton.SELECTED_START_BORDER_COLOR.toComposeColor(), - JBUI.CurrentTheme.SegmentedButton.SELECTED_END_BORDER_COLOR.toComposeColor(), - ) + JBUI.CurrentTheme.SegmentedButton.SELECTED_START_BORDER_COLOR.toComposeColor(), + JBUI.CurrentTheme.SegmentedButton.SELECTED_END_BORDER_COLOR.toComposeColor(), + ) .createVerticalBrush() val selectedDisabledBorder = listOf( - JBUI.CurrentTheme.Button.buttonOutlineColorStart(false).toComposeColor(), - JBUI.CurrentTheme.Button.buttonOutlineColorEnd(false).toComposeColor(), - ) + JBUI.CurrentTheme.Button.buttonOutlineColorStart(false).toComposeColor(), + JBUI.CurrentTheme.Button.buttonOutlineColorEnd(false).toComposeColor(), + ) .createVerticalBrush() val colors = @@ -41,7 +41,7 @@ internal fun readSegmentedControlButtonStyle(): SegmentedControlButtonStyle { backgroundHovered = SolidColor(JBUI.CurrentTheme.ActionButton.hoverBackground().toComposeColor()), backgroundSelected = selectedBackground, backgroundSelectedFocused = - SolidColor(JBUI.CurrentTheme.SegmentedButton.FOCUSED_SELECTED_BUTTON_COLOR.toComposeColor()), + SolidColor(JBUI.CurrentTheme.SegmentedButton.FOCUSED_SELECTED_BUTTON_COLOR.toComposeColor()), content = retrieveColorOrUnspecified("Button.foreground"), contentDisabled = retrieveColorOrUnspecified("Label.disabledForeground"), border = normalBorder, @@ -54,11 +54,11 @@ internal fun readSegmentedControlButtonStyle(): SegmentedControlButtonStyle { return SegmentedControlButtonStyle( colors = colors, metrics = - SegmentedControlButtonMetrics( - cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), - segmentedButtonPadding = PaddingValues(horizontal = 14.dp), - minSize = DpSize(minimumSize.width, minimumSize.height), - borderWidth = DarculaUIUtil.LW.dp, - ), + SegmentedControlButtonMetrics( + cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), + segmentedButtonPadding = PaddingValues(horizontal = 14.dp), + minSize = DpSize(minimumSize.width, minimumSize.height), + borderWidth = DarculaUIUtil.LW.dp, + ), ) } diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt index 677447fedd..a817e59f08 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt @@ -69,4 +69,3 @@ internal fun readDefaultTabStyle(): TabStyle { scrollbarStyle = readScrollbarStyle(isDark), ) } - From 65116fb552408800677595c01f66379ebceeab65 Mon Sep 17 00:00:00 2001 From: Ivan Morgillo Date: Fri, 6 Dec 2024 11:07:22 +0100 Subject: [PATCH 3/5] move readOutlinedButtonStyle() to IntUiBridgeButton Signed-off-by: Ivan Morgillo --- .../jewel/bridge/theme/IntUiBridgeButton.kt | 55 ++++++++++++++ .../bridge/theme/IntUiBridgeOutlinedButton.kt | 71 ------------------- 2 files changed, 55 insertions(+), 71 deletions(-) delete mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt index b194802e14..8d4811d58a 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt @@ -1,12 +1,16 @@ package org.jetbrains.jewel.bridge.theme import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.shape.CornerSize import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp +import com.intellij.ide.ui.laf.darcula.DarculaUIUtil import com.intellij.util.ui.JBUI import org.jetbrains.jewel.bridge.createVerticalBrush +import org.jetbrains.jewel.bridge.dp import org.jetbrains.jewel.bridge.retrieveArcAsCornerSizeWithFallbacks import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified import org.jetbrains.jewel.bridge.toComposeColor @@ -66,3 +70,54 @@ internal fun readDefaultButtonStyle(): ButtonStyle { focusOutlineAlignment = Stroke.Alignment.Center, ) } + +internal fun readOutlinedButtonStyle(): ButtonStyle { + val normalBackground = + listOf( + JBUI.CurrentTheme.Button.buttonColorStart().toComposeColor(), + JBUI.CurrentTheme.Button.buttonColorEnd().toComposeColor(), + ) + .createVerticalBrush() + + val normalContent = retrieveColorOrUnspecified("Button.foreground") + + val normalBorder = + listOf( + JBUI.CurrentTheme.Button.buttonOutlineColorStart(false).toComposeColor(), + JBUI.CurrentTheme.Button.buttonOutlineColorEnd(false).toComposeColor(), + ) + .createVerticalBrush() + + val colors = + ButtonColors( + background = normalBackground, + backgroundDisabled = SolidColor(Color.Transparent), + backgroundFocused = normalBackground, + backgroundPressed = normalBackground, + backgroundHovered = normalBackground, + content = normalContent, + contentDisabled = retrieveColorOrUnspecified("Button.disabledText"), + contentFocused = normalContent, + contentPressed = normalContent, + contentHovered = normalContent, + border = normalBorder, + borderDisabled = SolidColor(JBUI.CurrentTheme.Button.disabledOutlineColor().toComposeColor()), + borderFocused = SolidColor(JBUI.CurrentTheme.Button.focusBorderColor(false).toComposeColor()), + borderPressed = normalBorder, + borderHovered = normalBorder, + ) + + val minimumSize = JBUI.CurrentTheme.Button.minimumSize().toDpSize() + return ButtonStyle( + colors = colors, + metrics = + ButtonMetrics( + cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), + padding = PaddingValues(horizontal = 14.dp), // see DarculaButtonUI.HORIZONTAL_PADDING + minSize = DpSize(minimumSize.width, minimumSize.height), + borderWidth = DarculaUIUtil.LW.dp, + focusOutlineExpand = Dp.Unspecified, + ), + focusOutlineAlignment = Stroke.Alignment.Center, + ) +} \ No newline at end of file diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt deleted file mode 100644 index 925eb900ea..0000000000 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeOutlinedButton.kt +++ /dev/null @@ -1,71 +0,0 @@ -package org.jetbrains.jewel.bridge.theme - -import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.shape.CornerSize -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.SolidColor -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.DpSize -import androidx.compose.ui.unit.dp -import com.intellij.ide.ui.laf.darcula.DarculaUIUtil -import com.intellij.util.ui.JBUI -import org.jetbrains.jewel.bridge.createVerticalBrush -import org.jetbrains.jewel.bridge.dp -import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified -import org.jetbrains.jewel.bridge.toComposeColor -import org.jetbrains.jewel.bridge.toDpSize -import org.jetbrains.jewel.foundation.Stroke -import org.jetbrains.jewel.ui.component.styling.ButtonColors -import org.jetbrains.jewel.ui.component.styling.ButtonMetrics -import org.jetbrains.jewel.ui.component.styling.ButtonStyle - -internal fun readOutlinedButtonStyle(): ButtonStyle { - val normalBackground = - listOf( - JBUI.CurrentTheme.Button.buttonColorStart().toComposeColor(), - JBUI.CurrentTheme.Button.buttonColorEnd().toComposeColor(), - ) - .createVerticalBrush() - - val normalContent = retrieveColorOrUnspecified("Button.foreground") - - val normalBorder = - listOf( - JBUI.CurrentTheme.Button.buttonOutlineColorStart(false).toComposeColor(), - JBUI.CurrentTheme.Button.buttonOutlineColorEnd(false).toComposeColor(), - ) - .createVerticalBrush() - - val colors = - ButtonColors( - background = normalBackground, - backgroundDisabled = SolidColor(Color.Transparent), - backgroundFocused = normalBackground, - backgroundPressed = normalBackground, - backgroundHovered = normalBackground, - content = normalContent, - contentDisabled = retrieveColorOrUnspecified("Button.disabledText"), - contentFocused = normalContent, - contentPressed = normalContent, - contentHovered = normalContent, - border = normalBorder, - borderDisabled = SolidColor(JBUI.CurrentTheme.Button.disabledOutlineColor().toComposeColor()), - borderFocused = SolidColor(JBUI.CurrentTheme.Button.focusBorderColor(false).toComposeColor()), - borderPressed = normalBorder, - borderHovered = normalBorder, - ) - - val minimumSize = JBUI.CurrentTheme.Button.minimumSize().toDpSize() - return ButtonStyle( - colors = colors, - metrics = - ButtonMetrics( - cornerSize = CornerSize(DarculaUIUtil.BUTTON_ARC.dp / 2), - padding = PaddingValues(horizontal = 14.dp), // see DarculaButtonUI.HORIZONTAL_PADDING - minSize = DpSize(minimumSize.width, minimumSize.height), - borderWidth = DarculaUIUtil.LW.dp, - focusOutlineExpand = Dp.Unspecified, - ), - focusOutlineAlignment = Stroke.Alignment.Center, - ) -} From 51d8d29a7e594f69594cc60abcf08da4eb9b1b70 Mon Sep 17 00:00:00 2001 From: Ivan Morgillo Date: Fri, 6 Dec 2024 11:12:33 +0100 Subject: [PATCH 4/5] move readEditorTabStyle() to IntUiBridgeTab Signed-off-by: Ivan Morgillo --- .../bridge/theme/IntUiBridgeEditorTab.kt | 70 ------------------- .../jewel/bridge/theme/IntUiBridgeTab.kt | 53 ++++++++++++++ 2 files changed, 53 insertions(+), 70 deletions(-) delete mode 100644 ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt deleted file mode 100644 index a1c1f7477e..0000000000 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeEditorTab.kt +++ /dev/null @@ -1,70 +0,0 @@ -package org.jetbrains.jewel.bridge.theme - -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.takeOrElse -import com.intellij.util.ui.JBUI -import org.jetbrains.jewel.bridge.retrieveColorOrUnspecified -import org.jetbrains.jewel.bridge.retrieveInsetsAsPaddingValues -import org.jetbrains.jewel.bridge.retrieveIntAsDpOrUnspecified -import org.jetbrains.jewel.bridge.toComposeColor -import org.jetbrains.jewel.bridge.toComposeColorOrUnspecified -import org.jetbrains.jewel.ui.component.styling.TabColors -import org.jetbrains.jewel.ui.component.styling.TabContentAlpha -import org.jetbrains.jewel.ui.component.styling.TabIcons -import org.jetbrains.jewel.ui.component.styling.TabMetrics -import org.jetbrains.jewel.ui.component.styling.TabStyle -import org.jetbrains.jewel.ui.icons.AllIconsKeys - -internal fun readEditorTabStyle(): TabStyle { - val normalBackground = JBUI.CurrentTheme.EditorTabs.background().toComposeColor() - val selectedBackground = JBUI.CurrentTheme.EditorTabs.underlinedTabBackground().toComposeColorOrUnspecified() - val normalContent = retrieveColorOrUnspecified("TabbedPane.foreground") - val selectedUnderline = retrieveColorOrUnspecified("TabbedPane.underlineColor") - - val colors = - TabColors( - background = normalBackground, - backgroundDisabled = normalBackground, - backgroundPressed = selectedBackground, - backgroundHovered = JBUI.CurrentTheme.EditorTabs.hoverBackground().toComposeColor(), - backgroundSelected = selectedBackground, - content = normalContent, - contentDisabled = retrieveColorOrUnspecified("TabbedPane.disabledForeground"), - contentPressed = normalContent, - contentHovered = normalContent, - contentSelected = normalContent, - underline = Color.Unspecified, - underlineDisabled = retrieveColorOrUnspecified("TabbedPane.disabledUnderlineColor"), - underlinePressed = selectedUnderline, - underlineHovered = Color.Unspecified, - underlineSelected = selectedUnderline, - ) - - return TabStyle( - colors = colors, - metrics = - TabMetrics( - underlineThickness = retrieveIntAsDpOrUnspecified("TabbedPane.tabSelectionHeight").takeOrElse { 2.dp }, - tabPadding = retrieveInsetsAsPaddingValues("TabbedPane.tabInsets"), - closeContentGap = 4.dp, - tabContentSpacing = 4.dp, - tabHeight = retrieveIntAsDpOrUnspecified("TabbedPane.tabHeight").takeOrElse { 24.dp }, - ), - icons = TabIcons(close = AllIconsKeys.General.CloseSmall), - contentAlpha = - TabContentAlpha( - iconNormal = .7f, - iconDisabled = .7f, - iconPressed = 1f, - iconHovered = 1f, - iconSelected = 1f, - contentNormal = .7f, - contentDisabled = .7f, - contentPressed = 1f, - contentHovered = 1f, - contentSelected = 1f, - ), - scrollbarStyle = readScrollbarStyle(isDark), - ) -} diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt index a817e59f08..aed0cb78b3 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt @@ -69,3 +69,56 @@ internal fun readDefaultTabStyle(): TabStyle { scrollbarStyle = readScrollbarStyle(isDark), ) } + +internal fun readEditorTabStyle(): TabStyle { + val normalBackground = JBUI.CurrentTheme.EditorTabs.background().toComposeColor() + val selectedBackground = JBUI.CurrentTheme.EditorTabs.underlinedTabBackground().toComposeColorOrUnspecified() + val normalContent = retrieveColorOrUnspecified("TabbedPane.foreground") + val selectedUnderline = retrieveColorOrUnspecified("TabbedPane.underlineColor") + + val colors = + TabColors( + background = normalBackground, + backgroundDisabled = normalBackground, + backgroundPressed = selectedBackground, + backgroundHovered = JBUI.CurrentTheme.EditorTabs.hoverBackground().toComposeColor(), + backgroundSelected = selectedBackground, + content = normalContent, + contentDisabled = retrieveColorOrUnspecified("TabbedPane.disabledForeground"), + contentPressed = normalContent, + contentHovered = normalContent, + contentSelected = normalContent, + underline = Color.Unspecified, + underlineDisabled = retrieveColorOrUnspecified("TabbedPane.disabledUnderlineColor"), + underlinePressed = selectedUnderline, + underlineHovered = Color.Unspecified, + underlineSelected = selectedUnderline, + ) + + return TabStyle( + colors = colors, + metrics = + TabMetrics( + underlineThickness = retrieveIntAsDpOrUnspecified("TabbedPane.tabSelectionHeight").takeOrElse { 2.dp }, + tabPadding = retrieveInsetsAsPaddingValues("TabbedPane.tabInsets"), + closeContentGap = 4.dp, + tabContentSpacing = 4.dp, + tabHeight = retrieveIntAsDpOrUnspecified("TabbedPane.tabHeight").takeOrElse { 24.dp }, + ), + icons = TabIcons(close = AllIconsKeys.General.CloseSmall), + contentAlpha = + TabContentAlpha( + iconNormal = .7f, + iconDisabled = .7f, + iconPressed = 1f, + iconHovered = 1f, + iconSelected = 1f, + contentNormal = .7f, + contentDisabled = .7f, + contentPressed = 1f, + contentHovered = 1f, + contentSelected = 1f, + ), + scrollbarStyle = readScrollbarStyle(isDark), + ) +} \ No newline at end of file From 26dbcc0c68e53525e0bf803619b96be81b08b80a Mon Sep 17 00:00:00 2001 From: Ivan Morgillo Date: Fri, 6 Dec 2024 11:15:42 +0100 Subject: [PATCH 5/5] make formatter and linter happy --- .../org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt | 2 +- .../kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt index 8d4811d58a..c7b93c9d8c 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeButton.kt @@ -120,4 +120,4 @@ internal fun readOutlinedButtonStyle(): ButtonStyle { ), focusOutlineAlignment = Stroke.Alignment.Center, ) -} \ No newline at end of file +} diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt index aed0cb78b3..351c6a04de 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/theme/IntUiBridgeTab.kt @@ -121,4 +121,4 @@ internal fun readEditorTabStyle(): TabStyle { ), scrollbarStyle = readScrollbarStyle(isDark), ) -} \ No newline at end of file +}