Integrated FFplay functionality across the application. This includes support for setting up the FFplay path and invoking FFplay for media playback.
90 lines
2.2 KiB
Go
90 lines
2.2 KiB
Go
package kernel
|
|
|
|
import (
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/dialog"
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/helper"
|
|
"time"
|
|
)
|
|
|
|
type WindowContract interface {
|
|
SetContent(content fyne.CanvasObject)
|
|
SetMainMenu(menu *fyne.MainMenu)
|
|
NewFileOpen(callback func(fyne.URIReadCloser, error), location fyne.ListableURI) *dialog.FileDialog
|
|
NewFolderOpen(callback func(fyne.ListableURI, error), location fyne.ListableURI) *dialog.FileDialog
|
|
SetOnDropped(callback func(position fyne.Position, uris []fyne.URI))
|
|
ShowAndRun()
|
|
GetLayout() LayoutContract
|
|
}
|
|
|
|
type Window struct {
|
|
windowFyne fyne.Window
|
|
layout LayoutContract
|
|
}
|
|
|
|
func newWindow(w fyne.Window, layout LayoutContract) Window {
|
|
windowSize := fyne.Size{Width: 1039, Height: 599}
|
|
w.Resize(windowSize)
|
|
w.CenterOnScreen()
|
|
|
|
fyne.Do(func() {
|
|
/**
|
|
* Bug fixed.
|
|
* When starting the program, sometimes the window was displayed incorrectly.
|
|
*/
|
|
windowSize.Width += 1
|
|
windowSize.Height += 1
|
|
time.Sleep(time.Millisecond * 500)
|
|
w.Resize(windowSize)
|
|
})
|
|
|
|
return Window{
|
|
windowFyne: w,
|
|
layout: layout,
|
|
}
|
|
}
|
|
|
|
func (w Window) SetContent(content fyne.CanvasObject) {
|
|
fyne.Do(func() {
|
|
w.windowFyne.SetContent(w.layout.SetContent(content))
|
|
})
|
|
}
|
|
|
|
func (w Window) NewFileOpen(callback func(fyne.URIReadCloser, error), location fyne.ListableURI) *dialog.FileDialog {
|
|
fileDialog := dialog.NewFileOpen(callback, w.windowFyne)
|
|
helper.FileDialogResize(fileDialog, w.windowFyne)
|
|
fileDialog.Show()
|
|
if location != nil {
|
|
fileDialog.SetLocation(location)
|
|
}
|
|
return fileDialog
|
|
}
|
|
|
|
func (w Window) NewFolderOpen(callback func(fyne.ListableURI, error), location fyne.ListableURI) *dialog.FileDialog {
|
|
fileDialog := dialog.NewFolderOpen(callback, w.windowFyne)
|
|
helper.FileDialogResize(fileDialog, w.windowFyne)
|
|
fileDialog.Show()
|
|
if location != nil {
|
|
fileDialog.SetLocation(location)
|
|
}
|
|
return fileDialog
|
|
}
|
|
|
|
func (w Window) SetMainMenu(menu *fyne.MainMenu) {
|
|
w.windowFyne.SetMainMenu(menu)
|
|
}
|
|
|
|
func (w Window) ShowAndRun() {
|
|
w.windowFyne.ShowAndRun()
|
|
}
|
|
|
|
func (w Window) GetLayout() LayoutContract {
|
|
return w.layout
|
|
}
|
|
|
|
func (w Window) SetOnDropped(callback func(position fyne.Position, uris []fyne.URI)) {
|
|
fyne.Do(func() {
|
|
w.windowFyne.SetOnDropped(callback)
|
|
})
|
|
}
|