diff --git a/src/Autoload/DrawingAlgos.gd b/src/Autoload/DrawingAlgos.gd index 613036e28..bce1d1835 100644 --- a/src/Autoload/DrawingAlgos.gd +++ b/src/Autoload/DrawingAlgos.gd @@ -261,9 +261,8 @@ func crop_image() -> void: var used_rect := Rect2() for f in Global.current_project.frames: for cel in f.cels: - cel.image.unlock() + cel.image.unlock() # May be unneeded now, but keep it just in case var cel_used_rect : Rect2 = cel.image.get_used_rect() - cel.image.lock() if cel_used_rect == Rect2(0, 0, 0, 0): # If the cel has no content continue @@ -586,7 +585,6 @@ func generate_gradient(image : Image, colors : Array, steps : int, direction : i color = colors[-1].linear_interpolate(colors[0], t * i) colors.insert(1, color) - image.unlock() if direction == GradientDirection.BOTTOM or direction == GradientDirection.RIGHT: colors.invert() @@ -623,3 +621,5 @@ func generate_gradient(image : Image, colors : Array, steps : int, direction : i if selection and !project.selection_bitmap.get_bit(pos): continue image.set_pixelv(pos, colors[i]) + + image.unlock() diff --git a/src/Autoload/OpenSave.gd b/src/Autoload/OpenSave.gd index ce36236f0..40971ef0c 100644 --- a/src/Autoload/OpenSave.gd +++ b/src/Autoload/OpenSave.gd @@ -189,7 +189,6 @@ func open_old_pxo_file(file : File, new_project : Project, first_line : String) cel_opacity = file.get_float() var image := Image.new() image.create_from_data(width, height, false, Image.FORMAT_RGBA8, buffer) - image.lock() frame_class.cels.append(Cel.new(image, cel_opacity)) if file_major_version >= 0 and file_minor_version >= 7: if frame in linked_cels[layer_i]: @@ -352,7 +351,6 @@ func open_image_as_new_tab(path : String, image : Image) -> void: var frame := Frame.new() image.convert(Image.FORMAT_RGBA8) - image.lock() frame.cels.append(Cel.new(image, 1)) project.frames.append(frame) @@ -374,14 +372,12 @@ func open_image_as_spritesheet_tab(path : String, image : Image, horizontal : in cropped_image = image.get_rect(Rect2(frame_width * xx, frame_height * yy, frame_width, frame_height)) project.size = cropped_image.get_size() cropped_image.convert(Image.FORMAT_RGBA8) - cropped_image.lock() frame.cels.append(Cel.new(cropped_image, 1)) for _i in range(1, project.layers.size()): var empty_sprite := Image.new() empty_sprite.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8) empty_sprite.fill(Color(0, 0, 0, 0)) - empty_sprite.lock() frame.cels.append(Cel.new(empty_sprite, 1)) project.frames.append(frame) @@ -436,7 +432,6 @@ func open_image_at_frame(image : Image, layer_index := 0, frame_index := 0) -> v for i in project.frames.size(): if i == frame_index: image.convert(Image.FORMAT_RGBA8) - image.lock() frames[i].cels[layer_index] = (Cel.new(image, 1)) project.undo_redo.add_do_property(project.frames[i], "cels", frames[i].cels) project.undo_redo.add_undo_property(project.frames[i], "cels", project.frames[i].cels) @@ -461,12 +456,10 @@ func open_image_as_new_frame(image : Image, layer_index := 0) -> void: for i in project.layers.size(): if i == layer_index: image.convert(Image.FORMAT_RGBA8) - image.lock() frame.cels.append(Cel.new(image, 1)) else: var empty_image := Image.new() empty_image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8) - empty_image.lock() frame.cels.append(Cel.new(empty_image, 1)) new_frames.append(frame) @@ -498,12 +491,10 @@ func open_image_as_new_layer(image : Image, file_name : String, frame_index := 0 var new_cels : Array = project.frames[i].cels.duplicate(true) if i == frame_index: image.convert(Image.FORMAT_RGBA8) - image.lock() new_cels.append(Cel.new(image, 1)) else: var empty_image := Image.new() empty_image.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8) - empty_image.lock() new_cels.append(Cel.new(empty_image, 1)) project.undo_redo.add_do_property(project.frames[i], "cels", new_cels) diff --git a/src/Classes/ShaderImageEffect.gd b/src/Classes/ShaderImageEffect.gd index 5cfcc5418..6c02b4442 100644 --- a/src/Classes/ShaderImageEffect.gd +++ b/src/Classes/ShaderImageEffect.gd @@ -41,5 +41,4 @@ func generate_image(_img : Image,_shaderpath: String, _params : Dictionary , siz #Global.canvas.handle_undo("Draw") _img.copy_from(viewport_texture) #Global.canvas.handle_redo("Draw") - _img.lock() emit_signal("done") diff --git a/src/Tools/Bucket.gd b/src/Tools/Bucket.gd index ac60edbc0..e4a9b34da 100644 --- a/src/Tools/Bucket.gd +++ b/src/Tools/Bucket.gd @@ -124,8 +124,6 @@ func fill_in_color(position : Vector2) -> void: if tool_slot.color.is_equal_approx(color): return - image.lock() - for x in Global.current_project.size.x: for y in Global.current_project.size.y: var pos := Vector2(x, y) @@ -165,7 +163,6 @@ func _flood_fill(position : Vector2) -> void: if tool_slot.color.is_equal_approx(color): return - image.lock() var processed := BitMap.new() processed.create(image.get_size()) var q = [position] @@ -203,6 +200,7 @@ func _set_pixel(image : Image, x : int, y : int, color : Color) -> void: var px := int(x + _offset_x) % int(size.x) var py := int(y + _offset_y) % int(size.y) var pc := _pattern.image.get_pixel(px, py) + _pattern.image.unlock() image.set_pixel(x, y, pc) @@ -219,6 +217,7 @@ func commit_undo(action : String, undo_data : Dictionary) -> void: project.undo_redo.create_action(action) for image in redo_data: project.undo_redo.add_do_property(image, "data", redo_data[image]) + image.unlock() for image in undo_data: project.undo_redo.add_undo_property(image, "data", undo_data[image]) project.undo_redo.add_do_method(Global, "redo", frame, layer) diff --git a/src/Tools/Draw.gd b/src/Tools/Draw.gd index 79d30d306..c6b5b17b4 100644 --- a/src/Tools/Draw.gd +++ b/src/Tools/Draw.gd @@ -159,6 +159,7 @@ func commit_undo(action : String) -> void: project.undo_redo.create_action(action) for image in redo_data: project.undo_redo.add_do_property(image, "data", redo_data[image]) + image.unlock() for image in _undo_data: project.undo_redo.add_undo_property(image, "data", _undo_data[image]) project.undo_redo.add_do_method(Global, "redo", frame, layer) diff --git a/src/Tools/Move.gd b/src/Tools/Move.gd index 0b805ef9f..aecac5756 100644 --- a/src/Tools/Move.gd +++ b/src/Tools/Move.gd @@ -105,6 +105,7 @@ func commit_undo(action : String) -> void: project.undo_redo.create_action(action) for image in redo_data: project.undo_redo.add_do_property(image, "data", redo_data[image]) + image.unlock() for image in _undo_data: project.undo_redo.add_undo_property(image, "data", _undo_data[image]) project.undo_redo.add_do_method(Global, "redo", frame, layer) diff --git a/src/UI/Canvas/Canvas.gd b/src/UI/Canvas/Canvas.gd index 0f8a44017..89d8a144d 100644 --- a/src/UI/Canvas/Canvas.gd +++ b/src/UI/Canvas/Canvas.gd @@ -132,7 +132,6 @@ func new_empty_frame(first_time := false, single_layer := false, size := Global. fill_color = Global.config_cache.get_value("preferences", "default_fill_color") sprite.create(size.x, size.y, false, Image.FORMAT_RGBA8) sprite.fill(fill_color) - sprite.lock() frame.cels.append(Cel.new(sprite, 1)) if single_layer: diff --git a/src/UI/Canvas/Selection.gd b/src/UI/Canvas/Selection.gd index 539b3d73c..b4f25047a 100644 --- a/src/UI/Canvas/Selection.gd +++ b/src/UI/Canvas/Selection.gd @@ -538,6 +538,7 @@ func commit_undo(action : String, _undo_data : Dictionary) -> void: if not image is Image: continue project.undo_redo.add_do_property(image, "data", redo_data[image]) + image.unlock() for image in _undo_data: if not image is Image: continue diff --git a/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd b/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd index d55df164a..5a044319e 100644 --- a/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd +++ b/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd @@ -47,5 +47,6 @@ func flip_image(image : Image, affect_selection : bool, project : Project = Glob selected_image.flip_x() if flip_v.pressed: selected_image.flip_y() - + selected_image.unlock() image.blit_rect_mask(selected_image, selected_image, Rect2(Vector2.ZERO, selected_image.get_size()), Vector2.ZERO) + image.unlock() diff --git a/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd b/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd index 196e411d6..a416f607e 100644 --- a/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd +++ b/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd @@ -32,6 +32,7 @@ func _on_ResizeCanvas_about_to_show() -> void: var pixel_color := cel_image.get_pixel(xx, yy) var alpha : float = pixel_color.a * cel.opacity cel_image.set_pixel(xx, yy, Color(pixel_color.r, pixel_color.g, pixel_color.b, alpha)) + cel_image.unlock() image.blend_rect(cel_image, Rect2(Vector2.ZERO, Global.current_project.size), Vector2.ZERO) layer_i += 1 image.unlock() diff --git a/src/UI/Dialogs/ImageEffects/ShaderEffect.gd b/src/UI/Dialogs/ImageEffects/ShaderEffect.gd index 2663a699c..00b904bfd 100644 --- a/src/UI/Dialogs/ImageEffects/ShaderEffect.gd +++ b/src/UI/Dialogs/ImageEffects/ShaderEffect.gd @@ -63,7 +63,6 @@ func _on_ShaderEffect_confirmed() -> void: Global.canvas.handle_undo("Draw") current_cel.copy_from(viewport_texture) Global.canvas.handle_redo("Draw") - current_cel.lock() func _on_ShaderEffect_popup_hide() -> void: diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index ae8ac11b5..cad896bb6 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -1,5 +1,6 @@ extends Panel +var is_animation_running := false var animation_loop := 1 # 0 is no loop, 1 is cycle loop, 2 is ping-pong loop var animation_forward := true var first_frame := 0 @@ -173,7 +174,6 @@ func _on_CopyFrame_pressed(frame := -1) -> void: for cel in Global.current_project.frames[frame].cels: # Copy every cel var sprite := Image.new() sprite.copy_from(cel.image) - sprite.lock() var sprite_texture := ImageTexture.new() sprite_texture.create_from_image(sprite, 0) new_frame.cels.append(Cel.new(sprite, cel.opacity, sprite_texture)) @@ -304,6 +304,7 @@ func _on_AnimationTimer_timeout() -> void: Global.play_forward.pressed = false Global.play_backwards.pressed = false Global.animation_timer.stop() + is_animation_running = false 1: # Cycle loop Global.current_project.selected_cels.clear() Global.current_project.current_frame = first_frame @@ -325,6 +326,7 @@ func _on_AnimationTimer_timeout() -> void: Global.play_backwards.pressed = false Global.play_forward.pressed = false Global.animation_timer.stop() + is_animation_running = false 1: # Cycle loop Global.current_project.selected_cels.clear() Global.current_project.current_frame = last_frame @@ -372,6 +374,8 @@ func play_animation(play : bool, forward_dir : bool) -> void: else: Global.animation_timer.stop() + is_animation_running = play + func _on_NextFrame_pressed() -> void: Global.canvas.selection.transform_content_confirm() @@ -439,8 +443,6 @@ func add_layer(is_new := true) -> void: else: # Clone layer new_layer.copy_from(f.cels[Global.current_project.current_layer].image) - new_layer.lock() - var new_cels : Array = f.cels.duplicate() new_cels.append(Cel.new(new_layer, 1)) Global.current_project.undo_redo.add_do_property(f, "cels", new_cels) @@ -524,7 +526,6 @@ func _on_MergeDownLayer_pressed() -> void: new_cels[i] = Cel.new(new_cels[i].image, new_cels[i].opacity) var selected_layer := Image.new() selected_layer.copy_from(new_cels[Global.current_project.current_layer].image) - selected_layer.lock() if f.cels[Global.current_project.current_layer].opacity < 1: # If we have layer transparency for xx in selected_layer.get_size().x: @@ -535,7 +536,6 @@ func _on_MergeDownLayer_pressed() -> void: var new_layer := Image.new() new_layer.copy_from(f.cels[Global.current_project.current_layer - 1].image) - new_layer.lock() new_layer.blend_rect(selected_layer, Rect2(Vector2.ZERO, Global.current_project.size), Vector2.ZERO) new_cels.remove(Global.current_project.current_layer) if !selected_layer.is_invisible() and Global.current_project.layers[Global.current_project.current_layer - 1].linked_cels.size() > 1 and (f in Global.current_project.layers[Global.current_project.current_layer - 1].linked_cels): diff --git a/src/UI/Timeline/CelButton.gd b/src/UI/Timeline/CelButton.gd index 0ad551bf8..d86f7a293 100644 --- a/src/UI/Timeline/CelButton.gd +++ b/src/UI/Timeline/CelButton.gd @@ -116,7 +116,6 @@ func _on_PopupMenu_id_pressed(ID : int) -> void: new_layers[layer].linked_cels.remove(cel_index) var sprite := Image.new() sprite.copy_from(f.cels[layer].image) - sprite.lock() var sprite_texture := ImageTexture.new() sprite_texture.create_from_image(sprite, 0) new_cels[layer].image = sprite