diff --git a/v2/cmd/wails/internal/commands/generate/template/base/main.tmpl.go b/v2/cmd/wails/internal/commands/generate/template/base/main.tmpl.go index c7740ebd0..9c15b8740 100644 --- a/v2/cmd/wails/internal/commands/generate/template/base/main.tmpl.go +++ b/v2/cmd/wails/internal/commands/generate/template/base/main.tmpl.go @@ -35,7 +35,7 @@ func main() { Frameless: false, StartHidden: false, HideWindowOnClose: false, - RGBA: &options.RGBA{R: 255, G: 255, B: 255, A: 255}, + BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 255}, Assets: assets, Menu: nil, Logger: nil, diff --git a/v2/cmd/wails/internal/commands/initialise/templates/generate/plain/main.tmpl.go b/v2/cmd/wails/internal/commands/initialise/templates/generate/plain/main.tmpl.go index 5a79b1fe7..c84f4b9cb 100644 --- a/v2/cmd/wails/internal/commands/initialise/templates/generate/plain/main.tmpl.go +++ b/v2/cmd/wails/internal/commands/initialise/templates/generate/plain/main.tmpl.go @@ -36,7 +36,7 @@ func main() { Frameless: false, StartHidden: false, HideWindowOnClose: false, - RGBA: &options.RGBA{R: 255, G: 255, B: 255, A: 255}, + BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 255}, Assets: assets, Menu: nil, Logger: nil, diff --git a/v2/cmd/wails/internal/commands/initialise/templates/templates/plain/main.tmpl.go b/v2/cmd/wails/internal/commands/initialise/templates/templates/plain/main.tmpl.go index 5a79b1fe7..c84f4b9cb 100644 --- a/v2/cmd/wails/internal/commands/initialise/templates/templates/plain/main.tmpl.go +++ b/v2/cmd/wails/internal/commands/initialise/templates/templates/plain/main.tmpl.go @@ -36,7 +36,7 @@ func main() { Frameless: false, StartHidden: false, HideWindowOnClose: false, - RGBA: &options.RGBA{R: 255, G: 255, B: 255, A: 255}, + BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 255}, Assets: assets, Menu: nil, Logger: nil, diff --git a/v2/internal/frontend/desktop/darwin/window.go b/v2/internal/frontend/desktop/darwin/window.go index ec6e20d46..ad1a66f2a 100644 --- a/v2/internal/frontend/desktop/darwin/window.go +++ b/v2/internal/frontend/desktop/darwin/window.go @@ -92,8 +92,8 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window { context: unsafe.Pointer(context), } - if frontendOptions.RGBA != nil { - result.SetRGBA(frontendOptions.RGBA.R, frontendOptions.RGBA.G, frontendOptions.RGBA.B, frontendOptions.RGBA.A) + if frontendOptions.BackgroundColour != nil { + result.SetRGBA(frontendOptions.BackgroundColour.R, frontendOptions.BackgroundColour.G, frontendOptions.BackgroundColour.B, frontendOptions.BackgroundColour.A) } if frontendOptions.Mac != nil && frontendOptions.Mac.About != nil { diff --git a/v2/internal/frontend/desktop/linux/window.go b/v2/internal/frontend/desktop/linux/window.go index 47dc8233f..f115e7bc1 100644 --- a/v2/internal/frontend/desktop/linux/window.go +++ b/v2/internal/frontend/desktop/linux/window.go @@ -636,7 +636,7 @@ func NewWindow(appoptions *options.App, debug bool) *Window { } // Set background colour - RGBA := appoptions.RGBA + RGBA := appoptions.BackgroundColour result.SetRGBA(RGBA.R, RGBA.G, RGBA.B, RGBA.A) // Setup window diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go index 0d8bdf376..f8ebe5d74 100644 --- a/v2/internal/frontend/desktop/windows/frontend.go +++ b/v2/internal/frontend/desktop/windows/frontend.go @@ -406,7 +406,7 @@ func (f *Frontend) setupChromium() { onFocus.Bind(f.onFocus) // Set background colour - f.WindowSetRGBA(f.frontendOptions.RGBA) + f.WindowSetRGBA(f.frontendOptions.BackgroundColour) chromium.SetGlobalPermission(edge.CoreWebView2PermissionStateAllow) chromium.AddWebResourceRequestedFilter("*", edge.COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL) diff --git a/v2/internal/frontend/desktop/windows/window.go b/v2/internal/frontend/desktop/windows/window.go index 3464e4da9..386863a65 100644 --- a/v2/internal/frontend/desktop/windows/window.go +++ b/v2/internal/frontend/desktop/windows/window.go @@ -67,8 +67,8 @@ func NewWindow(parent winc.Controller, appoptions *options.App, versionInfo *ope } } - if appoptions.RGBA != nil { - win32.SetBackgroundColour(result.Handle(), appoptions.RGBA.R, appoptions.RGBA.G, appoptions.RGBA.B) + if appoptions.BackgroundColour != nil { + win32.SetBackgroundColour(result.Handle(), appoptions.BackgroundColour.R, appoptions.BackgroundColour.G, appoptions.BackgroundColour.B) } result.SetSize(appoptions.Width, appoptions.Height) diff --git a/v2/internal/menumanager/processedMenu.go b/v2/internal/menumanager/processedMenu.go index 2722f86cd..8d886e19e 100644 --- a/v2/internal/menumanager/processedMenu.go +++ b/v2/internal/menumanager/processedMenu.go @@ -70,7 +70,7 @@ func NewProcessedMenuItem(menuItemMap *MenuItemMap, menuItem *menu.MenuItem) *Pr Hidden: menuItem.Hidden, Checked: menuItem.Checked, SubMenu: nil, - //RGBA: menuItem.RGBA, + //BackgroundColour: menuItem.BackgroundColour, //FontSize: menuItem.FontSize, //FontName: menuItem.FontName, //Image: menuItem.Image, diff --git a/v2/pkg/options/options.go b/v2/pkg/options/options.go index 1e0b9dfca..c5e19ba38 100644 --- a/v2/pkg/options/options.go +++ b/v2/pkg/options/options.go @@ -41,18 +41,20 @@ type App struct { StartHidden bool HideWindowOnClose bool AlwaysOnTop bool - RGBA *RGBA - Assets fs.FS - AssetsHandler http.Handler - Menu *menu.Menu - Logger logger.Logger `json:"-"` - LogLevel logger.LogLevel - OnStartup func(ctx context.Context) `json:"-"` - OnDomReady func(ctx context.Context) `json:"-"` - OnShutdown func(ctx context.Context) `json:"-"` - OnBeforeClose func(ctx context.Context) (prevent bool) `json:"-"` - Bind []interface{} - WindowStartState WindowStartState + BackgroundColour *RGBA + // RGBA is deprecated. Please use BackgroundColour + RGBA *RGBA + Assets fs.FS + AssetsHandler http.Handler + Menu *menu.Menu + Logger logger.Logger `json:"-"` + LogLevel logger.LogLevel + OnStartup func(ctx context.Context) `json:"-"` + OnDomReady func(ctx context.Context) `json:"-"` + OnShutdown func(ctx context.Context) `json:"-"` + OnBeforeClose func(ctx context.Context) (prevent bool) `json:"-"` + Bind []interface{} + WindowStartState WindowStartState //ContextMenus []*menu.ContextMenu //TrayMenus []*menu.TrayMenu @@ -75,9 +77,9 @@ func MergeDefaults(appoptions *App) { log.Fatal(err) } - // DEfault colour. Doesn't work well with mergo - if appoptions.RGBA == nil { - appoptions.RGBA = &RGBA{ + // Default colour. Doesn't work well with mergo + if appoptions.BackgroundColour == nil { + appoptions.BackgroundColour = &RGBA{ R: 255, G: 255, B: 255, diff --git a/v2/wails.go b/v2/wails.go index 33d07a561..09d810ce3 100644 --- a/v2/wails.go +++ b/v2/wails.go @@ -10,6 +10,15 @@ import ( // Run creates an application based on the given config and executes it func Run(options *options.App) error { + if options.RGBA != nil { + println("---- WARNING ----") + println("The `RGBA` option has been deprecated. Please use `BackgroundColour`.") + + if options.BackgroundColour == nil { + options.BackgroundColour = options.RGBA + } + } + // Call an Init method manually err := Init() if err != nil { diff --git a/website/docs/reference/options.mdx b/website/docs/reference/options.mdx index 288075222..a15a468d2 100644 --- a/website/docs/reference/options.mdx +++ b/website/docs/reference/options.mdx @@ -27,7 +27,7 @@ func main() { MaxHeight: 1024, StartHidden: false, HideWindowOnClose: false, - RGBA: &options.RGBA{R: 0, G: 0, B: 0, A: 255}, + BackgroundColour: &options.RGBA{R: 0, G: 0, B: 0, A: 255}, AlwaysOnTop: false, Assets: assets, AssetsHandler: assetsHandler, @@ -196,14 +196,14 @@ Type: bool By default, closing the window will close the application. Setting this to `true` means closing the window will hide the window instead. -### RGBA +### BackgroundColour -Name: RGBA +Name: BackgroundColour Type: int (0xRRGGBBAA) Example: 0xFF000088 - Red at 50% transparency -This value is the RGBA value to set the window by default. +This value is the default background colour of the window. Default: 0xFFFFFFFF. ### AlwaysOnTop @@ -392,7 +392,7 @@ Name: WebviewIsTransparent Type: bool Setting this to `true` will make the webview background transparent when an alpha value of `0` is used. -This means that if you use `rgba(0,0,0,0)`, the host window will show through. +This means that if you use `rgba(0,0,0,0)` for `background-color` in your CSS, the host window will show through. Often combined with [WindowIsTranslucent](#WindowIsTranslucent) to make frosty-looking applications. ### WindowIsTranslucent @@ -545,7 +545,7 @@ Name: WebviewIsTransparent Type: bool Setting this to `true` will make the webview background transparent when an alpha value of `0` is used. -This means that if you use `rgba(0,0,0,0)`, the host window will show through. +This means that if you use `rgba(0,0,0,0)` for `background-color` in your CSS, the host window will show through. Often combined with [WindowIsTranslucent](#WindowIsTranslucent) to make frosty-looking applications. ### WindowIsTranslucent