1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Fix selection being incorrect when the image is being scaled (mostly when being made smaller).

This commit is contained in:
Emmanouil Papadeas 2024-01-23 19:54:23 +02:00
parent aca4c0bd14
commit eff79337e0

View file

@ -557,6 +557,12 @@ func general_do_and_undo_scale(
var x_ratio = project.size.x / width var x_ratio = project.size.x / width
var y_ratio = project.size.y / height var y_ratio = project.size.y / height
var selection_map_copy := SelectionMap.new()
selection_map_copy.copy_from(project.selection_map)
selection_map_copy.crop(size.x, size.y)
redo_data[project.selection_map] = selection_map_copy.data
undo_data[project.selection_map] = project.selection_map.data
var new_x_symmetry_point = project.x_symmetry_point / x_ratio var new_x_symmetry_point = project.x_symmetry_point / x_ratio
var new_y_symmetry_point = project.y_symmetry_point / y_ratio var new_y_symmetry_point = project.y_symmetry_point / y_ratio
var new_x_symmetry_axis_points = project.x_symmetry_axis.points var new_x_symmetry_axis_points = project.x_symmetry_axis.points
@ -569,14 +575,12 @@ func general_do_and_undo_scale(
project.undos += 1 project.undos += 1
project.undo_redo.create_action("Scale") project.undo_redo.create_action("Scale")
project.undo_redo.add_do_property(project, "size", size) project.undo_redo.add_do_property(project, "size", size)
project.undo_redo.add_do_method(project.selection_map, "crop", size.x, size.y)
project.undo_redo.add_do_property(project, "x_symmetry_point", new_x_symmetry_point) project.undo_redo.add_do_property(project, "x_symmetry_point", new_x_symmetry_point)
project.undo_redo.add_do_property(project, "y_symmetry_point", new_y_symmetry_point) project.undo_redo.add_do_property(project, "y_symmetry_point", new_y_symmetry_point)
project.undo_redo.add_do_property(project.x_symmetry_axis, "points", new_x_symmetry_axis_points) project.undo_redo.add_do_property(project.x_symmetry_axis, "points", new_x_symmetry_axis_points)
project.undo_redo.add_do_property(project.y_symmetry_axis, "points", new_y_symmetry_axis_points) project.undo_redo.add_do_property(project.y_symmetry_axis, "points", new_y_symmetry_axis_points)
Global.undo_redo_compress_images(redo_data, undo_data) Global.undo_redo_compress_images(redo_data, undo_data)
project.undo_redo.add_undo_property(project, "size", project.size) project.undo_redo.add_undo_property(project, "size", project.size)
project.undo_redo.add_undo_method(project.selection_map, "crop", project.size.x, project.size.y)
project.undo_redo.add_undo_property(project, "x_symmetry_point", project.x_symmetry_point) project.undo_redo.add_undo_property(project, "x_symmetry_point", project.x_symmetry_point)
project.undo_redo.add_undo_property(project, "y_symmetry_point", project.y_symmetry_point) project.undo_redo.add_undo_property(project, "y_symmetry_point", project.y_symmetry_point)
project.undo_redo.add_undo_property( project.undo_redo.add_undo_property(