5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 23:51:44 +08:00

[v2] Refactor app options

This commit is contained in:
Lea Anthony 2021-11-10 08:42:04 +11:00
parent 36570645ff
commit bad9ad3dd7

View File

@ -18,24 +18,24 @@ type Window struct {
dispatchq []func() dispatchq []func()
} }
func NewWindow(parent winc.Controller, options *options.App) *Window { func NewWindow(parent winc.Controller, appoptions *options.App) *Window {
result := new(Window) result := new(Window)
result.frontendOptions = options result.frontendOptions = appoptions
result.SetIsForm(true) result.SetIsForm(true)
var exStyle int var exStyle int
if options.Windows != nil { if appoptions.Windows != nil {
exStyle = w32.WS_EX_CONTROLPARENT | w32.WS_EX_APPWINDOW exStyle = w32.WS_EX_CONTROLPARENT | w32.WS_EX_APPWINDOW
if options.Windows.WindowIsTranslucent { if appoptions.Windows.WindowIsTranslucent {
exStyle |= w32.WS_EX_NOREDIRECTIONBITMAP exStyle |= w32.WS_EX_NOREDIRECTIONBITMAP
} }
} }
if options.AlwaysOnTop { if appoptions.AlwaysOnTop {
exStyle |= w32.WS_EX_TOPMOST exStyle |= w32.WS_EX_TOPMOST
} }
var dwStyle = w32.WS_OVERLAPPEDWINDOW var dwStyle = w32.WS_OVERLAPPEDWINDOW
if options.Frameless { if appoptions.Frameless {
dwStyle = w32.WS_POPUP dwStyle = w32.WS_POPUP
} }
@ -44,7 +44,7 @@ func NewWindow(parent winc.Controller, options *options.App) *Window {
result.SetParent(parent) result.SetParent(parent)
loadIcon := true loadIcon := true
if options.Windows != nil && options.Windows.DisableWindowIcon == true { if appoptions.Windows != nil && appoptions.Windows.DisableWindowIcon == true {
loadIcon = false loadIcon = false
} }
if loadIcon { if loadIcon {
@ -53,21 +53,21 @@ func NewWindow(parent winc.Controller, options *options.App) *Window {
} }
} }
result.SetSize(options.Width, options.Height) result.SetSize(appoptions.Width, appoptions.Height)
result.SetText(options.Title) result.SetText(appoptions.Title)
if options.Frameless == false && !options.Fullscreen { if appoptions.Frameless == false && !appoptions.Fullscreen {
result.EnableMaxButton(!options.DisableResize) result.EnableMaxButton(!appoptions.DisableResize)
result.EnableSizable(!options.DisableResize) result.EnableSizable(!appoptions.DisableResize)
result.SetMinSize(options.MinWidth, options.MinHeight) result.SetMinSize(appoptions.MinWidth, appoptions.MinHeight)
result.SetMaxSize(options.MaxWidth, options.MaxHeight) result.SetMaxSize(appoptions.MaxWidth, appoptions.MaxHeight)
} }
if options.Windows != nil { if appoptions.Windows != nil {
if options.Windows.WindowIsTranslucent { if appoptions.Windows.WindowIsTranslucent {
result.SetTranslucentBackground() result.SetTranslucentBackground()
} }
if options.Windows.DisableWindowIcon { if appoptions.Windows.DisableWindowIcon {
result.DisableIcon() result.DisableIcon()
} }
} }
@ -78,8 +78,8 @@ func NewWindow(parent winc.Controller, options *options.App) *Window {
result.SetFont(winc.DefaultFont) result.SetFont(winc.DefaultFont)
if options.Menu != nil { if appoptions.Menu != nil {
result.SetApplicationMenu(options.Menu) result.SetApplicationMenu(appoptions.Menu)
} }
return result return result