mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Add a transparent background for flip image dialog preview
Seems to be working fine, will do the same for the remaining dialogs.
This commit is contained in:
parent
0fbc2987ca
commit
ff54d2db8e
|
@ -24,6 +24,7 @@ func _ready() -> void:
|
|||
func _on_FlipImageDialog_about_to_show() -> void:
|
||||
current_cel = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image
|
||||
_on_SelectionCheckBox_toggled(selection_checkbox.pressed)
|
||||
update_transparent_background_size()
|
||||
|
||||
|
||||
func _on_FlipImageDialog_confirmed() -> void:
|
||||
|
@ -118,6 +119,19 @@ func flip_image(image : Image, _pixels : Array, project : Project = Global.curre
|
|||
image.blit_rect_mask(selected_image, selected_image, Rect2(Vector2.ZERO, selected_image.get_size()), Vector2.ZERO)
|
||||
|
||||
|
||||
func update_transparent_background_size() -> void:
|
||||
var image_size_y = preview.rect_size.y
|
||||
var image_size_x = preview.rect_size.x
|
||||
if preview_image.get_size().x > preview_image.get_size().y:
|
||||
var scale_ratio = preview_image.get_size().x / image_size_x
|
||||
image_size_y = preview_image.get_size().y / scale_ratio
|
||||
else:
|
||||
var scale_ratio = preview_image.get_size().y / image_size_y
|
||||
image_size_x = preview_image.get_size().x / scale_ratio
|
||||
|
||||
preview.get_node("TransparentChecker").rect_size.x = image_size_x
|
||||
preview.get_node("TransparentChecker").rect_size.y = image_size_y
|
||||
|
||||
|
||||
func _on_FlipImageDialog_popup_hide() -> void:
|
||||
Global.dialog_open(false)
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://src/UI/Dialogs/ImageEffects/FlipImageDialog.gd" type="Script" id=1]
|
||||
[ext_resource path="res://src/UI/TransparentChecker.tscn" type="PackedScene" id=2]
|
||||
|
||||
[node name="FlipImageDialog" type="ConfirmationDialog"]
|
||||
margin_right = 200.0
|
||||
margin_bottom = 70.0
|
||||
margin_right = 283.0
|
||||
margin_bottom = 300.0
|
||||
window_title = "Flip"
|
||||
resizable = true
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
|
@ -13,13 +15,21 @@ margin_left = 8.0
|
|||
margin_top = 8.0
|
||||
margin_right = 275.0
|
||||
margin_bottom = 264.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Preview" type="TextureRect" parent="VBoxContainer"]
|
||||
margin_right = 267.0
|
||||
margin_left = 33.0
|
||||
margin_right = 233.0
|
||||
margin_bottom = 200.0
|
||||
rect_min_size = Vector2( 200, 200 )
|
||||
size_flags_horizontal = 4
|
||||
expand = true
|
||||
stretch_mode = 6
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="TransparentChecker" parent="VBoxContainer/Preview" instance=ExtResource( 2 )]
|
||||
show_behind_parent = true
|
||||
|
||||
[node name="OptionsContainer" type="GridContainer" parent="VBoxContainer"]
|
||||
margin_top = 204.0
|
||||
|
|
|
@ -27,8 +27,6 @@ margin_bottom = 392.0
|
|||
[node name="RotateImage" parent="." instance=ExtResource( 9 )]
|
||||
|
||||
[node name="FlipImageDialog" parent="." instance=ExtResource( 1 )]
|
||||
margin_right = 283.0
|
||||
margin_bottom = 300.0
|
||||
|
||||
[node name="InvertColorsDialog" parent="." instance=ExtResource( 2 )]
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ func _on_ResizeCanvas_about_to_show() -> void:
|
|||
layer_i += 1
|
||||
image.unlock()
|
||||
|
||||
preview_rect.get_node("TransparentChecker").rect_size = preview_rect.rect_size
|
||||
update_preview()
|
||||
|
||||
|
||||
|
@ -80,6 +79,7 @@ func _on_CenterButton_pressed() -> void:
|
|||
|
||||
|
||||
func update_preview() -> void:
|
||||
# preview_image is the same as image but offsetted
|
||||
var preview_image := Image.new()
|
||||
preview_image.create(width, height, false, Image.FORMAT_RGBA8)
|
||||
preview_image.blend_rect(image, Rect2(Vector2.ZERO, Global.current_project.size), Vector2(offset_x, offset_y))
|
||||
|
|
|
@ -111,6 +111,7 @@ suffix = "px"
|
|||
margin_top = 130.0
|
||||
margin_right = 54.0
|
||||
margin_bottom = 150.0
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "Center"
|
||||
|
||||
[node name="Preview" type="TextureRect" parent="VBoxContainer"]
|
||||
|
|
Loading…
Reference in a new issue