mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Added show rulers & guides in the View menu
This commit is contained in:
parent
5ffd0ecf6a
commit
70bd1dde43
|
@ -17,6 +17,10 @@ var onion_skinning_blue_red := false
|
||||||
var tile_mode := false
|
var tile_mode := false
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var draw_grid := false
|
var draw_grid := false
|
||||||
|
# warning-ignore:unused_class_variable
|
||||||
|
var show_rulers := true
|
||||||
|
# warning-ignore:unused_class_variable
|
||||||
|
var show_guides := true
|
||||||
var canvases := []
|
var canvases := []
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var hidden_canvases := []
|
var hidden_canvases := []
|
||||||
|
@ -34,6 +38,7 @@ var right_square_indicator_visible := false
|
||||||
var camera : Camera2D
|
var camera : Camera2D
|
||||||
var camera2 : Camera2D
|
var camera2 : Camera2D
|
||||||
var selection_rectangle : Polygon2D
|
var selection_rectangle : Polygon2D
|
||||||
|
var horizontal_ruler : BaseButton
|
||||||
var vertical_ruler : BaseButton
|
var vertical_ruler : BaseButton
|
||||||
# warning-ignore:unused_class_variable
|
# warning-ignore:unused_class_variable
|
||||||
var selected_pixels := []
|
var selected_pixels := []
|
||||||
|
@ -126,6 +131,7 @@ func _ready() -> void:
|
||||||
camera = find_node_by_name(canvas_parent, "Camera2D")
|
camera = find_node_by_name(canvas_parent, "Camera2D")
|
||||||
camera2 = find_node_by_name(root, "Camera2D2")
|
camera2 = find_node_by_name(root, "Camera2D2")
|
||||||
selection_rectangle = find_node_by_name(root, "SelectionRectangle")
|
selection_rectangle = find_node_by_name(root, "SelectionRectangle")
|
||||||
|
horizontal_ruler = find_node_by_name(root, "HorizontalRuler")
|
||||||
vertical_ruler = find_node_by_name(root, "VerticalRuler")
|
vertical_ruler = find_node_by_name(root, "VerticalRuler")
|
||||||
image_clipboard = Image.new()
|
image_clipboard = Image.new()
|
||||||
|
|
||||||
|
|
|
@ -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)
|
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:
|
func _on_HorizontalRuler_pressed() -> void:
|
||||||
|
if !Global.show_guides:
|
||||||
|
return
|
||||||
var mouse_pos := get_local_mouse_position()
|
var mouse_pos := get_local_mouse_position()
|
||||||
if mouse_pos.x < RULER_WIDTH: #For double guides
|
if mouse_pos.x < RULER_WIDTH: #For double guides
|
||||||
Global.vertical_ruler._on_VerticalRuler_pressed()
|
Global.vertical_ruler._on_VerticalRuler_pressed()
|
||||||
|
|
|
@ -57,7 +57,9 @@ func _ready() -> void:
|
||||||
}
|
}
|
||||||
var view_menu_items := {
|
var view_menu_items := {
|
||||||
"Tile Mode" : KEY_MASK_CTRL + KEY_T,
|
"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 := {
|
var help_menu_items := {
|
||||||
"About Pixelorama" : 0
|
"About Pixelorama" : 0
|
||||||
|
@ -79,6 +81,8 @@ func _ready() -> void:
|
||||||
for item in view_menu_items.keys():
|
for item in view_menu_items.keys():
|
||||||
view_menu.add_check_item(item, i, view_menu_items[item])
|
view_menu.add_check_item(item, i, view_menu_items[item])
|
||||||
i += 1
|
i += 1
|
||||||
|
view_menu.set_item_checked(2, true) #Show Rulers
|
||||||
|
view_menu.set_item_checked(3, true) #Show Guides
|
||||||
i = 0
|
i = 0
|
||||||
for item in help_menu_items.keys():
|
for item in help_menu_items.keys():
|
||||||
help_menu.add_item(item, i, help_menu_items[item])
|
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
|
1: #Show grid
|
||||||
Global.draw_grid = !Global.draw_grid
|
Global.draw_grid = !Global.draw_grid
|
||||||
view_menu.set_item_checked(1, 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:
|
func help_menu_id_pressed(id : int) -> void:
|
||||||
match id:
|
match id:
|
||||||
|
|
|
@ -55,6 +55,8 @@ func _draw() -> void:
|
||||||
draw_line(Vector2(RULER_WIDTH * 0.66, position.y), Vector2(RULER_WIDTH, position.y), Color.white)
|
draw_line(Vector2(RULER_WIDTH * 0.66, position.y), Vector2(RULER_WIDTH, position.y), Color.white)
|
||||||
|
|
||||||
func _on_VerticalRuler_pressed() -> void:
|
func _on_VerticalRuler_pressed() -> void:
|
||||||
|
if !Global.show_guides:
|
||||||
|
return
|
||||||
var guide := Guide.new()
|
var guide := Guide.new()
|
||||||
guide.type = guide.TYPE.VERTICAL
|
guide.type = guide.TYPE.VERTICAL
|
||||||
guide.default_color = Color.purple
|
guide.default_color = Color.purple
|
||||||
|
|
Loading…
Reference in a new issue