mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Move Centralize Image to the frame menu (#884)
* moved centralize to frame menu And make it effect on selected frames * Formatting (1 of 2) * Formatting (2 of 2)
This commit is contained in:
parent
a099e2195d
commit
26aa9bda38
|
@ -462,32 +462,36 @@ func scale_image(width: int, height: int, interpolation: int) -> void:
|
||||||
general_undo_scale()
|
general_undo_scale()
|
||||||
|
|
||||||
|
|
||||||
func centralize() -> void:
|
func centralize(indices: Array) -> void:
|
||||||
|
var project: Project = Global.current_project
|
||||||
Global.canvas.selection.transform_content_confirm()
|
Global.canvas.selection.transform_content_confirm()
|
||||||
# Find used rect of the current frame (across all of the layers)
|
project.undos += 1
|
||||||
var used_rect := Rect2()
|
project.undo_redo.create_action("Centralize")
|
||||||
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
|
for frame in indices:
|
||||||
if not cel is PixelCel:
|
# Find used rect of the current frame (across all of the layers)
|
||||||
|
var used_rect := Rect2()
|
||||||
|
for cel in project.frames[frame].cels:
|
||||||
|
if not cel is PixelCel:
|
||||||
|
continue
|
||||||
|
var cel_rect: Rect2 = cel.image.get_used_rect()
|
||||||
|
if not cel_rect.has_no_area():
|
||||||
|
used_rect = cel_rect if used_rect.has_no_area() else used_rect.merge(cel_rect)
|
||||||
|
if used_rect.has_no_area():
|
||||||
continue
|
continue
|
||||||
var cel_rect: Rect2 = cel.image.get_used_rect()
|
|
||||||
if not cel_rect.has_no_area():
|
|
||||||
used_rect = cel_rect if used_rect.has_no_area() else used_rect.merge(cel_rect)
|
|
||||||
if used_rect.has_no_area():
|
|
||||||
return
|
|
||||||
|
|
||||||
var offset: Vector2 = (0.5 * (Global.current_project.size - used_rect.size)).floor()
|
# Now apply Centralization
|
||||||
general_do_centralize()
|
var offset: Vector2 = (0.5 * (project.size - used_rect.size)).floor()
|
||||||
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
|
for cel in project.frames[frame].cels:
|
||||||
if not cel is PixelCel:
|
if not cel is PixelCel:
|
||||||
continue
|
continue
|
||||||
var sprite := Image.new()
|
var sprite := Image.new()
|
||||||
sprite.create(
|
sprite.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
||||||
Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8
|
sprite.blend_rect(cel.image, used_rect, offset)
|
||||||
)
|
project.undo_redo.add_do_property(cel.image, "data", sprite.data)
|
||||||
sprite.blend_rect(cel.image, used_rect, offset)
|
project.undo_redo.add_undo_property(cel.image, "data", cel.image.data)
|
||||||
Global.current_project.undo_redo.add_do_property(cel.image, "data", sprite.data)
|
project.undo_redo.add_undo_method(Global, "undo_or_redo", true)
|
||||||
Global.current_project.undo_redo.add_undo_property(cel.image, "data", cel.image.data)
|
project.undo_redo.add_do_method(Global, "undo_or_redo", false)
|
||||||
general_undo_centralize()
|
project.undo_redo.commit_action()
|
||||||
|
|
||||||
|
|
||||||
func crop_image() -> void:
|
func crop_image() -> void:
|
||||||
|
@ -591,19 +595,6 @@ func general_undo_scale() -> void:
|
||||||
project.undo_redo.commit_action()
|
project.undo_redo.commit_action()
|
||||||
|
|
||||||
|
|
||||||
func general_do_centralize() -> void:
|
|
||||||
var project: Project = Global.current_project
|
|
||||||
project.undos += 1
|
|
||||||
project.undo_redo.create_action("Centralize")
|
|
||||||
|
|
||||||
|
|
||||||
func general_undo_centralize() -> void:
|
|
||||||
var project: Project = Global.current_project
|
|
||||||
project.undo_redo.add_undo_method(Global, "undo_or_redo", true)
|
|
||||||
project.undo_redo.add_do_method(Global, "undo_or_redo", false)
|
|
||||||
project.undo_redo.commit_action()
|
|
||||||
|
|
||||||
|
|
||||||
func generate_outline(
|
func generate_outline(
|
||||||
image: Image,
|
image: Image,
|
||||||
affect_selection: bool,
|
affect_selection: bool,
|
||||||
|
|
|
@ -29,7 +29,6 @@ enum ImageMenu {
|
||||||
SCALE_IMAGE,
|
SCALE_IMAGE,
|
||||||
CROP_IMAGE,
|
CROP_IMAGE,
|
||||||
FLIP,
|
FLIP,
|
||||||
CENTRALIZE_IMAGE,
|
|
||||||
ROTATE,
|
ROTATE,
|
||||||
OUTLINE,
|
OUTLINE,
|
||||||
DROP_SHADOW,
|
DROP_SHADOW,
|
||||||
|
@ -293,10 +292,6 @@ func _initialize_keychain() -> void:
|
||||||
Keychain.MenuInputAction.new("", "Edit menu", true, "EditMenu", EditMenu.PREFERENCES),
|
Keychain.MenuInputAction.new("", "Edit menu", true, "EditMenu", EditMenu.PREFERENCES),
|
||||||
"scale_image":
|
"scale_image":
|
||||||
Keychain.MenuInputAction.new("", "Image menu", true, "ImageMenu", ImageMenu.SCALE_IMAGE),
|
Keychain.MenuInputAction.new("", "Image menu", true, "ImageMenu", ImageMenu.SCALE_IMAGE),
|
||||||
"centralize_image":
|
|
||||||
Keychain.MenuInputAction.new(
|
|
||||||
"", "Image menu", true, "ImageMenu", ImageMenu.CENTRALIZE_IMAGE
|
|
||||||
),
|
|
||||||
"crop_image":
|
"crop_image":
|
||||||
Keychain.MenuInputAction.new("", "Image menu", true, "ImageMenu", ImageMenu.CROP_IMAGE),
|
Keychain.MenuInputAction.new("", "Image menu", true, "ImageMenu", ImageMenu.CROP_IMAGE),
|
||||||
"resize_canvas":
|
"resize_canvas":
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
extends Button
|
extends Button
|
||||||
|
|
||||||
enum { REMOVE, CLONE, MOVE_LEFT, MOVE_RIGHT, PROPERTIES, REVERSE }
|
enum { REMOVE, CLONE, MOVE_LEFT, MOVE_RIGHT, PROPERTIES, REVERSE, CENTRALIZE }
|
||||||
|
|
||||||
var frame := 0
|
var frame := 0
|
||||||
|
|
||||||
|
@ -92,6 +92,8 @@ func _on_PopupMenu_id_pressed(id: int) -> void:
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
REVERSE:
|
REVERSE:
|
||||||
Global.animation_timeline.reverse_frames(indices)
|
Global.animation_timeline.reverse_frames(indices)
|
||||||
|
CENTRALIZE:
|
||||||
|
DrawingAlgos.centralize(indices)
|
||||||
|
|
||||||
|
|
||||||
func change_frame_order(rate: int) -> void:
|
func change_frame_order(rate: int) -> void:
|
||||||
|
|
|
@ -20,7 +20,7 @@ __meta__ = {
|
||||||
margin_right = 20.0
|
margin_right = 20.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
items = [ "Remove Frame", null, 0, false, true, -1, 0, null, "", false, "Clone Frame", null, 0, false, false, -1, 0, null, "", false, "Move Left", null, 0, false, true, -1, 0, null, "", false, "Move Right", null, 0, false, true, -1, 0, null, "", false, "Frame Properties", null, 0, false, false, -1, 0, null, "", false, "Reverse Frames", null, 0, false, true, 5, 0, null, "", false ]
|
items = [ "Remove Frame", null, 0, false, true, -1, 0, null, "", false, "Clone Frame", null, 0, false, false, -1, 0, null, "", false, "Move Left", null, 0, false, true, -1, 0, null, "", false, "Move Right", null, 0, false, true, -1, 0, null, "", false, "Frame Properties", null, 0, false, false, -1, 0, null, "", false, "Reverse Frames", null, 0, false, true, 5, 0, null, "", false, "Centralize Frames", null, 0, false, false, 6, 0, null, "", false ]
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,7 +277,6 @@ func _setup_image_menu() -> void:
|
||||||
"Scale Image",
|
"Scale Image",
|
||||||
"Crop Image",
|
"Crop Image",
|
||||||
"Mirror Image",
|
"Mirror Image",
|
||||||
"Centralize Image",
|
|
||||||
"Rotate Image",
|
"Rotate Image",
|
||||||
"Outline",
|
"Outline",
|
||||||
"Drop Shadow",
|
"Drop Shadow",
|
||||||
|
@ -654,9 +653,6 @@ func image_menu_id_pressed(id: int) -> void:
|
||||||
Global.ImageMenu.OFFSET_IMAGE:
|
Global.ImageMenu.OFFSET_IMAGE:
|
||||||
_popup_dialog(Global.control.get_node("Dialogs/ImageEffects/OffsetImage"))
|
_popup_dialog(Global.control.get_node("Dialogs/ImageEffects/OffsetImage"))
|
||||||
|
|
||||||
Global.ImageMenu.CENTRALIZE_IMAGE:
|
|
||||||
DrawingAlgos.centralize()
|
|
||||||
|
|
||||||
Global.ImageMenu.CROP_IMAGE:
|
Global.ImageMenu.CROP_IMAGE:
|
||||||
DrawingAlgos.crop_image()
|
DrawingAlgos.crop_image()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue