Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarponi committed Oct 3, 2023
1 parent 627b346 commit 8c8acf7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 1 addition & 3 deletions core/src/main/kotlin/org/jetbrains/jewel/Tooltip.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ fun Tooltip(
) {
Box(
modifier = Modifier
.clip(
RoundedCornerShape(4.dp)
)
.clip(RoundedCornerShape(8.dp))
.background(style.colors.backgroundColor)
.border(1.dp, style.colors.borderColor)
.padding(style.metrics.paddingValues)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ import org.jetbrains.jewel.intui.standalone.styling.IntUiTextAreaStyle
import org.jetbrains.jewel.intui.standalone.styling.IntUiTextFieldColors
import org.jetbrains.jewel.intui.standalone.styling.IntUiTextFieldMetrics
import org.jetbrains.jewel.intui.standalone.styling.IntUiTextFieldStyle
import org.jetbrains.jewel.intui.standalone.styling.IntUiTooltipColors
import org.jetbrains.jewel.intui.standalone.styling.IntUiTooltipMetrics
import org.jetbrains.jewel.intui.standalone.styling.IntUiTooltipStyle
import org.jetbrains.jewel.styling.InputFieldStyle
import org.jetbrains.skiko.DependsOnJBR
import javax.swing.UIManager
Expand Down Expand Up @@ -164,6 +167,7 @@ internal fun createSwingIntUiComponentStyling(
scrollbarStyle = readScrollbarStyle(theme.isDark),
textAreaStyle = readTextAreaStyle(textAreaTextStyle, textFieldStyle.metrics),
circularProgressStyle = readCircularProgressStyle(theme.isDark),
tooltipStyle = readTooltipStyle(theme.isDark),
textFieldStyle = textFieldStyle,
)
}
Expand Down Expand Up @@ -402,7 +406,6 @@ private fun readDropdownStyle(

private fun readGroupHeaderStyle() = IntUiGroupHeaderStyle(
colors = IntUiGroupHeaderColors(
content = retrieveColorOrUnspecified("Separator.foreground"),
divider = retrieveColorOrUnspecified("Separator.separatorColor"),
),
metrics = IntUiGroupHeaderMetrics(
Expand Down Expand Up @@ -895,3 +898,20 @@ private fun readCircularProgressStyle(
.takeIf { it.isSpecified }
?: if (isDark) Color(0xFF6F737A) else Color(0xFFA8ADBD),
)

private fun readTooltipStyle(
isDark: Boolean,
): IntUiTooltipStyle {
val background =
if (isDark) "Tooltip.background" else "ToolTip.background"
val content =
if (isDark) "Tooltip.foreground" else "ToolTip.foreground"
return IntUiTooltipStyle(
metrics = IntUiTooltipMetrics(),
colors = IntUiTooltipColors(
contentColor = retrieveColorOrUnspecified(content),
backgroundColor = retrieveColorOrUnspecified(background),
borderColor = retrieveColorOrUnspecified("Tooltip.borderColor"),
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ data class IntUiTooltipColors(

@Stable
data class IntUiTooltipMetrics(
override val paddingValues: PaddingValues = PaddingValues(vertical = 4.dp, horizontal = 8.dp),
override val paddingValues: PaddingValues = PaddingValues(vertical = 8.dp, horizontal = 8.dp),
override val showDelay: Duration = 500.milliseconds,
) : TooltipMetrics
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import org.jetbrains.jewel.OutlinedButton
import org.jetbrains.jewel.RadioButtonRow
import org.jetbrains.jewel.Text
import org.jetbrains.jewel.TextField
import org.jetbrains.jewel.Tooltip
import org.jetbrains.jewel.bridge.SwingBridgeService
import org.jetbrains.jewel.bridge.SwingBridgeTheme
import org.jetbrains.jewel.bridge.addComposeTab
Expand Down Expand Up @@ -149,6 +150,16 @@ internal class JewelDemoToolWindow : ToolWindowFactory, DumbAware {
Text("Circular progress big: ")
CircularProgressIndicatorBig(svgLoader)
}
Row(verticalAlignment = Alignment.CenterVertically) {
Tooltip(tooltip = {
Text("This is a tooltip")
}) {
Text(
modifier = Modifier.border(1.dp, IntUiTheme.globalColors.borders.normal).padding(4.dp),
text = "Hover Me!"
)
}
}
}
}

Expand Down

0 comments on commit 8c8acf7

Please sign in to comment.