I decided to rewrite the program taking into account the experience gained.
141 lines
3.1 KiB
Go
141 lines
3.1 KiB
Go
package window
|
|
|
|
import (
|
|
"fyne.io/fyne/v2"
|
|
"fyne.io/fyne/v2/container"
|
|
"fyne.io/fyne/v2/lang"
|
|
"fyne.io/fyne/v2/widget"
|
|
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application"
|
|
)
|
|
|
|
type MainWindowContract interface {
|
|
SetContent(content fyne.CanvasObject)
|
|
Show()
|
|
InitLayout()
|
|
}
|
|
|
|
type mainWindow struct {
|
|
fyneWindow fyne.Window
|
|
layout *fyne.Container
|
|
progressBarService application.ProgressBarContract
|
|
}
|
|
|
|
func NewMainWindow(fyneWindow fyne.Window, progressBarService application.ProgressBarContract) MainWindowContract {
|
|
fyneWindow.Resize(fyne.Size{Width: 1039, Height: 599})
|
|
fyneWindow.CenterOnScreen()
|
|
|
|
return &mainWindow{
|
|
fyneWindow: fyneWindow,
|
|
progressBarService: progressBarService,
|
|
}
|
|
}
|
|
|
|
func (w *mainWindow) InitLayout() {
|
|
fyne.Do(func() {
|
|
rContainer := newRightContainer(w.progressBarService.GetContainer())
|
|
layout := container.NewAdaptiveGrid(2, widget.NewLabel(""), rContainer.GetCanvasObject())
|
|
w.fyneWindow.SetContent(layout)
|
|
|
|
w.layout = layout
|
|
})
|
|
}
|
|
|
|
func (w *mainWindow) SetContent(content fyne.CanvasObject) {
|
|
fyne.Do(func() {
|
|
if w.layout == nil {
|
|
w.fyneWindow.SetContent(content)
|
|
return
|
|
}
|
|
|
|
w.layout.Objects[0] = content
|
|
w.fyneWindow.SetContent(w.layout)
|
|
})
|
|
}
|
|
|
|
func (w *mainWindow) Show() {
|
|
w.fyneWindow.Show()
|
|
}
|
|
|
|
type RightMainContainerContract interface {
|
|
GetCanvasObject() fyne.CanvasObject
|
|
GetTabs() *container.AppTabs
|
|
GetAddedFilesContainer() *fyne.Container
|
|
GetFileQueueContainer() *fyne.Container
|
|
SelectFileQueueTab()
|
|
SelectAddedFilesTab()
|
|
}
|
|
|
|
type rightMainContainer struct {
|
|
container fyne.CanvasObject
|
|
|
|
tabs *container.AppTabs
|
|
|
|
addedFilesContainer *fyne.Container
|
|
addedFilesTab *container.TabItem
|
|
|
|
fileQueueContainer *fyne.Container
|
|
fileQueueTab *container.TabItem
|
|
}
|
|
|
|
func newRightContainer(blockProgressbar *fyne.Container) RightMainContainerContract {
|
|
|
|
addedFilesContainer := container.NewVBox()
|
|
addedFilesTab := container.NewTabItem(lang.L("addedFilesTitle"), addedFilesContainer)
|
|
|
|
fileQueueContainer := container.NewVBox()
|
|
fileQueueTab := container.NewTabItem(lang.L("fileQueueTitle"), fileQueueContainer)
|
|
|
|
tabs := container.NewAppTabs(
|
|
addedFilesTab,
|
|
fileQueueTab,
|
|
)
|
|
|
|
rightContainer := container.NewBorder(
|
|
container.NewVBox(
|
|
blockProgressbar,
|
|
widget.NewSeparator(),
|
|
),
|
|
nil,
|
|
nil,
|
|
nil,
|
|
tabs,
|
|
)
|
|
|
|
return &rightMainContainer{
|
|
container: rightContainer,
|
|
tabs: tabs,
|
|
addedFilesContainer: addedFilesContainer,
|
|
addedFilesTab: addedFilesTab,
|
|
fileQueueContainer: fileQueueContainer,
|
|
fileQueueTab: fileQueueTab,
|
|
}
|
|
}
|
|
|
|
func (r *rightMainContainer) GetCanvasObject() fyne.CanvasObject {
|
|
return r.container
|
|
}
|
|
|
|
func (r *rightMainContainer) GetTabs() *container.AppTabs {
|
|
return r.tabs
|
|
}
|
|
|
|
func (r *rightMainContainer) GetAddedFilesContainer() *fyne.Container {
|
|
return r.addedFilesContainer
|
|
}
|
|
|
|
func (r *rightMainContainer) GetFileQueueContainer() *fyne.Container {
|
|
return r.fileQueueContainer
|
|
}
|
|
|
|
func (r *rightMainContainer) SelectFileQueueTab() {
|
|
fyne.Do(func() {
|
|
r.tabs.Select(r.fileQueueTab)
|
|
})
|
|
}
|
|
|
|
func (r *rightMainContainer) SelectAddedFilesTab() {
|
|
fyne.Do(func() {
|
|
r.tabs.Select(r.addedFilesTab)
|
|
})
|
|
}
|