Add space key scrolling for convert settings

This commit is contained in:
Stu Leak 2026-01-04 05:45:59 -05:00
parent 3108882c7b
commit f6e748fa47
2 changed files with 86 additions and 3 deletions

View File

@ -551,6 +551,39 @@ func (f *FastVScroll) Scrolled(ev *fyne.ScrollEvent) {
f.scroll.Scrolled(fastEvent)
}
// ScrollBy scrolls the content by a delta in pixels (positive = down).
func (f *FastVScroll) ScrollBy(delta float32) {
if f == nil || f.scroll == nil || f.scroll.Content == nil {
return
}
max := f.scroll.Content.MinSize().Height - f.scroll.Size().Height
if max < 0 {
max = 0
}
newY := f.scroll.Offset.Y + delta
if newY < 0 {
newY = 0
} else if newY > max {
newY = max
}
f.scroll.ScrollToOffset(fyne.NewPos(f.scroll.Offset.X, newY))
}
// PageStep returns a reasonable scroll step based on the current viewport.
func (f *FastVScroll) PageStep() float32 {
if f == nil || f.scroll == nil {
return 0
}
height := f.scroll.Size().Height
if height <= 0 {
height = f.scroll.MinSize().Height
}
if height <= 0 {
height = 240
}
return height * 0.85
}
type fastScrollRenderer struct {
scroll *container.Scroll
}

56
main.go
View File

@ -505,18 +505,18 @@ func openFile(path string) error {
func generatePixelatedQRCode() (fyne.CanvasObject, error) {
docURL := "https://docs.leaktechnologies.dev/VideoTools"
// Generate QR code with fewer pixels for a chunkier, blockier look
qrBytes, err := qrcode.Encode(docURL, qrcode.Low, 112)
if err != nil {
return nil, err
}
// Convert to Fyne image with pixelated look
img := canvas.NewImageFromReader(bytes.NewReader(qrBytes), "qrcode.png")
img.FillMode = canvas.ImageFillOriginal // Keep pixelated look
img.SetMinSize(fyne.NewSize(112, 112))
return img, nil
}
@ -985,6 +985,7 @@ type appState struct {
inspectInterlaceAnalyzing bool
autoCompare bool // Auto-load Compare module after conversion
convertCommandPreviewShow bool // Show FFmpeg command preview in Convert module
convertScrollShortcuts bool
// Merge state
mergeClips []mergeClip
@ -6999,6 +7000,11 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
var updateDVDOptions func()
var buildCommandPreview func()
// Declare output widgets early to fix variable order issues
var outputExtLabel *widget.Label
var outputExtBG *canvas.Rectangle
var updateOutputHint func()
var formatLabels []string
for _, opt := range formatOptions {
formatLabels = append(formatLabels, opt.Label)
@ -9097,6 +9103,50 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject {
}
}
if !state.convertScrollShortcuts && state.window != nil {
state.convertScrollShortcuts = true
isTextEntryFocused := func() bool {
c := state.window.Canvas()
if c == nil {
return false
}
switch c.Focused().(type) {
case *widget.Entry, *widget.MultiLineEntry:
return true
default:
return false
}
}
scrollActive := func() *ui.FastVScroll {
if tabs.Selected() != nil && tabs.Selected().Text == "Advanced" {
return advancedScrollBox
}
return simpleScrollBox
}
state.window.Canvas().AddShortcut(&desktop.CustomShortcut{KeyName: fyne.KeySpace}, func(_ fyne.Shortcut) {
if state.active != "convert" || isTextEntryFocused() {
return
}
scroll := scrollActive()
if scroll == nil {
return
}
scroll.ScrollBy(scroll.PageStep())
})
state.window.Canvas().AddShortcut(&desktop.CustomShortcut{KeyName: fyne.KeySpace, Modifier: fyne.KeyModifierControl}, func(_ fyne.Shortcut) {
if state.active != "convert" || isTextEntryFocused() {
return
}
scroll := scrollActive()
if scroll == nil {
return
}
scroll.ScrollBy(-scroll.PageStep())
})
}
optionsRect := canvas.NewRectangle(utils.MustHex("#13182B"))
optionsRect.CornerRadius = 8
optionsRect.StrokeColor = gridColor