1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Put a transparent checker background to RotateImage dialog

Also made it extend the ImageEffect class.
This commit is contained in:
OverloadedOrama 2020-08-26 17:49:46 +03:00
parent e88b62ea44
commit b52a7c224a
4 changed files with 49 additions and 49 deletions

View file

@ -38,6 +38,8 @@ func _about_to_show() -> void:
Export.blend_layers(current_frame, frame) Export.blend_layers(current_frame, frame)
if selection_checkbox: if selection_checkbox:
_on_SelectionCheckBox_toggled(selection_checkbox.pressed) _on_SelectionCheckBox_toggled(selection_checkbox.pressed)
else:
update_preview()
update_transparent_background_size() update_transparent_background_size()

View file

@ -1,64 +1,63 @@
extends ConfirmationDialog extends ImageEffect
var texture : ImageTexture
var aux_img : Image
var layer : Image
func _ready() -> void: func _ready() -> void:
texture = ImageTexture.new()
aux_img = Image.new()
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Rotxel") $VBoxContainer/HBoxContainer2/OptionButton.add_item("Rotxel")
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Upscale, Rotate and Downscale") $VBoxContainer/HBoxContainer2/OptionButton.add_item("Upscale, Rotate and Downscale")
$VBoxContainer/HBoxContainer2/OptionButton.add_item("Nearest neighbour") $VBoxContainer/HBoxContainer2/OptionButton.add_item("Nearest neighbour")
func set_nodes() -> void:
preview = $VBoxContainer/Preview
func set_sprite(sprite : Image) -> void: func set_sprite(sprite : Image) -> void:
aux_img.copy_from(sprite) preview_image.copy_from(sprite)
layer = sprite current_cel = sprite
texture.create_from_image(aux_img, 0) preview_texture.create_from_image(preview_image, 0)
$VBoxContainer/TextureRect.texture = texture preview.texture = preview_texture
func _on_HSlider_value_changed(_value) -> void: func _about_to_show() -> void:
rotate() ._about_to_show()
$VBoxContainer/HBoxContainer/SpinBox.value = $VBoxContainer/HBoxContainer/HSlider.value $VBoxContainer/HBoxContainer/HSlider.value = 0
# set_sprite(current_cel)
func _on_SpinBox_value_changed(_value): func _confirmed() -> void:
$VBoxContainer/HBoxContainer/HSlider.value = $VBoxContainer/HBoxContainer/SpinBox.value
func _on_RotateImage_confirmed() -> void:
Global.canvas.handle_undo("Draw") Global.canvas.handle_undo("Draw")
match $VBoxContainer/HBoxContainer2/OptionButton.text: match $VBoxContainer/HBoxContainer2/OptionButton.text:
"Rotxel": "Rotxel":
DrawingAlgos.rotxel(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) DrawingAlgos.rotxel(current_cel,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
"Nearest neighbour": "Nearest neighbour":
DrawingAlgos.nn_rotate(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) DrawingAlgos.nn_rotate(current_cel,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
"Upscale, Rotate and Downscale": "Upscale, Rotate and Downscale":
DrawingAlgos.fake_rotsprite(layer,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) DrawingAlgos.fake_rotsprite(current_cel,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
Global.canvas.handle_redo("Draw") Global.canvas.handle_redo("Draw")
$VBoxContainer/HBoxContainer/HSlider.value = 0 $VBoxContainer/HBoxContainer/HSlider.value = 0
func rotate() -> void:
var sprite : Image = Image.new() func _on_HSlider_value_changed(_value : float) -> void:
sprite.copy_from(aux_img) update_preview()
$VBoxContainer/HBoxContainer/SpinBox.value = $VBoxContainer/HBoxContainer/HSlider.value
func _on_SpinBox_value_changed(_value : float) -> void:
$VBoxContainer/HBoxContainer/HSlider.value = $VBoxContainer/HBoxContainer/SpinBox.value
func update_preview() -> void:
preview_image.copy_from(current_cel)
match $VBoxContainer/HBoxContainer2/OptionButton.text: match $VBoxContainer/HBoxContainer2/OptionButton.text:
"Rotxel": "Rotxel":
DrawingAlgos.rotxel(sprite,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) DrawingAlgos.rotxel(preview_image,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
"Nearest neighbour": "Nearest neighbour":
DrawingAlgos.nn_rotate(sprite,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) DrawingAlgos.nn_rotate(preview_image,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
"Upscale, Rotate and Downscale": "Upscale, Rotate and Downscale":
DrawingAlgos.fake_rotsprite(sprite,$VBoxContainer/HBoxContainer/HSlider.value*PI/180) DrawingAlgos.fake_rotsprite(preview_image,$VBoxContainer/HBoxContainer/HSlider.value*PI/180)
texture.create_from_image(sprite, 0) preview_texture.create_from_image(preview_image, 0)
preview.texture = preview_texture
func _on_OptionButton_item_selected(_id) -> void: func _on_OptionButton_item_selected(_id : int) -> void:
rotate() update_preview()
func _on_RotateImage_about_to_show() -> void:
$VBoxContainer/HBoxContainer/HSlider.value = 0
func _on_RotateImage_popup_hide() -> void:
Global.dialog_open(false)

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://src/UI/Dialogs/ImageEffects/RotateImage.gd" type="Script" id=1] [ext_resource path="res://src/UI/Dialogs/ImageEffects/RotateImage.gd" type="Script" id=1]
[ext_resource path="res://src/UI/TransparentChecker.tscn" type="PackedScene" id=2]
[node name="RotateImage" type="ConfirmationDialog"] [node name="RotateImage" type="ConfirmationDialog"]
margin_right = 245.0 margin_right = 245.0
@ -23,12 +24,15 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="TextureRect" type="TextureRect" parent="VBoxContainer"] [node name="Preview" type="TextureRect" parent="VBoxContainer"]
margin_right = 229.0 margin_right = 229.0
margin_bottom = 145.0 margin_bottom = 145.0
size_flags_vertical = 3 rect_min_size = Vector2( 200, 200 )
expand = true expand = true
stretch_mode = 6 stretch_mode = 5
[node name="TransparentChecker" parent="VBoxContainer/Preview" instance=ExtResource( 2 )]
show_behind_parent = true
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"] [node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 149.0 margin_top = 149.0
@ -56,12 +60,12 @@ margin_bottom = 197.0
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"] [node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
margin_top = 5.0 margin_top = 5.0
margin_right = 44.0 margin_right = 40.0
margin_bottom = 19.0 margin_bottom = 19.0
text = "Angle:" text = "Angle:"
[node name="HSlider" type="HSlider" parent="VBoxContainer/HBoxContainer"] [node name="HSlider" type="HSlider" parent="VBoxContainer/HBoxContainer"]
margin_left = 48.0 margin_left = 44.0
margin_right = 151.0 margin_right = 151.0
margin_bottom = 24.0 margin_bottom = 24.0
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
@ -79,9 +83,6 @@ margin_bottom = 24.0
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
max_value = 359.0 max_value = 359.0
suffix = "°" suffix = "°"
[connection signal="about_to_show" from="." to="." method="_on_RotateImage_about_to_show"]
[connection signal="confirmed" from="." to="." method="_on_RotateImage_confirmed"]
[connection signal="popup_hide" from="." to="." method="_on_RotateImage_popup_hide"]
[connection signal="item_selected" from="VBoxContainer/HBoxContainer2/OptionButton" to="." method="_on_OptionButton_item_selected"] [connection signal="item_selected" from="VBoxContainer/HBoxContainer2/OptionButton" to="." method="_on_OptionButton_item_selected"]
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/HSlider" to="." method="_on_HSlider_value_changed"] [connection signal="value_changed" from="VBoxContainer/HBoxContainer/HSlider" to="." method="_on_HSlider_value_changed"]
[connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpinBox" to="." method="_on_SpinBox_value_changed"] [connection signal="value_changed" from="VBoxContainer/HBoxContainer/SpinBox" to="." method="_on_SpinBox_value_changed"]

View file

@ -352,8 +352,6 @@ func show_resize_canvas_popup() -> void:
func show_rotate_image_popup() -> void: func show_rotate_image_popup() -> void:
var image : Image = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image
Global.control.get_node("Dialogs/ImageEffects/RotateImage").set_sprite(image)
Global.control.get_node("Dialogs/ImageEffects/RotateImage").popup_centered() Global.control.get_node("Dialogs/ImageEffects/RotateImage").popup_centered()
Global.dialog_open(true) Global.dialog_open(true)