diff --git a/v2/internal/appoptions/mac.go b/v2/internal/appoptions/mac.go index 988745d00..155434b5e 100644 --- a/v2/internal/appoptions/mac.go +++ b/v2/internal/appoptions/mac.go @@ -6,4 +6,6 @@ type MacOptions struct { HideTitle bool HideTitleBar bool FullSizeContent bool + UseToolbar bool + HideToolbarSeparator bool } diff --git a/v2/internal/ffenestri/ffenestri_darwin.c b/v2/internal/ffenestri/ffenestri_darwin.c index ffcbd36e9..e50fbcac5 100644 --- a/v2/internal/ffenestri/ffenestri_darwin.c +++ b/v2/internal/ffenestri/ffenestri_darwin.c @@ -117,6 +117,8 @@ struct Application { int hideTitle; int hideTitleBar; int fullSizeContent; + int useToolBar; + int hideToolbarSeparator; // User Data char *HTML; @@ -145,6 +147,14 @@ void HideTitleBar(struct Application *app) { app->hideTitleBar = 1; } +void HideToolbarSeparator(struct Application *app) { + app->hideToolbarSeparator = 1; +} + +void UseToolbar(struct Application *app) { + app->useToolBar = 1; +} + void FullSizeContent(struct Application *app) { app->fullSizeContent = 1; } @@ -210,6 +220,8 @@ void* NewApplication(const char *title, int width, int height, int resizable, in result->hideTitle = 0; result->hideTitleBar = 0; result->fullSizeContent = 0; + result->useToolBar = 0; + result->hideToolbarSeparator = 0; result->titlebarAppearsTransparent = 0; printf("[l] setTitlebarAppearsTransparent %d\n", result->titlebarAppearsTransparent); @@ -685,6 +697,7 @@ void Run(void *applicationPointer, int argc, char **argv) { decorations |= NSWindowStyleMaskFullSizeContentView; } + id application = msg(c("NSApplication"), s("sharedApplication")); app->application = application; msg(application, s("setActivationPolicy:"), 0); @@ -758,6 +771,20 @@ void Run(void *applicationPointer, int argc, char **argv) { msg(mainWindow, s("setTitlebarAppearsTransparent:"), app->titlebarAppearsTransparent ? YES : NO); msg(app->mainWindow, s("setTitleVisibility:"), app->hideTitle); + // Toolbar + if( app->useToolBar ) { + Debug("Setting Toolbar"); + id toolbar = msg(c("NSToolbar"),s("alloc")); + msg(toolbar, s("initWithIdentifier:"), str("wails.toolbar")); + msg(toolbar, s("autorelease")); + + // Separator + if( app->hideToolbarSeparator ) { + msg(toolbar, s("setShowsBaselineSeparator:"), NO); + } + + msg(mainWindow, s("setToolbar:"), toolbar); + } } diff --git a/v2/internal/ffenestri/ffenestri_darwin.go b/v2/internal/ffenestri/ffenestri_darwin.go index 44445211c..6704aab22 100644 --- a/v2/internal/ffenestri/ffenestri_darwin.go +++ b/v2/internal/ffenestri/ffenestri_darwin.go @@ -8,6 +8,8 @@ extern void TitlebarAppearsTransparent(void *); extern void HideTitle(void *); extern void HideTitleBar(void *); extern void FullSizeContent(void *); +extern void UseToolbar(void *); +extern void HideToolbarSeparator(void *); */ import "C" @@ -28,7 +30,17 @@ func (a *Application) processPlatformSettings() { C.FullSizeContent(a.app) } + // Toolbar + if a.config.Mac.UseToolbar { + C.UseToolbar(a.app) + } + + if a.config.Mac.HideToolbarSeparator { + C.HideToolbarSeparator(a.app) + } + if a.config.Mac.TitlebarAppearsTransparent { C.TitlebarAppearsTransparent(a.app) } + } diff --git a/v2/test/runtime/main.go b/v2/test/runtime/main.go index 9b67e7d45..8645b2d99 100644 --- a/v2/test/runtime/main.go +++ b/v2/test/runtime/main.go @@ -23,8 +23,10 @@ func main() { Mac: wails.MacOptions{ HideTitle: true, HideTitleBar: false, - TitlebarAppearsTransparent: true, + TitlebarAppearsTransparent: false, FullSizeContent: true, + UseToolbar: true, + HideToolbarSeparator: true, }, })