mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-12 23:19:29 +08:00
Add Toolbar support for Mac
This commit is contained in:
parent
65d591e2a6
commit
5572fccaf6
@ -6,4 +6,6 @@ type MacOptions struct {
|
|||||||
HideTitle bool
|
HideTitle bool
|
||||||
HideTitleBar bool
|
HideTitleBar bool
|
||||||
FullSizeContent bool
|
FullSizeContent bool
|
||||||
|
UseToolbar bool
|
||||||
|
HideToolbarSeparator bool
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,8 @@ struct Application {
|
|||||||
int hideTitle;
|
int hideTitle;
|
||||||
int hideTitleBar;
|
int hideTitleBar;
|
||||||
int fullSizeContent;
|
int fullSizeContent;
|
||||||
|
int useToolBar;
|
||||||
|
int hideToolbarSeparator;
|
||||||
|
|
||||||
// User Data
|
// User Data
|
||||||
char *HTML;
|
char *HTML;
|
||||||
@ -145,6 +147,14 @@ void HideTitleBar(struct Application *app) {
|
|||||||
app->hideTitleBar = 1;
|
app->hideTitleBar = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HideToolbarSeparator(struct Application *app) {
|
||||||
|
app->hideToolbarSeparator = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UseToolbar(struct Application *app) {
|
||||||
|
app->useToolBar = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void FullSizeContent(struct Application *app) {
|
void FullSizeContent(struct Application *app) {
|
||||||
app->fullSizeContent = 1;
|
app->fullSizeContent = 1;
|
||||||
}
|
}
|
||||||
@ -210,6 +220,8 @@ void* NewApplication(const char *title, int width, int height, int resizable, in
|
|||||||
result->hideTitle = 0;
|
result->hideTitle = 0;
|
||||||
result->hideTitleBar = 0;
|
result->hideTitleBar = 0;
|
||||||
result->fullSizeContent = 0;
|
result->fullSizeContent = 0;
|
||||||
|
result->useToolBar = 0;
|
||||||
|
result->hideToolbarSeparator = 0;
|
||||||
|
|
||||||
result->titlebarAppearsTransparent = 0;
|
result->titlebarAppearsTransparent = 0;
|
||||||
printf("[l] setTitlebarAppearsTransparent %d\n", result->titlebarAppearsTransparent);
|
printf("[l] setTitlebarAppearsTransparent %d\n", result->titlebarAppearsTransparent);
|
||||||
@ -685,6 +697,7 @@ void Run(void *applicationPointer, int argc, char **argv) {
|
|||||||
decorations |= NSWindowStyleMaskFullSizeContentView;
|
decorations |= NSWindowStyleMaskFullSizeContentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
id application = msg(c("NSApplication"), s("sharedApplication"));
|
id application = msg(c("NSApplication"), s("sharedApplication"));
|
||||||
app->application = application;
|
app->application = application;
|
||||||
msg(application, s("setActivationPolicy:"), 0);
|
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(mainWindow, s("setTitlebarAppearsTransparent:"), app->titlebarAppearsTransparent ? YES : NO);
|
||||||
msg(app->mainWindow, s("setTitleVisibility:"), app->hideTitle);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@ extern void TitlebarAppearsTransparent(void *);
|
|||||||
extern void HideTitle(void *);
|
extern void HideTitle(void *);
|
||||||
extern void HideTitleBar(void *);
|
extern void HideTitleBar(void *);
|
||||||
extern void FullSizeContent(void *);
|
extern void FullSizeContent(void *);
|
||||||
|
extern void UseToolbar(void *);
|
||||||
|
extern void HideToolbarSeparator(void *);
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
@ -28,7 +30,17 @@ func (a *Application) processPlatformSettings() {
|
|||||||
C.FullSizeContent(a.app)
|
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 {
|
if a.config.Mac.TitlebarAppearsTransparent {
|
||||||
C.TitlebarAppearsTransparent(a.app)
|
C.TitlebarAppearsTransparent(a.app)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,10 @@ func main() {
|
|||||||
Mac: wails.MacOptions{
|
Mac: wails.MacOptions{
|
||||||
HideTitle: true,
|
HideTitle: true,
|
||||||
HideTitleBar: false,
|
HideTitleBar: false,
|
||||||
TitlebarAppearsTransparent: true,
|
TitlebarAppearsTransparent: false,
|
||||||
FullSizeContent: true,
|
FullSizeContent: true,
|
||||||
|
UseToolbar: true,
|
||||||
|
HideToolbarSeparator: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user