mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 19:50:15 +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,
|
Frameless: false,
|
||||||
StartHidden: false,
|
StartHidden: false,
|
||||||
HideWindowOnClose: 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,
|
Assets: assets,
|
||||||
Menu: nil,
|
Menu: nil,
|
||||||
Logger: nil,
|
Logger: nil,
|
||||||
|
@ -36,7 +36,7 @@ func main() {
|
|||||||
Frameless: false,
|
Frameless: false,
|
||||||
StartHidden: false,
|
StartHidden: false,
|
||||||
HideWindowOnClose: 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,
|
Assets: assets,
|
||||||
Menu: nil,
|
Menu: nil,
|
||||||
Logger: nil,
|
Logger: nil,
|
||||||
|
@ -36,7 +36,7 @@ func main() {
|
|||||||
Frameless: false,
|
Frameless: false,
|
||||||
StartHidden: false,
|
StartHidden: false,
|
||||||
HideWindowOnClose: 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,
|
Assets: assets,
|
||||||
Menu: nil,
|
Menu: nil,
|
||||||
Logger: nil,
|
Logger: nil,
|
||||||
|
@ -92,8 +92,8 @@ func NewWindow(frontendOptions *options.App, debugMode bool) *Window {
|
|||||||
context: unsafe.Pointer(context),
|
context: unsafe.Pointer(context),
|
||||||
}
|
}
|
||||||
|
|
||||||
if frontendOptions.RGBA != nil {
|
if frontendOptions.BackgroundColour != nil {
|
||||||
result.SetRGBA(frontendOptions.RGBA.R, frontendOptions.RGBA.G, frontendOptions.RGBA.B, frontendOptions.RGBA.A)
|
result.SetRGBA(frontendOptions.BackgroundColour.R, frontendOptions.BackgroundColour.G, frontendOptions.BackgroundColour.B, frontendOptions.BackgroundColour.A)
|
||||||
}
|
}
|
||||||
|
|
||||||
if frontendOptions.Mac != nil && frontendOptions.Mac.About != nil {
|
if frontendOptions.Mac != nil && frontendOptions.Mac.About != nil {
|
||||||
|
@ -636,7 +636,7 @@ func NewWindow(appoptions *options.App, debug bool) *Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set background colour
|
// Set background colour
|
||||||
RGBA := appoptions.RGBA
|
RGBA := appoptions.BackgroundColour
|
||||||
result.SetRGBA(RGBA.R, RGBA.G, RGBA.B, RGBA.A)
|
result.SetRGBA(RGBA.R, RGBA.G, RGBA.B, RGBA.A)
|
||||||
|
|
||||||
// Setup window
|
// Setup window
|
||||||
|
@ -406,7 +406,7 @@ func (f *Frontend) setupChromium() {
|
|||||||
onFocus.Bind(f.onFocus)
|
onFocus.Bind(f.onFocus)
|
||||||
|
|
||||||
// Set background colour
|
// Set background colour
|
||||||
f.WindowSetRGBA(f.frontendOptions.RGBA)
|
f.WindowSetRGBA(f.frontendOptions.BackgroundColour)
|
||||||
|
|
||||||
chromium.SetGlobalPermission(edge.CoreWebView2PermissionStateAllow)
|
chromium.SetGlobalPermission(edge.CoreWebView2PermissionStateAllow)
|
||||||
chromium.AddWebResourceRequestedFilter("*", edge.COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL)
|
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 {
|
if appoptions.BackgroundColour != nil {
|
||||||
win32.SetBackgroundColour(result.Handle(), appoptions.RGBA.R, appoptions.RGBA.G, appoptions.RGBA.B)
|
win32.SetBackgroundColour(result.Handle(), appoptions.BackgroundColour.R, appoptions.BackgroundColour.G, appoptions.BackgroundColour.B)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.SetSize(appoptions.Width, appoptions.Height)
|
result.SetSize(appoptions.Width, appoptions.Height)
|
||||||
|
@ -70,7 +70,7 @@ func NewProcessedMenuItem(menuItemMap *MenuItemMap, menuItem *menu.MenuItem) *Pr
|
|||||||
Hidden: menuItem.Hidden,
|
Hidden: menuItem.Hidden,
|
||||||
Checked: menuItem.Checked,
|
Checked: menuItem.Checked,
|
||||||
SubMenu: nil,
|
SubMenu: nil,
|
||||||
//RGBA: menuItem.RGBA,
|
//BackgroundColour: menuItem.BackgroundColour,
|
||||||
//FontSize: menuItem.FontSize,
|
//FontSize: menuItem.FontSize,
|
||||||
//FontName: menuItem.FontName,
|
//FontName: menuItem.FontName,
|
||||||
//Image: menuItem.Image,
|
//Image: menuItem.Image,
|
||||||
|
@ -41,18 +41,20 @@ type App struct {
|
|||||||
StartHidden bool
|
StartHidden bool
|
||||||
HideWindowOnClose bool
|
HideWindowOnClose bool
|
||||||
AlwaysOnTop bool
|
AlwaysOnTop bool
|
||||||
RGBA *RGBA
|
BackgroundColour *RGBA
|
||||||
Assets fs.FS
|
// RGBA is deprecated. Please use BackgroundColour
|
||||||
AssetsHandler http.Handler
|
RGBA *RGBA
|
||||||
Menu *menu.Menu
|
Assets fs.FS
|
||||||
Logger logger.Logger `json:"-"`
|
AssetsHandler http.Handler
|
||||||
LogLevel logger.LogLevel
|
Menu *menu.Menu
|
||||||
OnStartup func(ctx context.Context) `json:"-"`
|
Logger logger.Logger `json:"-"`
|
||||||
OnDomReady func(ctx context.Context) `json:"-"`
|
LogLevel logger.LogLevel
|
||||||
OnShutdown func(ctx context.Context) `json:"-"`
|
OnStartup func(ctx context.Context) `json:"-"`
|
||||||
OnBeforeClose func(ctx context.Context) (prevent bool) `json:"-"`
|
OnDomReady func(ctx context.Context) `json:"-"`
|
||||||
Bind []interface{}
|
OnShutdown func(ctx context.Context) `json:"-"`
|
||||||
WindowStartState WindowStartState
|
OnBeforeClose func(ctx context.Context) (prevent bool) `json:"-"`
|
||||||
|
Bind []interface{}
|
||||||
|
WindowStartState WindowStartState
|
||||||
|
|
||||||
//ContextMenus []*menu.ContextMenu
|
//ContextMenus []*menu.ContextMenu
|
||||||
//TrayMenus []*menu.TrayMenu
|
//TrayMenus []*menu.TrayMenu
|
||||||
@ -75,9 +77,9 @@ func MergeDefaults(appoptions *App) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEfault colour. Doesn't work well with mergo
|
// Default colour. Doesn't work well with mergo
|
||||||
if appoptions.RGBA == nil {
|
if appoptions.BackgroundColour == nil {
|
||||||
appoptions.RGBA = &RGBA{
|
appoptions.BackgroundColour = &RGBA{
|
||||||
R: 255,
|
R: 255,
|
||||||
G: 255,
|
G: 255,
|
||||||
B: 255,
|
B: 255,
|
||||||
|
@ -10,6 +10,15 @@ import (
|
|||||||
// Run creates an application based on the given config and executes it
|
// Run creates an application based on the given config and executes it
|
||||||
func Run(options *options.App) error {
|
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
|
// Call an Init method manually
|
||||||
err := Init()
|
err := Init()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -27,7 +27,7 @@ func main() {
|
|||||||
MaxHeight: 1024,
|
MaxHeight: 1024,
|
||||||
StartHidden: false,
|
StartHidden: false,
|
||||||
HideWindowOnClose: 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,
|
AlwaysOnTop: false,
|
||||||
Assets: assets,
|
Assets: assets,
|
||||||
AssetsHandler: assetsHandler,
|
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
|
By default, closing the window will close the application. Setting this to `true` means closing the window will
|
||||||
hide the window instead.
|
hide the window instead.
|
||||||
|
|
||||||
### RGBA
|
### BackgroundColour
|
||||||
|
|
||||||
Name: RGBA
|
Name: BackgroundColour
|
||||||
|
|
||||||
Type: int (0xRRGGBBAA)
|
Type: int (0xRRGGBBAA)
|
||||||
Example: 0xFF000088 - Red at 50% transparency
|
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.
|
Default: 0xFFFFFFFF.
|
||||||
|
|
||||||
### AlwaysOnTop
|
### AlwaysOnTop
|
||||||
@ -392,7 +392,7 @@ Name: WebviewIsTransparent
|
|||||||
Type: bool
|
Type: bool
|
||||||
|
|
||||||
Setting this to `true` will make the webview background transparent when an alpha value of `0` is used.
|
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.
|
Often combined with [WindowIsTranslucent](#WindowIsTranslucent) to make frosty-looking applications.
|
||||||
|
|
||||||
### WindowIsTranslucent
|
### WindowIsTranslucent
|
||||||
@ -545,7 +545,7 @@ Name: WebviewIsTransparent
|
|||||||
Type: bool
|
Type: bool
|
||||||
|
|
||||||
Setting this to `true` will make the webview background transparent when an alpha value of `0` is used.
|
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.
|
Often combined with [WindowIsTranslucent](#WindowIsTranslucent) to make frosty-looking applications.
|
||||||
|
|
||||||
### WindowIsTranslucent
|
### WindowIsTranslucent
|
||||||
|
Loading…
Reference in New Issue
Block a user