[JEWEL-993] Add MacOS Scrollbar Detection to Standalone#3407
[JEWEL-993] Add MacOS Scrollbar Detection to Standalone#3407DanielSouzaBertoldi wants to merge 1 commit intoJetBrains:masterfrom
Conversation
51a75a3 to
10ada21
Compare
|
|
||
| operator fun invoke(id: ID?, selector: String?, vararg args: Any?): ID = invoke(id, createSelector(selector), *args) | ||
|
|
||
| fun allocateObjcClassPair(superCls: ID, name: String) = |
There was a problem hiding this comment.
All code here was taken directly from com.intellij.ui.mac.foundation.Foundation.java class and converted to Kotlin.
However, I did not import 100% of the code there
|
|
||
| private fun listenToTrackClickBehaviorChange() { | ||
| callMac { | ||
| // Copied from MacScrollBarUI |
There was a problem hiding this comment.
Unfortunately, as is the case with ScrollbarHelper from bridge, we can't directly use the code in MacScrollBarUI since all its classes are internal.
This means this code is duplicated. We have the same lines over in bridge, but such is the case with our structure. The only difference is that bridge uses IJP's version of Foundation.
| Column { | ||
| Text("Configuration", style = JewelTheme.typography.h2TextStyle) | ||
|
|
||
| Spacer(Modifier.height(16.dp)) |
There was a problem hiding this comment.
We can't set the vertical arrangement to spacedBy(16.dp) in our parent Column because that screws up the animation:
Screen.Recording.2026-02-04.at.15.21.51.mov
See? it kinda jumps at the end. That's because the parent Column has to get rid of the space that was reserved for the settings row after it's done animating :(
...standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/StandaloneScrollbarHelper.kt
Outdated
Show resolved
Hide resolved
...e/src/main/kotlin/org/jetbrains/jewel/intui/standalone/StandalonePlatformCursorController.kt
Outdated
Show resolved
Hide resolved
...standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/StandaloneScrollbarHelper.kt
Outdated
Show resolved
Hide resolved
...standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/StandaloneScrollbarHelper.kt
Outdated
Show resolved
Hide resolved
...standalone/src/main/kotlin/org/jetbrains/jewel/intui/standalone/StandaloneScrollbarHelper.kt
Outdated
Show resolved
Hide resolved
nebojsa-vuksic
left a comment
There was a problem hiding this comment.
We are missing tests :)
437d4e2 to
18b4a03
Compare
|
@nebojsa-vuksic just pushed the changes you asked + added tests. However, to avoid having to add the JNA dependency in the test module, I had to make a bunch of changes to the code which in turn made it a bit more complex:
Like, I think this is still pretty okay overall, but let me know if you disagree (in other words, if you think it's a bit overkill) |
There was a problem hiding this comment.
To avoid making StandaloneScrollbarHelper inherit from JNA and subsequently forcing us to add the JNA dependency in our int-ui-standalone-tests module, I had to move references to JNA's Callback here.
With the use of callbacks, we can make StandaloneScrollbarHelper refresh its state with whatever the callback returns. BUT! We have to do this "hacky" thing to keep the reference from being purged by GC 😭
There was a problem hiding this comment.
Please feel free to suggest better names if you think of any! 🙏🏻
8cc29a5 to
287d07f
Compare
287d07f to
ff6d4aa
Compare
Context
After #3372 was merged, we finally have access to JNA in the
:int-ui-standalonemodule. This means we can safely fetch data directly from MacOS settings and use it in our components 🥳This PR basically just changes
ScrollbarStyle.Companion.macOsLight()andScrollbarStyle.Companion.macOsDark()to fetch the user's current option from the newStandaloneScrollbarHelperclass instead of hardcoding an option.I also added a minor bonus: now you can change the configurations of all scrollbars in our
Scrollbarshowcase, changing from "manual" mode to "system", check the screenshots below!Changes
StandalonePlatformCursorControllerandStandaloneScrollbarHelperuse JNA to fetch style information, I opted to just move all JNA code from:decorated-windowover to:int-ui-standalone, since the code we had there was more robust and:decorated-windowdepends on:int-ui-standaloneanyway.Foundationclass so that we can add observers via JNA.Scrollbarsshowcase code to add an option for scrollbars to follow the behavior/visibility of the system.Screenshots
Screen.Recording.2026-02-04.at.15.04.24.mov
Screen.Recording.2026-02-04.at.14.55.50.mov
Scrollbars Showcase
Screen.Recording.2026-02-04.at.14.59.09.mov
Screen.Recording.2026-02-04.at.15.01.01.mov