mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Made "Crop Image" affect all frames
This commit is contained in:
parent
74f3644e17
commit
4a0ffd8cd4
|
@ -43,6 +43,7 @@ sapient-cogbag, Kinwailo, Igor Santarek (jegor377), Dávid Gábor BODOR (dragonf
|
||||||
- Layer's LineEdit now saves the changes when it loses focus, or when the user presses ESC (or Enter).
|
- Layer's LineEdit now saves the changes when it loses focus, or when the user presses ESC (or Enter).
|
||||||
- LineEdits lose focus when the user presses Enter.
|
- LineEdits lose focus when the user presses Enter.
|
||||||
- When cloning a frame, the clone will appear next to the original.
|
- When cloning a frame, the clone will appear next to the original.
|
||||||
|
- Scale image and crop image now affect all frames.
|
||||||
- Layer visibility is taken into account when exporting the drawing as a `.png` file. This means that invisible layers will not be included in the final `.png` file.
|
- Layer visibility is taken into account when exporting the drawing as a `.png` file. This means that invisible layers will not be included in the final `.png` file.
|
||||||
- The Godot theme has changed and been renamed to Blue. The Gold theme has also been renamed to Caramel.
|
- The Godot theme has changed and been renamed to Blue. The Gold theme has also been renamed to Caramel.
|
||||||
- When a dialog is opened, the UI in the background gets darker.
|
- When a dialog is opened, the UI in the background gets darker.
|
||||||
|
@ -55,6 +56,7 @@ sapient-cogbag, Kinwailo, Igor Santarek (jegor377), Dávid Gábor BODOR (dragonf
|
||||||
- The splash screen has been revamped and is no longer purple, it now gets affected by the chosen theme.
|
- The splash screen has been revamped and is no longer purple, it now gets affected by the chosen theme.
|
||||||
- The brush selection popup now closes when a brush is selected.
|
- The brush selection popup now closes when a brush is selected.
|
||||||
- Pixelorama's version number now appears on the window title.
|
- Pixelorama's version number now appears on the window title.
|
||||||
|
- Images now get zoomed properly (fit to canvas frame) when they are first created or loaded.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Chinese characters not being rendered in notifications (the labels that appear when undoing/redoing) and at the splash screen for Platinum & Gold Sponsor Placeholder labels
|
- Chinese characters not being rendered in notifications (the labels that appear when undoing/redoing) and at the splash screen for Platinum & Gold Sponsor Placeholder labels
|
||||||
|
|
55
src/Main.gd
55
src/Main.gd
|
@ -355,19 +355,24 @@ func image_menu_id_pressed(id : int) -> void:
|
||||||
0: # Scale Image
|
0: # Scale Image
|
||||||
$ScaleImage.popup_centered()
|
$ScaleImage.popup_centered()
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
1: # Crop Image
|
|
||||||
# Use first layer as a starting rectangle
|
|
||||||
var used_rect : Rect2 = Global.canvas.layers[0][0].get_used_rect()
|
|
||||||
# However, if first layer is empty, loop through all layers until we find one that isn't
|
|
||||||
var i := 0
|
|
||||||
while(i < Global.canvas.layers.size() - 1 and Global.canvas.layers[i][0].get_used_rect() == Rect2(0, 0, 0, 0)):
|
|
||||||
i += 1
|
|
||||||
used_rect = Global.canvas.layers[i][0].get_used_rect()
|
|
||||||
|
|
||||||
# Merge all layers with content
|
1: # Crop Image
|
||||||
for j in range(Global.canvas.layers.size() - 1, i, -1):
|
# Use first cel as a starting rectangle
|
||||||
if Global.canvas.layers[j][0].get_used_rect() != Rect2(0, 0, 0, 0):
|
var used_rect : Rect2 = Global.canvases[0].layers[0][0].get_used_rect()
|
||||||
used_rect = used_rect.merge(Global.canvas.layers[j][0].get_used_rect())
|
|
||||||
|
for c in Global.canvases:
|
||||||
|
# However, if first cel is empty, loop through all cels until we find one that isn't
|
||||||
|
for layer in c.layers:
|
||||||
|
if used_rect != Rect2(0, 0, 0, 0):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if layer[0].get_used_rect() != Rect2(0, 0, 0, 0):
|
||||||
|
used_rect = layer[0].get_used_rect()
|
||||||
|
|
||||||
|
# Merge all layers with content
|
||||||
|
for layer in c.layers:
|
||||||
|
if layer[0].get_used_rect() != Rect2(0, 0, 0, 0):
|
||||||
|
used_rect = used_rect.merge(layer[0].get_used_rect())
|
||||||
|
|
||||||
# If no layer has any content, just return
|
# If no layer has any content, just return
|
||||||
if used_rect == Rect2(0, 0, 0, 0):
|
if used_rect == Rect2(0, 0, 0, 0):
|
||||||
|
@ -377,17 +382,19 @@ func image_menu_id_pressed(id : int) -> void:
|
||||||
var height := used_rect.size.y
|
var height := used_rect.size.y
|
||||||
Global.undos += 1
|
Global.undos += 1
|
||||||
Global.undo_redo.create_action("Scale")
|
Global.undo_redo.create_action("Scale")
|
||||||
Global.undo_redo.add_do_property(Global.canvas, "size", Vector2(width, height).floor())
|
for c in Global.canvases:
|
||||||
# Loop through all the layers to crop them
|
Global.undo_redo.add_do_property(c, "size", Vector2(width, height).floor())
|
||||||
for j in range(Global.canvas.layers.size() - 1, -1, -1):
|
# Loop through all the layers to crop them
|
||||||
var sprite : Image = Global.canvas.layers[j][0].get_rect(used_rect)
|
for j in range(Global.canvas.layers.size() - 1, -1, -1):
|
||||||
Global.undo_redo.add_do_property(Global.canvas.layers[j][0], "data", sprite.data)
|
var sprite : Image = c.layers[j][0].get_rect(used_rect)
|
||||||
Global.undo_redo.add_undo_property(Global.canvas.layers[j][0], "data", Global.canvas.layers[j][0].data)
|
Global.undo_redo.add_do_property(c.layers[j][0], "data", sprite.data)
|
||||||
|
Global.undo_redo.add_undo_property(c.layers[j][0], "data", c.layers[j][0].data)
|
||||||
|
|
||||||
Global.undo_redo.add_undo_property(Global.canvas, "size", Global.canvas.size)
|
Global.undo_redo.add_undo_property(c, "size", c.size)
|
||||||
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvas])
|
Global.undo_redo.add_undo_method(Global, "undo", Global.canvases)
|
||||||
Global.undo_redo.add_do_method(Global, "redo", [Global.canvas])
|
Global.undo_redo.add_do_method(Global, "redo", Global.canvases)
|
||||||
Global.undo_redo.commit_action()
|
Global.undo_redo.commit_action()
|
||||||
|
|
||||||
2: # Flip Horizontal
|
2: # Flip Horizontal
|
||||||
var canvas : Canvas = Global.canvas
|
var canvas : Canvas = Global.canvas
|
||||||
canvas.handle_undo("Draw")
|
canvas.handle_undo("Draw")
|
||||||
|
@ -395,6 +402,7 @@ func image_menu_id_pressed(id : int) -> void:
|
||||||
canvas.layers[Global.current_layer][0].flip_x()
|
canvas.layers[Global.current_layer][0].flip_x()
|
||||||
canvas.layers[Global.current_layer][0].lock()
|
canvas.layers[Global.current_layer][0].lock()
|
||||||
canvas.handle_redo("Draw")
|
canvas.handle_redo("Draw")
|
||||||
|
|
||||||
3: # Flip Vertical
|
3: # Flip Vertical
|
||||||
var canvas : Canvas = Global.canvas
|
var canvas : Canvas = Global.canvas
|
||||||
canvas.handle_undo("Draw")
|
canvas.handle_undo("Draw")
|
||||||
|
@ -402,11 +410,13 @@ func image_menu_id_pressed(id : int) -> void:
|
||||||
canvas.layers[Global.current_layer][0].flip_y()
|
canvas.layers[Global.current_layer][0].flip_y()
|
||||||
canvas.layers[Global.current_layer][0].lock()
|
canvas.layers[Global.current_layer][0].lock()
|
||||||
canvas.handle_redo("Draw")
|
canvas.handle_redo("Draw")
|
||||||
|
|
||||||
4: # Rotate
|
4: # Rotate
|
||||||
var image : Image = Global.canvas.layers[Global.current_layer][0]
|
var image : Image = Global.canvas.layers[Global.current_layer][0]
|
||||||
$RotateImage.set_sprite(image)
|
$RotateImage.set_sprite(image)
|
||||||
$RotateImage.popup_centered()
|
$RotateImage.popup_centered()
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
|
|
||||||
5: # Invert Colors
|
5: # Invert Colors
|
||||||
var image : Image = Global.canvas.layers[Global.current_layer][0]
|
var image : Image = Global.canvas.layers[Global.current_layer][0]
|
||||||
Global.canvas.handle_undo("Draw")
|
Global.canvas.handle_undo("Draw")
|
||||||
|
@ -417,6 +427,7 @@ func image_menu_id_pressed(id : int) -> void:
|
||||||
continue
|
continue
|
||||||
image.set_pixel(xx, yy, px_color)
|
image.set_pixel(xx, yy, px_color)
|
||||||
Global.canvas.handle_redo("Draw")
|
Global.canvas.handle_redo("Draw")
|
||||||
|
|
||||||
6: # Desaturation
|
6: # Desaturation
|
||||||
var image : Image = Global.canvas.layers[Global.current_layer][0]
|
var image : Image = Global.canvas.layers[Global.current_layer][0]
|
||||||
Global.canvas.handle_undo("Draw")
|
Global.canvas.handle_undo("Draw")
|
||||||
|
@ -429,9 +440,11 @@ func image_menu_id_pressed(id : int) -> void:
|
||||||
px_color = Color(gray, gray, gray, px_color.a)
|
px_color = Color(gray, gray, gray, px_color.a)
|
||||||
image.set_pixel(xx, yy, px_color)
|
image.set_pixel(xx, yy, px_color)
|
||||||
Global.canvas.handle_redo("Draw")
|
Global.canvas.handle_redo("Draw")
|
||||||
|
|
||||||
7: # Outline
|
7: # Outline
|
||||||
$OutlineDialog.popup_centered()
|
$OutlineDialog.popup_centered()
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
|
|
||||||
8: # HSV
|
8: # HSV
|
||||||
$HSVDialog.popup_centered()
|
$HSVDialog.popup_centered()
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
|
|
Loading…
Reference in a new issue