diff --git a/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd b/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd index d3805dee3..2ca104da1 100644 --- a/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd +++ b/src/UI/Dialogs/ImageEffects/ResizeCanvas.gd @@ -8,56 +8,66 @@ var image := Image.create(1, 1, false, Image.FORMAT_RGBA8) @onready var width_spinbox: SpinBox = $VBoxContainer/OptionsContainer/WidthValue @onready var height_spinbox: SpinBox = $VBoxContainer/OptionsContainer/HeightValue -@onready var x_spinbox: SpinBox = $VBoxContainer/OptionsContainer/XSpinBox -@onready var y_spinbox: SpinBox = $VBoxContainer/OptionsContainer/YSpinBox +@onready var x_offset_spinbox: SpinBox = $VBoxContainer/OptionsContainer/XOffsetSpinBox +@onready var y_offset_spinbox: SpinBox = $VBoxContainer/OptionsContainer/YOffsetSpinBox @onready var aspect_ratio_container: AspectRatioContainer = $VBoxContainer/AspectRatioContainer @onready var preview_rect: TextureRect = $VBoxContainer/AspectRatioContainer/Preview -func _on_ResizeCanvas_about_to_show() -> void: +func _on_about_to_popup() -> void: Global.canvas.selection.transform_content_confirm() image.resize(Global.current_project.size.x, Global.current_project.size.y) image.fill(Color(0.0, 0.0, 0.0, 0.0)) var frame := Global.current_project.frames[Global.current_project.current_frame] DrawingAlgos.blend_layers(image, frame) - width_spinbox.value = Global.current_project.size.x - height_spinbox.value = Global.current_project.size.y + if width_spinbox.value == Global.current_project.size.x: + _on_width_value_changed(width_spinbox.value) + else: + width_spinbox.value = Global.current_project.size.x + if height_spinbox.value == Global.current_project.size.y: + _on_height_value_changed(height_spinbox.value) + else: + height_spinbox.value = Global.current_project.size.y update_preview() -func _on_ResizeCanvas_confirmed() -> void: +func _on_confirmed() -> void: DrawingAlgos.resize_canvas(width, height, offset_x, offset_y) -func _on_WidthValue_value_changed(value: int) -> void: +func _on_width_value_changed(value: int) -> void: width = value - x_spinbox.min_value = mini(width - Global.current_project.size.x, 0) - x_spinbox.max_value = maxi(width - Global.current_project.size.x, 0) - x_spinbox.value = clampi(x_spinbox.value, x_spinbox.min_value, x_spinbox.max_value) + x_offset_spinbox.min_value = mini(width - Global.current_project.size.x, 0) + x_offset_spinbox.max_value = maxi(width - Global.current_project.size.x, 0) + x_offset_spinbox.value = clampi( + x_offset_spinbox.value, x_offset_spinbox.min_value, x_offset_spinbox.max_value + ) update_preview() -func _on_HeightValue_value_changed(value: int) -> void: +func _on_height_value_changed(value: int) -> void: height = value - y_spinbox.min_value = mini(height - Global.current_project.size.y, 0) - y_spinbox.max_value = maxi(height - Global.current_project.size.y, 0) - y_spinbox.value = clampi(y_spinbox.value, y_spinbox.min_value, y_spinbox.max_value) + y_offset_spinbox.min_value = mini(height - Global.current_project.size.y, 0) + y_offset_spinbox.max_value = maxi(height - Global.current_project.size.y, 0) + y_offset_spinbox.value = clampi( + y_offset_spinbox.value, y_offset_spinbox.min_value, y_offset_spinbox.max_value + ) update_preview() -func _on_XSpinBox_value_changed(value: int) -> void: +func _on_x_offset_spin_box_value_changed(value: int) -> void: offset_x = value update_preview() -func _on_YSpinBox_value_changed(value: int) -> void: +func _on_y_offset_spin_box_value_changed(value: int) -> void: offset_y = value update_preview() -func _on_CenterButton_pressed() -> void: - x_spinbox.value = (x_spinbox.min_value + x_spinbox.max_value) / 2 - y_spinbox.value = (y_spinbox.min_value + y_spinbox.max_value) / 2 +func _on_center_button_pressed() -> void: + x_offset_spinbox.value = (x_offset_spinbox.min_value + x_offset_spinbox.max_value) / 2 + y_offset_spinbox.value = (y_offset_spinbox.min_value + y_offset_spinbox.max_value) / 2 func update_preview() -> void: diff --git a/src/UI/Dialogs/ImageEffects/ResizeCanvas.tscn b/src/UI/Dialogs/ImageEffects/ResizeCanvas.tscn index ab8db99e7..94b1f5562 100644 --- a/src/UI/Dialogs/ImageEffects/ResizeCanvas.tscn +++ b/src/UI/Dialogs/ImageEffects/ResizeCanvas.tscn @@ -6,13 +6,14 @@ [node name="ResizeCanvas" type="ConfirmationDialog"] canvas_item_default_texture_filter = 0 title = "Resize Canvas" +size = Vector2i(216, 486) script = ExtResource("2") [node name="VBoxContainer" type="VBoxContainer" parent="."] offset_left = 8.0 offset_top = 8.0 offset_right = 208.0 -offset_bottom = 380.0 +offset_bottom = 437.0 [node name="ImageSize" type="Label" parent="VBoxContainer"] layout_mode = 2 @@ -61,24 +62,24 @@ text = "Offset" layout_mode = 2 size_flags_horizontal = 3 -[node name="XLabel" type="Label" parent="VBoxContainer/OptionsContainer"] +[node name="XOffsetLabel" type="Label" parent="VBoxContainer/OptionsContainer"] layout_mode = 2 size_flags_horizontal = 3 text = "X:" -[node name="XSpinBox" type="SpinBox" parent="VBoxContainer/OptionsContainer"] +[node name="XOffsetSpinBox" type="SpinBox" parent="VBoxContainer/OptionsContainer"] layout_mode = 2 size_flags_horizontal = 3 mouse_default_cursor_shape = 2 max_value = 0.0 suffix = "px" -[node name="YLabel" type="Label" parent="VBoxContainer/OptionsContainer"] +[node name="YOffsetLabel" type="Label" parent="VBoxContainer/OptionsContainer"] layout_mode = 2 size_flags_horizontal = 3 text = "Y:" -[node name="YSpinBox" type="SpinBox" parent="VBoxContainer/OptionsContainer"] +[node name="YOffsetSpinBox" type="SpinBox" parent="VBoxContainer/OptionsContainer"] layout_mode = 2 size_flags_horizontal = 3 mouse_default_cursor_shape = 2 @@ -105,11 +106,11 @@ stretch_mode = 5 show_behind_parent = true layout_mode = 2 -[connection signal="about_to_popup" from="." to="." method="_on_ResizeCanvas_about_to_show"] -[connection signal="confirmed" from="." to="." method="_on_ResizeCanvas_confirmed"] +[connection signal="about_to_popup" from="." to="." method="_on_about_to_popup"] +[connection signal="confirmed" from="." to="." method="_on_confirmed"] [connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] -[connection signal="value_changed" from="VBoxContainer/OptionsContainer/WidthValue" to="." method="_on_WidthValue_value_changed"] -[connection signal="value_changed" from="VBoxContainer/OptionsContainer/HeightValue" to="." method="_on_HeightValue_value_changed"] -[connection signal="value_changed" from="VBoxContainer/OptionsContainer/XSpinBox" to="." method="_on_XSpinBox_value_changed"] -[connection signal="value_changed" from="VBoxContainer/OptionsContainer/YSpinBox" to="." method="_on_YSpinBox_value_changed"] -[connection signal="pressed" from="VBoxContainer/OptionsContainer/CenterButton" to="." method="_on_CenterButton_pressed"] +[connection signal="value_changed" from="VBoxContainer/OptionsContainer/WidthValue" to="." method="_on_width_value_changed"] +[connection signal="value_changed" from="VBoxContainer/OptionsContainer/HeightValue" to="." method="_on_height_value_changed"] +[connection signal="value_changed" from="VBoxContainer/OptionsContainer/XOffsetSpinBox" to="." method="_on_x_offset_spin_box_value_changed"] +[connection signal="value_changed" from="VBoxContainer/OptionsContainer/YOffsetSpinBox" to="." method="_on_y_offset_spin_box_value_changed"] +[connection signal="pressed" from="VBoxContainer/OptionsContainer/CenterButton" to="." method="_on_center_button_pressed"]