1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Added more options to the OutlineDialog

This commit is contained in:
OverloadedOrama 2020-07-29 18:25:19 +03:00
parent 7e3fd089e4
commit bedede5970
2 changed files with 51 additions and 8 deletions

View file

@ -1,6 +1,9 @@
extends ConfirmationDialog
enum {CEL, FRAME, ALL_FRAMES, ALL_PROJECTS}
var affect : int = CEL
var pixels := []
var current_cel : Image
var preview_image : Image
@ -13,9 +16,6 @@ var inside_image := false
onready var preview : TextureRect = $VBoxContainer/Preview
onready var outline_color = $VBoxContainer/OptionsContainer/OutlineColor
#onready var thick_value = $VBoxContainer/OptionsContainer/ThickValue
#onready var diagonal_checkbox = $VBoxContainer/OptionsContainer/DiagonalCheckBox
#onready var inside_image_checkbox = $VBoxContainer/OptionsContainer/InsideImageCheckBox
onready var selection_checkbox = $VBoxContainer/OptionsContainer/SelectionCheckBox
@ -33,9 +33,38 @@ func _on_OutlineDialog_about_to_show() -> void:
func _on_OutlineDialog_confirmed() -> void:
Global.canvas.handle_undo("Draw")
DrawingAlgos.generate_outline(current_cel, pixels, color, thickness, diagonal, inside_image)
Global.canvas.handle_redo("Draw")
if affect == CEL:
Global.canvas.handle_undo("Draw")
DrawingAlgos.generate_outline(current_cel, pixels, color, thickness, diagonal, inside_image)
Global.canvas.handle_redo("Draw")
elif affect == FRAME:
Global.canvas.handle_undo("Draw", Global.current_project, -1)
for cel in Global.current_project.frames[Global.current_project.current_frame].cels:
DrawingAlgos.generate_outline(cel.image, pixels, color, thickness, diagonal, inside_image)
Global.canvas.handle_redo("Draw", Global.current_project, -1)
elif affect == ALL_FRAMES:
Global.canvas.handle_undo("Draw", Global.current_project, -1, -1)
for frame in Global.current_project.frames:
for cel in frame.cels:
DrawingAlgos.generate_outline(cel.image, pixels, color, thickness, diagonal, inside_image)
Global.canvas.handle_redo("Draw", Global.current_project, -1, -1)
elif affect == ALL_PROJECTS:
for project in Global.projects:
var _pixels := []
if selection_checkbox.pressed:
_pixels = project.selected_pixels.duplicate()
else:
for x in project.size.x:
for y in project.size.y:
_pixels.append(Vector2(x, y))
Global.canvas.handle_undo("Draw", project, -1, -1)
for frame in project.frames:
for cel in frame.cels:
DrawingAlgos.generate_outline(cel.image, _pixels, color, thickness, diagonal, inside_image)
Global.canvas.handle_redo("Draw", project, -1, -1)
func _on_SelectionCheckBox_toggled(button_pressed : bool) -> void:
@ -75,3 +104,7 @@ 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

View file

@ -21,14 +21,15 @@ __meta__ = {
[node name="Preview" type="TextureRect" parent="VBoxContainer"]
margin_right = 312.0
margin_bottom = 200.0
rect_min_size = Vector2( 200, 200 )
expand = true
stretch_mode = 6
[node name="OptionsContainer" type="GridContainer" parent="VBoxContainer"]
margin_top = 4.0
margin_top = 204.0
margin_right = 312.0
margin_bottom = 108.0
margin_bottom = 308.0
custom_constants/vseparation = 4
custom_constants/hseparation = 4
columns = 2
@ -88,6 +89,14 @@ margin_bottom = 104.0
mouse_default_cursor_shape = 2
pressed = true
text = "Only affect selection"
[node name="AffectOptionButton" type="OptionButton" parent="VBoxContainer/OptionsContainer"]
margin_right = 29.0
margin_bottom = 20.0
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="value_changed" from="VBoxContainer/OptionsContainer/ThickValue" to="." method="_on_ThickValue_value_changed"]
@ -95,3 +104,4 @@ text = "Only affect selection"
[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"]