Skip to content

Commit

Permalink
Compress mirror image in undo/redo
Browse files Browse the repository at this point in the history
  • Loading branch information
OverloadedOrama committed Nov 14, 2023
1 parent 4f5f37a commit e22794e
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/UI/Dialogs/ImageEffects/FlipImageDialog.gd
Original file line number Diff line number Diff line change
Expand Up @@ -51,37 +51,34 @@ func _commit_undo(action: String, undo_data: Dictionary, project: Project) -> vo
var redo_data := _get_undo_data(project)
project.undos += 1
project.undo_redo.create_action(action)
project.undo_redo.add_do_property(project, "selection_map", redo_data["selection_map"])
project.undo_redo.add_do_property(project, "selection_offset", redo_data["outline_offset"])
project.undo_redo.add_undo_property(project, "selection_map", undo_data["selection_map"])
project.undo_redo.add_undo_property(project, "selection_offset", undo_data["outline_offset"])

for image in redo_data:
if not image is Image:
continue
project.undo_redo.add_do_property(image, "data", redo_data[image])
for image in undo_data:
if not image is Image:
continue
project.undo_redo.add_undo_property(image, "data", undo_data[image])
if redo_data.has("selection_map"):
project.undo_redo.add_do_property(project, "selection_map", redo_data["selection_map"])
project.undo_redo.add_do_property(project, "selection_offset", redo_data["outline_offset"])
project.undo_redo.add_undo_property(project, "selection_map", undo_data["selection_map"])
project.undo_redo.add_undo_property(
project, "selection_offset", undo_data["outline_offset"]
)
project.undo_redo.add_do_method(project.selection_map_changed)
project.undo_redo.add_undo_method(project.selection_map_changed)

Global.undo_redo_compress_images(redo_data, undo_data, project)
project.undo_redo.add_do_method(Global.undo_or_redo.bind(false, -1, -1, project))
project.undo_redo.add_do_method(project.selection_map_changed)
project.undo_redo.add_undo_method(Global.undo_or_redo.bind(true, -1, -1, project))
project.undo_redo.add_undo_method(project.selection_map_changed)
project.undo_redo.commit_action()


func _get_undo_data(project: Project) -> Dictionary:
var bitmap_image := SelectionMap.new()
bitmap_image.copy_from(project.selection_map)
var affect_selection := selection_checkbox.button_pressed and project.has_selection
var data := {}
data["selection_map"] = bitmap_image
data["outline_offset"] = project.selection_offset
if affect_selection:
var bitmap_image := SelectionMap.new()
bitmap_image.copy_from(project.selection_map)
data["selection_map"] = bitmap_image
data["outline_offset"] = project.selection_offset

var images := _get_selected_draw_images(project)
for image in images:
data[image] = image.data

return data


Expand Down

0 comments on commit e22794e

Please sign in to comment.