github.com/secoba/wails/v2@v2.6.4/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  	// Disable all window decorations in Frameless mode, which means no "Aero Shadow" and no "Rounded Corner" will be shown.
    72  	// "Rounded Corners" are only available on Windows 11.
    73  	DisableFramelessWindowDecorations bool
    74  
    75  	// Path where the WebView2 stores the user data. If empty %APPDATA%\[BinaryName.exe] will be used.
    76  	// If the path is not valid, a messagebox will be displayed with the error and the app will exit with error code.
    77  	WebviewUserDataPath string
    78  
    79  	// Path to the directory with WebView2 executables. If empty WebView2 installed in the system will be used.
    80  	WebviewBrowserPath string
    81  
    82  	// Dark/Light or System Default Theme
    83  	Theme Theme
    84  
    85  	// Custom settings for dark/light mode
    86  	CustomTheme *ThemeSettings
    87  
    88  	// Select the type of translucent backdrop. Requires Windows 11 22621 or later.
    89  	BackdropType BackdropType
    90  
    91  	// User messages that can be customised
    92  	Messages *Messages
    93  
    94  	// ResizeDebounceMS is the amount of time to debounce redraws of webview2
    95  	// when resizing the window
    96  	ResizeDebounceMS uint16
    97  
    98  	// OnSuspend is called when Windows enters low power mode
    99  	OnSuspend func()
   100  
   101  	// OnResume is called when Windows resumes from low power mode
   102  	OnResume func()
   103  
   104  	// WebviewGpuIsDisabled is used to enable / disable GPU acceleration for the webview
   105  	WebviewGpuIsDisabled bool
   106  
   107  	// WebviewDisableRendererCodeIntegrity disables the `RendererCodeIntegrity` of WebView2. Some Security Endpoint
   108  	// Protection Software inject themself into the WebView2 with unsigned or wrongly signed dlls, which is not allowed
   109  	// and will stop the WebView2 processes. Those security software need an update to fix this issue or one can disable
   110  	// the integrity check with this flag.
   111  	//
   112  	// The event viewer log contains `Code Integrity Errors` like mentioned here: https://github.com/MicrosoftEdge/WebView2Feedback/issues/2051
   113  	//
   114  	// !! Please keep in mind when disabling this feature, this also allows malicious software to inject into the WebView2 !!
   115  	WebviewDisableRendererCodeIntegrity bool
   116  
   117  	// Configure whether swipe gestures should be enabled
   118  	EnableSwipeGestures bool
   119  }
   120  
   121  func DefaultMessages() *Messages {
   122  	return &Messages{
   123  		InstallationRequired: "The WebView2 runtime is required. Press Ok to download and install. Note: The installer will download silently so please wait.",
   124  		UpdateRequired:       "The WebView2 runtime needs updating. Press Ok to download and install. Note: The installer will download silently so please wait.",
   125  		MissingRequirements:  "Missing Requirements",
   126  		Webview2NotInstalled: "WebView2 runtime not installed",
   127  		Error:                "Error",
   128  		FailedToInstall:      "The runtime failed to install correctly. Please try again.",
   129  		DownloadPage:         "This application requires the WebView2 runtime. Press OK to open the download page. Minimum version required: ",
   130  		PressOKToInstall:     "Press Ok to install.",
   131  		ContactAdmin:         "The WebView2 runtime is required to run this application. Please contact your system administrator.",
   132  		InvalidFixedWebview2: "The WebView2 runtime is manually specified, but It is not valid. Check minimum required version and webview2 path.",
   133  		WebView2ProcessCrash: "The WebView2 process crashed and the application needs to be restarted.",
   134  	}
   135  }