macOS large title bar: add NSToolbar to NSWindow

This commit is contained in:
Karl Tauber
2023-12-10 13:34:41 +01:00
parent eed11d211b
commit f40baed65e
5 changed files with 88 additions and 1 deletions

View File

@@ -15,6 +15,14 @@ extern "C" {
JNIEXPORT jboolean JNICALL Java_com_formdev_flatlaf_ui_FlatNativeMacLibrary_setWindowRoundedBorder
(JNIEnv *, jclass, jobject, jfloat, jfloat, jint);
/*
* Class: com_formdev_flatlaf_ui_FlatNativeMacLibrary
* Method: setWindowToolbar
* Signature: (Ljava/awt/Window;)V
*/
JNIEXPORT void JNICALL Java_com_formdev_flatlaf_ui_FlatNativeMacLibrary_setWindowToolbar
(JNIEnv *, jclass, jobject);
#ifdef __cplusplus
}
#endif

View File

@@ -87,3 +87,27 @@ JNIEXPORT jboolean JNICALL Java_com_formdev_flatlaf_ui_FlatNativeMacLibrary_setW
JNI_COCOA_EXIT()
return FALSE;
}
extern "C"
JNIEXPORT void JNICALL Java_com_formdev_flatlaf_ui_FlatNativeMacLibrary_setWindowToolbar
( JNIEnv* env, jclass cls, jobject window )
{
JNI_COCOA_ENTER()
NSWindow* nsWindow = getNSWindow( env, cls, window );
if( nsWindow == NULL )
return;
[FlatJNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
NSLog( @"\n%@\n\n", [nsWindow.contentView.superview _subtreeDescription] );
NSToolbar* toolbar = [NSToolbar new];
nsWindow.toolbar = toolbar;
// TODO handle fullscreen
NSLog( @"\n%@\n\n", [nsWindow.contentView.superview _subtreeDescription] );
}];
JNI_COCOA_EXIT()
}