diff --git a/src/Classes/ImageEffect.gd b/src/Classes/ImageEffect.gd index ef2be24..49f6d0e 100644 --- a/src/Classes/ImageEffect.gd +++ b/src/Classes/ImageEffect.gd @@ -12,6 +12,7 @@ var preview_image : Image var preview_texture : ImageTexture var preview : TextureRect var selection_checkbox : CheckBox +var affect_option_button : OptionButton func _ready() -> void: @@ -24,6 +25,8 @@ func _ready() -> void: connect("confirmed", self, "_confirmed") if selection_checkbox: selection_checkbox.connect("toggled", self, "_on_SelectionCheckBox_toggled") + if affect_option_button: + affect_option_button.connect("item_selected", self, "_on_AffectOptionButton_item_selected") func _about_to_show() -> void: @@ -53,6 +56,10 @@ func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void: update_preview() +func _on_AffectOptionButton_item_selected(index : int) -> void: + affect = index + + func update_preview() -> void: pass diff --git a/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd b/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd index 974b3ad..43a9e62 100644 --- a/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd +++ b/src/UI/Dialogs/ImageEffects/DesaturateDialog.gd @@ -1,35 +1,19 @@ -extends ConfirmationDialog +extends ImageEffect -enum {CEL, FRAME, ALL_FRAMES, ALL_PROJECTS} - -var affect : int = CEL -var pixels := [] -var current_cel : Image -var preview_image : Image -var preview_texture : ImageTexture - var red := true var green := true var blue := true var alpha := false -onready var preview : TextureRect = $VBoxContainer/Preview -onready var selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox + +func set_nodes() -> void: + preview = $VBoxContainer/Preview + selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox + affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton -func _ready() -> void: - current_cel = Image.new() - preview_image = Image.new() - preview_texture = ImageTexture.new() - - -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) - - -func _on_FlipImageDialog_confirmed() -> void: +func _confirmed() -> void: if affect == CEL: Global.canvas.handle_undo("Draw") DrawingAlgos.desaturate_image(current_cel, pixels, red, green, blue, alpha) @@ -84,29 +68,9 @@ func _on_AButton_toggled(button_pressed : bool) -> void: update_preview() -func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void: - pixels.clear() - if button_pressed: - pixels = Global.current_project.selected_pixels.duplicate() - else: - for x in Global.current_project.size.x: - for y in Global.current_project.size.y: - pixels.append(Vector2(x, y)) - - update_preview() - - -func _on_AffectOptionButton_item_selected(index : int) -> void: - affect = index - - func update_preview() -> void: preview_image.copy_from(current_cel) DrawingAlgos.desaturate_image(preview_image, pixels, red, green, blue, alpha) preview_image.unlock() preview_texture.create_from_image(preview_image, 0) preview.texture = preview_texture - - -func _on_FlipImageDialog_popup_hide() -> void: - Global.dialog_open(false) diff --git a/src/UI/Dialogs/ImageEffects/DesaturateDialog.tscn b/src/UI/Dialogs/ImageEffects/DesaturateDialog.tscn index 82ac6ed..80a4f55 100644 --- a/src/UI/Dialogs/ImageEffects/DesaturateDialog.tscn +++ b/src/UI/Dialogs/ImageEffects/DesaturateDialog.tscn @@ -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/DesaturateDialog.gd" type="Script" id=1] +[ext_resource path="res://src/UI/TransparentChecker.tscn" type="PackedScene" id=2] [node name="DesaturateDialog" type="ConfirmationDialog"] margin_right = 200.0 @@ -23,7 +24,10 @@ margin_right = 263.0 margin_bottom = 200.0 rect_min_size = Vector2( 200, 200 ) expand = true -stretch_mode = 6 +stretch_mode = 5 + +[node name="TransparentChecker" parent="VBoxContainer/Preview" instance=ExtResource( 2 )] +show_behind_parent = true [node name="RGBAContainer" type="HBoxContainer" parent="VBoxContainer"] margin_top = 204.0 @@ -90,12 +94,7 @@ mouse_default_cursor_shape = 2 text = "Current cel" items = [ "Current cel", null, false, 0, null, "Current frame", null, false, 1, null, "All frames", null, false, 2, null, "All projects", null, false, 3, null ] selected = 0 -[connection signal="about_to_show" from="." to="." method="_on_FlipImageDialog_about_to_show"] -[connection signal="confirmed" from="." to="." method="_on_FlipImageDialog_confirmed"] -[connection signal="popup_hide" from="." to="." method="_on_FlipImageDialog_popup_hide"] [connection signal="toggled" from="VBoxContainer/RGBAContainer/RButton" to="." method="_on_RButton_toggled"] [connection signal="toggled" from="VBoxContainer/RGBAContainer/GButton" to="." method="_on_GButton_toggled"] [connection signal="toggled" from="VBoxContainer/RGBAContainer/BButton" to="." method="_on_BButton_toggled"] [connection signal="toggled" from="VBoxContainer/RGBAContainer/AButton" to="." method="_on_AButton_toggled"] -[connection signal="toggled" from="VBoxContainer/OptionsContainer/SelectionCheckBox" to="." method="_on_SelectionCheckBox_toggled"] -[connection signal="item_selected" from="VBoxContainer/OptionsContainer/AffectOptionButton" to="." method="_on_AffectOptionButton_item_selected"] diff --git a/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd b/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd index 5bb04fb..1b8584a 100644 --- a/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd +++ b/src/UI/Dialogs/ImageEffects/FlipImageDialog.gd @@ -8,6 +8,7 @@ onready var flip_v : CheckBox = $VBoxContainer/OptionsContainer/FlipVertical func set_nodes() -> void: preview = $VBoxContainer/Preview selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox + affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton func _confirmed() -> void: @@ -58,10 +59,6 @@ func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void: update_preview() -func _on_AffectOptionButton_item_selected(index : int) -> void: - affect = index - - func update_preview() -> void: preview_image.copy_from(current_cel) flip_image(preview_image, pixels) diff --git a/src/UI/Dialogs/ImageEffects/FlipImageDialog.tscn b/src/UI/Dialogs/ImageEffects/FlipImageDialog.tscn index 36dc6de..daffb5c 100644 --- a/src/UI/Dialogs/ImageEffects/FlipImageDialog.tscn +++ b/src/UI/Dialogs/ImageEffects/FlipImageDialog.tscn @@ -69,4 +69,3 @@ items = [ "Current cel", null, false, 0, null, "Current frame", null, false, 1, selected = 0 [connection signal="toggled" from="VBoxContainer/OptionsContainer/FlipHorizontal" to="." method="_on_FlipHorizontal_toggled"] [connection signal="toggled" from="VBoxContainer/OptionsContainer/FlipVertical" to="." method="_on_FlipVertical_toggled"] -[connection signal="item_selected" from="VBoxContainer/OptionsContainer/AffectOptionButton" to="." method="_on_AffectOptionButton_item_selected"] diff --git a/src/UI/Dialogs/ImageEffects/GradientDialog.gd b/src/UI/Dialogs/ImageEffects/GradientDialog.gd index a8cb9db..4dbad9d 100644 --- a/src/UI/Dialogs/ImageEffects/GradientDialog.gd +++ b/src/UI/Dialogs/ImageEffects/GradientDialog.gd @@ -1,32 +1,21 @@ -extends ConfirmationDialog +extends ImageEffect -enum {CEL, FRAME, ALL_FRAMES, ALL_PROJECTS} - -var affect : int = CEL -var pixels := [] -var current_cel : Image -var preview_image : Image -var preview_texture : ImageTexture - -onready var preview : TextureRect = $VBoxContainer/Preview onready var color1 : ColorPickerButton = $VBoxContainer/OptionsContainer/ColorsContainer/ColorPickerButton onready var color2 : ColorPickerButton = $VBoxContainer/OptionsContainer/ColorsContainer/ColorPickerButton2 onready var steps : SpinBox = $VBoxContainer/OptionsContainer/StepSpinBox onready var direction : OptionButton = $VBoxContainer/OptionsContainer/DirectionOptionButton -onready var selection_checkbox : CheckBox = $VBoxContainer/OptionsContainer/SelectionCheckBox func _ready() -> void: - preview_image = Image.new() - preview_texture = ImageTexture.new() color1.get_picker().presets_visible = false color2.get_picker().presets_visible = false -func _on_GradientDialog_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) +func set_nodes() -> void: + preview = $VBoxContainer/Preview + selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox + affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton func update_preview() -> void: @@ -48,27 +37,11 @@ func _on_StepSpinBox_value_changed(_value : int) -> void: update_preview() -func _on_OptionButton_item_selected(_index : int) -> void: +func _on_DirectionOptionButton_item_selected(_index : int) -> void: update_preview() -func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void: - pixels.clear() - if button_pressed: - pixels = Global.current_project.selected_pixels.duplicate() - else: - for x in Global.current_project.size.x: - for y in Global.current_project.size.y: - pixels.append(Vector2(x, y)) - - update_preview() - - -func _on_AffectOptionButton_item_selected(index : int) -> void: - affect = index - - -func _on_GradientDialog_confirmed() -> void: +func _confirmed() -> void: if affect == CEL: Global.canvas.handle_undo("Draw") DrawingAlgos.generate_gradient(current_cel, [color1.color, color2.color], steps.value, direction.selected, pixels) @@ -101,7 +74,3 @@ func _on_GradientDialog_confirmed() -> void: for cel in frame.cels: DrawingAlgos.generate_gradient(cel.image, [color1.color, color2.color], steps.value, direction.selected, _pixels) Global.canvas.handle_redo("Draw", project, -1, -1) - - -func _on_GradientDialog_popup_hide() -> void: - Global.dialog_open(false) diff --git a/src/UI/Dialogs/ImageEffects/GradientDialog.tscn b/src/UI/Dialogs/ImageEffects/GradientDialog.tscn index ad6a81c..dd90002 100644 --- a/src/UI/Dialogs/ImageEffects/GradientDialog.tscn +++ b/src/UI/Dialogs/ImageEffects/GradientDialog.tscn @@ -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/GradientDialog.gd" type="Script" id=1] +[ext_resource path="res://src/UI/TransparentChecker.tscn" type="PackedScene" id=2] [node name="GradientDialog" type="ConfirmationDialog"] margin_right = 200.0 @@ -28,7 +29,10 @@ margin_right = 285.0 margin_bottom = 100.0 rect_min_size = Vector2( 0, 100 ) 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 = 104.0 @@ -109,12 +113,7 @@ mouse_default_cursor_shape = 2 text = "Current cel" items = [ "Current cel", null, false, 0, null, "Current frame", null, false, 1, null, "All frames", null, false, 2, null, "All projects", null, false, 3, null ] selected = 0 -[connection signal="about_to_show" from="." to="." method="_on_GradientDialog_about_to_show"] -[connection signal="confirmed" from="." to="." method="_on_GradientDialog_confirmed"] -[connection signal="popup_hide" from="." to="." method="_on_GradientDialog_popup_hide"] [connection signal="color_changed" from="VBoxContainer/OptionsContainer/ColorsContainer/ColorPickerButton" to="." method="_on_ColorPickerButton_color_changed"] [connection signal="color_changed" from="VBoxContainer/OptionsContainer/ColorsContainer/ColorPickerButton2" to="." method="_on_ColorPickerButton2_color_changed"] [connection signal="value_changed" from="VBoxContainer/OptionsContainer/StepSpinBox" to="." method="_on_StepSpinBox_value_changed"] -[connection signal="item_selected" from="VBoxContainer/OptionsContainer/DirectionOptionButton" to="." method="_on_OptionButton_item_selected"] -[connection signal="toggled" from="VBoxContainer/OptionsContainer/SelectionCheckBox" to="." method="_on_SelectionCheckBox_toggled"] -[connection signal="item_selected" from="VBoxContainer/OptionsContainer/AffectOptionButton" to="." method="_on_AffectOptionButton_item_selected"] +[connection signal="item_selected" from="VBoxContainer/OptionsContainer/DirectionOptionButton" to="." method="_on_DirectionOptionButton_item_selected"] diff --git a/src/UI/Dialogs/ImageEffects/HSVDialog.gd b/src/UI/Dialogs/ImageEffects/HSVDialog.gd index 55caaae..f664660 100644 --- a/src/UI/Dialogs/ImageEffects/HSVDialog.gd +++ b/src/UI/Dialogs/ImageEffects/HSVDialog.gd @@ -1,14 +1,6 @@ -extends ConfirmationDialog +extends ImageEffect -enum {CEL, FRAME, ALL_FRAMES, ALL_PROJECTS} - -var affect : int = CEL -var pixels := [] -var current_cel : Image -var preview_image : Image -var preview_texture : ImageTexture - onready var hue_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Hue onready var sat_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Saturation onready var val_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Value @@ -17,24 +9,14 @@ onready var hue_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes onready var sat_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Saturation onready var val_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Value -onready var preview = $MarginContainer/VBoxContainer/TextureRect -onready var selection_checkbox : CheckBox = $MarginContainer/VBoxContainer/AffectHBoxContainer/SelectionCheckBox + +func set_nodes() -> void: + preview = $MarginContainer/VBoxContainer/Preview + selection_checkbox = $MarginContainer/VBoxContainer/AffectHBoxContainer/SelectionCheckBox + affect_option_button = $MarginContainer/VBoxContainer/AffectHBoxContainer/AffectOptionButton -func _ready() -> void: - current_cel = Image.new() - preview_image = Image.new() - preview_texture = ImageTexture.new() - - -func _on_HSVDialog_about_to_show() -> void: - current_cel = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image - preview_image.copy_from(current_cel) - _on_SelectionCheckBox_toggled(selection_checkbox.pressed) - update_preview() - - -func _on_HSVDialog_confirmed() -> void: +func _confirmed() -> void: if affect == CEL: Global.canvas.handle_undo("Draw") DrawingAlgos.adjust_hsv(current_cel, hue_slider.value, sat_slider.value, val_slider.value, pixels) @@ -123,23 +105,3 @@ func _on_Value_value_changed(value : float) -> void: val_spinbox.value = value val_slider.value = value update_preview() - - -func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void: - pixels.clear() - if button_pressed: - pixels = Global.current_project.selected_pixels.duplicate() - else: - for x in Global.current_project.size.x: - for y in Global.current_project.size.y: - pixels.append(Vector2(x, y)) - - update_preview() - - -func _on_AffectOptionButton_item_selected(index : int) -> void: - affect = index - - -func _on_HSVDialog_popup_hide() -> void: - Global.dialog_open(false) diff --git a/src/UI/Dialogs/ImageEffects/HSVDialog.tscn b/src/UI/Dialogs/ImageEffects/HSVDialog.tscn index 20345bc..5864f04 100644 --- a/src/UI/Dialogs/ImageEffects/HSVDialog.tscn +++ b/src/UI/Dialogs/ImageEffects/HSVDialog.tscn @@ -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/HSVDialog.gd" type="Script" id=1] +[ext_resource path="res://src/UI/TransparentChecker.tscn" type="PackedScene" id=2] [node name="HSVDialog" type="ConfirmationDialog"] margin_left = 1.0 @@ -35,12 +36,15 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="TextureRect" type="TextureRect" parent="MarginContainer/VBoxContainer"] +[node name="Preview" type="TextureRect" parent="MarginContainer/VBoxContainer"] margin_right = 437.0 margin_bottom = 149.0 size_flags_vertical = 3 expand = true -stretch_mode = 6 +stretch_mode = 5 + +[node name="TransparentChecker" parent="MarginContainer/VBoxContainer/Preview" instance=ExtResource( 2 )] +show_behind_parent = true [node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] margin_top = 153.0 @@ -156,14 +160,9 @@ mouse_default_cursor_shape = 2 text = "Current cel" items = [ "Current cel", null, false, 0, null, "Current frame", null, false, 1, null, "All frames", null, false, 2, null, "All projects", null, false, 3, null ] selected = 0 -[connection signal="about_to_show" from="." to="." method="_on_HSVDialog_about_to_show"] -[connection signal="confirmed" from="." to="." method="_on_HSVDialog_confirmed"] -[connection signal="popup_hide" from="." to="." method="_on_HSVDialog_popup_hide"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Hue" to="." method="_on_Hue_value_changed"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Saturation" to="." method="_on_Saturation_value_changed"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/Sliders/Value" to="." method="_on_Value_value_changed"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Hue" to="." method="_on_Hue_value_changed"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Saturation" to="." method="_on_Saturation_value_changed"] [connection signal="value_changed" from="MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Value" to="." method="_on_Value_value_changed"] -[connection signal="toggled" from="MarginContainer/VBoxContainer/AffectHBoxContainer/SelectionCheckBox" to="." method="_on_SelectionCheckBox_toggled"] -[connection signal="item_selected" from="MarginContainer/VBoxContainer/AffectHBoxContainer/AffectOptionButton" to="." method="_on_AffectOptionButton_item_selected"] diff --git a/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd b/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd index e37dd92..ecefbae 100644 --- a/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd +++ b/src/UI/Dialogs/ImageEffects/InvertColorsDialog.gd @@ -1,35 +1,19 @@ -extends ConfirmationDialog +extends ImageEffect -enum {CEL, FRAME, ALL_FRAMES, ALL_PROJECTS} - -var affect : int = CEL -var pixels := [] -var current_cel : Image -var preview_image : Image -var preview_texture : ImageTexture - var red := true var green := true var blue := true var alpha := false -onready var preview : TextureRect = $VBoxContainer/Preview -onready var selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox + +func set_nodes() -> void: + preview = $VBoxContainer/Preview + selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox + affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton -func _ready() -> void: - current_cel = Image.new() - preview_image = Image.new() - preview_texture = ImageTexture.new() - - -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) - - -func _on_FlipImageDialog_confirmed() -> void: +func _confirmed() -> void: if affect == CEL: Global.canvas.handle_undo("Draw") DrawingAlgos.invert_image_colors(current_cel, pixels, red, green, blue, alpha) @@ -84,29 +68,9 @@ func _on_AButton_toggled(button_pressed : bool) -> void: update_preview() -func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void: - pixels.clear() - if button_pressed: - pixels = Global.current_project.selected_pixels.duplicate() - else: - for x in Global.current_project.size.x: - for y in Global.current_project.size.y: - pixels.append(Vector2(x, y)) - - update_preview() - - -func _on_AffectOptionButton_item_selected(index : int) -> void: - affect = index - - func update_preview() -> void: preview_image.copy_from(current_cel) DrawingAlgos.invert_image_colors(preview_image, pixels, red, green, blue, alpha) preview_image.unlock() preview_texture.create_from_image(preview_image, 0) preview.texture = preview_texture - - -func _on_FlipImageDialog_popup_hide() -> void: - Global.dialog_open(false) diff --git a/src/UI/Dialogs/ImageEffects/InvertColorsDialog.tscn b/src/UI/Dialogs/ImageEffects/InvertColorsDialog.tscn index 337e76c..60699c2 100644 --- a/src/UI/Dialogs/ImageEffects/InvertColorsDialog.tscn +++ b/src/UI/Dialogs/ImageEffects/InvertColorsDialog.tscn @@ -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/InvertColorsDialog.gd" type="Script" id=1] +[ext_resource path="res://src/UI/TransparentChecker.tscn" type="PackedScene" id=2] [node name="InvertColorsDialog" type="ConfirmationDialog"] margin_right = 200.0 @@ -23,7 +24,10 @@ margin_right = 263.0 margin_bottom = 200.0 rect_min_size = Vector2( 200, 200 ) expand = true -stretch_mode = 6 +stretch_mode = 5 + +[node name="TransparentChecker" parent="VBoxContainer/Preview" instance=ExtResource( 2 )] +show_behind_parent = true [node name="RGBAContainer" type="HBoxContainer" parent="VBoxContainer"] margin_top = 204.0 @@ -90,12 +94,7 @@ mouse_default_cursor_shape = 2 text = "Current cel" items = [ "Current cel", null, false, 0, null, "Current frame", null, false, 1, null, "All frames", null, false, 2, null, "All projects", null, false, 3, null ] selected = 0 -[connection signal="about_to_show" from="." to="." method="_on_FlipImageDialog_about_to_show"] -[connection signal="confirmed" from="." to="." method="_on_FlipImageDialog_confirmed"] -[connection signal="popup_hide" from="." to="." method="_on_FlipImageDialog_popup_hide"] [connection signal="toggled" from="VBoxContainer/RGBAContainer/RButton" to="." method="_on_RButton_toggled"] [connection signal="toggled" from="VBoxContainer/RGBAContainer/GButton" to="." method="_on_GButton_toggled"] [connection signal="toggled" from="VBoxContainer/RGBAContainer/BButton" to="." method="_on_BButton_toggled"] [connection signal="toggled" from="VBoxContainer/RGBAContainer/AButton" to="." method="_on_AButton_toggled"] -[connection signal="toggled" from="VBoxContainer/OptionsContainer/SelectionCheckBox" to="." method="_on_SelectionCheckBox_toggled"] -[connection signal="item_selected" from="VBoxContainer/OptionsContainer/AffectOptionButton" to="." method="_on_AffectOptionButton_item_selected"] diff --git a/src/UI/Dialogs/ImageEffects/OutlineDialog.gd b/src/UI/Dialogs/ImageEffects/OutlineDialog.gd index 38e146a..816c733 100644 --- a/src/UI/Dialogs/ImageEffects/OutlineDialog.gd +++ b/src/UI/Dialogs/ImageEffects/OutlineDialog.gd @@ -1,38 +1,26 @@ -extends ConfirmationDialog +extends ImageEffect -enum {CEL, FRAME, ALL_FRAMES, ALL_PROJECTS} - -var affect : int = CEL -var pixels := [] -var current_cel : Image -var preview_image : Image -var preview_texture : ImageTexture - var color := Color.red var thickness := 1 var diagonal := false var inside_image := false -onready var preview : TextureRect = $VBoxContainer/Preview onready var outline_color = $VBoxContainer/OptionsContainer/OutlineColor -onready var selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox func _ready() -> void: - current_cel = Image.new() - preview_image = Image.new() - preview_texture = ImageTexture.new() outline_color.get_picker().presets_visible = false color = outline_color.color -func _on_OutlineDialog_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) +func set_nodes() -> void: + preview = $VBoxContainer/Preview + selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox + affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton -func _on_OutlineDialog_confirmed() -> void: +func _confirmed() -> void: if affect == CEL: Global.canvas.handle_undo("Draw") DrawingAlgos.generate_outline(current_cel, pixels, color, thickness, diagonal, inside_image) @@ -67,18 +55,6 @@ func _on_OutlineDialog_confirmed() -> void: Global.canvas.handle_redo("Draw", project, -1, -1) -func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void: - pixels.clear() - if button_pressed: - pixels = Global.current_project.selected_pixels.duplicate() - else: - for x in Global.current_project.size.x: - for y in Global.current_project.size.y: - pixels.append(Vector2(x, y)) - - update_preview() - - func _on_ThickValue_value_changed(value : int) -> void: thickness = value update_preview() @@ -104,11 +80,3 @@ func update_preview() -> void: DrawingAlgos.generate_outline(preview_image, pixels, color, thickness, diagonal, inside_image) preview_texture.create_from_image(preview_image, 0) preview.texture = preview_texture - - -func _on_AffectOptionButton_item_selected(index : int) -> void: - affect = index - - -func _on_OutlineDialog_popup_hide() -> void: - Global.dialog_open(false) diff --git a/src/UI/Dialogs/ImageEffects/OutlineDialog.tscn b/src/UI/Dialogs/ImageEffects/OutlineDialog.tscn index fa170ea..e3cf2eb 100644 --- a/src/UI/Dialogs/ImageEffects/OutlineDialog.tscn +++ b/src/UI/Dialogs/ImageEffects/OutlineDialog.tscn @@ -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/OutlineDialog.gd" type="Script" id=1] +[ext_resource path="res://src/UI/TransparentChecker.tscn" type="PackedScene" id=2] [node name="OutlineDialog" type="ConfirmationDialog"] margin_right = 200.0 @@ -26,7 +27,10 @@ margin_right = 312.0 margin_bottom = 200.0 rect_min_size = Vector2( 200, 200 ) 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 @@ -99,12 +103,7 @@ mouse_default_cursor_shape = 2 text = "Current cel" items = [ "Current cel", null, false, 0, null, "Current frame", null, false, 1, null, "All frames", null, false, 2, null, "All projects", null, false, 3, null ] selected = 0 -[connection signal="about_to_show" from="." to="." method="_on_OutlineDialog_about_to_show"] -[connection signal="confirmed" from="." to="." method="_on_OutlineDialog_confirmed"] -[connection signal="popup_hide" from="." to="." method="_on_OutlineDialog_popup_hide"] [connection signal="value_changed" from="VBoxContainer/OptionsContainer/ThickValue" to="." method="_on_ThickValue_value_changed"] [connection signal="color_changed" from="VBoxContainer/OptionsContainer/OutlineColor" to="." method="_on_OutlineColor_color_changed"] [connection signal="toggled" from="VBoxContainer/OptionsContainer/DiagonalCheckBox" to="." method="_on_DiagonalCheckBox_toggled"] [connection signal="toggled" from="VBoxContainer/OptionsContainer/InsideImageCheckBox" to="." method="_on_InsideImageCheckBox_toggled"] -[connection signal="toggled" from="VBoxContainer/OptionsContainer/SelectionCheckBox" to="." method="_on_SelectionCheckBox_toggled"] -[connection signal="item_selected" from="VBoxContainer/OptionsContainer/AffectOptionButton" to="." method="_on_AffectOptionButton_item_selected"]