Support TitleBar Default

Fixed merging defaults
This commit is contained in:
Lea Anthony 2020-09-24 06:39:08 +10:00
commit a5e909337e
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
6 changed files with 31 additions and 19 deletions

View file

@ -4,6 +4,7 @@ go 1.13
require (
github.com/fsnotify/fsnotify v1.4.9
github.com/imdario/mergo v0.3.11
github.com/leaanthony/clir v1.0.4
github.com/leaanthony/gosod v0.0.4
github.com/leaanthony/slicer v1.4.1

View file

@ -29,6 +29,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eTO0Q8=
@ -110,5 +112,7 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k=
nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=

View file

@ -1,5 +1,7 @@
package options
import "github.com/wailsapp/wails/v2/pkg/options/mac"
// Default options for creating the App
var Default = &App{
Title: "My Wails App",
@ -7,4 +9,7 @@ var Default = &App{
Height: 768,
DevTools: true,
Colour: 0xFFFFFFFF,
Mac: &mac.Options{
TitleBar: mac.TitleBarDefault(),
},
}

View file

@ -10,6 +10,18 @@ type TitleBar struct {
HideToolbarSeparator bool
}
// TitleBarDefault results in the default Mac Titlebar
func TitleBarDefault() *TitleBar {
return &TitleBar{
TitlebarAppearsTransparent: false,
HideTitle: false,
HideTitleBar: false,
FullSizeContent: false,
UseToolbar: false,
HideToolbarSeparator: false,
}
}
// Credit: Comments from Electron site
// TitleBarHidden results in a hidden title bar and a full size content window,

View file

@ -1,6 +1,11 @@
package options
import "github.com/wailsapp/wails/v2/pkg/options/mac"
import (
"log"
"github.com/imdario/mergo"
"github.com/wailsapp/wails/v2/pkg/options/mac"
)
// App contains options for creating the App
type App struct {
@ -22,19 +27,8 @@ type App struct {
// MergeDefaults will set the minimum default values for an application
func (a *App) MergeDefaults() {
// Create a default title
if len(a.Title) == 0 {
a.Title = "My Wails App"
}
// Default width
if a.Width == 0 {
a.Width = 1024
}
// Default height
if a.Height == 0 {
a.Height = 768
err := mergo.Merge(a, Default)
if err != nil {
log.Fatal(err)
}
}

View file

@ -3,7 +3,6 @@ package main
import (
wails "github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/mac"
)
type Echo struct {
@ -23,9 +22,6 @@ func main() {
DisableResize: false,
Fullscreen: false,
Colour: 0xFF000088,
Mac: &mac.Options{
TitleBar: mac.TitleBarHiddenInset(),
},
})
// You can also use the simplified call: