feat(window): add fill-center title bar policy and BasicTitleBar APIs#245
feat(window): add fill-center title bar policy and BasicTitleBar APIs#245RavenLiao wants to merge 5 commits into
Conversation
|
Thank you very much for your work, I'm thinking of accepting the PR, although long-term I wonder if using a title bar is really a good pattern. It's originally a fork of Jewel, but honestly I think we'd just need a modifier that indicates a given composable should allow the window to be dragged, and simply overlay the native buttons in the right position — that would allow for unified UIs with a sidebar and not necessarily a title bar. This would also resolve issue #129 and would perhaps make things much simpler. I don't think I'd deprecate the title bar, but in my opinion it's just an old inherited pattern |
Yes, something like this? data class WindowControlsArea(
val side: WindowControlsSide, // Start (macOS) or End (Windows)
val width: Dp, // horizontal space the buttons occupy
val height: Dp, // how far down they extend
val offsetY: Dp = 0.dp, // shifts during fullscreen menu-bar animation
)
val LocalWindowControlsArea = staticCompositionLocalOf { WindowControlsArea(...) }
// ---
DecoratedWindow(...) {
val controls = LocalWindowControlsArea.current
Box(Modifier.fillMaxSize()) {
HeroImage(Modifier.fillMaxSize())
Sidebar(
Modifier
.windowDraggableArea()
.windowControlsPadding() // reads LocalWindowControlsArea internally
)
}
}
This also feels like the natural resolution to #129 — content extends freely, each element opts in to avoidance rather than being forced into a fixed TitleBar layout. |
🚀 Description
This PR introduces a new title bar layout customization layer with a built-in fill-center policy and adds dedicated basic title bar APIs for advanced layout scenarios.
Key updates include:
TitleBarLayoutPolicywithDefault(legacy-compatible) andFillCenterbehavior.BasicTitleBar(...)andBasicDialogTitleBar(...)as low-level entry points.TitleBar(...)/DialogTitleBar(...)APIs compatible by delegating toBasic*+Default.layoutPolicythrough core/JBR/JNI title bar paths.examplefor behavior validation.titleBarClickable, improving macOS fullscreen interaction stability.📄 Motivation and Context
Current title bar center content behavior is primarily wrap-content oriented, which makes "center fills remaining space" scenarios (e.g. tab strips) hard to express consistently.
This change provides a framework-native fill-center layout model while preserving existing behavior and API compatibility:
FillCenterviaBasic*APIs.🧪 How Has This Been Tested?
Build/test checks:
./gradlew.bat :decorated-window-core:compileKotlin :decorated-window-jbr:compileKotlin :decorated-window-jni:compileKotlin :example:compileKotlinResult: BUILD SUCCESSFUL
Manual validation:
clickablein title bar hit-test-sensitive area.📦 Types of changes
✅ Checklist