Move snippet/options previews into drawers
This commit is contained in:
parent
30eeaef753
commit
55d4969bc2
112
main.go
112
main.go
|
|
@ -6977,7 +6977,7 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
// Callbacks for state updates
|
// Callbacks for state updates
|
||||||
updateEncodingControls func()
|
updateEncodingControls func()
|
||||||
updateAspectBoxVisibility func()
|
updateAspectBoxVisibility func()
|
||||||
buildCommandPreview func()
|
buildCommandPreview func() fyne.CanvasObject
|
||||||
}
|
}
|
||||||
|
|
||||||
uiState := &convertUIState{
|
uiState := &convertUIState{
|
||||||
|
|
@ -7258,20 +7258,68 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
})
|
})
|
||||||
clearCompletedBtn.Importance = widget.LowImportance
|
clearCompletedBtn.Importance = widget.LowImportance
|
||||||
|
|
||||||
// Command Preview toggle button
|
var commandDrawer *widget.PopUp
|
||||||
cmdPreviewBtn := widget.NewButton("Command Preview", func() {
|
var snippetDrawer *widget.PopUp
|
||||||
state.convertCommandPreviewShow = !state.convertCommandPreviewShow
|
drawerWidth := float32(420)
|
||||||
state.showModule("convert")
|
drawerInset := float32(8)
|
||||||
|
buildDrawer := func(title string, body fyne.CanvasObject, onClose func()) *widget.PopUp {
|
||||||
|
closeBtn := widget.NewButton("✕", func() {
|
||||||
|
if onClose != nil {
|
||||||
|
onClose()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
closeBtn.Importance = widget.LowImportance
|
||||||
|
header := container.NewBorder(nil, nil,
|
||||||
|
widget.NewLabelWithStyle(title, fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
|
||||||
|
closeBtn,
|
||||||
|
)
|
||||||
|
bodyScroll := container.NewVScroll(body)
|
||||||
|
bodyScroll.SetMinSize(fyne.NewSize(0, 200))
|
||||||
|
panel := container.NewBorder(header, nil, nil, nil, bodyScroll)
|
||||||
|
|
||||||
|
bg := canvas.NewRectangle(utils.MustHex("#13182B"))
|
||||||
|
bg.CornerRadius = 10
|
||||||
|
bg.StrokeColor = gridColor
|
||||||
|
bg.StrokeWidth = 1
|
||||||
|
drawer := container.NewMax(bg, container.NewPadded(panel))
|
||||||
|
|
||||||
|
pop := widget.NewPopUp(drawer, state.window.Canvas())
|
||||||
|
canvasSize := state.window.Canvas().Size()
|
||||||
|
height := canvasSize.Height - (drawerInset * 2)
|
||||||
|
if height < 220 {
|
||||||
|
height = 220
|
||||||
|
}
|
||||||
|
pop.Resize(fyne.NewSize(drawerWidth, height))
|
||||||
|
pop.ShowAtPosition(fyne.NewPos(canvasSize.Width-drawerWidth-drawerInset, drawerInset))
|
||||||
|
return pop
|
||||||
|
}
|
||||||
|
toggleDrawer := func(active **widget.PopUp, title string, body fyne.CanvasObject) {
|
||||||
|
if *active != nil {
|
||||||
|
(*active).Hide()
|
||||||
|
*active = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
*active = buildDrawer(title, body, func() {
|
||||||
|
if *active != nil {
|
||||||
|
(*active).Hide()
|
||||||
|
*active = nil
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command Preview toggle button (drawer)
|
||||||
|
cmdPreviewBtn := widget.NewButton("Command Preview…", func() {
|
||||||
|
if src == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
body := buildCommandPreview()
|
||||||
|
toggleDrawer(&commandDrawer, "FFmpeg Command Preview", body)
|
||||||
})
|
})
|
||||||
cmdPreviewBtn.Importance = widget.LowImportance
|
cmdPreviewBtn.Importance = widget.LowImportance
|
||||||
|
|
||||||
// Update button text and state based on preview visibility and source
|
// Update button text and state based on preview visibility and source
|
||||||
if src == nil {
|
if src == nil {
|
||||||
cmdPreviewBtn.Disable()
|
cmdPreviewBtn.Disable()
|
||||||
} else if state.convertCommandPreviewShow {
|
|
||||||
cmdPreviewBtn.SetText("Hide Preview")
|
|
||||||
} else {
|
|
||||||
cmdPreviewBtn.SetText("Show Preview")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build back bar
|
// Build back bar
|
||||||
|
|
@ -7313,7 +7361,7 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
|
|
||||||
// Forward declare functions needed by formatContainer callback
|
// Forward declare functions needed by formatContainer callback
|
||||||
var updateDVDOptions func()
|
var updateDVDOptions func()
|
||||||
var buildCommandPreview func()
|
var buildCommandPreview func() fyne.CanvasObject
|
||||||
var updateChapterWarning func()
|
var updateChapterWarning func()
|
||||||
var updateQualityOptions func()
|
var updateQualityOptions func()
|
||||||
var updateQualityVisibility func()
|
var updateQualityVisibility func()
|
||||||
|
|
@ -9712,9 +9760,6 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
snippetModeCheck,
|
snippetModeCheck,
|
||||||
snippetModeHint,
|
snippetModeHint,
|
||||||
)
|
)
|
||||||
snippetConfigScroll := container.NewVScroll(snippetConfigRow)
|
|
||||||
snippetConfigScroll.SetMinSize(fyne.NewSize(0, 140))
|
|
||||||
snippetConfigScroll.Hide()
|
|
||||||
|
|
||||||
snippetBtn := widget.NewButton("Generate Snippet", func() {
|
snippetBtn := widget.NewButton("Generate Snippet", func() {
|
||||||
if state.source == nil {
|
if state.source == nil {
|
||||||
|
|
@ -9847,17 +9892,9 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
|
|
||||||
snippetHint := widget.NewLabel("Creates a clip centred on the timeline midpoint.")
|
snippetHint := widget.NewLabel("Creates a clip centred on the timeline midpoint.")
|
||||||
|
|
||||||
snippetOptionsVisible := false
|
|
||||||
var snippetOptionsBtn *widget.Button
|
var snippetOptionsBtn *widget.Button
|
||||||
snippetOptionsBtn = widget.NewButton("Convert Options", func() {
|
snippetOptionsBtn = widget.NewButton("Snippet Options…", func() {
|
||||||
if snippetOptionsVisible {
|
toggleDrawer(&snippetDrawer, "Snippet Options", snippetConfigRow)
|
||||||
snippetConfigScroll.Hide()
|
|
||||||
snippetOptionsBtn.SetText("Convert Options")
|
|
||||||
} else {
|
|
||||||
snippetConfigScroll.Show()
|
|
||||||
snippetOptionsBtn.SetText("Hide Options")
|
|
||||||
}
|
|
||||||
snippetOptionsVisible = !snippetOptionsVisible
|
|
||||||
})
|
})
|
||||||
snippetOptionsBtn.Importance = widget.LowImportance
|
snippetOptionsBtn.Importance = widget.LowImportance
|
||||||
if src == nil {
|
if src == nil {
|
||||||
|
|
@ -10059,14 +10096,11 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
|
|
||||||
// FFmpeg Command Preview
|
// FFmpeg Command Preview
|
||||||
var commandPreviewWidget *ui.FFmpegCommandWidget
|
var commandPreviewWidget *ui.FFmpegCommandWidget
|
||||||
var commandPreviewRow *fyne.Container
|
var commandPreviewBody *fyne.Container
|
||||||
|
|
||||||
buildCommandPreview = func() {
|
buildCommandPreview = func() fyne.CanvasObject {
|
||||||
if src == nil || !state.convertCommandPreviewShow {
|
if src == nil {
|
||||||
if commandPreviewRow != nil {
|
return widget.NewLabel("Load a video to see the FFmpeg command.")
|
||||||
commandPreviewRow.Hide()
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build command from current state
|
// Build command from current state
|
||||||
|
|
@ -10124,23 +10158,15 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
|
|
||||||
if commandPreviewWidget == nil {
|
if commandPreviewWidget == nil {
|
||||||
commandPreviewWidget = ui.NewFFmpegCommandWidget(cmdStr, state.window)
|
commandPreviewWidget = ui.NewFFmpegCommandWidget(cmdStr, state.window)
|
||||||
commandLabel := widget.NewLabel("FFmpeg Command Preview:")
|
commandPreviewBody = container.NewVBox(commandPreviewWidget)
|
||||||
commandLabel.TextStyle = fyne.TextStyle{Bold: true}
|
|
||||||
commandPreviewRow = container.NewVBox(
|
|
||||||
widget.NewSeparator(),
|
|
||||||
commandLabel,
|
|
||||||
commandPreviewWidget,
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
commandPreviewWidget.SetCommand(cmdStr)
|
commandPreviewWidget.SetCommand(cmdStr)
|
||||||
}
|
}
|
||||||
if commandPreviewRow != nil {
|
return commandPreviewBody
|
||||||
commandPreviewRow.Show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build initial preview if source is loaded
|
// Build initial preview if source is loaded
|
||||||
buildCommandPreview()
|
_ = buildCommandPreview()
|
||||||
|
|
||||||
leftControls := container.NewHBox(resetBtn, loadCfgBtn, saveCfgBtn, autoCompareCheck)
|
leftControls := container.NewHBox(resetBtn, loadCfgBtn, saveCfgBtn, autoCompareCheck)
|
||||||
rightControls := container.NewHBox(cancelBtn, cancelQueueBtn, viewLogBtn, addAllQueueBtn, addQueueBtn, convertBtn)
|
rightControls := container.NewHBox(cancelBtn, cancelQueueBtn, viewLogBtn, addAllQueueBtn, addQueueBtn, convertBtn)
|
||||||
|
|
@ -10224,12 +10250,8 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
|
||||||
// Build footer sections
|
// Build footer sections
|
||||||
footerSections := []fyne.CanvasObject{
|
footerSections := []fyne.CanvasObject{
|
||||||
snippetRow,
|
snippetRow,
|
||||||
snippetConfigScroll,
|
|
||||||
widget.NewSeparator(),
|
widget.NewSeparator(),
|
||||||
}
|
}
|
||||||
if commandPreviewRow != nil && state.convertCommandPreviewShow {
|
|
||||||
footerSections = append(footerSections, commandPreviewRow)
|
|
||||||
}
|
|
||||||
|
|
||||||
mainWithFooter := container.NewBorder(
|
mainWithFooter := container.NewBorder(
|
||||||
nil,
|
nil,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user