diff --git a/Prefabs/AnimationTimeline.tscn b/Prefabs/AnimationTimeline.tscn index 07f6b3f3a..44724c746 100644 --- a/Prefabs/AnimationTimeline.tscn +++ b/Prefabs/AnimationTimeline.tscn @@ -103,30 +103,26 @@ margin_right = 543.0 margin_bottom = 196.0 size_flags_horizontal = 3 -[node name="FrameLayerButtonContainer" type="HBoxContainer" parent="AnimationContainer/TimelineContainer"] +[node name="LayerButtons" type="HBoxContainer" parent="AnimationContainer/TimelineContainer"] margin_right = 543.0 -margin_bottom = 36.0 +margin_bottom = 32.0 -[node name="LayerButtons" type="HBoxContainer" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer"] -margin_right = 326.0 -margin_bottom = 36.0 - -[node name="AddLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons" groups=[ +[node name="AddLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/LayerButtons" groups=[ "UIButtons", ]] margin_right = 32.0 -margin_bottom = 36.0 +margin_bottom = 32.0 hint_tooltip = "LAYERNEW_HT" mouse_default_cursor_shape = 2 texture_normal = ExtResource( 2 ) texture_hover = ExtResource( 3 ) -[node name="RemoveLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons" groups=[ +[node name="RemoveLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/LayerButtons" groups=[ "UIButtons", ]] margin_left = 36.0 margin_right = 68.0 -margin_bottom = 36.0 +margin_bottom = 32.0 hint_tooltip = "LAYERREMOVE_HT" mouse_default_cursor_shape = 8 disabled = true @@ -134,12 +130,12 @@ texture_normal = ExtResource( 4 ) texture_hover = ExtResource( 5 ) texture_disabled = ExtResource( 6 ) -[node name="MoveUpLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons" groups=[ +[node name="MoveUpLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/LayerButtons" groups=[ "UIButtons", ]] margin_left = 72.0 margin_right = 104.0 -margin_bottom = 36.0 +margin_bottom = 32.0 hint_tooltip = "LAYERUP_HT" mouse_default_cursor_shape = 8 disabled = true @@ -147,12 +143,12 @@ texture_normal = ExtResource( 7 ) texture_hover = ExtResource( 8 ) texture_disabled = ExtResource( 9 ) -[node name="MovwDownLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons" groups=[ +[node name="MovwDownLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/LayerButtons" groups=[ "UIButtons", ]] margin_left = 108.0 margin_right = 140.0 -margin_bottom = 36.0 +margin_bottom = 32.0 hint_tooltip = "LAYERDOWN_HT" mouse_default_cursor_shape = 8 disabled = true @@ -160,23 +156,23 @@ texture_normal = ExtResource( 10 ) texture_hover = ExtResource( 11 ) texture_disabled = ExtResource( 12 ) -[node name="CloneLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons" groups=[ +[node name="CloneLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/LayerButtons" groups=[ "UIButtons", ]] margin_left = 144.0 margin_right = 176.0 -margin_bottom = 36.0 +margin_bottom = 32.0 hint_tooltip = "LAYERCLONE_HT" mouse_default_cursor_shape = 2 texture_normal = ExtResource( 13 ) texture_hover = ExtResource( 14 ) -[node name="MergeDownLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons" groups=[ +[node name="MergeDownLayer" type="TextureButton" parent="AnimationContainer/TimelineContainer/LayerButtons" groups=[ "UIButtons", ]] margin_left = 180.0 margin_right = 212.0 -margin_bottom = 36.0 +margin_bottom = 32.0 hint_tooltip = "LAYERMERGE_HT" mouse_default_cursor_shape = 8 disabled = true @@ -184,39 +180,30 @@ texture_normal = ExtResource( 15 ) texture_hover = ExtResource( 16 ) texture_disabled = ExtResource( 17 ) -[node name="TagsAndFrameIDs" type="VBoxContainer" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons"] +[node name="AnimationTags" type="VBoxContainer" parent="AnimationContainer/TimelineContainer/LayerButtons"] margin_left = 216.0 margin_right = 326.0 -margin_bottom = 36.0 +margin_bottom = 32.0 -[node name="AnimationTags" type="VBoxContainer" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons/TagsAndFrameIDs"] -editor/display_folded = true -margin_right = 110.0 -margin_bottom = 36.0 -size_flags_vertical = 0 - -[node name="Line2D" type="Line2D" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons/TagsAndFrameIDs/AnimationTags"] +[node name="Line2D" type="Line2D" parent="AnimationContainer/TimelineContainer/LayerButtons/AnimationTags"] points = PoolVector2Array( 0, 32, 0, 0, 110, 0, 110, 32 ) width = 1.0 -[node name="Label" type="Label" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons/TagsAndFrameIDs/AnimationTags"] +[node name="Label" type="Label" parent="AnimationContainer/TimelineContainer/LayerButtons/AnimationTags"] margin_right = 110.0 margin_bottom = 32.0 rect_min_size = Vector2( 110, 32 ) -size_flags_vertical = 1 +size_flags_horizontal = 0 +size_flags_vertical = 0 text = "Animation Tags" align = 1 valign = 1 -[node name="FramesContainer" type="HBoxContainer" parent="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons/TagsAndFrameIDs/AnimationTags"] -margin_top = 36.0 -margin_right = 110.0 -margin_bottom = 36.0 - [node name="OpacityContainer" type="HBoxContainer" parent="AnimationContainer/TimelineContainer"] -margin_top = 40.0 +editor/display_folded = true +margin_top = 36.0 margin_right = 543.0 -margin_bottom = 64.0 +margin_bottom = 60.0 custom_constants/separation = 2 [node name="OpacityLabel" type="Label" parent="AnimationContainer/TimelineContainer/OpacityContainer"] @@ -246,36 +233,50 @@ size_flags_vertical = 4 value = 100.0 align = 1 -[node name="FrameIDs" type="HBoxContainer" parent="AnimationContainer/TimelineContainer/OpacityContainer"] -margin_left = 245.0 -margin_right = 281.0 -margin_bottom = 24.0 +[node name="TimelineScroll" type="ScrollContainer" parent="AnimationContainer/TimelineContainer"] +margin_top = 64.0 +margin_right = 543.0 +margin_bottom = 160.0 +size_flags_vertical = 3 -[node name="Label" type="Label" parent="AnimationContainer/TimelineContainer/OpacityContainer/FrameIDs"] -margin_top = 5.0 +[node name="LayersAndFrames" type="HBoxContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll"] +margin_right = 252.0 +margin_bottom = 96.0 +size_flags_vertical = 3 + +[node name="LayersContainer" type="VBoxContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames"] +margin_right = 212.0 +margin_bottom = 96.0 + +[node name="LayerLabel" type="Label" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames/LayersContainer"] +margin_right = 212.0 +margin_bottom = 16.0 +rect_min_size = Vector2( 0, 16 ) +text = "Layers" +align = 1 +valign = 1 + +[node name="LayerContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames/LayersContainer" instance=ExtResource( 18 )] +margin_top = 20.0 +margin_right = 212.0 +margin_bottom = 56.0 + +[node name="FramesContainer" type="VBoxContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames"] +margin_left = 216.0 +margin_right = 252.0 +margin_bottom = 96.0 + +[node name="FrameIDs" type="HBoxContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames/FramesContainer"] margin_right = 36.0 -margin_bottom = 19.0 +margin_bottom = 14.0 + +[node name="Label" type="Label" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames/FramesContainer/FrameIDs"] +margin_right = 36.0 +margin_bottom = 14.0 rect_min_size = Vector2( 36, 0 ) text = "1" align = 1 -[node name="TimelineScroll" type="ScrollContainer" parent="AnimationContainer/TimelineContainer"] -margin_top = 68.0 -margin_right = 543.0 -margin_bottom = 160.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="LayersAndFrames" type="GridContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll"] -margin_right = 212.0 -margin_bottom = 36.0 -custom_constants/vseparation = 4 -custom_constants/hseparation = 4 -columns = 2 - -[node name="LayerContainer" parent="AnimationContainer/TimelineContainer/TimelineScroll/LayersAndFrames" instance=ExtResource( 18 )] -margin_right = 212.0 - [node name="HSeparator" type="HSeparator" parent="AnimationContainer/TimelineContainer"] margin_top = 164.0 margin_right = 543.0 @@ -476,12 +477,12 @@ margin_right = 689.0 margin_bottom = 196.0 [node name="AnimationTimer" type="Timer" parent="."] -[connection signal="pressed" from="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons/AddLayer" to="." method="add_layer" binds= [ true ]] -[connection signal="pressed" from="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons/RemoveLayer" to="." method="_on_RemoveLayer_pressed"] -[connection signal="pressed" from="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons/MoveUpLayer" to="." method="change_layer_order" binds= [ 1 ]] -[connection signal="pressed" from="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons/MovwDownLayer" to="." method="change_layer_order" binds= [ -1 ]] -[connection signal="pressed" from="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons/CloneLayer" to="." method="add_layer" binds= [ false ]] -[connection signal="pressed" from="AnimationContainer/TimelineContainer/FrameLayerButtonContainer/LayerButtons/MergeDownLayer" to="." method="_on_MergeDownLayer_pressed"] +[connection signal="pressed" from="AnimationContainer/TimelineContainer/LayerButtons/AddLayer" to="." method="add_layer" binds= [ true ]] +[connection signal="pressed" from="AnimationContainer/TimelineContainer/LayerButtons/RemoveLayer" to="." method="_on_RemoveLayer_pressed"] +[connection signal="pressed" from="AnimationContainer/TimelineContainer/LayerButtons/MoveUpLayer" to="." method="change_layer_order" binds= [ 1 ]] +[connection signal="pressed" from="AnimationContainer/TimelineContainer/LayerButtons/MovwDownLayer" to="." method="change_layer_order" binds= [ -1 ]] +[connection signal="pressed" from="AnimationContainer/TimelineContainer/LayerButtons/CloneLayer" to="." method="add_layer" binds= [ false ]] +[connection signal="pressed" from="AnimationContainer/TimelineContainer/LayerButtons/MergeDownLayer" to="." method="_on_MergeDownLayer_pressed"] [connection signal="value_changed" from="AnimationContainer/TimelineContainer/OpacityContainer/OpacitySlider" to="." method="_on_OpacitySlider_value_changed"] [connection signal="value_changed" from="AnimationContainer/TimelineContainer/OpacityContainer/OpacitySpinBox" to="." method="_on_OpacitySlider_value_changed"] [connection signal="pressed" from="AnimationContainer/TimelineContainer/AnimationButtons/AddFrame" to="." method="add_frame"] diff --git a/Scripts/Global.gd b/Scripts/Global.gd index e13f17cd7..3e3d3561e 100644 --- a/Scripts/Global.gd +++ b/Scripts/Global.gd @@ -231,7 +231,8 @@ var loop_animation_button : BaseButton var play_forward : BaseButton var play_backwards : BaseButton var timeline_seconds : Control -var layer_and_frame_container : GridContainer +var layers_container : VBoxContainer +var frames_container : VBoxContainer var remove_layer_button : BaseButton var move_up_layer_button : BaseButton @@ -342,7 +343,8 @@ func _ready() -> void: animation_timeline = find_node_by_name(root, "AnimationTimeline") - layer_and_frame_container = find_node_by_name(animation_timeline, "LayersAndFrames") + layers_container = find_node_by_name(animation_timeline, "LayersContainer") + frames_container = find_node_by_name(animation_timeline, "FramesContainer") animation_timer = find_node_by_name(animation_timeline, "AnimationTimer") frame_ids = find_node_by_name(animation_timeline, "FrameIDs") current_frame_label = find_node_by_name(animation_timeline, "CurrentFrame") @@ -373,7 +375,7 @@ func _ready() -> void: # Store [layer name, frame container] layers.append([tr("Layer") + " 0", HBoxContainer.new()]) - layer_and_frame_container.add_child(layers[0][1]) + frames_container.add_child(layers[0][1]) # Thanks to https://godotengine.org/qa/17524/how-to-find-an-instanced-scene-by-its-name func find_node_by_name(root, node_name) -> Node: @@ -417,7 +419,7 @@ func undo(_canvases : Array, layer_index : int = -1) -> void: if action_name == "Add Frame": canvas_parent.remove_child(_canvases[0]) - layer_and_frame_container.remove_child(_canvases[0].frame_button) + frames_container.remove_child(_canvases[0].frame_button) # This actually means that canvases.size is one, but it hasn't been updated yet if canvases.size() == 2: # Stop animating play_forward.pressed = false @@ -426,10 +428,10 @@ func undo(_canvases : Array, layer_index : int = -1) -> void: elif action_name == "Remove Frame": canvas_parent.add_child(_canvases[0]) canvas_parent.move_child(_canvases[0], _canvases[0].frame) - layer_and_frame_container.add_child(_canvases[0].frame_button) - layer_and_frame_container.move_child(_canvases[0].frame_button, _canvases[0].frame) + frames_container.add_child(_canvases[0].frame_button) + frames_container.move_child(_canvases[0].frame_button, _canvases[0].frame) elif action_name == "Change Frame Order": - layer_and_frame_container.move_child(_canvases[0].frame_button, _canvases[0].frame) + frames_container.move_child(_canvases[0].frame_button, _canvases[0].frame) canvas_parent.move_child(_canvases[0], _canvases[0].frame) canvas.update() @@ -459,11 +461,11 @@ func redo(_canvases : Array, layer_index : int = -1) -> void: layer_container.i = current_layer layer_container.get_child(0).get_child(1).text = _canvases[0].layers[current_layer][2] layer_container.get_child(0).get_child(2).text = _canvases[0].layers[current_layer][2] - layer_and_frame_container.add_child(layer_container) - layer_and_frame_container.move_child(layer_container, 0) + layers_container.add_child(layer_container) + layers_container.move_child(layer_container, 1) - layer_and_frame_container.add_child(layers[current_layer][1]) - layer_and_frame_container.move_child(layers[current_layer][1], 1) + frames_container.add_child(layers[current_layer][1]) + frames_container.move_child(layers[current_layer][1], 2) for i in range(canvases.size()): var frame_button = load("res://Prefabs/FrameButton.tscn").instance() frame_button.frame = i @@ -485,17 +487,17 @@ func redo(_canvases : Array, layer_index : int = -1) -> void: label.align = Label.ALIGN_CENTER label.text = str(canvases.size() + 1) frame_ids.add_child(label) - if !layer_and_frame_container.is_a_parent_of(_canvases[0].frame_button): - layer_and_frame_container.add_child(_canvases[0].frame_button) + if !frames_container.is_a_parent_of(_canvases[0].frame_button): + frames_container.add_child(_canvases[0].frame_button) elif action_name == "Remove Frame": canvas_parent.remove_child(_canvases[0]) - layer_and_frame_container.remove_child(_canvases[0].frame_button) + frames_container.remove_child(_canvases[0].frame_button) if canvases.size() == 1: # Stop animating play_forward.pressed = false play_backwards.pressed = false animation_timer.stop() elif action_name == "Change Frame Order": - layer_and_frame_container.move_child(_canvases[0].frame_button, _canvases[0].frame) + frames_container.move_child(_canvases[0].frame_button, _canvases[0].frame) canvas_parent.move_child(_canvases[0], _canvases[0].frame) canvas.update()