From d790fcca3ff7e51634d54e431a716fbcb9ff83ee Mon Sep 17 00:00:00 2001 From: fscarponi Date: Tue, 17 Oct 2023 15:49:40 +0200 Subject: [PATCH] Improve UI control outlines management 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. --- core/src/main/kotlin/org/jetbrains/jewel/Dropdown.kt | 3 ++- core/src/main/kotlin/org/jetbrains/jewel/InputField.kt | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/src/main/kotlin/org/jetbrains/jewel/Dropdown.kt b/core/src/main/kotlin/org/jetbrains/jewel/Dropdown.kt index 8b16a780d..96920ff51 100644 --- a/core/src/main/kotlin/org/jetbrains/jewel/Dropdown.kt +++ b/core/src/main/kotlin/org/jetbrains/jewel/Dropdown.kt @@ -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( @@ -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) diff --git a/core/src/main/kotlin/org/jetbrains/jewel/InputField.kt b/core/src/main/kotlin/org/jetbrains/jewel/InputField.kt index cea7afeb3..c98196a94 100644 --- a/core/src/main/kotlin/org/jetbrains/jewel/InputField.kt +++ b/core/src/main/kotlin/org/jetbrains/jewel/InputField.kt @@ -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, @@ -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,