[windows] support runtime.WindowSetRGBA

This commit is contained in:
Lea Anthony
2021-09-12 16:32:43 +10:00
parent c9f93cd313
commit 3c0da9fd15
15 changed files with 178 additions and 96 deletions

View File

@@ -8,7 +8,6 @@ import (
var Default = &App{
Width: 1024,
Height: 768,
RGBA: 0xFFFFFFFF,
Logger: logger.NewDefaultLogger(),
LogLevel: logger.INFO,
}

View File

@@ -26,7 +26,7 @@ type App struct {
MaxHeight int
StartHidden bool
HideWindowOnClose bool
RGBA int
RGBA *RGBA
Assets embed.FS
Menu *menu.Menu
Logger logger.Logger `json:"-"`
@@ -42,6 +42,13 @@ type App struct {
//Mac *mac.Options
}
type RGBA struct {
R uint8 `json:"r"`
G uint8 `json:"g"`
B uint8 `json:"b"`
A uint8 `json:"a"`
}
// MergeDefaults will set the minimum default values for an application
func MergeDefaults(appoptions *App) {
err := mergo.Merge(appoptions, Default)
@@ -49,6 +56,16 @@ func MergeDefaults(appoptions *App) {
log.Fatal(err)
}
// DEfault colour. Doesn't work well with mergo
if appoptions.RGBA == nil {
appoptions.RGBA = &RGBA{
R: 255,
G: 255,
B: 255,
A: 255,
}
}
// Ensure max and min are valid
if appoptions.MinWidth > 0 && appoptions.MaxWidth > 0 {
if appoptions.MinWidth > appoptions.MaxWidth {

View File

@@ -2,6 +2,7 @@ package runtime
import (
"context"
"github.com/wailsapp/wails/v2/pkg/options"
)
// WindowSetTitle sets the title of the window
@@ -93,3 +94,8 @@ func WindowUnminimise(ctx context.Context) {
appFrontend := getFrontend(ctx)
appFrontend.WindowUnminimise()
}
func WindowSetRGBA(ctx context.Context, col *options.RGBA) {
appFrontend := getFrontend(ctx)
appFrontend.WindowSetRGBA(col)
}