Skip to content

Commit

Permalink
File > Export > Animation: overhaul completely
Browse files Browse the repository at this point in the history
Relates to #513 .  Thank you to @hi5 for their thoughtful discussion on how to improve PD's Export menu.

PD's various `File > Export > Animated GIF/JPEG-XL/PNG/WebP` menus are now merged into a single Export > Animation menu.  This menu launches a standard Save dialog where you can choose between those formats, and the dialog has the same auto-detect-format behavior if you manually type in a file extension.

This change was more cumbersome than I expected.  To ensure smooth workflows, PhotoDemon needs to remember export details for a given image (so that, for example, if you load an animated GIF and export it to an animated WebP, when you return to the Export dialog it needs to auto-suggest WebP as the format - not GIF).  It also needs to choose intelligent defaults when it can.  These little nuances add up and lead to a lot of extra code.

Next up: writing a new `Export > Image to file` menu that allows you to export the active image to arbitrary new formats (without modifying image save state).
  • Loading branch information
tannerhelland committed Jan 16, 2024
1 parent 3e1a297 commit e711652
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 91 deletions.
16 changes: 8 additions & 8 deletions Forms/MainWindow.frm
Expand Up @@ -150,19 +150,19 @@ Begin VB.Form FormMain
Caption = "Export"
Index = 12
Begin VB.Menu MnuFileExport
Caption = "Animated GIF..."
Caption = "Image to file..."
Index = 0
End
Begin VB.Menu MnuFileExport
Caption = "Animated JPEG XL..."
Caption = "Layers to files..."
Index = 1
End
Begin VB.Menu MnuFileExport
Caption = "Animated PNG..."
Caption = "-"
Index = 2
End
Begin VB.Menu MnuFileExport
Caption = "Animated WebP..."
Caption = "Animation..."
Index = 3
End
Begin VB.Menu MnuFileExport
Expand Down Expand Up @@ -3089,13 +3089,13 @@ End Sub
Private Sub MnuFileExport_Click(Index As Integer)
Select Case Index
Case 0
Actions.LaunchAction_ByName "file_export_animatedgif"
Actions.LaunchAction_ByName "file_export_image"
Case 1
Actions.LaunchAction_ByName "file_export_animatedjxl"
Actions.LaunchAction_ByName "file_export_layers"
Case 2
Actions.LaunchAction_ByName "file_export_animatedpng"
'(separator)
Case 3
Actions.LaunchAction_ByName "file_export_animatedwebp"
Actions.LaunchAction_ByName "file_export_animation"
Case 4
'(separator)
Case 5
Expand Down
16 changes: 6 additions & 10 deletions Modules/Actions.bas
Expand Up @@ -233,21 +233,17 @@ Private Function Launch_ByName_MenuFile(ByRef srcMenuName As String, Optional By
Process "Revert", False, , UNDO_Everything

Case "file_export"
Case "file_export_animatedgif"
Case "file_export_image"
If (Not PDImages.IsImageActive()) Then Exit Function
Process "Export animated GIF", True
Process "Export image", True

Case "file_export_animatedjxl"
Case "file_export_layers"
If (Not PDImages.IsImageActive()) Then Exit Function
Process "Export animated JPEG XL", True
Process "Export layers", True

Case "file_export_animatedpng"
Case "file_export_animation"
If (Not PDImages.IsImageActive()) Then Exit Function
Process "Export animated PNG", True

Case "file_export_animatedwebp"
If (Not PDImages.IsImageActive()) Then Exit Function
Process "Export animated WebP", True
Process "Export animation", True

Case "file_export_colorlookup"
If (Not PDImages.IsImageActive()) Then Exit Function
Expand Down
8 changes: 4 additions & 4 deletions Modules/Menus.bas
Expand Up @@ -177,10 +177,10 @@ Public Sub InitializeMenus()
AddMenuItem "Save as...", "file_saveas", 0, 10, , "file_saveas"
AddMenuItem "Revert", "file_revert", 0, 11
AddMenuItem "Export", "file_export", 0, 12
AddMenuItem "Animated GIF...", "file_export_animatedgif", 0, 12, 0
AddMenuItem "Animated JPEG XL...", "file_export_animatedjxl", 0, 12, 1
AddMenuItem "Animated PNG...", "file_export_animatedpng", 0, 12, 2
AddMenuItem "Animated WebP...", "file_export_animatedwebp", 0, 12, 3
AddMenuItem "Image to file...", "file_export_image", 0, 12, 0
AddMenuItem "Layers to files...", "file_export_layers", 0, 12, 1
AddMenuItem "-", "-", 0, 12, 2
AddMenuItem "Animation...", "file_export_animation", 0, 12, 3
AddMenuItem "-", "-", 0, 12, 4
AddMenuItem "Color lookup...", "file_export_colorlookup", 0, 12, 5
AddMenuItem "Color profile...", "file_export_colorprofile", 0, 12, 6
Expand Down
19 changes: 9 additions & 10 deletions Modules/Processor.bas
Expand Up @@ -1396,20 +1396,19 @@ Private Function Process_FileMenu(ByVal processID As String, Optional raiseDialo
End If
Process_FileMenu = True

ElseIf Strings.StringsEqual(processID, "Export animated GIF", True) Then
Saving.Export_Animation PDIF_GIF, PDImages.GetActiveImage()
ElseIf Strings.StringsEqual(processID, "Export image", True) Then
'TODO:
'Saving.Export_Animation PDIF_GIF, PDImages.GetActiveImage()
Process_FileMenu = True

ElseIf Strings.StringsEqual(processID, "Export animated JPEG XL", True) Then
Saving.Export_Animation PDIF_JXL, PDImages.GetActiveImage()
ElseIf Strings.StringsEqual(processID, "Export layers", True) Then
'TODO:
'Saving.Export_Animation PDIF_JXL, PDImages.GetActiveImage()
Process_FileMenu = True

ElseIf Strings.StringsEqual(processID, "Export animated PNG", True) Then
Saving.Export_Animation PDIF_PNG, PDImages.GetActiveImage()
Process_FileMenu = True

ElseIf Strings.StringsEqual(processID, "Export animated WebP", True) Then
Saving.Export_Animation PDIF_WEBP, PDImages.GetActiveImage()
ElseIf Strings.StringsEqual(processID, "Export animation", True) Then
'TODO:
Saving.Export_Animation PDImages.GetActiveImage()
Process_FileMenu = True

ElseIf Strings.StringsEqual(processID, "Export color lookup", True) Then
Expand Down

0 comments on commit e711652

Please sign in to comment.