mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Move even more code away from Global and Project to AnimationTimeline
This time related to layer buttons
This commit is contained in:
parent
80e351a2a1
commit
f893e68d59
|
@ -489,14 +489,6 @@ var cel_button_scene: PackedScene = load("res://src/UI/Timeline/CelButton.tscn")
|
||||||
@onready var cel_vbox: VBoxContainer = animation_timeline.find_child("CelVBox")
|
@onready var cel_vbox: VBoxContainer = animation_timeline.find_child("CelVBox")
|
||||||
## The container of animation tags.
|
## The container of animation tags.
|
||||||
@onready var tag_container: Control = animation_timeline.find_child("TagContainer")
|
@onready var tag_container: Control = animation_timeline.find_child("TagContainer")
|
||||||
## Remove layer button.
|
|
||||||
@onready var remove_layer_button: BaseButton = animation_timeline.find_child("RemoveLayer")
|
|
||||||
## Move layer up button.
|
|
||||||
@onready var move_up_layer_button: BaseButton = animation_timeline.find_child("MoveUpLayer")
|
|
||||||
## Move layer down button.
|
|
||||||
@onready var move_down_layer_button: BaseButton = animation_timeline.find_child("MoveDownLayer")
|
|
||||||
## Merge with layer below button.
|
|
||||||
@onready var merge_down_layer_button: BaseButton = animation_timeline.find_child("MergeDownLayer")
|
|
||||||
|
|
||||||
## The brushes popup dialog used to display brushes.
|
## The brushes popup dialog used to display brushes.
|
||||||
## It has the [param BrushesPopup.gd] script attached.
|
## It has the [param BrushesPopup.gd] script attached.
|
||||||
|
|
|
@ -178,7 +178,6 @@ func change_project() -> void:
|
||||||
Global.animation_timeline.project_changed()
|
Global.animation_timeline.project_changed()
|
||||||
|
|
||||||
Global.current_frame_mark_label.text = "%s/%s" % [str(current_frame + 1), frames.size()]
|
Global.current_frame_mark_label.text = "%s/%s" % [str(current_frame + 1), frames.size()]
|
||||||
toggle_layer_buttons()
|
|
||||||
animation_tags = animation_tags
|
animation_tags = animation_tags
|
||||||
|
|
||||||
# Change the guides
|
# Change the guides
|
||||||
|
@ -516,7 +515,6 @@ func change_cel(new_frame: int, new_layer := -1) -> void:
|
||||||
|
|
||||||
if new_layer != current_layer: # If the layer has changed
|
if new_layer != current_layer: # If the layer has changed
|
||||||
current_layer = new_layer
|
current_layer = new_layer
|
||||||
toggle_layer_buttons()
|
|
||||||
|
|
||||||
Global.transparent_checker.update_rect()
|
Global.transparent_checker.update_rect()
|
||||||
Global.cel_changed.emit()
|
Global.cel_changed.emit()
|
||||||
|
@ -527,31 +525,6 @@ func change_cel(new_frame: int, new_layer := -1) -> void:
|
||||||
Global.canvas.queue_redraw()
|
Global.canvas.queue_redraw()
|
||||||
|
|
||||||
|
|
||||||
func toggle_layer_buttons() -> void:
|
|
||||||
if layers.is_empty() or current_layer >= layers.size():
|
|
||||||
return
|
|
||||||
var child_count: int = layers[current_layer].get_child_count(true)
|
|
||||||
|
|
||||||
Global.disable_button(
|
|
||||||
Global.remove_layer_button,
|
|
||||||
layers[current_layer].is_locked_in_hierarchy() or layers.size() == child_count + 1
|
|
||||||
)
|
|
||||||
Global.disable_button(Global.move_up_layer_button, current_layer == layers.size() - 1)
|
|
||||||
Global.disable_button(
|
|
||||||
Global.move_down_layer_button,
|
|
||||||
current_layer == child_count and not is_instance_valid(layers[current_layer].parent)
|
|
||||||
)
|
|
||||||
Global.disable_button(
|
|
||||||
Global.merge_down_layer_button,
|
|
||||||
(
|
|
||||||
current_layer == child_count
|
|
||||||
or layers[current_layer] is GroupLayer
|
|
||||||
or layers[current_layer - 1] is GroupLayer
|
|
||||||
or layers[current_layer - 1] is Layer3D
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
func _animation_tags_changed(value: Array[AnimationTag]) -> void:
|
func _animation_tags_changed(value: Array[AnimationTag]) -> void:
|
||||||
animation_tags = value
|
animation_tags = value
|
||||||
for child in Global.tag_container.get_children():
|
for child in Global.tag_container.get_children():
|
||||||
|
@ -866,4 +839,3 @@ func _update_layer_ui() -> void:
|
||||||
for f in frames.size():
|
for f in frames.size():
|
||||||
cel_hbox.get_child(f).layer = l
|
cel_hbox.get_child(f).layer = l
|
||||||
cel_hbox.get_child(f).button_setup()
|
cel_hbox.get_child(f).button_setup()
|
||||||
toggle_layer_buttons()
|
|
||||||
|
|
|
@ -20,15 +20,19 @@ var future_above_canvas := true
|
||||||
@onready var layer_settings_container := %LayerSettingsContainer as VBoxContainer
|
@onready var layer_settings_container := %LayerSettingsContainer as VBoxContainer
|
||||||
@onready var layer_container := %LayerContainer as VBoxContainer
|
@onready var layer_container := %LayerContainer as VBoxContainer
|
||||||
@onready var add_layer_list := %AddLayerList as MenuButton
|
@onready var add_layer_list := %AddLayerList as MenuButton
|
||||||
|
@onready var remove_layer := %RemoveLayer as Button
|
||||||
|
@onready var move_up_layer := %MoveUpLayer as Button
|
||||||
|
@onready var move_down_layer := %MoveDownLayer as Button
|
||||||
|
@onready var merge_down_layer := %MergeDownLayer as Button
|
||||||
@onready var blend_modes_button := %BlendModes as OptionButton
|
@onready var blend_modes_button := %BlendModes as OptionButton
|
||||||
@onready var opacity_slider: ValueSlider = %OpacitySlider
|
@onready var opacity_slider: ValueSlider = %OpacitySlider
|
||||||
@onready var frame_scroll_container := %FrameScrollContainer as Control
|
@onready var frame_scroll_container := %FrameScrollContainer as Control
|
||||||
@onready var frame_scroll_bar := %FrameScrollBar as HScrollBar
|
@onready var frame_scroll_bar := %FrameScrollBar as HScrollBar
|
||||||
@onready var tag_scroll_container := %TagScroll as ScrollContainer
|
@onready var tag_scroll_container := %TagScroll as ScrollContainer
|
||||||
@onready var layer_frame_h_split := %LayerFrameHSplit as HSplitContainer
|
@onready var layer_frame_h_split := %LayerFrameHSplit as HSplitContainer
|
||||||
@onready var delete_frame: Button = %DeleteFrame
|
@onready var delete_frame := %DeleteFrame as Button
|
||||||
@onready var move_frame_left: Button = %MoveFrameLeft
|
@onready var move_frame_left := %MoveFrameLeft as Button
|
||||||
@onready var move_frame_right: Button = %MoveFrameRight
|
@onready var move_frame_right := %MoveFrameRight as Button
|
||||||
@onready var play_backwards := %PlayBackwards as Button
|
@onready var play_backwards := %PlayBackwards as Button
|
||||||
@onready var play_forward := %PlayForward as Button
|
@onready var play_forward := %PlayForward as Button
|
||||||
@onready var fps_spinbox := %FPSValue as ValueSlider
|
@onready var fps_spinbox := %FPSValue as ValueSlider
|
||||||
|
@ -993,6 +997,7 @@ func _on_onion_skinning_settings_visibility_changed() -> void:
|
||||||
|
|
||||||
func _cel_changed() -> void:
|
func _cel_changed() -> void:
|
||||||
_toggle_frame_buttons()
|
_toggle_frame_buttons()
|
||||||
|
_toggle_layer_buttons()
|
||||||
var project := Global.current_project
|
var project := Global.current_project
|
||||||
var cel_opacity := project.get_current_cel().opacity
|
var cel_opacity := project.get_current_cel().opacity
|
||||||
opacity_slider.value = cel_opacity * 100
|
opacity_slider.value = cel_opacity * 100
|
||||||
|
@ -1009,9 +1014,36 @@ func _toggle_frame_buttons() -> void:
|
||||||
Global.disable_button(move_frame_right, project.current_frame == project.frames.size() - 1)
|
Global.disable_button(move_frame_right, project.current_frame == project.frames.size() - 1)
|
||||||
|
|
||||||
|
|
||||||
|
func _toggle_layer_buttons() -> void:
|
||||||
|
var project := Global.current_project
|
||||||
|
if project.layers.is_empty() or project.current_layer >= project.layers.size():
|
||||||
|
return
|
||||||
|
var layer := project.layers[project.current_layer]
|
||||||
|
var child_count := layer.get_child_count(true)
|
||||||
|
|
||||||
|
Global.disable_button(
|
||||||
|
remove_layer, layer.is_locked_in_hierarchy() or project.layers.size() == child_count + 1
|
||||||
|
)
|
||||||
|
Global.disable_button(move_up_layer, project.current_layer == project.layers.size() - 1)
|
||||||
|
Global.disable_button(
|
||||||
|
move_down_layer,
|
||||||
|
project.current_layer == child_count and not is_instance_valid(layer.parent)
|
||||||
|
)
|
||||||
|
Global.disable_button(
|
||||||
|
merge_down_layer,
|
||||||
|
(
|
||||||
|
project.current_layer == child_count
|
||||||
|
or layer is GroupLayer
|
||||||
|
or project.layers[project.current_layer - 1] is GroupLayer
|
||||||
|
or project.layers[project.current_layer - 1] is Layer3D
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func project_changed() -> void:
|
func project_changed() -> void:
|
||||||
var project := Global.current_project
|
var project := Global.current_project
|
||||||
_toggle_frame_buttons()
|
_toggle_frame_buttons()
|
||||||
|
_toggle_layer_buttons()
|
||||||
# These must be removed from tree immediately to not mess up the indices of
|
# These must be removed from tree immediately to not mess up the indices of
|
||||||
# the new buttons, so use either free or queue_free + parent.remove_child
|
# the new buttons, so use either free or queue_free + parent.remove_child
|
||||||
for layer_button in Global.layer_vbox.get_children():
|
for layer_button in Global.layer_vbox.get_children():
|
||||||
|
|
|
@ -254,6 +254,7 @@ offset_bottom = 6.0
|
||||||
texture = ExtResource("10")
|
texture = ExtResource("10")
|
||||||
|
|
||||||
[node name="RemoveLayer" type="Button" parent="TimelineContainer/TimelineButtons/LayerTools/LayerSettingsContainer/LayerButtons" groups=["UIButtons"]]
|
[node name="RemoveLayer" type="Button" parent="TimelineContainer/TimelineButtons/LayerTools/LayerSettingsContainer/LayerButtons" groups=["UIButtons"]]
|
||||||
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(24, 24)
|
custom_minimum_size = Vector2(24, 24)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
@ -279,6 +280,7 @@ size_flags_vertical = 0
|
||||||
texture = ExtResource("6")
|
texture = ExtResource("6")
|
||||||
|
|
||||||
[node name="MoveUpLayer" type="Button" parent="TimelineContainer/TimelineButtons/LayerTools/LayerSettingsContainer/LayerButtons" groups=["UIButtons"]]
|
[node name="MoveUpLayer" type="Button" parent="TimelineContainer/TimelineButtons/LayerTools/LayerSettingsContainer/LayerButtons" groups=["UIButtons"]]
|
||||||
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(24, 24)
|
custom_minimum_size = Vector2(24, 24)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
@ -304,6 +306,7 @@ size_flags_vertical = 0
|
||||||
texture = ExtResource("4")
|
texture = ExtResource("4")
|
||||||
|
|
||||||
[node name="MoveDownLayer" type="Button" parent="TimelineContainer/TimelineButtons/LayerTools/LayerSettingsContainer/LayerButtons" groups=["UIButtons"]]
|
[node name="MoveDownLayer" type="Button" parent="TimelineContainer/TimelineButtons/LayerTools/LayerSettingsContainer/LayerButtons" groups=["UIButtons"]]
|
||||||
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(24, 24)
|
custom_minimum_size = Vector2(24, 24)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
@ -353,6 +356,7 @@ size_flags_vertical = 0
|
||||||
texture = ExtResource("7")
|
texture = ExtResource("7")
|
||||||
|
|
||||||
[node name="MergeDownLayer" type="Button" parent="TimelineContainer/TimelineButtons/LayerTools/LayerSettingsContainer/LayerButtons" groups=["UIButtons"]]
|
[node name="MergeDownLayer" type="Button" parent="TimelineContainer/TimelineButtons/LayerTools/LayerSettingsContainer/LayerButtons" groups=["UIButtons"]]
|
||||||
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(24, 24)
|
custom_minimum_size = Vector2(24, 24)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
|
Loading…
Reference in a new issue