diff --git a/src/UI/Timeline/AnimationTimeline.gd b/src/UI/Timeline/AnimationTimeline.gd index df064d2d2..a909957bf 100644 --- a/src/UI/Timeline/AnimationTimeline.gd +++ b/src/UI/Timeline/AnimationTimeline.gd @@ -212,14 +212,14 @@ func _on_MoveLeft_pressed() -> void: var frame : int = Global.current_project.current_frame if frame == 0: return - Global.current_project.layers[Global.current_project.current_layer].frame_container.get_child(frame).change_frame_order(-1) + Global.frame_ids.get_child(frame).change_frame_order(-1) func _on_MoveRight_pressed() -> void: var frame : int = Global.current_project.current_frame if frame == last_frame: return - Global.current_project.layers[Global.current_project.current_layer].frame_container.get_child(frame).change_frame_order(1) + Global.frame_ids.get_child(frame).change_frame_order(1) func _on_OnionSkinning_pressed() -> void: diff --git a/src/UI/Timeline/CelButton.gd b/src/UI/Timeline/CelButton.gd index fa2f311bd..d37fddc1e 100644 --- a/src/UI/Timeline/CelButton.gd +++ b/src/UI/Timeline/CelButton.gd @@ -13,12 +13,12 @@ func _ready() -> void: hint_tooltip = tr("Frame: %s, Layer: %s") % [frame + 1, layer] if Global.current_project.frames[frame] in Global.current_project.layers[layer].linked_cels: get_node("LinkedIndicator").visible = true - popup_menu.set_item_text(4, "Unlink Cel") - popup_menu.set_item_metadata(4, "Unlink Cel") + popup_menu.set_item_text(0, "Unlink Cel") + popup_menu.set_item_metadata(0, "Unlink Cel") else: get_node("LinkedIndicator").visible = false - popup_menu.set_item_text(4, "Link Cel") - popup_menu.set_item_metadata(4, "Link Cel") + popup_menu.set_item_text(0, "Link Cel") + popup_menu.set_item_metadata(0, "Link Cel") # Reset the checkers size because it assumes you want the same size as the canvas var checker = $CelTexture/TransparentChecker @@ -40,16 +40,6 @@ func _on_CelButton_pressed() -> void: Global.current_project.current_frame = frame Global.current_project.current_layer = layer elif Input.is_action_just_released("right_mouse"): - if Global.current_project.frames.size() == 1: - popup_menu.set_item_disabled(0, true) - popup_menu.set_item_disabled(2, true) - popup_menu.set_item_disabled(3, true) - else: - popup_menu.set_item_disabled(0, false) - if frame > 0: - popup_menu.set_item_disabled(2, false) - if frame < Global.current_project.frames.size() - 1: - popup_menu.set_item_disabled(3, false) popup_menu.popup(Rect2(get_global_mouse_position(), Vector2.ONE)) pressed = !pressed elif Input.is_action_just_released("middle_mouse"): # Middle mouse click @@ -61,15 +51,7 @@ func _on_CelButton_pressed() -> void: func _on_PopupMenu_id_pressed(ID : int) -> void: match ID: - 0: # Remove Frame - Global.animation_timeline._on_DeleteFrame_pressed(frame) - 1: # Clone Frame - Global.animation_timeline._on_CopyFrame_pressed(frame) - 2: # Move Left - change_frame_order(-1) - 3: # Move Right - change_frame_order(1) - 4: # Unlink Cel + 0: # Unlink Cel var cel_index : int = Global.current_project.layers[layer].linked_cels.find(Global.current_project.frames[frame]) var f = Global.current_project.frames[frame] var new_layers : Array = Global.current_project.layers.duplicate() @@ -82,7 +64,7 @@ func _on_PopupMenu_id_pressed(ID : int) -> void: for i in new_cels.size(): new_cels[i] = Cel.new(new_cels[i].image, new_cels[i].opacity) - if popup_menu.get_item_metadata(4) == "Unlink Cel": + if popup_menu.get_item_metadata(0) == "Unlink Cel": new_layers[layer].linked_cels.remove(cel_index) var sprite := Image.new() sprite.copy_from(Global.current_project.frames[frame].cels[layer].image) @@ -98,7 +80,7 @@ func _on_PopupMenu_id_pressed(ID : int) -> void: Global.current_project.undo_redo.add_undo_method(Global, "undo") Global.current_project.undo_redo.add_do_method(Global, "redo") Global.current_project.undo_redo.commit_action() - elif popup_menu.get_item_metadata(4) == "Link Cel": + elif popup_menu.get_item_metadata(0) == "Link Cel": new_layers[layer].linked_cels.append(Global.current_project.frames[frame]) Global.current_project.undo_redo.create_action("Link Cel") Global.current_project.undo_redo.add_do_property(Global.current_project, "layers", new_layers) @@ -114,32 +96,6 @@ func _on_PopupMenu_id_pressed(ID : int) -> void: Global.current_project.undo_redo.add_undo_method(Global, "undo") Global.current_project.undo_redo.add_do_method(Global, "redo") Global.current_project.undo_redo.commit_action() - 5: # Frame Properties - Global.frame_properties.popup_centered() - Global.dialog_open(true) - Global.frame_properties.set_frame_label(frame) - Global.frame_properties.set_frame_dur(Global.current_project.frames[frame].duration) - - -func change_frame_order(rate : int) -> void: - var change = frame + rate - var new_frames : Array = Global.current_project.frames.duplicate() - var temp = new_frames[frame] - new_frames[frame] = new_frames[change] - new_frames[change] = temp - - Global.current_project.undo_redo.create_action("Change Frame Order") - Global.current_project.undo_redo.add_do_property(Global.current_project, "frames", new_frames) - - if Global.current_project.current_frame == frame: - Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", change) - Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", Global.current_project.current_frame) - - Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames) - - Global.current_project.undo_redo.add_undo_method(Global, "undo") - Global.current_project.undo_redo.add_do_method(Global, "redo") - Global.current_project.undo_redo.commit_action() func get_drag_data(_position) -> Array: diff --git a/src/UI/Timeline/CelButton.tscn b/src/UI/Timeline/CelButton.tscn index 996879970..8f9488459 100644 --- a/src/UI/Timeline/CelButton.tscn +++ b/src/UI/Timeline/CelButton.tscn @@ -7,6 +7,7 @@ [sub_resource type="ShaderMaterial" id=1] shader = ExtResource( 3 ) shader_param/size = 10.0 +shader_param/alpha = 1.0 shader_param/color1 = Color( 0.7, 0.7, 0.7, 1 ) shader_param/color2 = Color( 1, 1, 1, 1 ) shader_param/offset = Vector2( 0, 0 ) @@ -56,7 +57,7 @@ margin_bottom = 0.0 margin_right = 20.0 margin_bottom = 20.0 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, "Link Cel", null, 0, false, false, -1, 0, null, "", false, "Frame Properties", null, 0, false, false, 5, 0, null, "", false ] +items = [ "Link Cel", null, 0, false, false, -1, 0, null, "", false ] __meta__ = { "_edit_use_anchors_": false } @@ -66,6 +67,7 @@ color = Color( 0.0627451, 0.741176, 0.215686, 1 ) invert_enable = true invert_border = 1.0 polygon = PoolVector2Array( 0, 0, 36, 0, 36, 36, 0, 36 ) + [connection signal="pressed" from="." to="." method="_on_CelButton_pressed"] [connection signal="resized" from="." to="." method="_on_CelButton_resized"] [connection signal="id_pressed" from="PopupMenu" to="." method="_on_PopupMenu_id_pressed"] diff --git a/src/UI/Timeline/FrameButton.gd b/src/UI/Timeline/FrameButton.gd index c323fb3bc..422990dd2 100644 --- a/src/UI/Timeline/FrameButton.gd +++ b/src/UI/Timeline/FrameButton.gd @@ -3,10 +3,69 @@ extends Button var frame := 0 +onready var popup_menu : PopupMenu = $PopupMenu + func _ready() -> void: connect("pressed", self, "_button_pressed") func _button_pressed() -> void: - Global.current_project.current_frame = frame + if Input.is_action_just_released("left_mouse"): + Global.current_project.current_frame = frame + elif Input.is_action_just_released("right_mouse"): + if Global.current_project.frames.size() == 1: + popup_menu.set_item_disabled(0, true) + popup_menu.set_item_disabled(2, true) + popup_menu.set_item_disabled(3, true) + else: + popup_menu.set_item_disabled(0, false) + if frame > 0: + popup_menu.set_item_disabled(2, false) + if frame < Global.current_project.frames.size() - 1: + popup_menu.set_item_disabled(3, false) + popup_menu.popup(Rect2(get_global_mouse_position(), Vector2.ONE)) + pressed = !pressed + elif Input.is_action_just_released("middle_mouse"): # Middle mouse click + pressed = !pressed + Global.animation_timeline._on_DeleteFrame_pressed(frame) + else: # An example of this would be Space + pressed = !pressed + + +func _on_PopupMenu_id_pressed(id : int) -> void: + match id: + 0: # Remove Frame + Global.animation_timeline._on_DeleteFrame_pressed(frame) + 1: # Clone Frame + Global.animation_timeline._on_CopyFrame_pressed(frame) + 2: # Move Left + change_frame_order(-1) + 3: # Move Right + change_frame_order(1) + 4: # Frame Properties + Global.frame_properties.popup_centered() + Global.dialog_open(true) + Global.frame_properties.set_frame_label(frame) + Global.frame_properties.set_frame_dur(Global.current_project.frames[frame].duration) + + +func change_frame_order(rate : int) -> void: + var change = frame + rate + var new_frames : Array = Global.current_project.frames.duplicate() + var temp = new_frames[frame] + new_frames[frame] = new_frames[change] + new_frames[change] = temp + + Global.current_project.undo_redo.create_action("Change Frame Order") + Global.current_project.undo_redo.add_do_property(Global.current_project, "frames", new_frames) + + if Global.current_project.current_frame == frame: + Global.current_project.undo_redo.add_do_property(Global.current_project, "current_frame", change) + Global.current_project.undo_redo.add_undo_property(Global.current_project, "current_frame", Global.current_project.current_frame) + + Global.current_project.undo_redo.add_undo_property(Global.current_project, "frames", Global.current_project.frames) + + Global.current_project.undo_redo.add_undo_method(Global, "undo") + Global.current_project.undo_redo.add_do_method(Global, "redo") + Global.current_project.undo_redo.commit_action() diff --git a/src/UI/Timeline/FrameButton.tscn b/src/UI/Timeline/FrameButton.tscn index 5c52d24ed..a56f1303e 100644 --- a/src/UI/Timeline/FrameButton.tscn +++ b/src/UI/Timeline/FrameButton.tscn @@ -6,8 +6,20 @@ margin_right = 12.0 margin_bottom = 20.0 mouse_default_cursor_shape = 2 +button_mask = 7 text = "1" script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } + +[node name="PopupMenu" type="PopupMenu" parent="."] +margin_right = 20.0 +margin_bottom = 20.0 +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 ] +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="id_pressed" from="PopupMenu" to="." method="_on_PopupMenu_id_pressed"]