From 40e647ee5bdad24801e5e0d0c35c1783ed511935 Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Mon, 29 Dec 2025 01:45:11 -0500 Subject: [PATCH] Add color-coded format badges to Convert module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implemented semantic color-coded badges for format selection: - Badge displays next to format dropdown showing container name - Uses semantic color system (MKV=teal, MP4=blue, MOV=indigo, etc.) - Updates dynamically when format selection changes - Appears in both Simple and Advanced modes Changes: - Created buildFormatBadge() function to generate colored badges - Added formatBadgeContainer with updateFormatBadge() callback - Integrated badge into both Simple and Advanced mode layouts - Badge provides visual recognition of container type at a glance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- main.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/main.go b/main.go index 89ab19b..eab5f2d 100644 --- a/main.go +++ b/main.go @@ -6227,6 +6227,35 @@ func (s *appState) executeConversion() { } } +// buildFormatBadge creates a color-coded badge for a format option +// Example: "MKV (AV1)" → teal badge with "MKV (AV1)" text +func buildFormatBadge(formatLabel string) fyne.CanvasObject { + // Parse format label: "MKV (AV1)" → containerName: "mkv" + parts := strings.Split(formatLabel, " (") + if len(parts) < 1 { + return widget.NewLabel(formatLabel) + } + + containerName := strings.ToLower(strings.TrimSpace(parts[0])) + + // Get container color + badgeColor := ui.GetContainerColor(containerName) + + // Create colored background + bg := canvas.NewRectangle(badgeColor) + bg.CornerRadius = 4 + bg.SetMinSize(fyne.NewSize(120, 32)) + + // Create label + label := canvas.NewText(formatLabel, color.White) + label.TextStyle = fyne.TextStyle{Bold: true} + label.Alignment = fyne.TextAlignCenter + label.TextSize = 13 + + // Stack background and label + return container.NewMax(bg, container.NewCenter(label)) +} + func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject { convertColor := moduleColor("convert") @@ -6859,6 +6888,13 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject { } } + // Create format badge with semantic color + formatBadgeContainer := container.NewMax() + updateFormatBadge := func(label string) { + formatBadgeContainer.Objects = []fyne.CanvasObject{buildFormatBadge(label)} + formatBadgeContainer.Refresh() + } + updateFormatBadge(state.convert.SelectedFormat.Label) formatSelect := widget.NewSelect(formatLabels, func(value string) { for _, opt := range formatOptions { if opt.Label == value { @@ -6893,11 +6929,13 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject { if buildCommandPreview != nil { buildCommandPreview() } + updateFormatBadge(value) break } } }) formatSelect.SetSelected(state.convert.SelectedFormat.Label) + updateChapterWarning() // Initial visibility if !state.convert.AspectUserSet { @@ -8141,6 +8179,7 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject { widget.NewLabelWithStyle("═══ OUTPUT ═══", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}), widget.NewLabelWithStyle("Format", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}), formatSelect, + formatBadgeContainer, chapterWarningLabel, // Warning when converting chapters to DVD preserveChaptersCheck, dvdAspectBox, // DVD options appear here when DVD format selected @@ -8203,6 +8242,7 @@ func buildConvertView(state *appState, src *videoSource) fyne.CanvasObject { widget.NewLabelWithStyle("═══ OUTPUT ═══", fyne.TextAlignCenter, fyne.TextStyle{Bold: true}), widget.NewLabelWithStyle("Format", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}), formatSelect, + formatBadgeContainer, chapterWarningLabel, // Warning when converting chapters to DVD preserveChaptersCheck, dvdAspectBox, // DVD options appear here when DVD format selected