Files

143 lines
3.6 KiB
Go
Raw Permalink Normal View History

2021-07-22 19:49:54 +10:00
package frontend
import (
"context"
"github.com/wailsapp/wails/v2/pkg/menu"
2021-09-12 16:32:43 +10:00
"github.com/wailsapp/wails/v2/pkg/options"
)
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"`
// 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
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)
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()
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)
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()
WindowSetBackgroundColour(col *options.RGBA)
WindowReload()
WindowReloadApp()
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()
// Events
Notify(name string, data ...interface{})
// 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
}