mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 08:41:41 +08:00
Add BackgroundColour
and deprecate RGBA
(#1475)
This commit is contained in:
parent
cb169611b1
commit
c477100374
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user