Compare commits

...

3 Commits

2 changed files with 75 additions and 33 deletions

View File

@ -9,6 +9,7 @@ import (
"strings"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/layout"
@ -49,7 +50,7 @@ func buildAuthorView(state *appState) fyne.CanvasObject {
bottomBar := moduleFooter(authorColor, layout.NewSpacer(), state.statsBar)
tabs := container.NewAppTabs(
container.NewTabItem("Video Clips", buildVideoClipsTab(state)),
container.NewTabItem("Videos", buildVideoClipsTab(state)),
container.NewTabItem("Chapters", buildChaptersTab(state)),
container.NewTabItem("Subtitles", buildSubtitlesTab(state)),
container.NewTabItem("Settings", buildAuthorSettingsTab(state)),
@ -73,6 +74,7 @@ func buildVideoClipsTab(state *appState) fyne.CanvasObject {
if emptyOverlay != nil {
emptyOverlay.Show()
}
list.Refresh()
return
}
@ -81,25 +83,32 @@ func buildVideoClipsTab(state *appState) fyne.CanvasObject {
}
for i, clip := range state.authorClips {
idx := i
card := widget.NewCard(clip.DisplayName, fmt.Sprintf("%.2fs", clip.Duration), nil)
nameLabel := widget.NewLabel(clip.DisplayName)
nameLabel.TextStyle = fyne.TextStyle{Bold: true}
durationLabel := widget.NewLabel(fmt.Sprintf("%.2fs", clip.Duration))
durationLabel.TextStyle = fyne.TextStyle{Italic: true}
durationLabel.Alignment = fyne.TextAlignTrailing
removeBtn := widget.NewButton("Remove", func() {
state.authorClips = append(state.authorClips[:idx], state.authorClips[idx+1:]...)
rebuildList()
state.updateAuthorSummary()
})
removeBtn.Importance = widget.MediumImportance
durationLabel := widget.NewLabel(fmt.Sprintf("Duration: %.2f seconds", clip.Duration))
durationLabel.TextStyle = fyne.TextStyle{Italic: true}
cardContent := container.NewVBox(
durationLabel,
widget.NewSeparator(),
removeBtn,
row := container.NewBorder(
nil,
nil,
nil,
container.NewVBox(durationLabel, removeBtn),
container.NewVBox(nameLabel),
)
card.SetContent(cardContent)
list.Add(card)
cardBg := canvas.NewRectangle(utils.MustHex("#171C2A"))
cardBg.CornerRadius = 6
cardBg.SetMinSize(fyne.NewSize(0, nameLabel.MinSize().Height+durationLabel.MinSize().Height+12))
list.Add(container.NewPadded(container.NewMax(cardBg, row)))
}
list.Refresh()
}
addBtn := widget.NewButton("Add Files", func() {
@ -117,6 +126,7 @@ func buildVideoClipsTab(state *appState) fyne.CanvasObject {
clearBtn := widget.NewButton("Clear All", func() {
state.authorClips = []authorClip{}
rebuildList()
state.updateAuthorSummary()
})
clearBtn.Importance = widget.MediumImportance
@ -149,7 +159,7 @@ func buildVideoClipsTab(state *appState) fyne.CanvasObject {
listArea := container.NewMax(dropTarget, emptyOverlay)
controls := container.NewBorder(
widget.NewLabel("Video Clips:"),
widget.NewLabel("Videos:"),
container.NewHBox(addBtn, clearBtn, compileBtn),
nil,
nil,
@ -233,32 +243,24 @@ func buildChaptersTab(state *appState) fyne.CanvasObject {
func buildSubtitlesTab(state *appState) fyne.CanvasObject {
list := container.NewVBox()
listScroll := container.NewVScroll(list)
var buildSubList func()
var emptyOverlay *fyne.Container
buildSubList = func() {
list.Objects = nil
if len(state.authorSubtitles) == 0 {
emptyLabel := widget.NewLabel("Drag and drop subtitle files here\nor click 'Add Subtitles' to select")
emptyLabel.Alignment = fyne.TextAlignCenter
emptyDrop := ui.NewDroppable(container.NewCenter(emptyLabel), func(items []fyne.URI) {
var paths []string
for _, uri := range items {
if uri.Scheme() == "file" {
paths = append(paths, uri.Path())
}
}
if len(paths) > 0 {
state.authorSubtitles = append(state.authorSubtitles, paths...)
buildSubList()
}
})
list.Add(container.NewMax(emptyDrop))
if emptyOverlay != nil {
emptyOverlay.Show()
}
list.Refresh()
return
}
if emptyOverlay != nil {
emptyOverlay.Hide()
}
for i, path := range state.authorSubtitles {
idx := i
card := widget.NewCard(filepath.Base(path), "", nil)
@ -266,6 +268,7 @@ func buildSubtitlesTab(state *appState) fyne.CanvasObject {
removeBtn := widget.NewButton("Remove", func() {
state.authorSubtitles = append(state.authorSubtitles[:idx], state.authorSubtitles[idx+1:]...)
buildSubList()
state.updateAuthorSummary()
})
removeBtn.Importance = widget.MediumImportance
@ -273,6 +276,7 @@ func buildSubtitlesTab(state *appState) fyne.CanvasObject {
card.SetContent(cardContent)
list.Add(card)
}
list.Refresh()
}
addBtn := widget.NewButton("Add Subtitles", func() {
@ -283,6 +287,7 @@ func buildSubtitlesTab(state *appState) fyne.CanvasObject {
defer reader.Close()
state.authorSubtitles = append(state.authorSubtitles, reader.URI().Path())
buildSubList()
state.updateAuthorSummary()
}, state.window)
})
addBtn.Importance = widget.HighImportance
@ -290,14 +295,36 @@ func buildSubtitlesTab(state *appState) fyne.CanvasObject {
clearBtn := widget.NewButton("Clear All", func() {
state.authorSubtitles = []string{}
buildSubList()
state.updateAuthorSummary()
})
clearBtn.Importance = widget.MediumImportance
controls := container.NewVBox(
dropTarget := ui.NewDroppable(listScroll, func(items []fyne.URI) {
var paths []string
for _, uri := range items {
if uri.Scheme() == "file" {
paths = append(paths, uri.Path())
}
}
if len(paths) > 0 {
state.authorSubtitles = append(state.authorSubtitles, paths...)
buildSubList()
state.updateAuthorSummary()
}
})
emptyLabel := widget.NewLabel("Drag and drop subtitle files here\nor click 'Add Subtitles' to select")
emptyLabel.Alignment = fyne.TextAlignCenter
emptyOverlay = container.NewCenter(emptyLabel)
listArea := container.NewMax(dropTarget, emptyOverlay)
controls := container.NewBorder(
widget.NewLabel("Subtitle Tracks:"),
container.NewScroll(list),
widget.NewSeparator(),
container.NewHBox(addBtn, clearBtn),
nil,
nil,
listArea,
)
buildSubList()
@ -311,6 +338,7 @@ func buildAuthorSettingsTab(state *appState) fyne.CanvasObject {
} else {
state.authorOutputType = "iso"
}
state.updateAuthorSummary()
})
if state.authorOutputType == "iso" {
outputType.SetSelected("ISO Image")
@ -320,6 +348,7 @@ func buildAuthorSettingsTab(state *appState) fyne.CanvasObject {
regionSelect := widget.NewSelect([]string{"AUTO", "NTSC", "PAL"}, func(value string) {
state.authorRegion = value
state.updateAuthorSummary()
})
if state.authorRegion == "" {
regionSelect.SetSelected("AUTO")
@ -329,6 +358,7 @@ func buildAuthorSettingsTab(state *appState) fyne.CanvasObject {
aspectSelect := widget.NewSelect([]string{"AUTO", "4:3", "16:9"}, func(value string) {
state.authorAspectRatio = value
state.updateAuthorSummary()
})
if state.authorAspectRatio == "" {
aspectSelect.SetSelected("AUTO")
@ -341,10 +371,12 @@ func buildAuthorSettingsTab(state *appState) fyne.CanvasObject {
titleEntry.SetText(state.authorTitle)
titleEntry.OnChanged = func(value string) {
state.authorTitle = value
state.updateAuthorSummary()
}
createMenuCheck := widget.NewCheck("Create DVD Menu", func(checked bool) {
state.authorCreateMenu = checked
state.updateAuthorSummary()
})
createMenuCheck.SetChecked(state.authorCreateMenu)
@ -382,6 +414,7 @@ func buildAuthorDiscTab(state *appState) fyne.CanvasObject {
summaryLabel := widget.NewLabel(authorSummary(state))
summaryLabel.Wrapping = fyne.TextWrapWord
state.authorSummaryLabel = summaryLabel
controls := container.NewVBox(
widget.NewLabel("Generate DVD/ISO:"),
@ -397,7 +430,7 @@ func buildAuthorDiscTab(state *appState) fyne.CanvasObject {
func authorSummary(state *appState) string {
summary := "Ready to generate:\n\n"
if len(state.authorClips) > 0 {
summary += fmt.Sprintf("Video Clips: %d\n", len(state.authorClips))
summary += fmt.Sprintf("Videos: %d\n", len(state.authorClips))
for i, clip := range state.authorClips {
summary += fmt.Sprintf(" %d. %s (%.2fs)\n", i+1, clip.DisplayName, clip.Duration)
}
@ -437,6 +470,14 @@ func (s *appState) addAuthorFiles(paths []string) {
}
s.authorClips = append(s.authorClips, clip)
}
s.updateAuthorSummary()
}
func (s *appState) updateAuthorSummary() {
if s.authorSummaryLabel == nil {
return
}
s.authorSummaryLabel.SetText(authorSummary(s))
}
func (s *appState) startAuthorGeneration() {

View File

@ -915,6 +915,7 @@ type appState struct {
authorTitle string // DVD title
authorSubtitles []string // Subtitle file paths
authorAudioTracks []string // Additional audio tracks
authorSummaryLabel *widget.Label
}
type mergeClip struct {