From f6e748fa47533081794cea90f9494e47162913f9 Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Sun, 4 Jan 2026 05:45:59 -0500 Subject: [PATCH] Add space key scrolling for convert settings --- internal/ui/components.go | 33 +++++++++++++++++++++++ main.go | 56 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/internal/ui/components.go b/internal/ui/components.go index 41955e8..515df85 100644 --- a/internal/ui/components.go +++ b/internal/ui/components.go @@ -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 } diff --git a/main.go b/main.go index c4a5714..f12c967 100644 --- a/main.go +++ b/main.go @@ -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