mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
[windows] support runtime.WindowSetRGBA
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
var Default = &App{
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
RGBA: 0xFFFFFFFF,
|
||||
Logger: logger.NewDefaultLogger(),
|
||||
LogLevel: logger.INFO,
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user