Skip to content

Commit

Permalink
Turn Symmetry Guides visibility on and off if mirroring is enabled
Browse files Browse the repository at this point in the history
Also fixed issue with "Show Guides" view menu option and having multiple projects with guides. Only think remaining is to make the Symmetry Guides look different than regular guides. Closes #133.
  • Loading branch information
OverloadedOrama committed Jul 16, 2020
1 parent 9fa91ff commit a5a8bf1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/Autoload/Global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/Classes/Project.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions src/Tools/Base.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/UI/Rulers/SymmetryGuide.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class_name SymmetryGuide extends Guide
func _ready() -> void:
._ready()
has_focus = false
visible = false


func _input(_event : InputEvent) -> void:
Expand Down
7 changes: 6 additions & 1 deletion src/UI/TopMenuContainer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a5a8bf1

Please sign in to comment.