diff --git a/CHANGELOG.md b/CHANGELOG.md index 26a1d3180..c7c1eceaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Darshan Phaldesai (luiq54), Igor Santarek (jegor377), rob-a-bolton, Kinwailo - You can now drag & drop files into the program while it's running to open them. You can open .pxo files, image files and palette (json and gpl) files this way. - You can now draw on the tiling mode previews! ([#65](https://github.com/Orama-Interactive/Pixelorama/issues/65)) - Added Resize Canvas option to Image menu. +- Added Symmetry Guides. They let you change the axis of symmetry for mirroring. ([#133](https://github.com/Orama-Interactive/Pixelorama/issues/133)) - Palettes can now be created from the colors of the selected sprite. - You can now preview how the frames of the spritesheet you are importing will look. - You can now import image files as layers. Their size will be cropped to the project's size. diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 65076edb7..c93e65f42 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -42,6 +42,8 @@ var right_cursor_tool_texture := ImageTexture.new() var image_clipboard : Image var play_only_tags := true +var show_x_symmetry_axis := false +var show_y_symmetry_axis := false # Preferences var theme_type : int = Theme_Types.DARK diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index 90c853359..4cee8602a 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -126,7 +126,12 @@ func change_project() -> void: for guide in Global.canvas.get_children(): if guide is Guide: if guide in guides: - guide.visible = true + guide.visible = Global.show_guides + if guide is SymmetryGuide: + if guide.type == Guide.Types.HORIZONTAL: + guide.visible = Global.show_x_symmetry_axis and Global.show_guides + else: + guide.visible = Global.show_y_symmetry_axis and Global.show_guides else: guide.visible = false diff --git a/src/Tools/Base.gd b/src/Tools/Base.gd index b2939db82..f281dc120 100644 --- a/src/Tools/Base.gd +++ b/src/Tools/Base.gd @@ -27,11 +27,21 @@ func _on_PixelPerfect_toggled(button_pressed : bool): func _on_Horizontal_toggled(button_pressed : bool): tool_slot.horizontal_mirror = button_pressed tool_slot.save_config() + Global.show_y_symmetry_axis = button_pressed + # If the button is not pressed but another button is, keep the symmetry guide visible + if !button_pressed and (Tools._slots[BUTTON_LEFT].horizontal_mirror or Tools._slots[BUTTON_RIGHT].horizontal_mirror): + Global.show_y_symmetry_axis = true + Global.current_project.y_symmetry_axis.visible = Global.show_y_symmetry_axis and Global.show_guides func _on_Vertical_toggled(button_pressed : bool): tool_slot.vertical_mirror = button_pressed tool_slot.save_config() + Global.show_x_symmetry_axis = button_pressed + # If the button is not pressed but another button is, keep the symmetry guide visible + if !button_pressed and (Tools._slots[BUTTON_LEFT].vertical_mirror or Tools._slots[BUTTON_RIGHT].vertical_mirror): + Global.show_x_symmetry_axis = true + Global.current_project.x_symmetry_axis.visible = Global.show_x_symmetry_axis and Global.show_guides func save_config() -> void: diff --git a/src/UI/Rulers/SymmetryGuide.gd b/src/UI/Rulers/SymmetryGuide.gd index 7f9301c1a..0e08794ce 100644 --- a/src/UI/Rulers/SymmetryGuide.gd +++ b/src/UI/Rulers/SymmetryGuide.gd @@ -4,6 +4,7 @@ class_name SymmetryGuide extends Guide func _ready() -> void: ._ready() has_focus = false + visible = false func _input(_event : InputEvent) -> void: diff --git a/src/UI/TopMenuContainer.gd b/src/UI/TopMenuContainer.gd index 8352e9e69..8482d8082 100644 --- a/src/UI/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer.gd @@ -260,8 +260,13 @@ func toggle_show_guides() -> void: Global.show_guides = !Global.show_guides view_menu.set_item_checked(3, Global.show_guides) for guide in Global.canvas.get_children(): - if guide is Guide: + if guide is Guide and guide in Global.current_project.guides: guide.visible = Global.show_guides + if guide is SymmetryGuide: + if guide.type == Guide.Types.HORIZONTAL: + guide.visible = Global.show_x_symmetry_axis and Global.show_guides + else: + guide.visible = Global.show_y_symmetry_axis and Global.show_guides func toggle_show_anim_timeline() -> void: