diff --git a/mkdocs-website/docs/API/application.md b/mkdocs-website/docs/API/application.md index 454318112..25927888b 100644 --- a/mkdocs-website/docs/API/application.md +++ b/mkdocs-website/docs/API/application.md @@ -311,4 +311,20 @@ This is a brief summary of the exported methods in the provided `App` struct. Do --8<-- ../v3/pkg/application/options_application.go --8<-- +``` + +### Windows Options + +```go title="application_options_windows.go" +--8<-- +../v3/pkg/application/options_application_win.go +--8<-- +``` + +### Mac Options + +```go title="options_application_mac.go" +--8<-- +../v3/pkg/application/options_application_mac.go +--8<-- ``` \ No newline at end of file diff --git a/v3/examples/screen/main.go b/v3/examples/screen/main.go index 566dca2cf..3f80e2106 100644 --- a/v3/examples/screen/main.go +++ b/v3/examples/screen/main.go @@ -19,6 +19,12 @@ func main() { Mac: application.MacOptions{ ApplicationShouldTerminateAfterLastWindowClosed: true, }, + Windows: application.WindowsOptions{ + WndProcInterceptor: nil, + DisableQuitOnLastWindowClosed: false, + WebviewUserDataPath: "", + WebviewBrowserPath: "", + }, Assets: application.AssetOptions{ FS: assets, }, diff --git a/v3/pkg/application/options_application.go b/v3/pkg/application/options_application.go index 4d606c5c8..ae69f39df 100644 --- a/v3/pkg/application/options_application.go +++ b/v3/pkg/application/options_application.go @@ -20,7 +20,7 @@ type Options struct { Mac MacOptions // Windows is the Windows specific configuration for Windows builds - Windows WindowsApplicationOptions + Windows WindowsOptions // Bind allows you to bind Go methods to the frontend. Bind []any diff --git a/v3/pkg/application/options_application_mac.go b/v3/pkg/application/options_application_mac.go new file mode 100644 index 000000000..ddfbc80e6 --- /dev/null +++ b/v3/pkg/application/options_application_mac.go @@ -0,0 +1,22 @@ +package application + +// ActivationPolicy is the activation policy for the application. +type ActivationPolicy int + +const ( + // ActivationPolicyRegular is used for applications that have a user interface, + ActivationPolicyRegular ActivationPolicy = iota + // ActivationPolicyAccessory is used for applications that do not have a main window, + // such as system tray applications or background applications. + ActivationPolicyAccessory + ActivationPolicyProhibited +) + +// MacOptions contains options for macOS applications. +type MacOptions struct { + // ActivationPolicy is the activation policy for the application. Defaults to + // applicationActivationPolicyRegular. + ActivationPolicy ActivationPolicy + // If set to true, the application will terminate when the last window is closed. + ApplicationShouldTerminateAfterLastWindowClosed bool +} diff --git a/v3/pkg/application/options_application_win.go b/v3/pkg/application/options_application_win.go new file mode 100644 index 000000000..b5a7afdb7 --- /dev/null +++ b/v3/pkg/application/options_application_win.go @@ -0,0 +1,21 @@ +package application + +// WindowsOptions contains options for Windows applications. +type WindowsOptions struct { + + // WndProcInterceptor is a function that will be called for every message sent in the application. + // Use this to hook into the main message loop. This is useful for handling custom window messages. + // If `shouldReturn` is `true` then `returnCode` will be returned by the main message loop. + // If `shouldReturn` is `false` then returnCode will be ignored and the message will be processed by the main message loop. + WndProcInterceptor func(hwnd uintptr, msg uint32, wParam, lParam uintptr) (returnCode uintptr, shouldReturn bool) + + // DisableQuitOnLastWindowClosed disables the auto quit of the application if the last window has been closed. + DisableQuitOnLastWindowClosed bool + + // Path where the WebView2 stores the user data. If empty %APPDATA%\[BinaryName.exe] will be used. + // If the path is not valid, a messagebox will be displayed with the error and the app will exit with error code. + WebviewUserDataPath string + + // Path to the directory with WebView2 executables. If empty WebView2 installed in the system will be used. + WebviewBrowserPath string +} diff --git a/v3/pkg/application/options_mac.go b/v3/pkg/application/options_mac.go index a50a76d41..5b9546d8f 100644 --- a/v3/pkg/application/options_mac.go +++ b/v3/pkg/application/options_mac.go @@ -2,32 +2,19 @@ package application import "github.com/wailsapp/wails/v3/pkg/events" -type ActivationPolicy int - -const ( - ActivationPolicyRegular ActivationPolicy = iota - // ActivationPolicyAccessory is used for applications that do not have a main window, - // such as system tray applications or background applications. - ActivationPolicyAccessory - ActivationPolicyProhibited -) - -type MacOptions struct { - // ActivationPolicy is the activation policy for the application. Defaults to - // applicationActivationPolicyRegular. - ActivationPolicy ActivationPolicy - // If set to true, the application will terminate when the last window is closed. - ApplicationShouldTerminateAfterLastWindowClosed bool -} - +// MacBackdrop is the backdrop type for macOS type MacBackdrop int const ( + // MacBackdropNormal - The default value. The window will have a normal opaque background. MacBackdropNormal MacBackdrop = iota + // MacBackdropTransparent - The window will have a transparent background, with the content underneath it being visible MacBackdropTransparent + // MacBackdropTranslucent - The window will have a translucent background, with the content underneath it being "fuzzy" or "frosted" MacBackdropTranslucent ) +// MacToolbarStyle is the style of toolbar for macOS type MacToolbarStyle int const ( @@ -43,14 +30,19 @@ const ( MacToolbarStyleUnifiedCompact ) -// MacWindow contains macOS specific options +// MacWindow contains macOS specific options for Webview Windows type MacWindow struct { - Backdrop MacBackdrop - DisableShadow bool - TitleBar MacTitleBar - Appearance MacAppearanceType + // Backdrop is the backdrop type for the window + Backdrop MacBackdrop + // DisableShadow will disable the window shadow + DisableShadow bool + // TitleBar contains options for the Mac titlebar + TitleBar MacTitleBar + // Appearance is the appearance type for the window + Appearance MacAppearanceType + // InvisibleTitleBarHeight defines the height of an invisible titlebar which responds to dragging InvisibleTitleBarHeight int - // Maps events from platform specific to the event name + // Maps events from platform specific to common event types EventMapping map[events.WindowEventType]events.WindowEventType // EnableFraudulentWebsiteWarnings will enable warnings for fraudulent websites. @@ -60,13 +52,20 @@ type MacWindow struct { // MacTitleBar contains options for the Mac titlebar type MacTitleBar struct { - AppearsTransparent bool - Hide bool - HideTitle bool - FullSizeContent bool - UseToolbar bool + // AppearsTransparent will make the titlebar transparent + AppearsTransparent bool + // Hide will hide the titlebar + Hide bool + // HideTitle will hide the title + HideTitle bool + // FullSizeContent will extend the window content to the full size of the window + FullSizeContent bool + // UseToolbar will use a toolbar instead of a titlebar + UseToolbar bool + // HideToolbarSeparator will hide the toolbar separator HideToolbarSeparator bool - ToolbarStyle MacToolbarStyle + // ToolbarStyle is the style of toolbar to use + ToolbarStyle MacToolbarStyle } // MacTitleBarDefault results in the default Mac MacTitleBar diff --git a/v3/pkg/application/options_win.go b/v3/pkg/application/options_webview_window_win.go similarity index 73% rename from v3/pkg/application/options_win.go rename to v3/pkg/application/options_webview_window_win.go index da75aa12d..1e8a10d46 100644 --- a/v3/pkg/application/options_win.go +++ b/v3/pkg/application/options_webview_window_win.go @@ -2,24 +2,6 @@ package application import "github.com/wailsapp/wails/v3/pkg/events" -type WindowsApplicationOptions struct { - // WndProcInterceptor is a function that will be called for every message sent in the application. - // Use this to hook into the main message loop. This is useful for handling custom window messages. - // If `shouldReturn` is `true` then `returnCode` will be returned by the main message loop. - // If `shouldReturn` is `false` then returnCode will be ignored and the message will be processed by the main message loop. - WndProcInterceptor func(hwnd uintptr, msg uint32, wParam, lParam uintptr) (returnCode uintptr, shouldReturn bool) - - // DisableQuitOnLastWindowClosed disables the auto quit of the application if the last window has been closed. - DisableQuitOnLastWindowClosed bool - - // Path where the WebView2 stores the user data. If empty %APPDATA%\[BinaryName.exe] will be used. - // If the path is not valid, a messagebox will be displayed with the error and the app will exit with error code. - WebviewUserDataPath string - - // Path to the directory with WebView2 executables. If empty WebView2 installed in the system will be used. - WebviewBrowserPath string -} - type BackdropType int32 const (