From 118e2e7671986115e48f43e9b127e2c4063e9826 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Thu, 20 Apr 2023 22:29:03 +0300 Subject: [PATCH] Move set_nodes() logic to parent class ImageEffect Also fixes a crash when trying to change the affected cels option in image effects that do not have animation options --- src/Classes/ImageEffect.gd | 7 ++++++- src/UI/Dialogs/ImageEffects/DesaturateDialog.gd | 6 ------ src/UI/Dialogs/ImageEffects/DropShadowDialog.gd | 9 --------- src/UI/Dialogs/ImageEffects/FlipImageDialog.gd | 6 ------ src/UI/Dialogs/ImageEffects/GradientDialog.gd | 6 ------ src/UI/Dialogs/ImageEffects/GradientMapDialog.gd | 6 ------ src/UI/Dialogs/ImageEffects/HSVDialog.gd | 9 --------- src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd | 6 ------ src/UI/Dialogs/ImageEffects/OutlineDialog.gd | 9 --------- src/UI/Dialogs/ImageEffects/Posterize.gd | 6 ------ src/UI/Dialogs/ImageEffects/RotateImage.gd | 9 --------- src/UI/Dialogs/ImageEffects/RotateImage.tscn | 2 +- 12 files changed, 7 insertions(+), 74 deletions(-) diff --git a/src/Classes/ImageEffect.gd b/src/Classes/ImageEffect.gd index acfb8acca..6f465df82 100644 --- a/src/Classes/ImageEffect.gd +++ b/src/Classes/ImageEffect.gd @@ -122,7 +122,12 @@ func commit_action(_cel: Image, _project: Project = Global.current_project) -> v func set_nodes() -> void: - pass + preview = $VBoxContainer/AspectRatioContainer/Preview + selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox + affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton + animate_options_container = $VBoxContainer/AnimationOptions + animate_menu = $"%AnimateMenu".get_popup() + initial_button = $"%InitalButton" func set_animate_menu(elements: int) -> void: diff --git a/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd b/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd index b92ec5361..1544eef86 100644 --- a/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd +++ b/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd @@ -14,12 +14,6 @@ func _ready() -> void: preview.set_material(sm) -func set_nodes() -> void: - preview = $VBoxContainer/AspectRatioContainer/Preview - selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox - affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton - - func commit_action(cel: Image, project: Project = Global.current_project) -> void: var selection_tex := ImageTexture.new() if selection_checkbox.pressed and project.has_selection: diff --git a/src/UI/Dialogs/ImageEffects/DropShadowDialog.gd b/src/UI/Dialogs/ImageEffects/DropShadowDialog.gd index 54111dac4..66746baee 100644 --- a/src/UI/Dialogs/ImageEffects/DropShadowDialog.gd +++ b/src/UI/Dialogs/ImageEffects/DropShadowDialog.gd @@ -16,15 +16,6 @@ func _ready() -> void: preview.set_material(sm) -func set_nodes() -> void: - preview = $VBoxContainer/AspectRatioContainer/Preview - selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox - affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton - animate_options_container = $VBoxContainer/AnimationOptions - animate_menu = $"%AnimateMenu".get_popup() - initial_button = $"%InitalButton" - - func set_animate_menu(_elements) -> void: # set as in enum animate_menu.add_check_item("Offset X", Animate.OFFSET_X) diff --git a/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd b/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd index 4d0c5817d..aee63a937 100644 --- a/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd +++ b/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd @@ -4,12 +4,6 @@ onready var flip_h := $VBoxContainer/FlipOptions/FlipHorizontal as CheckBox onready var flip_v := $VBoxContainer/FlipOptions/FlipVertical as CheckBox -func set_nodes() -> void: - preview = $VBoxContainer/AspectRatioContainer/Preview - selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox - affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton - - func commit_action(cel: Image, project: Project = Global.current_project) -> void: _flip_image(cel, selection_checkbox.pressed, project) diff --git a/src/UI/Dialogs/ImageEffects/GradientDialog.gd b/src/UI/Dialogs/ImageEffects/GradientDialog.gd index bf2deb578..25ba89654 100644 --- a/src/UI/Dialogs/ImageEffects/GradientDialog.gd +++ b/src/UI/Dialogs/ImageEffects/GradientDialog.gd @@ -45,12 +45,6 @@ func _ready() -> void: dithering_option_button.add_item(matrix.name) -func set_nodes() -> void: - preview = $VBoxContainer/AspectRatioContainer/Preview - selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox - affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton - - func commit_action(cel: Image, project: Project = Global.current_project) -> void: var selection: Image var selection_tex := ImageTexture.new() diff --git a/src/UI/Dialogs/ImageEffects/GradientMapDialog.gd b/src/UI/Dialogs/ImageEffects/GradientMapDialog.gd index 2794f3070..7527fed04 100644 --- a/src/UI/Dialogs/ImageEffects/GradientMapDialog.gd +++ b/src/UI/Dialogs/ImageEffects/GradientMapDialog.gd @@ -9,12 +9,6 @@ func _ready() -> void: preview.set_material(sm) -func set_nodes() -> void: - preview = $VBoxContainer/AspectRatioContainer/Preview - selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox - affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton - - func commit_action(cel: Image, project: Project = Global.current_project) -> void: var selection_tex := ImageTexture.new() if selection_checkbox.pressed and project.has_selection: diff --git a/src/UI/Dialogs/ImageEffects/HSVDialog.gd b/src/UI/Dialogs/ImageEffects/HSVDialog.gd index 0e813c04f..49a134518 100644 --- a/src/UI/Dialogs/ImageEffects/HSVDialog.gd +++ b/src/UI/Dialogs/ImageEffects/HSVDialog.gd @@ -19,15 +19,6 @@ func _about_to_show() -> void: ._about_to_show() -func set_nodes() -> void: - preview = $VBoxContainer/AspectRatioContainer/Preview - selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox - affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton - animate_options_container = $VBoxContainer/AnimationOptions - animate_menu = $"%AnimateMenu".get_popup() - initial_button = $"%InitalButton" - - func set_animate_menu(_elements) -> void: # set as in enum animate_menu.add_check_item("Hue", Animate.HUE) diff --git a/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd b/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd index d17e9a727..16270cb29 100644 --- a/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd +++ b/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd @@ -14,12 +14,6 @@ func _ready() -> void: preview.set_material(sm) -func set_nodes() -> void: - preview = $VBoxContainer/AspectRatioContainer/Preview - selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox - affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton - - func commit_action(cel: Image, project: Project = Global.current_project) -> void: var selection_tex := ImageTexture.new() if selection_checkbox.pressed and project.has_selection: diff --git a/src/UI/Dialogs/ImageEffects/OutlineDialog.gd b/src/UI/Dialogs/ImageEffects/OutlineDialog.gd index a4bb3b57d..9e85cedbb 100644 --- a/src/UI/Dialogs/ImageEffects/OutlineDialog.gd +++ b/src/UI/Dialogs/ImageEffects/OutlineDialog.gd @@ -22,15 +22,6 @@ func _ready() -> void: color = outline_color.color -func set_nodes() -> void: - preview = $VBoxContainer/AspectRatioContainer/Preview - selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox - affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton - animate_options_container = $VBoxContainer/AnimationOptions - animate_menu = $"%AnimateMenu".get_popup() - initial_button = $"%InitalButton" - - func set_animate_menu(_elements) -> void: # set as in enum animate_menu.add_check_item("Thickness", Animate.THICKNESS) diff --git a/src/UI/Dialogs/ImageEffects/Posterize.gd b/src/UI/Dialogs/ImageEffects/Posterize.gd index 373dc87c1..0b443b5ce 100644 --- a/src/UI/Dialogs/ImageEffects/Posterize.gd +++ b/src/UI/Dialogs/ImageEffects/Posterize.gd @@ -11,12 +11,6 @@ func _ready() -> void: preview.set_material(sm) -func set_nodes() -> void: - preview = $VBoxContainer/AspectRatioContainer/Preview - selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox - affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton - - func commit_action(cel: Image, project: Project = Global.current_project) -> void: var selection_tex := ImageTexture.new() if selection_checkbox.pressed and project.has_selection: diff --git a/src/UI/Dialogs/ImageEffects/RotateImage.gd b/src/UI/Dialogs/ImageEffects/RotateImage.gd index 9d23975f4..5ee8fda03 100644 --- a/src/UI/Dialogs/ImageEffects/RotateImage.gd +++ b/src/UI/Dialogs/ImageEffects/RotateImage.gd @@ -34,15 +34,6 @@ func _ready() -> void: type_option_button.emit_signal("item_selected", 0) -func set_nodes() -> void: - preview = $VBoxContainer/AspectRatioContainer/Preview - selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox - affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton - animate_options_container = $VBoxContainer/AnimationOptions - animate_menu = $"%AnimateMenu".get_popup() - initial_button = $"%InitalButton" - - func set_animate_menu(_elements) -> void: # set as in enum animate_menu.add_check_item("Angle", Animate.ANGLE) diff --git a/src/UI/Dialogs/ImageEffects/RotateImage.tscn b/src/UI/Dialogs/ImageEffects/RotateImage.tscn index 9c1f6307a..4ccc88397 100644 --- a/src/UI/Dialogs/ImageEffects/RotateImage.tscn +++ b/src/UI/Dialogs/ImageEffects/RotateImage.tscn @@ -10,7 +10,7 @@ window_title = "Rotate Image" script = ExtResource( 1 ) [node name="VBoxContainer" parent="." index="3"] -margin_bottom = 458.0 +margin_bottom = 416.0 [node name="AspectRatioContainer" parent="VBoxContainer" index="0"] margin_right = 278.0