1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Compare commits

...

2 commits

Author SHA1 Message Date
Emmanouil Papadeas 77feb2434a Add V as a shortcut for the crop tool 2025-01-12 20:41:04 +02:00
Emmanouil Papadeas f273918368 Fix the resize canvas dialog's offset not resetting to zero on dialog popup
Also renamed some of the script's methods to be snake_case
2025-01-12 20:31:25 +02:00
3 changed files with 52 additions and 31 deletions

View file

@ -965,6 +965,16 @@ tile_flip_vertical={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":86,"key_label":0,"unicode":86,"location":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":86,"key_label":0,"unicode":86,"location":0,"echo":false,"script":null)
] ]
} }
left_crop_tool={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":86,"key_label":0,"unicode":118,"location":0,"echo":false,"script":null)
]
}
right_crop_tool={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":true,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":86,"key_label":0,"unicode":118,"location":0,"echo":false,"script":null)
]
}
[input_devices] [input_devices]

View file

@ -8,56 +8,66 @@ var image := Image.create(1, 1, false, Image.FORMAT_RGBA8)
@onready var width_spinbox: SpinBox = $VBoxContainer/OptionsContainer/WidthValue @onready var width_spinbox: SpinBox = $VBoxContainer/OptionsContainer/WidthValue
@onready var height_spinbox: SpinBox = $VBoxContainer/OptionsContainer/HeightValue @onready var height_spinbox: SpinBox = $VBoxContainer/OptionsContainer/HeightValue
@onready var x_spinbox: SpinBox = $VBoxContainer/OptionsContainer/XSpinBox @onready var x_offset_spinbox: SpinBox = $VBoxContainer/OptionsContainer/XOffsetSpinBox
@onready var y_spinbox: SpinBox = $VBoxContainer/OptionsContainer/YSpinBox @onready var y_offset_spinbox: SpinBox = $VBoxContainer/OptionsContainer/YOffsetSpinBox
@onready var aspect_ratio_container: AspectRatioContainer = $VBoxContainer/AspectRatioContainer @onready var aspect_ratio_container: AspectRatioContainer = $VBoxContainer/AspectRatioContainer
@onready var preview_rect: TextureRect = $VBoxContainer/AspectRatioContainer/Preview @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() Global.canvas.selection.transform_content_confirm()
image.resize(Global.current_project.size.x, Global.current_project.size.y) image.resize(Global.current_project.size.x, Global.current_project.size.y)
image.fill(Color(0.0, 0.0, 0.0, 0.0)) image.fill(Color(0.0, 0.0, 0.0, 0.0))
var frame := Global.current_project.frames[Global.current_project.current_frame] var frame := Global.current_project.frames[Global.current_project.current_frame]
DrawingAlgos.blend_layers(image, frame) DrawingAlgos.blend_layers(image, frame)
width_spinbox.value = Global.current_project.size.x if width_spinbox.value == Global.current_project.size.x:
height_spinbox.value = Global.current_project.size.y _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() update_preview()
func _on_ResizeCanvas_confirmed() -> void: func _on_confirmed() -> void:
DrawingAlgos.resize_canvas(width, height, offset_x, offset_y) 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 width = value
x_spinbox.min_value = mini(width - Global.current_project.size.x, 0) x_offset_spinbox.min_value = mini(width - Global.current_project.size.x, 0)
x_spinbox.max_value = maxi(width - Global.current_project.size.x, 0) x_offset_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.value = clampi(
x_offset_spinbox.value, x_offset_spinbox.min_value, x_offset_spinbox.max_value
)
update_preview() update_preview()
func _on_HeightValue_value_changed(value: int) -> void: func _on_height_value_changed(value: int) -> void:
height = value height = value
y_spinbox.min_value = mini(height - Global.current_project.size.y, 0) y_offset_spinbox.min_value = mini(height - Global.current_project.size.y, 0)
y_spinbox.max_value = maxi(height - Global.current_project.size.y, 0) y_offset_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.value = clampi(
y_offset_spinbox.value, y_offset_spinbox.min_value, y_offset_spinbox.max_value
)
update_preview() update_preview()
func _on_XSpinBox_value_changed(value: int) -> void: func _on_x_offset_spin_box_value_changed(value: int) -> void:
offset_x = value offset_x = value
update_preview() update_preview()
func _on_YSpinBox_value_changed(value: int) -> void: func _on_y_offset_spin_box_value_changed(value: int) -> void:
offset_y = value offset_y = value
update_preview() update_preview()
func _on_CenterButton_pressed() -> void: func _on_center_button_pressed() -> void:
x_spinbox.value = (x_spinbox.min_value + x_spinbox.max_value) / 2 x_offset_spinbox.value = (x_offset_spinbox.min_value + x_offset_spinbox.max_value) / 2
y_spinbox.value = (y_spinbox.min_value + y_spinbox.max_value) / 2 y_offset_spinbox.value = (y_offset_spinbox.min_value + y_offset_spinbox.max_value) / 2
func update_preview() -> void: func update_preview() -> void:

View file

@ -6,13 +6,14 @@
[node name="ResizeCanvas" type="ConfirmationDialog"] [node name="ResizeCanvas" type="ConfirmationDialog"]
canvas_item_default_texture_filter = 0 canvas_item_default_texture_filter = 0
title = "Resize Canvas" title = "Resize Canvas"
size = Vector2i(216, 486)
script = ExtResource("2") script = ExtResource("2")
[node name="VBoxContainer" type="VBoxContainer" parent="."] [node name="VBoxContainer" type="VBoxContainer" parent="."]
offset_left = 8.0 offset_left = 8.0
offset_top = 8.0 offset_top = 8.0
offset_right = 208.0 offset_right = 208.0
offset_bottom = 380.0 offset_bottom = 437.0
[node name="ImageSize" type="Label" parent="VBoxContainer"] [node name="ImageSize" type="Label" parent="VBoxContainer"]
layout_mode = 2 layout_mode = 2
@ -61,24 +62,24 @@ text = "Offset"
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
[node name="XLabel" type="Label" parent="VBoxContainer/OptionsContainer"] [node name="XOffsetLabel" type="Label" parent="VBoxContainer/OptionsContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "X:" text = "X:"
[node name="XSpinBox" type="SpinBox" parent="VBoxContainer/OptionsContainer"] [node name="XOffsetSpinBox" type="SpinBox" parent="VBoxContainer/OptionsContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
max_value = 0.0 max_value = 0.0
suffix = "px" suffix = "px"
[node name="YLabel" type="Label" parent="VBoxContainer/OptionsContainer"] [node name="YOffsetLabel" type="Label" parent="VBoxContainer/OptionsContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "Y:" text = "Y:"
[node name="YSpinBox" type="SpinBox" parent="VBoxContainer/OptionsContainer"] [node name="YOffsetSpinBox" type="SpinBox" parent="VBoxContainer/OptionsContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
@ -105,11 +106,11 @@ stretch_mode = 5
show_behind_parent = true show_behind_parent = true
layout_mode = 2 layout_mode = 2
[connection signal="about_to_popup" from="." to="." method="_on_ResizeCanvas_about_to_show"] [connection signal="about_to_popup" from="." to="." method="_on_about_to_popup"]
[connection signal="confirmed" from="." to="." method="_on_ResizeCanvas_confirmed"] [connection signal="confirmed" from="." to="." method="_on_confirmed"]
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"] [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/WidthValue" to="." method="_on_width_value_changed"]
[connection signal="value_changed" from="VBoxContainer/OptionsContainer/HeightValue" to="." method="_on_HeightValue_value_changed"] [connection signal="value_changed" from="VBoxContainer/OptionsContainer/HeightValue" to="." method="_on_height_value_changed"]
[connection signal="value_changed" from="VBoxContainer/OptionsContainer/XSpinBox" to="." method="_on_XSpinBox_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/YSpinBox" to="." method="_on_YSpinBox_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_CenterButton_pressed"] [connection signal="pressed" from="VBoxContainer/OptionsContainer/CenterButton" to="." method="_on_center_button_pressed"]