mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
Moved options to own package
This commit is contained in:
@@ -10,7 +10,7 @@ package app
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/appoptions"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
)
|
||||
|
||||
// App defines a Wails application structure
|
||||
@@ -25,7 +25,7 @@ type App struct {
|
||||
}
|
||||
|
||||
// CreateApp returns a null application
|
||||
func CreateApp(options *appoptions.Options) *App {
|
||||
func CreateApp(options *options.App) *App {
|
||||
return &App{}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ package app
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/appoptions"
|
||||
"github.com/wailsapp/wails/v2/internal/binding"
|
||||
"github.com/wailsapp/wails/v2/internal/ffenestri"
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
@@ -13,6 +12,7 @@ import (
|
||||
"github.com/wailsapp/wails/v2/internal/servicebus"
|
||||
"github.com/wailsapp/wails/v2/internal/signal"
|
||||
"github.com/wailsapp/wails/v2/internal/subsystem"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
)
|
||||
|
||||
// App defines a Wails application structure
|
||||
@@ -38,7 +38,7 @@ type App struct {
|
||||
}
|
||||
|
||||
// Create App
|
||||
func CreateApp(options *appoptions.Options) *App {
|
||||
func CreateApp(options *options.App) *App {
|
||||
|
||||
// Merge default options
|
||||
options.MergeDefaults()
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/appoptions"
|
||||
"github.com/wailsapp/wails/v2/internal/logger"
|
||||
"github.com/wailsapp/wails/v2/internal/messagedispatcher"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -58,7 +58,7 @@ var DEBUG bool = true
|
||||
|
||||
// Application is our main application object
|
||||
type Application struct {
|
||||
config *appoptions.Options
|
||||
config *options.App
|
||||
memory []unsafe.Pointer
|
||||
|
||||
// This is the main app pointer
|
||||
@@ -83,7 +83,7 @@ func init() {
|
||||
}
|
||||
|
||||
// NewApplicationWithConfig creates a new application based on the given config
|
||||
func NewApplicationWithConfig(config *appoptions.Options, logger *logger.Logger) *Application {
|
||||
func NewApplicationWithConfig(config *options.App, logger *logger.Logger) *Application {
|
||||
return &Application{
|
||||
config: config,
|
||||
logger: logger.CustomLogger("Ffenestri"),
|
||||
@@ -93,7 +93,7 @@ func NewApplicationWithConfig(config *appoptions.Options, logger *logger.Logger)
|
||||
// NewApplication creates a new Application with the default config
|
||||
func NewApplication(logger *logger.Logger) *Application {
|
||||
return &Application{
|
||||
config: appoptions.Default,
|
||||
config: options.Default,
|
||||
logger: logger.CustomLogger("Ffenestri"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package appoptions
|
||||
package options
|
||||
|
||||
// Default options for creating the App
|
||||
var Default = &Options{
|
||||
var Default = &App{
|
||||
Title: "My Wails App",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
@@ -1,7 +1,7 @@
|
||||
package appoptions
|
||||
package options
|
||||
|
||||
// MacOptions ae options speific to Mas
|
||||
type MacOptions struct {
|
||||
// Mac ae options speific to Mas
|
||||
type Mac struct {
|
||||
TitlebarAppearsTransparent bool
|
||||
HideTitle bool
|
||||
HideTitleBar bool
|
||||
@@ -1,7 +1,7 @@
|
||||
package appoptions
|
||||
package options
|
||||
|
||||
// Options for creating the App
|
||||
type Options struct {
|
||||
// App contains options for creating the App
|
||||
type App struct {
|
||||
Title string
|
||||
Width int
|
||||
Height int
|
||||
@@ -15,24 +15,24 @@ type Options struct {
|
||||
StartHidden bool
|
||||
DevTools bool
|
||||
Colour int
|
||||
Mac MacOptions
|
||||
Mac Mac
|
||||
}
|
||||
|
||||
// MergeDefaults will set the minimum default values for an application
|
||||
func (o *Options) MergeDefaults() {
|
||||
func (a *App) MergeDefaults() {
|
||||
|
||||
// Create a default title
|
||||
if len(o.Title) == 0 {
|
||||
o.Title = "My Wails App"
|
||||
if len(a.Title) == 0 {
|
||||
a.Title = "My Wails App"
|
||||
}
|
||||
|
||||
// Default width
|
||||
if o.Width == 0 {
|
||||
o.Width = 1024
|
||||
if a.Width == 0 {
|
||||
a.Width = 1024
|
||||
}
|
||||
|
||||
// Default height
|
||||
if o.Height == 0 {
|
||||
o.Height = 768
|
||||
if a.Height == 0 {
|
||||
a.Height = 768
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
wails "github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
)
|
||||
|
||||
type Echo struct {
|
||||
@@ -14,14 +15,14 @@ func (e *Echo) Echo(message string) string {
|
||||
func main() {
|
||||
|
||||
// Create application with options
|
||||
app := wails.CreateAppWithOptions(&wails.Options{
|
||||
app := wails.CreateAppWithOptions(&options.App{
|
||||
Title: "Runtime Tester!",
|
||||
Width: 850,
|
||||
Height: 620,
|
||||
DisableResize: false,
|
||||
Fullscreen: false,
|
||||
Colour: 0xFF000088,
|
||||
Mac: wails.MacOptions{
|
||||
Mac: options.Mac{
|
||||
HideTitle: false,
|
||||
HideTitleBar: false,
|
||||
TitlebarAppearsTransparent: true,
|
||||
|
||||
12
v2/wails.go
12
v2/wails.go
@@ -4,28 +4,22 @@ package wails
|
||||
|
||||
import (
|
||||
"github.com/wailsapp/wails/v2/internal/app"
|
||||
"github.com/wailsapp/wails/v2/internal/appoptions"
|
||||
"github.com/wailsapp/wails/v2/internal/runtime/goruntime"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
)
|
||||
|
||||
// Runtime is an alias for the goruntime.Runtime struct
|
||||
type Runtime = goruntime.Runtime
|
||||
|
||||
// Options is an alias for the app.Options struct
|
||||
type Options = appoptions.Options
|
||||
|
||||
// MacOptions are Mac specific options
|
||||
type MacOptions = appoptions.MacOptions
|
||||
|
||||
// CreateAppWithOptions creates an application based on the given config
|
||||
func CreateAppWithOptions(options *Options) *app.App {
|
||||
func CreateAppWithOptions(options *options.App) *app.App {
|
||||
return app.CreateApp(options)
|
||||
}
|
||||
|
||||
// CreateApp creates an application based on the given title, width and height
|
||||
func CreateApp(title string, width int, height int) *app.App {
|
||||
|
||||
options := &Options{
|
||||
options := &options.App{
|
||||
Title: title,
|
||||
Width: width,
|
||||
Height: height,
|
||||
|
||||
Reference in New Issue
Block a user