mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 09:09:47 +00:00
Moved live preview code to ImageEffect Dialog (#978)
* live fixes * added accidentally disconected signals * Update RotateImage.tscn * improved code * Formatting
This commit is contained in:
parent
975f223ace
commit
81dbc0177d
|
@ -11,11 +11,15 @@ var current_frame := Image.create(1, 1, false, Image.FORMAT_RGBA8)
|
|||
var preview_image := Image.new()
|
||||
var aspect_ratio_container: AspectRatioContainer
|
||||
var preview: TextureRect
|
||||
var live_checkbox: CheckBox
|
||||
var wait_time_slider: ValueSlider
|
||||
var wait_apply_timer: Timer
|
||||
var selection_checkbox: CheckBox
|
||||
var affect_option_button: OptionButton
|
||||
var animate_panel: AnimatePanel
|
||||
var commit_idx := -1 ## The current frame the image effect is being applied to
|
||||
var has_been_confirmed := false
|
||||
var live_preview := true
|
||||
var _preview_idx := 0 ## The current frame being previewed
|
||||
|
||||
|
||||
|
@ -134,10 +138,14 @@ func commit_action(_cel: Image, _project := Global.current_project) -> void:
|
|||
func set_nodes() -> void:
|
||||
aspect_ratio_container = $VBoxContainer/AspectRatioContainer
|
||||
preview = $VBoxContainer/AspectRatioContainer/Preview
|
||||
live_checkbox = $VBoxContainer/LiveSettings/LiveCheckbox
|
||||
wait_time_slider = $VBoxContainer/LiveSettings/WaitTime
|
||||
wait_apply_timer = $VBoxContainer/LiveSettings/WaitApply
|
||||
selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox
|
||||
affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton
|
||||
animate_panel = $"%AnimatePanel"
|
||||
animate_panel.image_effect_node = self
|
||||
live_checkbox.button_pressed = live_preview
|
||||
|
||||
|
||||
func display_animate_dialog():
|
||||
|
@ -205,7 +213,11 @@ func set_and_update_preview_image(frame_idx: int) -> void:
|
|||
update_preview()
|
||||
|
||||
|
||||
func update_preview() -> void:
|
||||
func update_preview(using_timer := false) -> void:
|
||||
if !live_preview and !using_timer:
|
||||
wait_apply_timer.start()
|
||||
return
|
||||
|
||||
match affect:
|
||||
SELECTED_CELS:
|
||||
preview_image.copy_from(selected_cels)
|
||||
|
@ -224,3 +236,19 @@ func _visibility_changed() -> void:
|
|||
selected_cels.resize(1, 1)
|
||||
current_frame.resize(1, 1)
|
||||
preview_image = Image.new()
|
||||
|
||||
|
||||
func _on_live_checkbox_toggled(toggled_on: bool) -> void:
|
||||
live_preview = toggled_on
|
||||
wait_time_slider.editable = !live_preview
|
||||
wait_time_slider.visible = !live_preview
|
||||
if !toggled_on:
|
||||
size.y += 1 # Reset size of dialog
|
||||
|
||||
|
||||
func _on_wait_apply_timeout() -> void:
|
||||
update_preview(true)
|
||||
|
||||
|
||||
func _on_wait_time_value_changed(value: float) -> void:
|
||||
wait_apply_timer.wait_time = value / 1000.0
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://bybqhhayl5ay5"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bybqhhayl5ay5"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dmlgx1jgau8a5" path="res://src/UI/Nodes/AnimatePanel.tscn" id="1"]
|
||||
[ext_resource type="PackedScene" uid="uid://3pmb60gpst7b" path="res://src/UI/Nodes/TransparentChecker.tscn" id="2"]
|
||||
[ext_resource type="Script" path="res://src/Classes/ImageEffect.gd" id="3"]
|
||||
[ext_resource type="Texture2D" uid="uid://blrd4x0ma7b3h" path="res://assets/graphics/misc/animate.png" id="4"]
|
||||
[ext_resource type="PackedScene" uid="uid://yjhp0ssng2mp" path="res://src/UI/Nodes/ValueSlider.tscn" id="4_whox6"]
|
||||
|
||||
[node name="ImageEffectParent" type="ConfirmationDialog"]
|
||||
canvas_item_default_texture_filter = 0
|
||||
size = Vector2i(360, 316)
|
||||
position = Vector2i(0, 36)
|
||||
size = Vector2i(362, 379)
|
||||
exclusive = false
|
||||
popup_window = true
|
||||
script = ExtResource("3")
|
||||
|
@ -15,8 +17,8 @@ script = ExtResource("3")
|
|||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
offset_left = 8.0
|
||||
offset_top = 8.0
|
||||
offset_right = 352.0
|
||||
offset_bottom = 267.0
|
||||
offset_right = 354.0
|
||||
offset_bottom = 330.0
|
||||
|
||||
[node name="ShowAnimate" type="Button" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
|
@ -54,6 +56,29 @@ anchors_preset = 0
|
|||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="LiveSettings" type="VBoxContainer" parent="VBoxContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="LiveCheckbox" type="CheckBox" parent="VBoxContainer/LiveSettings"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "Live Preview"
|
||||
|
||||
[node name="WaitTime" parent="VBoxContainer/LiveSettings" instance=ExtResource("4_whox6")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 1000.0
|
||||
value = 200.0
|
||||
editable = false
|
||||
prefix = "Preview delay:"
|
||||
suffix = "ms"
|
||||
|
||||
[node name="WaitApply" type="Timer" parent="VBoxContainer/LiveSettings"]
|
||||
|
||||
[node name="OptionsContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
|
@ -90,3 +115,7 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
offset_right = 0.0
|
||||
offset_bottom = 0.0
|
||||
|
||||
[connection signal="toggled" from="VBoxContainer/LiveSettings/LiveCheckbox" to="." method="_on_live_checkbox_toggled"]
|
||||
[connection signal="value_changed" from="VBoxContainer/LiveSettings/WaitTime" to="." method="_on_wait_time_value_changed"]
|
||||
[connection signal="timeout" from="VBoxContainer/LiveSettings/WaitApply" to="." method="_on_wait_apply_timeout"]
|
||||
|
|
|
@ -3,7 +3,6 @@ extends ImageEffect
|
|||
enum { ROTXEL_SMEAR, CLEANEDGE, OMNISCALE, NNS, NN, ROTXEL, URD }
|
||||
enum Animate { ANGLE, INITIAL_ANGLE }
|
||||
|
||||
var live_preview := true
|
||||
var rotxel_shader := preload("res://src/Shaders/Effects/Rotation/SmearRotxel.gdshader")
|
||||
var nn_shader := preload("res://src/Shaders/Effects/Rotation/NearestNeighbour.gdshader")
|
||||
var pivot := Vector2.INF
|
||||
|
@ -16,8 +15,6 @@ var drag_pivot := false
|
|||
@onready var smear_options: Container = $VBoxContainer/SmearOptions
|
||||
@onready var init_angle_slider: ValueSlider = smear_options.get_node("InitialAngleSlider")
|
||||
@onready var tolerance_slider: ValueSlider = smear_options.get_node("ToleranceSlider")
|
||||
@onready var wait_apply_timer: Timer = $WaitApply
|
||||
@onready var wait_time_slider: ValueSlider = $VBoxContainer/WaitTime
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -178,40 +175,15 @@ func _on_TypeOptionButton_item_selected(_id: int) -> void:
|
|||
|
||||
|
||||
func _on_AngleSlider_value_changed(_value: float) -> void:
|
||||
if live_preview:
|
||||
update_preview()
|
||||
else:
|
||||
wait_apply_timer.start()
|
||||
|
||||
|
||||
func _on_InitialAngleSlider_value_changed(_value: float) -> void:
|
||||
if live_preview:
|
||||
update_preview()
|
||||
else:
|
||||
wait_apply_timer.start()
|
||||
|
||||
|
||||
func _on_ToleranceSlider_value_changed(_value: float) -> void:
|
||||
if live_preview:
|
||||
update_preview()
|
||||
else:
|
||||
wait_apply_timer.start()
|
||||
|
||||
|
||||
func _on_WaitApply_timeout() -> void:
|
||||
update_preview()
|
||||
|
||||
|
||||
func _on_WaitTime_value_changed(value: float) -> void:
|
||||
wait_apply_timer.wait_time = value / 1000.0
|
||||
func _on_InitialAngleSlider_value_changed(_value: float) -> void:
|
||||
update_preview()
|
||||
|
||||
|
||||
func _on_LiveCheckbox_toggled(button_pressed: bool) -> void:
|
||||
live_preview = button_pressed
|
||||
wait_time_slider.editable = !live_preview
|
||||
wait_time_slider.visible = !live_preview
|
||||
if !button_pressed:
|
||||
size.y += 1 # Reset size of dialog
|
||||
func _on_ToleranceSlider_value_changed(_value: float) -> void:
|
||||
update_preview()
|
||||
|
||||
|
||||
func _on_quick_change_angle_pressed(angle_value: int) -> void:
|
||||
|
|
|
@ -7,35 +7,20 @@
|
|||
|
||||
[node name="RotateImage" instance=ExtResource("2")]
|
||||
title = "Rotate Image"
|
||||
size = Vector2i(362, 535)
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="VBoxContainer" parent="." index="3"]
|
||||
offset_bottom = 416.0
|
||||
offset_bottom = 486.0
|
||||
|
||||
[node name="Indicator" type="Control" parent="VBoxContainer/AspectRatioContainer" index="1"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
|
||||
[node name="LiveSettings" type="HBoxContainer" parent="VBoxContainer" index="2"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
[node name="LiveSettings" parent="VBoxContainer" index="2"]
|
||||
visible = true
|
||||
|
||||
[node name="LiveCheckbox" type="CheckBox" parent="VBoxContainer/LiveSettings" index="0"]
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 2
|
||||
text = "Live Preview"
|
||||
|
||||
[node name="WaitTime" parent="VBoxContainer" index="3" instance=ExtResource("3")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
min_value = 1.0
|
||||
max_value = 1000.0
|
||||
value = 200.0
|
||||
editable = false
|
||||
prefix = "Preview delay:"
|
||||
suffix = "ms"
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer" index="4"]
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer" index="3"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2" index="0"]
|
||||
|
@ -48,10 +33,10 @@ size_flags_horizontal = 3
|
|||
size_flags_vertical = 3
|
||||
mouse_default_cursor_shape = 2
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer" index="5"]
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer" index="4"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PivotOptions" type="HBoxContainer" parent="VBoxContainer" index="6"]
|
||||
[node name="PivotOptions" type="HBoxContainer" parent="VBoxContainer" index="5"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Pivot" parent="VBoxContainer/PivotOptions" index="0" instance=ExtResource("4")]
|
||||
|
@ -70,17 +55,17 @@ tooltip_text = "Places the pivot at the center of the image, or at the center of
|
|||
mouse_default_cursor_shape = 2
|
||||
text = "Center"
|
||||
|
||||
[node name="HSeparator2" type="HSeparator" parent="VBoxContainer" index="7"]
|
||||
[node name="HSeparator2" type="HSeparator" parent="VBoxContainer" index="6"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="AngleSlider" parent="VBoxContainer" index="8" instance=ExtResource("3")]
|
||||
[node name="AngleSlider" parent="VBoxContainer" index="7" instance=ExtResource("3")]
|
||||
layout_mode = 2
|
||||
max_value = 359.0
|
||||
prefix = "Angle:"
|
||||
suffix = "°"
|
||||
snap_step = 45.0
|
||||
|
||||
[node name="QuickRotations" type="HBoxContainer" parent="VBoxContainer" index="9"]
|
||||
[node name="QuickRotations" type="HBoxContainer" parent="VBoxContainer" index="8"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
|
@ -114,7 +99,7 @@ size_flags_horizontal = 3
|
|||
mouse_default_cursor_shape = 2
|
||||
text = "+90"
|
||||
|
||||
[node name="SmearOptions" type="VBoxContainer" parent="VBoxContainer" index="10"]
|
||||
[node name="SmearOptions" type="VBoxContainer" parent="VBoxContainer" index="9"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
|
@ -139,15 +124,11 @@ prefix = "Initial angle:"
|
|||
suffix = "°"
|
||||
snap_step = 45.0
|
||||
|
||||
[node name="HSeparator3" type="HSeparator" parent="VBoxContainer" index="11"]
|
||||
[node name="HSeparator3" type="HSeparator" parent="VBoxContainer" index="10"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="WaitApply" type="Timer" parent="." index="5"]
|
||||
|
||||
[connection signal="draw" from="VBoxContainer/AspectRatioContainer/Indicator" to="." method="_on_Indicator_draw"]
|
||||
[connection signal="gui_input" from="VBoxContainer/AspectRatioContainer/Indicator" to="." method="_on_Indicator_gui_input"]
|
||||
[connection signal="toggled" from="VBoxContainer/LiveSettings/LiveCheckbox" to="." method="_on_LiveCheckbox_toggled"]
|
||||
[connection signal="value_changed" from="VBoxContainer/WaitTime" to="." method="_on_WaitTime_value_changed"]
|
||||
[connection signal="item_selected" from="VBoxContainer/HBoxContainer2/TypeOptionButton" to="." method="_on_TypeOptionButton_item_selected"]
|
||||
[connection signal="value_changed" from="VBoxContainer/PivotOptions/Pivot" to="." method="_on_Pivot_value_changed"]
|
||||
[connection signal="pressed" from="VBoxContainer/PivotOptions/Centre" to="." method="_on_Centre_pressed"]
|
||||
|
@ -159,4 +140,3 @@ layout_mode = 2
|
|||
[connection signal="pressed" from="VBoxContainer/QuickRotations/Add90" to="." method="_on_quick_change_angle_pressed" binds= [90]]
|
||||
[connection signal="value_changed" from="VBoxContainer/SmearOptions/ToleranceSlider" to="." method="_on_ToleranceSlider_value_changed"]
|
||||
[connection signal="value_changed" from="VBoxContainer/SmearOptions/InitialAngleSlider" to="." method="_on_InitialAngleSlider_value_changed"]
|
||||
[connection signal="timeout" from="WaitApply" to="." method="_on_WaitApply_timeout"]
|
||||
|
|
Loading…
Reference in a new issue