Skip to content

Commit

Permalink
move readOutlinedButtonStyle() to IntUiBridgeButton
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Morgillo <[email protected]>
  • Loading branch information
hamen committed Dec 6, 2024
1 parent fd4cbb9 commit 65116fb
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
)
}

This file was deleted.

0 comments on commit 65116fb

Please sign in to comment.