5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-07 05:42:31 +08:00

Add some more API docs. Small refactors.

This commit is contained in:
Lea Anthony 2023-09-24 17:23:24 +10:00
parent 31c167b412
commit fb820bcdad
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
7 changed files with 95 additions and 49 deletions

View File

@ -312,3 +312,19 @@ This is a brief summary of the exported methods in the provided `App` struct. Do
../v3/pkg/application/options_application.go ../v3/pkg/application/options_application.go
--8<-- --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<--
```

View File

@ -19,6 +19,12 @@ func main() {
Mac: application.MacOptions{ Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true, ApplicationShouldTerminateAfterLastWindowClosed: true,
}, },
Windows: application.WindowsOptions{
WndProcInterceptor: nil,
DisableQuitOnLastWindowClosed: false,
WebviewUserDataPath: "",
WebviewBrowserPath: "",
},
Assets: application.AssetOptions{ Assets: application.AssetOptions{
FS: assets, FS: assets,
}, },

View File

@ -20,7 +20,7 @@ type Options struct {
Mac MacOptions Mac MacOptions
// Windows is the Windows specific configuration for Windows builds // Windows is the Windows specific configuration for Windows builds
Windows WindowsApplicationOptions Windows WindowsOptions
// Bind allows you to bind Go methods to the frontend. // Bind allows you to bind Go methods to the frontend.
Bind []any Bind []any

View File

@ -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
}

View File

@ -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
}

View File

@ -2,32 +2,19 @@ package application
import "github.com/wailsapp/wails/v3/pkg/events" import "github.com/wailsapp/wails/v3/pkg/events"
type ActivationPolicy int // MacBackdrop is the backdrop type for macOS
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
}
type MacBackdrop int type MacBackdrop int
const ( const (
// MacBackdropNormal - The default value. The window will have a normal opaque background.
MacBackdropNormal MacBackdrop = iota MacBackdropNormal MacBackdrop = iota
// MacBackdropTransparent - The window will have a transparent background, with the content underneath it being visible
MacBackdropTransparent MacBackdropTransparent
// MacBackdropTranslucent - The window will have a translucent background, with the content underneath it being "fuzzy" or "frosted"
MacBackdropTranslucent MacBackdropTranslucent
) )
// MacToolbarStyle is the style of toolbar for macOS
type MacToolbarStyle int type MacToolbarStyle int
const ( const (
@ -43,14 +30,19 @@ const (
MacToolbarStyleUnifiedCompact MacToolbarStyleUnifiedCompact
) )
// MacWindow contains macOS specific options // MacWindow contains macOS specific options for Webview Windows
type MacWindow struct { type MacWindow struct {
Backdrop MacBackdrop // Backdrop is the backdrop type for the window
DisableShadow bool Backdrop MacBackdrop
TitleBar MacTitleBar // DisableShadow will disable the window shadow
Appearance MacAppearanceType 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 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 EventMapping map[events.WindowEventType]events.WindowEventType
// EnableFraudulentWebsiteWarnings will enable warnings for fraudulent websites. // EnableFraudulentWebsiteWarnings will enable warnings for fraudulent websites.
@ -60,13 +52,20 @@ type MacWindow struct {
// MacTitleBar contains options for the Mac titlebar // MacTitleBar contains options for the Mac titlebar
type MacTitleBar struct { type MacTitleBar struct {
AppearsTransparent bool // AppearsTransparent will make the titlebar transparent
Hide bool AppearsTransparent bool
HideTitle bool // Hide will hide the titlebar
FullSizeContent bool Hide bool
UseToolbar 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 HideToolbarSeparator bool
ToolbarStyle MacToolbarStyle // ToolbarStyle is the style of toolbar to use
ToolbarStyle MacToolbarStyle
} }
// MacTitleBarDefault results in the default Mac MacTitleBar // MacTitleBarDefault results in the default Mac MacTitleBar

View File

@ -2,24 +2,6 @@ package application
import "github.com/wailsapp/wails/v3/pkg/events" 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 type BackdropType int32
const ( const (