5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 17:39:58 +08:00
wails/v2/internal/frontend/frontend.go
ZanderCodes 70c484f603
Add Some WindowState (#1349)
* Add Check for WindowState IsMaximised, IsMinimized, IsNormal and IsFullscreen

Solve conflicts

# Conflicts:
#	v2/internal/frontend/desktop/darwin/WailsContext.m
#	v2/internal/frontend/desktop/darwin/frontend.go
#	v2/internal/frontend/desktop/linux/window.go
#	v2/internal/frontend/desktop/windows/window.go

* Add Check for WindowState IsMaximised, IsMinimized, IsNormal and IsFullscreen

Solve conflict
# Conflicts:
#	v2/pkg/runtime/window.go

* Forgot some function to use it

# Conflicts:
#	v2/internal/frontend/desktop/darwin/WailsContext.h
#	v2/internal/frontend/desktop/windows/win32/consts.go
#	v2/internal/frontend/desktop/windows/win32/window.go

* Modify the instructions

# Conflicts:
#	v2/internal/frontend/devserver/devserver.go

* Add Functions to DevServer

# Conflicts:
#	v2/internal/frontend/dispatcher/systemcalls.go
#	v2/internal/frontend/runtime/desktop/window.js
#	v2/internal/frontend/runtime/package-lock.json
#	v2/internal/frontend/runtime/runtime_prod_desktop.js
#	v2/internal/frontend/runtime/wrapper/runtime.d.ts
#	v2/internal/frontend/runtime/wrapper/runtime.js

* Add Callback and JavaScript Functions

# Conflicts:
#	v2/cmd/wails/internal/commands/initialise/templates/generate/assets/common/frontend/wailsjs/runtime/runtime.js
#	v2/internal/frontend/runtime/package-lock.json
#	v2/internal/frontend/runtime/runtime_dev_desktop.js

* Remove Merge lines

* Fix IsMaximised

* Add WindowState Docs

* Update docs

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
2022-08-30 06:52:01 +10:00

122 lines
3.1 KiB
Go

package frontend
import (
"context"
"github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/options"
)
// FileFilter defines a filter for dialog boxes
type FileFilter struct {
DisplayName string // Filter information EG: "Image Files (*.jpg, *.png)"
Pattern string // semi-colon separated list of extensions, EG: "*.jpg;*.png"
}
// OpenDialogOptions contains the options for the OpenDialogOptions runtime method
type OpenDialogOptions struct {
DefaultDirectory string
DefaultFilename string
Title string
Filters []FileFilter
ShowHiddenFiles bool
CanCreateDirectories bool
ResolvesAliases bool
TreatPackagesAsDirectories bool
}
// SaveDialogOptions contains the options for the SaveDialog runtime method
type SaveDialogOptions struct {
DefaultDirectory string
DefaultFilename string
Title string
Filters []FileFilter
ShowHiddenFiles bool
CanCreateDirectories bool
TreatPackagesAsDirectories bool
}
type DialogType string
const (
InfoDialog DialogType = "info"
WarningDialog DialogType = "warning"
ErrorDialog DialogType = "error"
QuestionDialog DialogType = "question"
)
type Screen struct {
IsCurrent bool `json:"isCurrent"`
IsPrimary bool `json:"isPrimary"`
Width int `json:"width"`
Height int `json:"height"`
}
// MessageDialogOptions contains the options for the Message dialogs, EG Info, Warning, etc runtime methods
type MessageDialogOptions struct {
Type DialogType
Title string
Message string
Buttons []string
DefaultButton string
CancelButton string
Icon []byte
}
type Frontend interface {
Run(context.Context) error
Hide()
Show()
Quit()
// Dialog
OpenFileDialog(dialogOptions OpenDialogOptions) (string, error)
OpenMultipleFilesDialog(dialogOptions OpenDialogOptions) ([]string, error)
OpenDirectoryDialog(dialogOptions OpenDialogOptions) (string, error)
SaveFileDialog(dialogOptions SaveDialogOptions) (string, error)
MessageDialog(dialogOptions MessageDialogOptions) (string, error)
// Window
WindowSetTitle(title string)
WindowShow()
WindowHide()
WindowCenter()
WindowToggleMaximise()
WindowMaximise()
WindowUnmaximise()
WindowMinimise()
WindowUnminimise()
WindowSetAlwaysOnTop(b bool)
WindowSetPosition(x int, y int)
WindowGetPosition() (int, int)
WindowSetSize(width int, height int)
WindowGetSize() (int, int)
WindowSetMinSize(width int, height int)
WindowSetMaxSize(width int, height int)
WindowFullscreen()
WindowUnfullscreen()
WindowSetBackgroundColour(col *options.RGBA)
WindowReload()
WindowReloadApp()
WindowSetSystemDefaultTheme()
WindowSetLightTheme()
WindowSetDarkTheme()
WindowIsMaximised() bool
WindowIsMinimised() bool
WindowIsNormal() bool
WindowIsFullscreen() bool
//Screen
ScreenGetAll() ([]Screen, error)
// Menus
MenuSetApplicationMenu(menu *menu.Menu)
MenuUpdateApplicationMenu()
// Events
Notify(name string, data ...interface{})
// Browser
BrowserOpenURL(url string)
}