2021-07-22 19:49:54 +10:00
|
|
|
package frontend
|
|
|
|
|
|
2021-08-01 22:14:33 +10:00
|
|
|
import (
|
|
|
|
|
"context"
|
2021-09-13 12:58:27 +08:00
|
|
|
|
2021-08-01 22:14:33 +10:00
|
|
|
"github.com/wailsapp/wails/v2/pkg/menu"
|
2021-09-12 16:32:43 +10:00
|
|
|
"github.com/wailsapp/wails/v2/pkg/options"
|
2021-08-01 22:14:33 +10:00
|
|
|
)
|
2021-07-25 20:21:21 +10:00
|
|
|
|
|
|
|
|
// FileFilter defines a filter for dialog boxes
|
|
|
|
|
type FileFilter struct {
|
|
|
|
|
DisplayName string // Filter information EG: "Image Files (*.jpg, *.png)"
|
2022-09-29 18:43:35 +10:00
|
|
|
Pattern string // semicolon separated list of extensions, EG: "*.jpg;*.png"
|
2021-07-25 20:21:21 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
|
)
|
|
|
|
|
|
2022-07-16 05:33:37 +03:00
|
|
|
type Screen struct {
|
|
|
|
|
IsCurrent bool `json:"isCurrent"`
|
|
|
|
|
IsPrimary bool `json:"isPrimary"`
|
2023-08-26 02:11:01 +02:00
|
|
|
|
|
|
|
|
// Deprecated: Please use Size and PhysicalSize
|
|
|
|
|
Width int `json:"width"`
|
|
|
|
|
// Deprecated: Please use Size and PhysicalSize
|
|
|
|
|
Height int `json:"height"`
|
|
|
|
|
|
|
|
|
|
// Size is the size of the screen in logical pixel space, used when setting sizes in Wails
|
|
|
|
|
Size ScreenSize `json:"size"`
|
|
|
|
|
// PhysicalSize is the physical size of the screen in pixels
|
|
|
|
|
PhysicalSize ScreenSize `json:"physicalSize"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ScreenSize struct {
|
|
|
|
|
Width int `json:"width"`
|
|
|
|
|
Height int `json:"height"`
|
2022-07-16 05:33:37 +03:00
|
|
|
}
|
|
|
|
|
|
2021-07-25 20:21:21 +10:00
|
|
|
// 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
|
2021-10-31 08:50:14 +11:00
|
|
|
Icon []byte
|
2021-07-25 20:21:21 +10:00
|
|
|
}
|
|
|
|
|
|
2021-07-22 19:49:54 +10:00
|
|
|
type Frontend interface {
|
2023-11-12 12:30:49 +11:00
|
|
|
Run(ctx context.Context) error
|
2022-09-29 18:43:35 +10:00
|
|
|
RunMainLoop()
|
2022-10-05 08:44:23 +11:00
|
|
|
ExecJS(js string)
|
2022-07-20 20:59:49 +10:00
|
|
|
Hide()
|
|
|
|
|
Show()
|
2021-07-22 19:49:54 +10:00
|
|
|
Quit()
|
|
|
|
|
|
2021-07-25 20:21:21 +10:00
|
|
|
// 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)
|
2021-07-22 19:49:54 +10:00
|
|
|
|
|
|
|
|
// Window
|
2021-07-24 06:55:47 +10:00
|
|
|
WindowSetTitle(title string)
|
2021-07-22 19:49:54 +10:00
|
|
|
WindowShow()
|
|
|
|
|
WindowHide()
|
2021-07-24 06:55:47 +10:00
|
|
|
WindowCenter()
|
2022-02-18 20:28:16 +11:00
|
|
|
WindowToggleMaximise()
|
2021-07-24 06:55:47 +10:00
|
|
|
WindowMaximise()
|
|
|
|
|
WindowUnmaximise()
|
|
|
|
|
WindowMinimise()
|
|
|
|
|
WindowUnminimise()
|
2022-06-22 18:55:02 +08:00
|
|
|
WindowSetAlwaysOnTop(b bool)
|
2022-02-03 21:42:14 +11:00
|
|
|
WindowSetPosition(x int, y int)
|
|
|
|
|
WindowGetPosition() (int, int)
|
2021-07-24 06:55:47 +10:00
|
|
|
WindowSetSize(width int, height int)
|
2021-07-24 10:34:43 +10:00
|
|
|
WindowGetSize() (int, int)
|
|
|
|
|
WindowSetMinSize(width int, height int)
|
|
|
|
|
WindowSetMaxSize(width int, height int)
|
2021-07-22 19:49:54 +10:00
|
|
|
WindowFullscreen()
|
2022-02-19 20:29:55 +11:00
|
|
|
WindowUnfullscreen()
|
2022-06-29 22:31:49 +10:00
|
|
|
WindowSetBackgroundColour(col *options.RGBA)
|
2021-08-24 23:48:03 +10:00
|
|
|
WindowReload()
|
2022-04-20 20:28:41 +10:00
|
|
|
WindowReloadApp()
|
2022-03-31 11:04:14 +02:00
|
|
|
WindowSetSystemDefaultTheme()
|
|
|
|
|
WindowSetLightTheme()
|
|
|
|
|
WindowSetDarkTheme()
|
2022-08-29 13:52:01 -07:00
|
|
|
WindowIsMaximised() bool
|
|
|
|
|
WindowIsMinimised() bool
|
|
|
|
|
WindowIsNormal() bool
|
|
|
|
|
WindowIsFullscreen() bool
|
2022-09-29 18:43:35 +10:00
|
|
|
WindowClose()
|
2023-09-05 22:55:36 +01:00
|
|
|
WindowPrint()
|
2021-07-25 20:21:21 +10:00
|
|
|
|
2023-11-12 12:30:49 +11:00
|
|
|
// Screen
|
2022-07-16 05:33:37 +03:00
|
|
|
ScreenGetAll() ([]Screen, error)
|
|
|
|
|
|
2021-07-25 20:21:21 +10:00
|
|
|
// Menus
|
2021-09-12 20:45:40 +10:00
|
|
|
MenuSetApplicationMenu(menu *menu.Menu)
|
|
|
|
|
MenuUpdateApplicationMenu()
|
2021-08-10 06:35:12 +10:00
|
|
|
|
|
|
|
|
// Events
|
|
|
|
|
Notify(name string, data ...interface{})
|
2021-09-13 12:58:27 +08:00
|
|
|
|
|
|
|
|
// Browser
|
|
|
|
|
BrowserOpenURL(url string)
|
2023-01-05 06:41:07 +01:00
|
|
|
|
|
|
|
|
// Clipboard
|
|
|
|
|
ClipboardGetText() (string, error)
|
|
|
|
|
ClipboardSetText(text string) error
|
2021-07-22 19:49:54 +10:00
|
|
|
}
|