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

Improve UI control outlines management #187

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/src/main/kotlin/org/jetbrains/jewel/Dropdown.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ fun Dropdown(
val minSize = metrics.minSize
val arrowMinSize = style.metrics.arrowMinSize
val borderColor by colors.borderFor(dropdownState)
val hasNoOutline = outline == Outline.None

Box(
modifier.clickable(
Expand All @@ -110,7 +111,7 @@ fun Dropdown(
indication = null,
)
.background(colors.backgroundFor(dropdownState).value, shape)
.border(Stroke.Alignment.Center, style.metrics.borderWidth, borderColor, shape)
.appendIf(hasNoOutline) { border(Stroke.Alignment.Center, style.metrics.borderWidth, borderColor, shape) }
.appendIf(outline == Outline.None) { focusOutline(dropdownState, shape) }
.outline(dropdownState, outline, shape)
.width(IntrinsicSize.Max)
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/kotlin/org/jetbrains/jewel/InputField.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ internal fun InputField(
}

val borderColor by style.colors.borderFor(inputState)
val borderModifier = Modifier.appendIf(!undecorated && borderColor.isSpecified) {
val hasNoOutline = outline == Outline.None
val borderModifier = Modifier.appendIf(!undecorated && borderColor.isSpecified && hasNoOutline) {
Modifier.border(
alignment = Stroke.Alignment.Center,
width = style.metrics.borderWidth,
Expand All @@ -93,8 +94,8 @@ internal fun InputField(
value = value,
modifier = modifier.then(backgroundModifier)
.then(borderModifier)
.appendIf(!undecorated) { focusOutline(inputState, shape) }
.outline(inputState, outline, shape),
.appendIf(!undecorated && hasNoOutline) { focusOutline(inputState, shape) }
.outline(inputState, outline, shape, Stroke.Alignment.Center),
onValueChange = onValueChange,
enabled = enabled,
readOnly = readOnly,
Expand Down