Skip to content

Commit

Permalink
Improve UI control outlines management (#187)
Browse files Browse the repository at this point in the history
Added boolean check 'hasNoOutline' to determine presence of an outline in Dropdown and InputField classes. This allows rendering elements especially those using TreeBuilder without an outline, facilitating better alignment with varying design requirements. This check is used in conjunction with existing 'undecorated' variable for better UX and flexibility.
  • Loading branch information
fscarponi authored Oct 17, 2023
1 parent 863f096 commit bfa6344
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit bfa6344

Please sign in to comment.