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

Added option to affect all projects in the HSVDialog

HSVDialog should be ready now. These options will also appear in the rest of the image effects.
This commit is contained in:
OverloadedOrama 2020-07-24 03:41:10 +03:00
parent 95ccd42e48
commit 2cb07fb848
4 changed files with 51 additions and 38 deletions

View file

@ -277,71 +277,73 @@ func notification_label(text : String) -> void:
get_tree().get_root().add_child(notification)
func general_undo() -> void:
current_project.undos -= 1
var action_name : String = current_project.undo_redo.get_current_action_name()
func general_undo(project : Project = current_project) -> void:
project.undos -= 1
var action_name : String = project.undo_redo.get_current_action_name()
notification_label("Undo: %s" % action_name)
func general_redo() -> void:
if current_project.undos < current_project.undo_redo.get_version(): # If we did undo and then redo
current_project.undos = current_project.undo_redo.get_version()
func general_redo(project : Project = current_project) -> void:
if project.undos < project.undo_redo.get_version(): # If we did undo and then redo
project.undos = project.undo_redo.get_version()
if control.redone:
var action_name : String = current_project.undo_redo.get_current_action_name()
var action_name : String = project.undo_redo.get_current_action_name()
notification_label("Redo: %s" % action_name)
func undo(_frame_index := -1, _layer_index := -1) -> void:
general_undo()
var action_name : String = current_project.undo_redo.get_current_action_name()
func undo(_frame_index := -1, _layer_index := -1, project : Project = current_project) -> void:
general_undo(project)
var action_name : String = project.undo_redo.get_current_action_name()
if action_name == "Draw" or action_name == "Rectangle Select" or action_name == "Scale" or action_name == "Merge Layer" or action_name == "Link Cel" or action_name == "Unlink Cel":
if _layer_index > -1 and _frame_index > -1:
canvas.update_texture(_layer_index, _frame_index)
canvas.update_texture(_layer_index, _frame_index, project)
else:
for i in current_project.frames.size():
for j in current_project.layers.size():
canvas.update_texture(j, i)
for i in project.frames.size():
for j in project.layers.size():
canvas.update_texture(j, i, project)
if action_name == "Scale":
canvas.camera_zoom()
elif "Frame" in action_name:
# This actually means that frames.size is one, but it hasn't been updated yet
if current_project.frames.size() == 2: # Stop animating
if project.frames.size() == 2: # Stop animating
play_forward.pressed = false
play_backwards.pressed = false
animation_timer.stop()
canvas.update()
if !current_project.has_changed:
current_project.has_changed = true
self.window_title = window_title + "(*)"
if !project.has_changed:
project.has_changed = true
if project == current_project:
self.window_title = window_title + "(*)"
func redo(_frame_index := -1, _layer_index := -1) -> void:
general_redo()
var action_name : String = current_project.undo_redo.get_current_action_name()
func redo(_frame_index := -1, _layer_index := -1, project : Project = current_project) -> void:
general_redo(project)
var action_name : String = project.undo_redo.get_current_action_name()
if action_name == "Draw" or action_name == "Rectangle Select" or action_name == "Scale" or action_name == "Merge Layer" or action_name == "Link Cel" or action_name == "Unlink Cel":
if _layer_index > -1 and _frame_index > -1:
canvas.update_texture(_layer_index, _frame_index)
canvas.update_texture(_layer_index, _frame_index, project)
else:
for i in current_project.frames.size():
for j in current_project.layers.size():
canvas.update_texture(j, i)
for i in project.frames.size():
for j in project.layers.size():
canvas.update_texture(j, i, project)
if action_name == "Scale":
canvas.camera_zoom()
elif "Frame" in action_name:
if current_project.frames.size() == 1: # Stop animating
if project.frames.size() == 1: # Stop animating
play_forward.pressed = false
play_backwards.pressed = false
animation_timer.stop()
canvas.update()
if !current_project.has_changed:
current_project.has_changed = true
self.window_title = window_title + "(*)"
if !project.has_changed:
project.has_changed = true
if project == current_project:
self.window_title = window_title + "(*)"
func title_changed(value : String) -> void:

View file

@ -164,7 +164,7 @@ func handle_undo(action : String, project : Project = Global.current_project, la
var data = cel.image.data
cel.image.lock()
project.undo_redo.add_undo_property(cel.image, "data", data)
project.undo_redo.add_undo_method(Global, "undo", frame_index, layer_index)
project.undo_redo.add_undo_method(Global, "undo", frame_index, layer_index, project)
can_undo = false
@ -199,19 +199,20 @@ func handle_redo(_action : String, project : Project = Global.current_project, l
for cel in cels:
project.undo_redo.add_do_property(cel.image, "data", cel.image.data)
project.undo_redo.add_do_method(Global, "redo", frame_index, layer_index)
project.undo_redo.add_do_method(Global, "redo", frame_index, layer_index, project)
project.undo_redo.commit_action()
func update_texture(layer_index : int, frame_index := -1) -> void:
func update_texture(layer_index : int, frame_index := -1, project : Project = Global.current_project) -> void:
if frame_index == -1:
frame_index = Global.current_project.current_frame
var current_cel : Cel = Global.current_project.frames[frame_index].cels[layer_index]
frame_index = project.current_frame
var current_cel : Cel = project.frames[frame_index].cels[layer_index]
current_cel.image_texture.create_from_image(current_cel.image, 0)
var frame_texture_rect : TextureRect
frame_texture_rect = Global.find_node_by_name(Global.current_project.layers[layer_index].frame_container.get_child(frame_index), "CelTexture")
frame_texture_rect.texture = current_cel.image_texture
if project == Global.current_project:
var frame_texture_rect : TextureRect
frame_texture_rect = Global.find_node_by_name(project.layers[layer_index].frame_container.get_child(frame_index), "CelTexture")
frame_texture_rect.texture = current_cel.image_texture
func onion_skinning() -> void:

View file

@ -45,17 +45,27 @@ func _on_Apply_pressed() -> void:
Global.canvas.handle_undo("Draw")
DrawingAlgos.adjust_hsv(current_cel, hue_slider.value, sat_slider.value, val_slider.value, pixels)
Global.canvas.handle_redo("Draw")
elif affect == FRAME:
Global.canvas.handle_undo("Draw", Global.current_project, -1)
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
DrawingAlgos.adjust_hsv(cel.image, hue_slider.value, sat_slider.value, val_slider.value, pixels)
Global.canvas.handle_redo("Draw", Global.current_project, -1)
elif affect == ALL_FRAMES:
Global.canvas.handle_undo("Draw", Global.current_project, -1, -1)
for frame in Global.current_project.frames:
for cel in frame.cels:
DrawingAlgos.adjust_hsv(cel.image, hue_slider.value, sat_slider.value, val_slider.value, pixels)
Global.canvas.handle_redo("Draw", Global.current_project, -1, -1)
elif affect == ALL_PROJECTS:
for project in Global.projects:
Global.canvas.handle_undo("Draw", project, -1, -1)
for frame in project.frames:
for cel in frame.cels:
DrawingAlgos.adjust_hsv(cel.image, hue_slider.value, sat_slider.value, val_slider.value, pixels)
Global.canvas.handle_redo("Draw", project, -1, -1)
reset()
visible = false

View file

@ -150,7 +150,7 @@ margin_right = 263.0
margin_bottom = 24.0
mouse_default_cursor_shape = 2
text = "Current cel"
items = [ "Current cel", null, false, 0, null, "Current frame", null, false, 1, null, "All frames", null, false, 2, null, "All projects", null, true, 3, null ]
items = [ "Current cel", null, false, 0, null, "Current frame", null, false, 1, null, "All frames", null, false, 2, null, "All projects", null, false, 3, null ]
selected = 0
[node name="HBoxContainer2" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]