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

Added show rulers & guides in the View menu

This commit is contained in:
OverloadedOrama 2019-12-03 02:30:38 +02:00
parent 5ffd0ecf6a
commit 70bd1dde43
4 changed files with 27 additions and 1 deletions

View file

@ -17,6 +17,10 @@ var onion_skinning_blue_red := false
var tile_mode := false
# warning-ignore:unused_class_variable
var draw_grid := false
# warning-ignore:unused_class_variable
var show_rulers := true
# warning-ignore:unused_class_variable
var show_guides := true
var canvases := []
# warning-ignore:unused_class_variable
var hidden_canvases := []
@ -34,6 +38,7 @@ var right_square_indicator_visible := false
var camera : Camera2D
var camera2 : Camera2D
var selection_rectangle : Polygon2D
var horizontal_ruler : BaseButton
var vertical_ruler : BaseButton
# warning-ignore:unused_class_variable
var selected_pixels := []
@ -126,6 +131,7 @@ func _ready() -> void:
camera = find_node_by_name(canvas_parent, "Camera2D")
camera2 = find_node_by_name(root, "Camera2D2")
selection_rectangle = find_node_by_name(root, "SelectionRectangle")
horizontal_ruler = find_node_by_name(root, "HorizontalRuler")
vertical_ruler = find_node_by_name(root, "VerticalRuler")
image_clipboard = Image.new()

View file

@ -55,6 +55,8 @@ func _draw() -> void:
draw_line(Vector2(position.x + RULER_WIDTH, RULER_WIDTH * 0.66), Vector2(position.x + RULER_WIDTH, RULER_WIDTH), Color.white)
func _on_HorizontalRuler_pressed() -> void:
if !Global.show_guides:
return
var mouse_pos := get_local_mouse_position()
if mouse_pos.x < RULER_WIDTH: #For double guides
Global.vertical_ruler._on_VerticalRuler_pressed()

View file

@ -57,7 +57,9 @@ func _ready() -> void:
}
var view_menu_items := {
"Tile Mode" : KEY_MASK_CTRL + KEY_T,
"Show Grid" : KEY_MASK_CTRL + KEY_G
"Show Grid" : KEY_MASK_CTRL + KEY_G,
"Show Rulers": KEY_MASK_CTRL + KEY_R,
"Show Guides": KEY_MASK_CTRL + KEY_Y
}
var help_menu_items := {
"About Pixelorama" : 0
@ -79,6 +81,8 @@ func _ready() -> void:
for item in view_menu_items.keys():
view_menu.add_check_item(item, i, view_menu_items[item])
i += 1
view_menu.set_item_checked(2, true) #Show Rulers
view_menu.set_item_checked(3, true) #Show Guides
i = 0
for item in help_menu_items.keys():
help_menu.add_item(item, i, help_menu_items[item])
@ -257,6 +261,18 @@ func view_menu_id_pressed(id : int) -> void:
1: #Show grid
Global.draw_grid = !Global.draw_grid
view_menu.set_item_checked(1, Global.draw_grid)
2: #Show rulers
Global.show_rulers = !Global.show_rulers
view_menu.set_item_checked(2, Global.show_rulers)
Global.horizontal_ruler.visible = Global.show_rulers
Global.vertical_ruler.visible = Global.show_rulers
3: #Show guides
Global.show_guides = !Global.show_guides
view_menu.set_item_checked(3, Global.show_guides)
for canvas in Global.canvases:
for guide in canvas.get_children():
if guide is Guide:
guide.visible = Global.show_guides
func help_menu_id_pressed(id : int) -> void:
match id:

View file

@ -55,6 +55,8 @@ func _draw() -> void:
draw_line(Vector2(RULER_WIDTH * 0.66, position.y), Vector2(RULER_WIDTH, position.y), Color.white)
func _on_VerticalRuler_pressed() -> void:
if !Global.show_guides:
return
var guide := Guide.new()
guide.type = guide.TYPE.VERTICAL
guide.default_color = Color.purple