diff --git a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/modifier/Activation.kt b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/modifier/Activation.kt index f74c3b2fae..8a45645b5b 100644 --- a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/modifier/Activation.kt +++ b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/modifier/Activation.kt @@ -28,77 +28,80 @@ import java.awt.event.FocusListener import java.awt.event.WindowAdapter import java.awt.event.WindowEvent -fun Modifier.trackWindowActivation(window: Window) = composed( - inspectorInfo = debugInspectorInfo { - name = "activateRoot" - properties["window"] = window - }, -) { - var parentActivated by remember { mutableStateOf(false) } - - DisposableEffect(window) { - val listener = object : WindowAdapter() { - override fun windowActivated(e: WindowEvent?) { - parentActivated = true +public fun Modifier.trackWindowActivation(window: Window): Modifier = + composed( + inspectorInfo = debugInspectorInfo { + name = "activateRoot" + properties["window"] = window + }, + ) { + var parentActivated by remember { mutableStateOf(false) } + + DisposableEffect(window) { + val listener = object : WindowAdapter() { + override fun windowActivated(e: WindowEvent?) { + parentActivated = true + } + + override fun windowDeactivated(e: WindowEvent?) { + parentActivated = false + } } - - override fun windowDeactivated(e: WindowEvent?) { - parentActivated = false + window.addWindowListener(listener) + onDispose { + window.removeWindowListener(listener) } } - window.addWindowListener(listener) - onDispose { - window.removeWindowListener(listener) + Modifier.modifierLocalProvider(ModifierLocalActivated) { + parentActivated } } - Modifier.modifierLocalProvider(ModifierLocalActivated) { - parentActivated - } -} -fun Modifier.trackComponentActivation(awtParent: Component) = composed( - inspectorInfo = debugInspectorInfo { - name = "activateRoot" - properties["parent"] = awtParent - }, -) { - var parentActivated by remember { mutableStateOf(false) } - - DisposableEffect(awtParent) { - val listener = object : FocusListener { - override fun focusGained(e: FocusEvent?) { - parentActivated = true +public fun Modifier.trackComponentActivation(awtParent: Component): Modifier = + composed( + inspectorInfo = debugInspectorInfo { + name = "activateRoot" + properties["parent"] = awtParent + }, + ) { + var parentActivated by remember { mutableStateOf(false) } + + DisposableEffect(awtParent) { + val listener = object : FocusListener { + override fun focusGained(e: FocusEvent?) { + parentActivated = true + } + + override fun focusLost(e: FocusEvent?) { + parentActivated = false + } } - - override fun focusLost(e: FocusEvent?) { - parentActivated = false + awtParent.addFocusListener(listener) + onDispose { + awtParent.removeFocusListener(listener) } } - awtParent.addFocusListener(listener) - onDispose { - awtParent.removeFocusListener(listener) + Modifier.modifierLocalProvider(ModifierLocalActivated) { + parentActivated } } - Modifier.modifierLocalProvider(ModifierLocalActivated) { - parentActivated - } -} @Stable -fun Modifier.trackActivation() = composed( - inspectorInfo = debugInspectorInfo { - name = "trackActivation" - }, -) { - val activatedModifierLocal = remember { ActivatedModifierLocal() } - Modifier.focusGroup().onFocusChanged { - if (it.hasFocus) { - activatedModifierLocal.childGainedFocus() - } else { - activatedModifierLocal.childLostFocus() - } - }.then(activatedModifierLocal) -} +public fun Modifier.trackActivation(): Modifier = + composed( + inspectorInfo = debugInspectorInfo { + name = "trackActivation" + }, + ) { + val activatedModifierLocal = remember { ActivatedModifierLocal() } + Modifier.focusGroup().onFocusChanged { + if (it.hasFocus) { + activatedModifierLocal.childGainedFocus() + } else { + activatedModifierLocal.childLostFocus() + } + }.then(activatedModifierLocal) + } private class ActivatedModifierLocal : ModifierLocalProvider, ModifierLocalConsumer { @@ -126,15 +129,14 @@ private class ActivatedModifierLocal : ModifierLocalProvider, ModifierL } } -val ModifierLocalActivated = modifierLocalOf { - false -} +public val ModifierLocalActivated: ProvidableModifierLocal = + modifierLocalOf { false } -fun Modifier.onActivated( +public fun Modifier.onActivated( enabled: Boolean = true, onChanged: (Boolean) -> Unit, -) = then( - if (enabled) { +): Modifier = + this then if (enabled) { ActivateChangedModifierElement( onChanged, inspectorInfo = debugInspectorInfo { @@ -144,8 +146,7 @@ fun Modifier.onActivated( ) } else { Modifier - }, -) + } private class ActivateChangedModifierElement( private val onChanged: (Boolean) -> Unit, diff --git a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/state/SelectableComponentState.kt b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/state/SelectableComponentState.kt index fc8fe46c31..7eb145a8ec 100644 --- a/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/state/SelectableComponentState.kt +++ b/foundation/src/main/kotlin/org/jetbrains/jewel/foundation/state/SelectableComponentState.kt @@ -2,5 +2,5 @@ package org.jetbrains.jewel.foundation.state public interface SelectableComponentState : InteractiveComponentState { - val isSelected: Boolean + public val isSelected: Boolean } diff --git a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/ToolWindowExtensions.kt b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/ToolWindowExtensions.kt index 9a97e7e065..c6a4d095bd 100644 --- a/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/ToolWindowExtensions.kt +++ b/ide-laf-bridge/src/main/kotlin/org/jetbrains/jewel/bridge/ToolWindowExtensions.kt @@ -30,9 +30,9 @@ public fun ToolWindow.addComposeTab( contentManager.addContent(tabContent) } -interface ToolWindowScope { +public interface ToolWindowScope { - val toolWindow: ToolWindow + public val toolWindow: ToolWindow - val panel: ComposePanel + public val panel: ComposePanel } diff --git a/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/styling/IntUiTitleBarStyling.kt b/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/styling/IntUiTitleBarStyling.kt index fbc01425c1..b37d20874e 100644 --- a/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/styling/IntUiTitleBarStyling.kt +++ b/int-ui/int-ui-decorated-window/src/main/kotlin/org/jetbrains/jewel/intui/window/styling/IntUiTitleBarStyling.kt @@ -183,18 +183,18 @@ private fun titleBarIconButtonStyle( IconButtonStyle( IconButtonColors( foregroundSelectedActivated = Color.Unspecified, - background = Color.Unspecified, + background = Color.Unspecified, backgroundDisabled = Color.Unspecified, - backgroundSelected = Color.Unspecified, - backgroundSelectedActivated = Color.Unspecified, + backgroundSelected = Color.Unspecified, + backgroundSelectedActivated = Color.Unspecified, backgroundFocused = Color.Unspecified, backgroundPressed = hoveredBackground, backgroundHovered = pressedBackground, border = Color.Unspecified, borderDisabled = Color.Unspecified, borderSelected = Color.Unspecified, - borderSelectedActivated = Color.Unspecified, - borderFocused = hoveredBackground, + borderSelectedActivated = Color.Unspecified, + borderFocused = hoveredBackground, borderPressed = pressedBackground, borderHovered = Color.Unspecified, ), diff --git a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTabStyling.kt b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTabStyling.kt index 7d10a8ac9c..0f5e3143bb 100644 --- a/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTabStyling.kt +++ b/int-ui/int-ui-standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/styling/IntUiTabStyling.kt @@ -84,19 +84,16 @@ public object IntUiDefaultTabColorsFactory { TabColors( background = background, backgroundDisabled = backgroundDisabled, - backgroundFocused = backgroundFocused, backgroundPressed = backgroundPressed, backgroundHovered = backgroundHovered, backgroundSelected = backgroundSelected, content = content, contentDisabled = contentDisabled, - contentFocused = contentFocused, contentPressed = contentPressed, contentHovered = contentHovered, contentSelected = contentSelected, underline = underline, underlineDisabled = underlineDisabled, - underlineFocused = underlineFocused, underlinePressed = underlinePressed, underlineHovered = underlineHovered, underlineSelected = underlineSelected, @@ -122,19 +119,16 @@ public object IntUiDefaultTabColorsFactory { TabColors( background = background, backgroundDisabled = backgroundDisabled, - backgroundFocused = backgroundFocused, backgroundPressed = backgroundPressed, backgroundHovered = backgroundHovered, backgroundSelected = backgroundSelected, content = content, contentDisabled = contentDisabled, - contentFocused = contentFocused, contentPressed = contentPressed, contentHovered = contentHovered, contentSelected = contentSelected, underline = underline, underlineDisabled = underlineDisabled, - underlineFocused = underlineFocused, underlinePressed = underlinePressed, underlineHovered = underlineHovered, underlineSelected = underlineSelected, @@ -166,19 +160,16 @@ public object IntUiEditorTabColorsFactory { TabColors( background = background, backgroundDisabled = backgroundDisabled, - backgroundFocused = backgroundFocused, backgroundPressed = backgroundPressed, backgroundHovered = backgroundHovered, backgroundSelected = backgroundSelected, content = content, contentDisabled = contentDisabled, - contentFocused = contentFocused, contentPressed = contentPressed, contentHovered = contentHovered, contentSelected = contentSelected, underline = underline, underlineDisabled = underlineDisabled, - underlineFocused = underlineFocused, underlinePressed = underlinePressed, underlineHovered = underlineHovered, underlineSelected = underlineSelected, @@ -204,19 +195,16 @@ public object IntUiEditorTabColorsFactory { TabColors( background = background, backgroundDisabled = backgroundDisabled, - backgroundFocused = backgroundFocused, backgroundPressed = backgroundPressed, backgroundHovered = backgroundHovered, backgroundSelected = backgroundSelected, content = content, contentDisabled = contentDisabled, - contentFocused = contentFocused, contentPressed = contentPressed, contentHovered = contentHovered, contentSelected = contentSelected, underline = underline, underlineDisabled = underlineDisabled, - underlineFocused = underlineFocused, underlinePressed = underlinePressed, underlineHovered = underlineHovered, underlineSelected = underlineSelected, diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/IntUiThemes.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/IntUiThemes.kt index 53e76ec378..d8d0c981e8 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/IntUiThemes.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/IntUiThemes.kt @@ -19,7 +19,7 @@ public enum class IntUiThemes { public companion object { - public fun fromSystemTheme(systemTheme: SystemTheme) = + public fun fromSystemTheme(systemTheme: SystemTheme): IntUiThemes = if (systemTheme == SystemTheme.LIGHT) Light else Dark } } diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/Main.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/Main.kt index 7145300892..651495ab1d 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/Main.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/Main.kt @@ -34,7 +34,7 @@ public fun main() { themeDefinition, ComponentStyling.decoratedWindow( titleBarStyle = - when (MainViewModel.theme) { + when (MainViewModel.theme) { IntUiThemes.Light -> TitleBarStyle.light() IntUiThemes.LightWithLightHeader -> TitleBarStyle.lightWithLightHeader() IntUiThemes.Dark -> TitleBarStyle.dark() diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Icons.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/components/Icons.kt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/ComponentsView.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/ComponentsView.kt index 4e50af6e30..52642fc6a6 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/ComponentsView.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/ComponentsView.kt @@ -33,7 +33,7 @@ import org.jetbrains.jewel.ui.painter.rememberResourcePainterProvider @Composable @View(title = "Components", position = 1, icon = "icons/structure.svg") -fun ComponentsView() { +public fun ComponentsView() { Row(Modifier.trackActivation().fillMaxSize().background(JewelTheme.globalColors.paneBackground)) { ComponentsToolBar() Divider(Orientation.Vertical) @@ -42,7 +42,7 @@ fun ComponentsView() { } @Composable -fun ComponentsToolBar() { +public fun ComponentsToolBar() { Column(Modifier.fillMaxHeight().width(40.dp)) { ComponentsViewModel.views.forEach { Tooltip({ @@ -62,7 +62,7 @@ fun ComponentsToolBar() { } @Composable -fun ComponentView(view: ViewInfo) { +public fun ComponentView(view: ViewInfo) { Column(Modifier.fillMaxSize().padding(24.dp), verticalArrangement = Arrangement.spacedBy(24.dp)) { Text(view.title, fontSize = 20.sp) view.content() diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/TitleBarView.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/TitleBarView.kt index 21de995ecc..31cd709899 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/TitleBarView.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/TitleBarView.kt @@ -27,7 +27,7 @@ import java.awt.Desktop import java.net.URI @Composable -fun DecoratedWindowScope.TitleBarView() { +public fun DecoratedWindowScope.TitleBarView() { TitleBar(Modifier.newFullscreenControls(), gradientStartColor = MainViewModel.projectColor) { Row(Modifier.align(Alignment.Start)) { Dropdown(Modifier.height(30.dp), menuContent = { diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/WelcomeView.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/WelcomeView.kt index 5d89da89eb..af1c46b5a2 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/WelcomeView.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/view/WelcomeView.kt @@ -29,7 +29,7 @@ import org.jetbrains.jewel.ui.painter.rememberResourcePainterProvider @Composable @View(title = "Welcome", position = 0, icon = "icons/meetNewUi.svg") -fun WelcomeView() { +public fun WelcomeView() { Box( Modifier.trackActivation().fillMaxSize() .background(JewelTheme.globalColors.paneBackground) @@ -74,7 +74,7 @@ fun WelcomeView() { } @Composable -fun ThemeSelectionChip(theme: IntUiThemes, name: String, icon: String) { +public fun ThemeSelectionChip(theme: IntUiThemes, name: String, icon: String) { RadioButtonChip( selected = MainViewModel.theme == theme, onClick = { MainViewModel.theme = theme }, diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/ComponentsViewModel.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/ComponentsViewModel.kt index 073b6f14da..391659273d 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/ComponentsViewModel.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/ComponentsViewModel.kt @@ -3,12 +3,15 @@ package org.jetbrains.jewel.samples.standalone.viewmodel import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshots.SnapshotStateList import androidx.compose.runtime.toMutableStateList import org.jetbrains.jewel.samples.standalone.reflection.findViews -object ComponentsViewModel { +public object ComponentsViewModel { - val views = findViews("org.jetbrains.jewel.samples.standalone.view.component").toMutableStateList() + public val views: SnapshotStateList = + findViews("org.jetbrains.jewel.samples.standalone.view.component") + .toMutableStateList() - var currentView by mutableStateOf(views.first()) + public var currentView: ViewInfo by mutableStateOf(views.first()) } diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/MainViewModel.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/MainViewModel.kt index c45f0bfbf5..7b6b2bbe44 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/MainViewModel.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/MainViewModel.kt @@ -3,25 +3,28 @@ package org.jetbrains.jewel.samples.standalone.viewmodel import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshots.SnapshotStateList import androidx.compose.runtime.toMutableStateList import androidx.compose.ui.graphics.Color import org.jetbrains.jewel.samples.standalone.IntUiThemes import org.jetbrains.jewel.samples.standalone.reflection.findViews -object MainViewModel { +public object MainViewModel { - var theme: IntUiThemes by mutableStateOf(IntUiThemes.Light) + public var theme: IntUiThemes by mutableStateOf(IntUiThemes.Light) - var swingCompat: Boolean by mutableStateOf(false) + public var swingCompat: Boolean by mutableStateOf(false) - val projectColor + public val projectColor: Color get() = if (theme.isLightHeader()) { Color(0xFFF5D4C1) } else { Color(0xFF654B40) } - val views = findViews("org.jetbrains.jewel.samples.standalone.view").toMutableStateList() + public val views: SnapshotStateList = + findViews("org.jetbrains.jewel.samples.standalone.view") + .toMutableStateList() - var currentView by mutableStateOf(views.first()) + public var currentView: ViewInfo by mutableStateOf(views.first()) } diff --git a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/View.kt b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/View.kt index aec63c969a..1d2d6676dc 100644 --- a/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/View.kt +++ b/samples/standalone/src/main/kotlin/org/jetbrains/jewel/samples/standalone/viewmodel/View.kt @@ -2,16 +2,16 @@ package org.jetbrains.jewel.samples.standalone.viewmodel import androidx.compose.runtime.Composable -data class ViewInfo( - val title: String, - val position: Int, - val icon: String, - val content: @Composable () -> Unit, +public data class ViewInfo( + public val title: String, + public val position: Int, + public val icon: String, + public val content: @Composable () -> Unit, ) @Target(AnnotationTarget.FUNCTION) -annotation class View( - val title: String, - val position: Int = 0, - val icon: String = "icons/stub.svg", +public annotation class View( + public val title: String, + public val position: Int = 0, + public val icon: String = "icons/stub.svg", ) diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/ComponentStyling.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/ComponentStyling.kt index 51753c2684..3f4df40a3e 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/ComponentStyling.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/ComponentStyling.kt @@ -35,7 +35,7 @@ public interface ComponentStyling { @Composable override fun styles(): Array> = emptyArray() - override fun toString() = "ComponentStyleProvider" + override fun toString(): String = "ComponentStyleProvider" } } diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/DefaultComponentStyling.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/DefaultComponentStyling.kt index 30ee9523c7..fecad358ea 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/DefaultComponentStyling.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/DefaultComponentStyling.kt @@ -50,29 +50,29 @@ import org.jetbrains.jewel.ui.component.styling.TooltipStyle @Stable @GenerateDataFunctions -class DefaultComponentStyling( - val checkboxStyle: CheckboxStyle, - val chipStyle: ChipStyle, - val circularProgressStyle: CircularProgressStyle, - val defaultButtonStyle: ButtonStyle, - val defaultDropdownStyle: DropdownStyle, - val defaultTabStyle: TabStyle, - val dividerStyle: DividerStyle, - val editorTabStyle: TabStyle, - val groupHeaderStyle: GroupHeaderStyle, - val horizontalProgressBarStyle: HorizontalProgressBarStyle, - val iconButtonStyle: IconButtonStyle, - val labelledTextFieldStyle: LabelledTextFieldStyle, - val lazyTreeStyle: LazyTreeStyle, - val linkStyle: LinkStyle, - val menuStyle: MenuStyle, - val outlinedButtonStyle: ButtonStyle, - val radioButtonStyle: RadioButtonStyle, - val scrollbarStyle: ScrollbarStyle, - val textAreaStyle: TextAreaStyle, - val textFieldStyle: TextFieldStyle, - val tooltipStyle: TooltipStyle, - val undecoratedDropdownStyle: DropdownStyle, +public class DefaultComponentStyling( + public val checkboxStyle: CheckboxStyle, + public val chipStyle: ChipStyle, + public val circularProgressStyle: CircularProgressStyle, + public val defaultButtonStyle: ButtonStyle, + public val defaultDropdownStyle: DropdownStyle, + public val defaultTabStyle: TabStyle, + public val dividerStyle: DividerStyle, + public val editorTabStyle: TabStyle, + public val groupHeaderStyle: GroupHeaderStyle, + public val horizontalProgressBarStyle: HorizontalProgressBarStyle, + public val iconButtonStyle: IconButtonStyle, + public val labelledTextFieldStyle: LabelledTextFieldStyle, + public val lazyTreeStyle: LazyTreeStyle, + public val linkStyle: LinkStyle, + public val menuStyle: MenuStyle, + public val outlinedButtonStyle: ButtonStyle, + public val radioButtonStyle: RadioButtonStyle, + public val scrollbarStyle: ScrollbarStyle, + public val textAreaStyle: TextAreaStyle, + public val textFieldStyle: TextFieldStyle, + public val tooltipStyle: TooltipStyle, + public val undecoratedDropdownStyle: DropdownStyle, ) : ComponentStyling { @Composable diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/IconButton.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/IconButton.kt index 912387ba0f..7f305d7880 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/IconButton.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/IconButton.kt @@ -46,7 +46,8 @@ public fun IconButton( val buttonState = remember(interactionSource) { mutableStateOf(IconButtonState.of(enabled = enabled)) } - remember(enabled) { buttonState .value = buttonState.value.copy(enabled = enabled) + remember(enabled) { + buttonState.value = buttonState.value.copy(enabled = enabled) } IconButtonImpl( @@ -66,7 +67,7 @@ public fun IconButton( } @Composable -fun SelectableIconButton( +public fun SelectableIconButton( selected: Boolean, onClick: () -> Unit, modifier: Modifier = Modifier, @@ -93,7 +94,8 @@ fun SelectableIconButton( indication = null, selected = selected, ).onActivated(enabled = enabled) { - buttonState.value = buttonState.value.copy(active = it) }, + buttonState.value = buttonState.value.copy(active = it) + }, style = style, interactionSource = interactionSource, content = content, @@ -117,6 +119,7 @@ private fun IconButtonImpl( is PressInteraction.Cancel, is PressInteraction.Release, -> buttonState = buttonState.copy(pressed = false) + is HoverInteraction.Enter -> buttonState = buttonState.copy(hovered = true) is HoverInteraction.Exit -> buttonState = buttonState.copy(hovered = false) is FocusInteraction.Focus -> buttonState = buttonState.copy(focused = true) @@ -141,7 +144,7 @@ private fun IconButtonImpl( @Immutable @JvmInline -value class IconButtonState(val state: ULong) : FocusableComponentState, SelectableComponentState { +public value class IconButtonState(public val state: ULong) : FocusableComponentState, SelectableComponentState { @Stable override val isSelected: Boolean @@ -167,43 +170,45 @@ value class IconButtonState(val state: ULong) : FocusableComponentState, Selecta override val isPressed: Boolean get() = state and CommonStateBitMask.Pressed != 0UL - fun copy( + public fun copy( enabled: Boolean = isEnabled, selected: Boolean = isSelected, focused: Boolean = isFocused, pressed: Boolean = isPressed, hovered: Boolean = isHovered, active: Boolean = isActive, - ) = of( - enabled = enabled, - selected = selected, - focused = focused, - pressed = pressed, - hovered = hovered, - active = active, - ) + ): IconButtonState = + of( + enabled = enabled, + selected = selected, + focused = focused, + pressed = pressed, + hovered = hovered, + active = active, + ) - override fun toString() = + override fun toString(): String = "${javaClass.simpleName}(isEnabled=$isEnabled, isSelected=$isSelected, " + "isFocused=$isFocused, isHovered=$isHovered, isPressed=$isPressed, " + "isActive=$isActive)" - companion object { + public companion object { - fun of( + public fun of( enabled: Boolean = true, selected: Boolean = false, focused: Boolean = false, pressed: Boolean = false, hovered: Boolean = false, active: Boolean = false, - ) = IconButtonState( - state = (if (enabled) CommonStateBitMask.Enabled else 0UL) or - (if (selected) CommonStateBitMask.Selected else 0UL) or - (if (focused) CommonStateBitMask.Focused else 0UL) or - (if (hovered) CommonStateBitMask.Hovered else 0UL) or - (if (pressed) CommonStateBitMask.Pressed else 0UL) or - (if (active) CommonStateBitMask.Active else 0UL), - ) + ): IconButtonState = + IconButtonState( + (if (enabled) CommonStateBitMask.Enabled else 0UL) or + (if (selected) CommonStateBitMask.Selected else 0UL) or + (if (focused) CommonStateBitMask.Focused else 0UL) or + (if (hovered) CommonStateBitMask.Hovered else 0UL) or + (if (pressed) CommonStateBitMask.Pressed else 0UL) or + (if (active) CommonStateBitMask.Active else 0UL), + ) } } diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/IconButtonStyling.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/IconButtonStyling.kt index 7c936f1907..1819c6964e 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/IconButtonStyling.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/IconButtonStyling.kt @@ -29,50 +29,52 @@ public class IconButtonStyle( @GenerateDataFunctions public class IconButtonColors( public val foregroundSelectedActivated: Color, - val background: Color, + public val background: Color, public val backgroundDisabled: Color, public val backgroundSelected: Color, - val backgroundSelectedActivated: Color, - val backgroundFocused: Color, + public val backgroundSelectedActivated: Color, + public val backgroundFocused: Color, public val backgroundPressed: Color, public val backgroundHovered: Color, public val border: Color, public val borderDisabled: Color, - val borderSelected: Color, - val borderSelectedActivated: Color, + public val borderSelected: Color, + public val borderSelectedActivated: Color, public val borderFocused: Color, public val borderPressed: Color, public val borderHovered: Color, ) { @Composable - public fun foregroundFor(state: IconButtonState) = rememberUpdatedState( - when { - state.isActive && state.isSelected -> foregroundSelectedActivated - else -> Color.Unspecified - }, - ) + public fun foregroundFor(state: IconButtonState): State = + rememberUpdatedState( + when { + state.isActive && state.isSelected -> foregroundSelectedActivated + else -> Color.Unspecified + }, + ) @Composable - public fun backgroundFor(state: IconButtonState) = rememberUpdatedState( - when { - !state.isEnabled -> backgroundDisabled - state.isActive && state.isSelected -> backgroundSelectedActivated - state.isSelected -> backgroundSelected - state.isPressed -> backgroundPressed - state.isHovered -> backgroundHovered - state.isFocused -> backgroundFocused - else -> background - }, - ) + public fun backgroundFor(state: IconButtonState): State = + rememberUpdatedState( + when { + !state.isEnabled -> backgroundDisabled + state.isActive && state.isSelected -> backgroundSelectedActivated + state.isSelected -> backgroundSelected + state.isPressed -> backgroundPressed + state.isHovered -> backgroundHovered + state.isFocused -> backgroundFocused + else -> background + }, + ) @Composable public fun borderFor(state: IconButtonState): State = rememberUpdatedState( when { !state.isEnabled -> borderDisabled - state.isActive && state.isSelected -> borderSelectedActivated - state.isSelected -> borderSelected + state.isActive && state.isSelected -> borderSelectedActivated + state.isSelected -> borderSelected state.isFocused -> borderFocused state.isPressed -> borderPressed state.isHovered -> borderHovered diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/MenuStyling.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/MenuStyling.kt index a3ccb2ccb9..98a1e7f7aa 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/MenuStyling.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/MenuStyling.kt @@ -20,7 +20,7 @@ import org.jetbrains.jewel.ui.painter.PainterProvider @GenerateDataFunctions public class MenuStyle( public val isDark: Boolean, - val colors: MenuColors, + public val colors: MenuColors, public val metrics: MenuMetrics, public val icons: MenuIcons, ) { diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/TabStyling.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/TabStyling.kt index cbecd73508..3250ca7ca4 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/TabStyling.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/styling/TabStyling.kt @@ -74,7 +74,7 @@ public class TabColors( state.chooseValueIgnoreCompat( normal = content, disabled = contentDisabled, - + pressed = contentPressed, hovered = contentHovered, active = content, @@ -89,7 +89,7 @@ public class TabColors( !state.isEnabled -> backgroundDisabled state.isPressed -> backgroundPressed state.isHovered -> backgroundHovered - + state.isActive -> background state.isSelected -> backgroundSelected else -> background @@ -105,7 +105,7 @@ public class TabColors( state.chooseValueIgnoreCompat( normal = underline, disabled = underlineDisabled, - + pressed = underlinePressed, hovered = underlineHovered, active = underline, @@ -140,7 +140,7 @@ public class TabContentAlpha( state.chooseValueIgnoreCompat( normal = iconNormal, disabled = iconDisabled, - + pressed = iconPressed, hovered = iconHovered, active = iconNormal, @@ -157,7 +157,7 @@ public class TabContentAlpha( state.chooseValueIgnoreCompat( normal = labelNormal, disabled = labelDisabled, - + pressed = labelPressed, hovered = labelHovered, active = labelNormal, diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/PainterHint.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/PainterHint.kt index db0d4e4abf..5e785f0bda 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/PainterHint.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/PainterHint.kt @@ -68,7 +68,7 @@ public interface PainterPathHint : PainterHint { /** * Replace the entire path with the given value. */ - fun PainterProviderScope.patch(): String + public fun PainterProviderScope.patch(): String } /** diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/PainterProviderScope.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/PainterProviderScope.kt index c9684d05b6..5fb7dfed5d 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/PainterProviderScope.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/PainterProviderScope.kt @@ -2,16 +2,16 @@ package org.jetbrains.jewel.ui.painter import androidx.compose.ui.unit.Density -interface PainterProviderScope : Density { +public interface PainterProviderScope : Density { - val rawPath: String + public val rawPath: String - val path: String + public val path: String - val acceptedHints: List + public val acceptedHints: List } -interface ResourcePainterProviderScope : PainterProviderScope { +public interface ResourcePainterProviderScope : PainterProviderScope { - val classLoaders: Set + public val classLoaders: Set } diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/ResizedPainter.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/ResizedPainter.kt index 40ffb3170c..9af2d6b972 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/ResizedPainter.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/ResizedPainter.kt @@ -4,7 +4,7 @@ import androidx.compose.ui.geometry.Size import androidx.compose.ui.graphics.drawscope.DrawScope import androidx.compose.ui.graphics.painter.Painter -class ResizedPainter(private val delegate: Painter, private val size: Size) : DelegatePainter(delegate) { +public class ResizedPainter(private val delegate: Painter, private val size: Size) : DelegatePainter(delegate) { override val intrinsicSize: Size get() = size diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/ResourcePainterProvider.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/ResourcePainterProvider.kt index b17923a3a0..de0b865516 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/ResourcePainterProvider.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/ResourcePainterProvider.kt @@ -78,10 +78,10 @@ public class ResourcePainterProvider( currentHintsProvider.priorityHints(basePath).forEach { scope.resolveHint(it) } - hints.forEach { + hints.forEach { scope.resolveHint(it) } - currentHintsProvider.hints(basePath).forEach { + currentHintsProvider.hints(basePath).forEach { scope.resolveHint(it) } diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Dark.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Dark.kt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/DarkOrStroke.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/DarkOrStroke.kt index 41d3b29fdb..9d2c956c71 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/DarkOrStroke.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/DarkOrStroke.kt @@ -73,14 +73,16 @@ private class StrokeImpl(private val color: Color) : PainterSuffixHint(), Painte ) } -fun Stroke(color: Color): PainterHint = if (color.isSpecified) { - StrokeImpl(color) -} else { - PainterHint.None -} +public fun Stroke(color: Color): PainterHint = + if (color.isSpecified) { + StrokeImpl(color) + } else { + PainterHint.None + } -fun Dark(isDark: Boolean = true): PainterHint = if (isDark) { - DarkImpl -} else { - PainterHint.None -} +public fun Dark(isDark: Boolean = true): PainterHint = + if (isDark) { + DarkImpl + } else { + PainterHint.None + } diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Palette.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Palette.kt index 2c8b93611b..2d5ce65f12 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Palette.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Palette.kt @@ -72,35 +72,35 @@ private fun fromHexOrNull(rawColor: String, alpha: Float): Color? { val length = rawColor.length - startPos val alphaOverride = alpha.takeIf { it != 1.0f }?.let { (it * 255).roundToInt() } - return when (length) { - 3 -> - Color( - red = rawColor.substring(startPos, startPos + 1).toInt(16), - green = rawColor.substring(startPos + 1, startPos + 2).toInt(16), - blue = rawColor.substring(startPos + 2, startPos + 3).toInt(16), - alpha = alphaOverride ?: 255, - ) - 4 -> - Color( - red = rawColor.substring(startPos, startPos + 1).toInt(16), - green = rawColor.substring(startPos + 1, startPos + 2).toInt(16), - blue = rawColor.substring(startPos + 2, startPos + 3).toInt(16), - alpha = alphaOverride ?: rawColor.substring(startPos + 3, startPos + 4).toInt(16), - ) - 6 -> - Color( - red = rawColor.substring(startPos, startPos + 2).toInt(16), - green = rawColor.substring(startPos + 2, startPos + 4).toInt(16), - blue = rawColor.substring(startPos + 4, startPos + 6).toInt(16), - alpha = alphaOverride ?: 255, - ) - 8 -> - Color( - red = rawColor.substring(startPos, startPos + 2).toInt(16), - green = rawColor.substring(startPos + 2, startPos + 4).toInt(16), - blue = rawColor.substring(startPos + 4, startPos + 6).toInt(16), - alpha = alphaOverride ?: rawColor.substring(startPos + 6, startPos + 8).toInt(16), - ) + return when (length) { + 3 -> + Color( + red = rawColor.substring(startPos, startPos + 1).toInt(16), + green = rawColor.substring(startPos + 1, startPos + 2).toInt(16), + blue = rawColor.substring(startPos + 2, startPos + 3).toInt(16), + alpha = alphaOverride ?: 255, + ) + 4 -> + Color( + red = rawColor.substring(startPos, startPos + 1).toInt(16), + green = rawColor.substring(startPos + 1, startPos + 2).toInt(16), + blue = rawColor.substring(startPos + 2, startPos + 3).toInt(16), + alpha = alphaOverride ?: rawColor.substring(startPos + 3, startPos + 4).toInt(16), + ) + 6 -> + Color( + red = rawColor.substring(startPos, startPos + 2).toInt(16), + green = rawColor.substring(startPos + 2, startPos + 4).toInt(16), + blue = rawColor.substring(startPos + 4, startPos + 6).toInt(16), + alpha = alphaOverride ?: 255, + ) + 8 -> + Color( + red = rawColor.substring(startPos, startPos + 2).toInt(16), + green = rawColor.substring(startPos + 2, startPos + 4).toInt(16), + blue = rawColor.substring(startPos + 4, startPos + 6).toInt(16), + alpha = alphaOverride ?: rawColor.substring(startPos + 6, startPos + 8).toInt(16), + ) else -> null } } diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Size.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Size.kt index e9feb6d811..4e1b6caf1e 100644 --- a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Size.kt +++ b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Size.kt @@ -51,7 +51,7 @@ private class SizeImpl( } } -fun Size(width: Int, height: Int = width): PainterHint { +public fun Size(width: Int, height: Int = width): PainterHint { require(width > 0 && height > 0) { "Width and height must be positive" } diff --git a/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Stroke.kt b/ui/src/main/kotlin/org/jetbrains/jewel/ui/painter/hints/Stroke.kt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ui/src/test/kotlin/org/jetbrains/jewel/PainterHintTest.kt b/ui/src/test/kotlin/org/jetbrains/jewel/PainterHintTest.kt index f1646c1c59..8f96c33328 100644 --- a/ui/src/test/kotlin/org/jetbrains/jewel/PainterHintTest.kt +++ b/ui/src/test/kotlin/org/jetbrains/jewel/PainterHintTest.kt @@ -62,22 +62,23 @@ class PainterHintTest : BasicJewelUiTest() { var result = rawPath hints.forEach { if (it !is PainterPathHint) return@forEach - with (it) { + with(it) { if (!canApply()) return@forEach result = patch() } + } + return result } - return result - } fun applyPaletteHints(svg: String, vararg hints: PainterHint): String { val doc = documentBuilderFactory.newDocumentBuilder().parse(svg.toByteArray().inputStream()) - hints.filterIsInstance().onEach { with(it) { - if (!canApply()) return@onEach - patch(doc.documentElement) - } + hints.filterIsInstance().onEach { + with(it) { + if (!canApply()) return@onEach + patch(doc.documentElement) } + } return doc.writeToString() } @@ -286,7 +287,7 @@ class PainterHintTest : BasicJewelUiTest() { .trimIndent() val patchedSvg = testScope("fake_icon.svg").applyPaletteHints( - baseSvg, + baseSvg, Palette( mapOf( Color(0x80000000) to Color(0xFF123456),