mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Make CelProperties its own scene and put it in Main.tscn instead of having it as a child of each CelButton
This drastically reduces the number of nodes. Before, each cel would have its own property node which, when the project had many cels, drove the node count quite high.
This commit is contained in:
parent
7f1aad280c
commit
b75573d19c
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=20 format=3 uid="uid://dbylw5k04ulp8"]
|
||||
[gd_scene load_steps=21 format=3 uid="uid://dbylw5k04ulp8"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://d6j8rvqw7ekv" path="res://assets/themes/dark/theme.tres" id="1"]
|
||||
[ext_resource type="Script" path="res://src/Main.gd" id="2"]
|
||||
|
@ -14,6 +14,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://b3aeqj2k58wdk" path="res://src/UI/Dialogs/OpenSprite.tscn" id="12"]
|
||||
[ext_resource type="PackedScene" uid="uid://d1phd84dk4t5e" path="res://src/UI/Dialogs/ManageLayouts.tscn" id="13"]
|
||||
[ext_resource type="PackedScene" uid="uid://c0nuukjakmai2" path="res://src/UI/Dialogs/TileModeOffsetsDialog.tscn" id="14"]
|
||||
[ext_resource type="PackedScene" uid="uid://clbjfkdupw52l" path="res://src/UI/Timeline/CelProperties.tscn" id="17_ucs64"]
|
||||
[ext_resource type="PackedScene" uid="uid://bnpb1aip3wdvw" path="res://src/UI/Dialogs/SplashDialog.tscn" id="27"]
|
||||
[ext_resource type="PackedScene" uid="uid://btjf3lj873q1t" path="res://src/UI/Dialogs/CreateNewImage.tscn" id="28"]
|
||||
[ext_resource type="PackedScene" uid="uid://b3hkjj3s6pe4x" path="res://src/Preferences/PreferencesDialog.tscn" id="32"]
|
||||
|
@ -99,6 +100,8 @@ dialog_text = "Autosaved project(s) from a crashed session were found.
|
|||
Do you want to recover the data?"
|
||||
dialog_autowrap = true
|
||||
|
||||
[node name="CelProperties" parent="Dialogs" instance=ExtResource("17_ucs64")]
|
||||
|
||||
[node name="FrameProperties" parent="Dialogs" instance=ExtResource("9")]
|
||||
|
||||
[node name="WindowOpacityDialog" parent="Dialogs" instance=ExtResource("10")]
|
||||
|
|
|
@ -15,8 +15,7 @@ var _call_theme_changed := true
|
|||
@onready var linked: ColorRect = $Linked
|
||||
@onready var cel_texture: TextureRect = $CelTexture
|
||||
@onready var transparent_checker: ColorRect = $CelTexture/TransparentChecker
|
||||
@onready var properties: AcceptDialog = $Properties
|
||||
@onready var opacity_slider: ValueSlider = %OpacitySlider
|
||||
@onready var properties: AcceptDialog = Global.control.find_child("CelProperties")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -120,7 +119,7 @@ func _on_CelButton_pressed() -> void:
|
|||
func _on_PopupMenu_id_pressed(id: int) -> void:
|
||||
match id:
|
||||
MenuOptions.PROPERTIES:
|
||||
opacity_slider.value = cel.opacity * 100.0
|
||||
properties.cel = cel
|
||||
properties.popup_centered()
|
||||
MenuOptions.DELETE:
|
||||
_delete_cel_content()
|
||||
|
@ -318,19 +317,3 @@ func _get_region_rect(x_begin: float, x_end: float) -> Rect2:
|
|||
rect.position.x += rect.size.x * x_begin
|
||||
rect.size.x *= x_end - x_begin
|
||||
return rect
|
||||
|
||||
|
||||
func _on_opacity_slider_value_changed(value: float) -> void:
|
||||
cel.opacity = value / 100.0
|
||||
Global.canvas.queue_redraw()
|
||||
|
||||
|
||||
func _on_z_index_slider_value_changed(value: float) -> void:
|
||||
cel.z_index = value
|
||||
Global.current_project.order_layers()
|
||||
Global.canvas.update_all_layers = true
|
||||
Global.canvas.queue_redraw()
|
||||
|
||||
|
||||
func _on_properties_visibility_changed() -> void:
|
||||
Global.dialog_open(properties.visible)
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dw7ci3uixjuev"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dw7ci3uixjuev"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/UI/Timeline/CelButton.gd" id="1_iewgo"]
|
||||
[ext_resource type="PackedScene" uid="uid://3pmb60gpst7b" path="res://src/UI/Nodes/TransparentChecker.tscn" id="2_mi8wp"]
|
||||
[ext_resource type="Shader" path="res://src/Shaders/TransparentChecker.gdshader" id="3_qv21g"]
|
||||
[ext_resource type="Script" path="res://src/UI/Nodes/ValueSlider.gd" id="4_wcpcc"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="1"]
|
||||
shader = ExtResource("3_qv21g")
|
||||
|
@ -83,63 +82,5 @@ item_2/id = 2
|
|||
item_3/text = "Unlink Cels"
|
||||
item_3/id = 3
|
||||
|
||||
[node name="Properties" type="AcceptDialog" parent="."]
|
||||
title = "Cel properties"
|
||||
size = Vector2i(300, 111)
|
||||
exclusive = false
|
||||
popup_window = true
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="Properties"]
|
||||
offset_left = 8.0
|
||||
offset_top = 8.0
|
||||
offset_right = 292.0
|
||||
offset_bottom = 66.0
|
||||
columns = 2
|
||||
|
||||
[node name="OpacityLabel" type="Label" parent="Properties/GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Opacity:"
|
||||
|
||||
[node name="OpacitySlider" type="TextureProgressBar" parent="Properties/GridContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
focus_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
theme_type_variation = &"ValueSlider"
|
||||
value = 100.0
|
||||
nine_patch_stretch = true
|
||||
stretch_margin_left = 3
|
||||
stretch_margin_top = 3
|
||||
stretch_margin_right = 3
|
||||
stretch_margin_bottom = 3
|
||||
script = ExtResource("4_wcpcc")
|
||||
|
||||
[node name="ZIndexLabel" type="Label" parent="Properties/GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Z-Index:"
|
||||
|
||||
[node name="ZIndexSlider" type="TextureProgressBar" parent="Properties/GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
focus_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
theme_type_variation = &"ValueSlider"
|
||||
min_value = -64.0
|
||||
max_value = 64.0
|
||||
allow_greater = true
|
||||
allow_lesser = true
|
||||
nine_patch_stretch = true
|
||||
stretch_margin_left = 3
|
||||
stretch_margin_top = 3
|
||||
stretch_margin_right = 3
|
||||
stretch_margin_bottom = 3
|
||||
script = ExtResource("4_wcpcc")
|
||||
|
||||
[connection signal="pressed" from="." to="." method="_on_CelButton_pressed"]
|
||||
[connection signal="id_pressed" from="PopupMenu" to="." method="_on_PopupMenu_id_pressed"]
|
||||
[connection signal="visibility_changed" from="Properties" to="." method="_on_properties_visibility_changed"]
|
||||
[connection signal="value_changed" from="Properties/GridContainer/OpacitySlider" to="." method="_on_opacity_slider_value_changed"]
|
||||
[connection signal="value_changed" from="Properties/GridContainer/ZIndexSlider" to="." method="_on_z_index_slider_value_changed"]
|
||||
|
|
31
src/UI/Timeline/CelProperties.gd
Normal file
31
src/UI/Timeline/CelProperties.gd
Normal file
|
@ -0,0 +1,31 @@
|
|||
extends AcceptDialog
|
||||
|
||||
var cel: BaseCel
|
||||
|
||||
@onready var opacity_slider := $GridContainer/OpacitySlider as ValueSlider
|
||||
@onready var z_index_slider := $GridContainer/ZIndexSlider as ValueSlider
|
||||
|
||||
|
||||
func _on_visibility_changed() -> void:
|
||||
Global.dialog_open(visible)
|
||||
if visible:
|
||||
opacity_slider.value = cel.opacity * 100.0
|
||||
z_index_slider.value = cel.z_index
|
||||
else:
|
||||
cel = null
|
||||
|
||||
|
||||
func _on_opacity_slider_value_changed(value: float) -> void:
|
||||
if not is_instance_valid(cel):
|
||||
return
|
||||
cel.opacity = value / 100.0
|
||||
Global.canvas.queue_redraw()
|
||||
|
||||
|
||||
func _on_z_index_slider_value_changed(value: float) -> void:
|
||||
if not is_instance_valid(cel):
|
||||
return
|
||||
cel.z_index = value
|
||||
Global.current_project.order_layers()
|
||||
Global.canvas.update_all_layers = true
|
||||
Global.canvas.queue_redraw()
|
63
src/UI/Timeline/CelProperties.tscn
Normal file
63
src/UI/Timeline/CelProperties.tscn
Normal file
|
@ -0,0 +1,63 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://clbjfkdupw52l"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/UI/Nodes/ValueSlider.gd" id="1_85pb7"]
|
||||
[ext_resource type="Script" path="res://src/UI/Timeline/CelProperties.gd" id="1_lyy7i"]
|
||||
|
||||
[node name="CelProperties" type="AcceptDialog"]
|
||||
title = "Cel properties"
|
||||
size = Vector2i(300, 111)
|
||||
exclusive = false
|
||||
popup_window = true
|
||||
script = ExtResource("1_lyy7i")
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="."]
|
||||
offset_left = 8.0
|
||||
offset_top = 8.0
|
||||
offset_right = 292.0
|
||||
offset_bottom = 66.0
|
||||
columns = 2
|
||||
|
||||
[node name="OpacityLabel" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Opacity:"
|
||||
|
||||
[node name="OpacitySlider" type="TextureProgressBar" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
focus_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
theme_type_variation = &"ValueSlider"
|
||||
value = 100.0
|
||||
nine_patch_stretch = true
|
||||
stretch_margin_left = 3
|
||||
stretch_margin_top = 3
|
||||
stretch_margin_right = 3
|
||||
stretch_margin_bottom = 3
|
||||
script = ExtResource("1_85pb7")
|
||||
|
||||
[node name="ZIndexLabel" type="Label" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Z-Index:"
|
||||
|
||||
[node name="ZIndexSlider" type="TextureProgressBar" parent="GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
focus_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
theme_type_variation = &"ValueSlider"
|
||||
min_value = -64.0
|
||||
max_value = 64.0
|
||||
allow_greater = true
|
||||
allow_lesser = true
|
||||
nine_patch_stretch = true
|
||||
stretch_margin_left = 3
|
||||
stretch_margin_top = 3
|
||||
stretch_margin_right = 3
|
||||
stretch_margin_bottom = 3
|
||||
script = ExtResource("1_85pb7")
|
||||
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
||||
[connection signal="value_changed" from="GridContainer/OpacitySlider" to="." method="_on_opacity_slider_value_changed"]
|
||||
[connection signal="value_changed" from="GridContainer/ZIndexSlider" to="." method="_on_z_index_slider_value_changed"]
|
Loading…
Reference in a new issue