mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-05-05 12:14:49 -04:00
Put checker backgrounds to almost all image effect dialog previews
Also made them inherit ImageEffect, resulting in much less and cleaner code. Only RotateImage remains. Partially addresses #206.
This commit is contained in:
parent
2af677016e
commit
f121c39ddc
13 changed files with 74 additions and 249 deletions
|
@ -12,6 +12,7 @@ var preview_image : Image
|
||||||
var preview_texture : ImageTexture
|
var preview_texture : ImageTexture
|
||||||
var preview : TextureRect
|
var preview : TextureRect
|
||||||
var selection_checkbox : CheckBox
|
var selection_checkbox : CheckBox
|
||||||
|
var affect_option_button : OptionButton
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -24,6 +25,8 @@ func _ready() -> void:
|
||||||
connect("confirmed", self, "_confirmed")
|
connect("confirmed", self, "_confirmed")
|
||||||
if selection_checkbox:
|
if selection_checkbox:
|
||||||
selection_checkbox.connect("toggled", self, "_on_SelectionCheckBox_toggled")
|
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:
|
func _about_to_show() -> void:
|
||||||
|
@ -53,6 +56,10 @@ func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void:
|
||||||
update_preview()
|
update_preview()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_AffectOptionButton_item_selected(index : int) -> void:
|
||||||
|
affect = index
|
||||||
|
|
||||||
|
|
||||||
func update_preview() -> void:
|
func update_preview() -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -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 red := true
|
||||||
var green := true
|
var green := true
|
||||||
var blue := true
|
var blue := true
|
||||||
var alpha := false
|
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:
|
func _confirmed() -> 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:
|
|
||||||
if affect == CEL:
|
if affect == CEL:
|
||||||
Global.canvas.handle_undo("Draw")
|
Global.canvas.handle_undo("Draw")
|
||||||
DrawingAlgos.desaturate_image(current_cel, pixels, red, green, blue, alpha)
|
DrawingAlgos.desaturate_image(current_cel, pixels, red, green, blue, alpha)
|
||||||
|
@ -84,29 +68,9 @@ func _on_AButton_toggled(button_pressed : bool) -> void:
|
||||||
update_preview()
|
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:
|
func update_preview() -> void:
|
||||||
preview_image.copy_from(current_cel)
|
preview_image.copy_from(current_cel)
|
||||||
DrawingAlgos.desaturate_image(preview_image, pixels, red, green, blue, alpha)
|
DrawingAlgos.desaturate_image(preview_image, pixels, red, green, blue, alpha)
|
||||||
preview_image.unlock()
|
preview_image.unlock()
|
||||||
preview_texture.create_from_image(preview_image, 0)
|
preview_texture.create_from_image(preview_image, 0)
|
||||||
preview.texture = preview_texture
|
preview.texture = preview_texture
|
||||||
|
|
||||||
|
|
||||||
func _on_FlipImageDialog_popup_hide() -> void:
|
|
||||||
Global.dialog_open(false)
|
|
||||||
|
|
|
@ -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/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"]
|
[node name="DesaturateDialog" type="ConfirmationDialog"]
|
||||||
margin_right = 200.0
|
margin_right = 200.0
|
||||||
|
@ -23,7 +24,10 @@ margin_right = 263.0
|
||||||
margin_bottom = 200.0
|
margin_bottom = 200.0
|
||||||
rect_min_size = Vector2( 200, 200 )
|
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="RGBAContainer" type="HBoxContainer" parent="VBoxContainer"]
|
[node name="RGBAContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
margin_top = 204.0
|
margin_top = 204.0
|
||||||
|
@ -90,12 +94,7 @@ mouse_default_cursor_shape = 2
|
||||||
text = "Current cel"
|
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 ]
|
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
|
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/RButton" to="." method="_on_RButton_toggled"]
|
||||||
[connection signal="toggled" from="VBoxContainer/RGBAContainer/GButton" to="." method="_on_GButton_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/BButton" to="." method="_on_BButton_toggled"]
|
||||||
[connection signal="toggled" from="VBoxContainer/RGBAContainer/AButton" to="." method="_on_AButton_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"]
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ onready var flip_v : CheckBox = $VBoxContainer/OptionsContainer/FlipVertical
|
||||||
func set_nodes() -> void:
|
func set_nodes() -> void:
|
||||||
preview = $VBoxContainer/Preview
|
preview = $VBoxContainer/Preview
|
||||||
selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox
|
selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox
|
||||||
|
affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton
|
||||||
|
|
||||||
|
|
||||||
func _confirmed() -> void:
|
func _confirmed() -> void:
|
||||||
|
@ -58,10 +59,6 @@ func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void:
|
||||||
update_preview()
|
update_preview()
|
||||||
|
|
||||||
|
|
||||||
func _on_AffectOptionButton_item_selected(index : int) -> void:
|
|
||||||
affect = index
|
|
||||||
|
|
||||||
|
|
||||||
func update_preview() -> void:
|
func update_preview() -> void:
|
||||||
preview_image.copy_from(current_cel)
|
preview_image.copy_from(current_cel)
|
||||||
flip_image(preview_image, pixels)
|
flip_image(preview_image, pixels)
|
||||||
|
|
|
@ -69,4 +69,3 @@ items = [ "Current cel", null, false, 0, null, "Current frame", null, false, 1,
|
||||||
selected = 0
|
selected = 0
|
||||||
[connection signal="toggled" from="VBoxContainer/OptionsContainer/FlipHorizontal" to="." method="_on_FlipHorizontal_toggled"]
|
[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="toggled" from="VBoxContainer/OptionsContainer/FlipVertical" to="." method="_on_FlipVertical_toggled"]
|
||||||
[connection signal="item_selected" from="VBoxContainer/OptionsContainer/AffectOptionButton" to="." method="_on_AffectOptionButton_item_selected"]
|
|
||||||
|
|
|
@ -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 color1 : ColorPickerButton = $VBoxContainer/OptionsContainer/ColorsContainer/ColorPickerButton
|
||||||
onready var color2 : ColorPickerButton = $VBoxContainer/OptionsContainer/ColorsContainer/ColorPickerButton2
|
onready var color2 : ColorPickerButton = $VBoxContainer/OptionsContainer/ColorsContainer/ColorPickerButton2
|
||||||
onready var steps : SpinBox = $VBoxContainer/OptionsContainer/StepSpinBox
|
onready var steps : SpinBox = $VBoxContainer/OptionsContainer/StepSpinBox
|
||||||
onready var direction : OptionButton = $VBoxContainer/OptionsContainer/DirectionOptionButton
|
onready var direction : OptionButton = $VBoxContainer/OptionsContainer/DirectionOptionButton
|
||||||
onready var selection_checkbox : CheckBox = $VBoxContainer/OptionsContainer/SelectionCheckBox
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
preview_image = Image.new()
|
|
||||||
preview_texture = ImageTexture.new()
|
|
||||||
color1.get_picker().presets_visible = false
|
color1.get_picker().presets_visible = false
|
||||||
color2.get_picker().presets_visible = false
|
color2.get_picker().presets_visible = false
|
||||||
|
|
||||||
|
|
||||||
func _on_GradientDialog_about_to_show() -> void:
|
func set_nodes() -> void:
|
||||||
current_cel = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image
|
preview = $VBoxContainer/Preview
|
||||||
_on_SelectionCheckBox_toggled(selection_checkbox.pressed)
|
selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox
|
||||||
|
affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton
|
||||||
|
|
||||||
|
|
||||||
func update_preview() -> void:
|
func update_preview() -> void:
|
||||||
|
@ -48,27 +37,11 @@ func _on_StepSpinBox_value_changed(_value : int) -> void:
|
||||||
update_preview()
|
update_preview()
|
||||||
|
|
||||||
|
|
||||||
func _on_OptionButton_item_selected(_index : int) -> void:
|
func _on_DirectionOptionButton_item_selected(_index : int) -> void:
|
||||||
update_preview()
|
update_preview()
|
||||||
|
|
||||||
|
|
||||||
func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void:
|
func _confirmed() -> 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:
|
|
||||||
if affect == CEL:
|
if affect == CEL:
|
||||||
Global.canvas.handle_undo("Draw")
|
Global.canvas.handle_undo("Draw")
|
||||||
DrawingAlgos.generate_gradient(current_cel, [color1.color, color2.color], steps.value, direction.selected, pixels)
|
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:
|
for cel in frame.cels:
|
||||||
DrawingAlgos.generate_gradient(cel.image, [color1.color, color2.color], steps.value, direction.selected, _pixels)
|
DrawingAlgos.generate_gradient(cel.image, [color1.color, color2.color], steps.value, direction.selected, _pixels)
|
||||||
Global.canvas.handle_redo("Draw", project, -1, -1)
|
Global.canvas.handle_redo("Draw", project, -1, -1)
|
||||||
|
|
||||||
|
|
||||||
func _on_GradientDialog_popup_hide() -> void:
|
|
||||||
Global.dialog_open(false)
|
|
||||||
|
|
|
@ -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/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"]
|
[node name="GradientDialog" type="ConfirmationDialog"]
|
||||||
margin_right = 200.0
|
margin_right = 200.0
|
||||||
|
@ -28,7 +29,10 @@ margin_right = 285.0
|
||||||
margin_bottom = 100.0
|
margin_bottom = 100.0
|
||||||
rect_min_size = Vector2( 0, 100 )
|
rect_min_size = Vector2( 0, 100 )
|
||||||
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="OptionsContainer" type="GridContainer" parent="VBoxContainer"]
|
[node name="OptionsContainer" type="GridContainer" parent="VBoxContainer"]
|
||||||
margin_top = 104.0
|
margin_top = 104.0
|
||||||
|
@ -109,12 +113,7 @@ mouse_default_cursor_shape = 2
|
||||||
text = "Current cel"
|
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 ]
|
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
|
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/ColorPickerButton" to="." method="_on_ColorPickerButton_color_changed"]
|
||||||
[connection signal="color_changed" from="VBoxContainer/OptionsContainer/ColorsContainer/ColorPickerButton2" to="." method="_on_ColorPickerButton2_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="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="item_selected" from="VBoxContainer/OptionsContainer/DirectionOptionButton" to="." method="_on_DirectionOptionButton_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"]
|
|
||||||
|
|
|
@ -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 hue_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Hue
|
||||||
onready var sat_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Saturation
|
onready var sat_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Saturation
|
||||||
onready var val_slider = $MarginContainer/VBoxContainer/HBoxContainer/Sliders/Value
|
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 sat_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Saturation
|
||||||
onready var val_spinbox = $MarginContainer/VBoxContainer/HBoxContainer/TextBoxes/Value
|
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:
|
func _confirmed() -> 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:
|
|
||||||
if affect == CEL:
|
if affect == CEL:
|
||||||
Global.canvas.handle_undo("Draw")
|
Global.canvas.handle_undo("Draw")
|
||||||
DrawingAlgos.adjust_hsv(current_cel, hue_slider.value, sat_slider.value, val_slider.value, pixels)
|
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_spinbox.value = value
|
||||||
val_slider.value = value
|
val_slider.value = value
|
||||||
update_preview()
|
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)
|
|
||||||
|
|
|
@ -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/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"]
|
[node name="HSVDialog" type="ConfirmationDialog"]
|
||||||
margin_left = 1.0
|
margin_left = 1.0
|
||||||
|
@ -35,12 +36,15 @@ __meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_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_right = 437.0
|
||||||
margin_bottom = 149.0
|
margin_bottom = 149.0
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
expand = true
|
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"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
|
||||||
margin_top = 153.0
|
margin_top = 153.0
|
||||||
|
@ -156,14 +160,9 @@ mouse_default_cursor_shape = 2
|
||||||
text = "Current cel"
|
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 ]
|
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
|
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/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/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/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/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/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="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"]
|
|
||||||
|
|
|
@ -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 red := true
|
||||||
var green := true
|
var green := true
|
||||||
var blue := true
|
var blue := true
|
||||||
var alpha := false
|
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:
|
func _confirmed() -> 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:
|
|
||||||
if affect == CEL:
|
if affect == CEL:
|
||||||
Global.canvas.handle_undo("Draw")
|
Global.canvas.handle_undo("Draw")
|
||||||
DrawingAlgos.invert_image_colors(current_cel, pixels, red, green, blue, alpha)
|
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()
|
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:
|
func update_preview() -> void:
|
||||||
preview_image.copy_from(current_cel)
|
preview_image.copy_from(current_cel)
|
||||||
DrawingAlgos.invert_image_colors(preview_image, pixels, red, green, blue, alpha)
|
DrawingAlgos.invert_image_colors(preview_image, pixels, red, green, blue, alpha)
|
||||||
preview_image.unlock()
|
preview_image.unlock()
|
||||||
preview_texture.create_from_image(preview_image, 0)
|
preview_texture.create_from_image(preview_image, 0)
|
||||||
preview.texture = preview_texture
|
preview.texture = preview_texture
|
||||||
|
|
||||||
|
|
||||||
func _on_FlipImageDialog_popup_hide() -> void:
|
|
||||||
Global.dialog_open(false)
|
|
||||||
|
|
|
@ -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/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"]
|
[node name="InvertColorsDialog" type="ConfirmationDialog"]
|
||||||
margin_right = 200.0
|
margin_right = 200.0
|
||||||
|
@ -23,7 +24,10 @@ margin_right = 263.0
|
||||||
margin_bottom = 200.0
|
margin_bottom = 200.0
|
||||||
rect_min_size = Vector2( 200, 200 )
|
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="RGBAContainer" type="HBoxContainer" parent="VBoxContainer"]
|
[node name="RGBAContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
margin_top = 204.0
|
margin_top = 204.0
|
||||||
|
@ -90,12 +94,7 @@ mouse_default_cursor_shape = 2
|
||||||
text = "Current cel"
|
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 ]
|
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
|
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/RButton" to="." method="_on_RButton_toggled"]
|
||||||
[connection signal="toggled" from="VBoxContainer/RGBAContainer/GButton" to="." method="_on_GButton_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/BButton" to="." method="_on_BButton_toggled"]
|
||||||
[connection signal="toggled" from="VBoxContainer/RGBAContainer/AButton" to="." method="_on_AButton_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"]
|
|
||||||
|
|
|
@ -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 color := Color.red
|
||||||
var thickness := 1
|
var thickness := 1
|
||||||
var diagonal := false
|
var diagonal := false
|
||||||
var inside_image := false
|
var inside_image := false
|
||||||
|
|
||||||
onready var preview : TextureRect = $VBoxContainer/Preview
|
|
||||||
onready var outline_color = $VBoxContainer/OptionsContainer/OutlineColor
|
onready var outline_color = $VBoxContainer/OptionsContainer/OutlineColor
|
||||||
onready var selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox
|
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
current_cel = Image.new()
|
|
||||||
preview_image = Image.new()
|
|
||||||
preview_texture = ImageTexture.new()
|
|
||||||
outline_color.get_picker().presets_visible = false
|
outline_color.get_picker().presets_visible = false
|
||||||
color = outline_color.color
|
color = outline_color.color
|
||||||
|
|
||||||
|
|
||||||
func _on_OutlineDialog_about_to_show() -> void:
|
func set_nodes() -> void:
|
||||||
current_cel = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image
|
preview = $VBoxContainer/Preview
|
||||||
_on_SelectionCheckBox_toggled(selection_checkbox.pressed)
|
selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox
|
||||||
|
affect_option_button = $VBoxContainer/OptionsContainer/AffectOptionButton
|
||||||
|
|
||||||
|
|
||||||
func _on_OutlineDialog_confirmed() -> void:
|
func _confirmed() -> void:
|
||||||
if affect == CEL:
|
if affect == CEL:
|
||||||
Global.canvas.handle_undo("Draw")
|
Global.canvas.handle_undo("Draw")
|
||||||
DrawingAlgos.generate_outline(current_cel, pixels, color, thickness, diagonal, inside_image)
|
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)
|
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:
|
func _on_ThickValue_value_changed(value : int) -> void:
|
||||||
thickness = value
|
thickness = value
|
||||||
update_preview()
|
update_preview()
|
||||||
|
@ -104,11 +80,3 @@ func update_preview() -> void:
|
||||||
DrawingAlgos.generate_outline(preview_image, pixels, color, thickness, diagonal, inside_image)
|
DrawingAlgos.generate_outline(preview_image, pixels, color, thickness, diagonal, inside_image)
|
||||||
preview_texture.create_from_image(preview_image, 0)
|
preview_texture.create_from_image(preview_image, 0)
|
||||||
preview.texture = preview_texture
|
preview.texture = preview_texture
|
||||||
|
|
||||||
|
|
||||||
func _on_AffectOptionButton_item_selected(index : int) -> void:
|
|
||||||
affect = index
|
|
||||||
|
|
||||||
|
|
||||||
func _on_OutlineDialog_popup_hide() -> void:
|
|
||||||
Global.dialog_open(false)
|
|
||||||
|
|
|
@ -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/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"]
|
[node name="OutlineDialog" type="ConfirmationDialog"]
|
||||||
margin_right = 200.0
|
margin_right = 200.0
|
||||||
|
@ -26,7 +27,10 @@ margin_right = 312.0
|
||||||
margin_bottom = 200.0
|
margin_bottom = 200.0
|
||||||
rect_min_size = Vector2( 200, 200 )
|
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="OptionsContainer" type="GridContainer" parent="VBoxContainer"]
|
[node name="OptionsContainer" type="GridContainer" parent="VBoxContainer"]
|
||||||
margin_top = 204.0
|
margin_top = 204.0
|
||||||
|
@ -99,12 +103,7 @@ mouse_default_cursor_shape = 2
|
||||||
text = "Current cel"
|
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 ]
|
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
|
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="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="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/DiagonalCheckBox" to="." method="_on_DiagonalCheckBox_toggled"]
|
||||||
[connection signal="toggled" from="VBoxContainer/OptionsContainer/InsideImageCheckBox" to="." method="_on_InsideImageCheckBox_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"]
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue