github.com/AlpineAIO/wails/v2@v2.0.0-beta.32.0.20240505041856-1047a8fa5fef/pkg/options/windows/windows.go (about)

     1  package windows
     2  
     3  type Theme int
     4  
     5  type Messages struct {
     6  	InstallationRequired string
     7  	UpdateRequired       string
     8  	MissingRequirements  string
     9  	Webview2NotInstalled string
    10  	Error                string
    11  	FailedToInstall      string
    12  	DownloadPage         string
    13  	PressOKToInstall     string
    14  	ContactAdmin         string
    15  	InvalidFixedWebview2 string
    16  	WebView2ProcessCrash string
    17  }
    18  
    19  const (
    20  	// SystemDefault will use whatever the system theme is. The application will follow system theme changes.
    21  	SystemDefault Theme = 0
    22  	// Dark Mode
    23  	Dark Theme = 1
    24  	// Light Mode
    25  	Light Theme = 2
    26  )
    27  
    28  type BackdropType int32
    29  
    30  const (
    31  	Auto    BackdropType = 0
    32  	None    BackdropType = 1
    33  	Mica    BackdropType = 2
    34  	Acrylic BackdropType = 3
    35  	Tabbed  BackdropType = 4
    36  )
    37  
    38  func RGB(r, g, b uint8) int32 {
    39  	col := int32(b)
    40  	col = col<<8 | int32(g)
    41  	col = col<<8 | int32(r)
    42  	return col
    43  }
    44  
    45  // ThemeSettings contains optional colours to use.
    46  // They may be set using the hex values: 0x00BBGGRR
    47  type ThemeSettings struct {
    48  	DarkModeTitleBar           int32
    49  	DarkModeTitleBarInactive   int32
    50  	DarkModeTitleText          int32
    51  	DarkModeTitleTextInactive  int32
    52  	DarkModeBorder             int32
    53  	DarkModeBorderInactive     int32
    54  	LightModeTitleBar          int32
    55  	LightModeTitleBarInactive  int32
    56  	LightModeTitleText         int32
    57  	LightModeTitleTextInactive int32
    58  	LightModeBorder            int32
    59  	LightModeBorderInactive    int32
    60  }
    61  
    62  // Options are options specific to Windows
    63  type Options struct {
    64  	WebviewIsTransparent bool
    65  	WindowIsTranslucent  bool
    66  	DisableWindowIcon    bool
    67  
    68  	IsZoomControlEnabled bool
    69  	ZoomFactor           float64
    70  
    71  	DisablePinchZoom bool
    72  
    73  	// Disable all window decorations in Frameless mode, which means no "Aero Shadow" and no "Rounded Corner" will be shown.
    74  	// "Rounded Corners" are only available on Windows 11.
    75  	DisableFramelessWindowDecorations bool
    76  
    77  	// Path where the WebView2 stores the user data. If empty %APPDATA%\[BinaryName.exe] will be used.
    78  	// If the path is not valid, a messagebox will be displayed with the error and the app will exit with error code.
    79  	WebviewUserDataPath string
    80  
    81  	// Path to the directory with WebView2 executables. If empty WebView2 installed in the system will be used.
    82  	WebviewBrowserPath string
    83  
    84  	// Dark/Light or System Default Theme
    85  	Theme Theme
    86  
    87  	// Custom settings for dark/light mode
    88  	CustomTheme *ThemeSettings
    89  
    90  	// Select the type of translucent backdrop. Requires Windows 11 22621 or later.
    91  	BackdropType BackdropType
    92  
    93  	// User messages that can be customised
    94  	Messages *Messages
    95  
    96  	// ResizeDebounceMS is the amount of time to debounce redraws of webview2
    97  	// when resizing the window
    98  	ResizeDebounceMS uint16
    99  
   100  	// OnSuspend is called when Windows enters low power mode
   101  	OnSuspend func()
   102  
   103  	// OnResume is called when Windows resumes from low power mode
   104  	OnResume func()
   105  
   106  	// WebviewGpuIsDisabled is used to enable / disable GPU acceleration for the webview
   107  	WebviewGpuIsDisabled bool
   108  
   109  	// WebviewDisableRendererCodeIntegrity disables the `RendererCodeIntegrity` of WebView2. Some Security Endpoint
   110  	// Protection Software inject themself into the WebView2 with unsigned or wrongly signed dlls, which is not allowed
   111  	// and will stop the WebView2 processes. Those security software need an update to fix this issue or one can disable
   112  	// the integrity check with this flag.
   113  	//
   114  	// The event viewer log contains `Code Integrity Errors` like mentioned here: https://github.com/MicrosoftEdge/WebView2Feedback/issues/2051
   115  	//
   116  	// !! Please keep in mind when disabling this feature, this also allows malicious software to inject into the WebView2 !!
   117  	WebviewDisableRendererCodeIntegrity bool
   118  
   119  	// Configure whether swipe gestures should be enabled
   120  	EnableSwipeGestures bool
   121  }
   122  
   123  func DefaultMessages() *Messages {
   124  	return &Messages{
   125  		InstallationRequired: "The WebView2 runtime is required. Press Ok to download and install. Note: The installer will download silently so please wait.",
   126  		UpdateRequired:       "The WebView2 runtime needs updating. Press Ok to download and install. Note: The installer will download silently so please wait.",
   127  		MissingRequirements:  "Missing Requirements",
   128  		Webview2NotInstalled: "WebView2 runtime not installed",
   129  		Error:                "Error",
   130  		FailedToInstall:      "The runtime failed to install correctly. Please try again.",
   131  		DownloadPage:         "This application requires the WebView2 runtime. Press OK to open the download page. Minimum version required: ",
   132  		PressOKToInstall:     "Press Ok to install.",
   133  		ContactAdmin:         "The WebView2 runtime is required to run this application. Please contact your system administrator.",
   134  		InvalidFixedWebview2: "The WebView2 runtime is manually specified, but It is not valid. Check minimum required version and webview2 path.",
   135  		WebView2ProcessCrash: "The WebView2 process crashed and the application needs to be restarted.",
   136  	}
   137  }