GraphicsEditor/addons/graphics_editor/Navbar.gd

85 lines
1.7 KiB
GDScript3
Raw Normal View History

2019-08-04 09:57:42 +02:00
tool
extends Control
2020-10-25 18:39:10 +01:00
var editor
var paint_canvas
2019-11-27 06:09:09 +01:00
2019-08-04 09:57:42 +02:00
func _ready():
2020-10-25 18:39:10 +01:00
editor = owner
paint_canvas = editor.find_node("PaintCanvas")
2019-08-04 09:57:42 +02:00
for i in get_node("Buttons").get_children():
i.connect("item_pressed", self, "button_pressed")
func button_pressed(button_name, button_item):
2020-10-25 18:39:10 +01:00
print("pressed: ", button_name)
print("pressed item is: '%s'" % button_item)
match button_name:
"File":
handle_file_menu(button_item)
"Edit":
handle_edit_menu(button_item)
"Canvas":
handle_canvas_menu(button_item)
"Layer":
handle_layer_menu(button_item)
"Grid":
handle_grid_menu(button_item)
"Magic":
handle_magic_menu(button_item)
"Editor":
handle_editor_menu(button_item)
func handle_file_menu(pressed_item: String):
match pressed_item:
"Save":
owner.get_node("SaveFileDialog").show()
func handle_edit_menu(pressed_item: String):
match pressed_item:
"Add Layer":
editor.add_new_layer()
func handle_canvas_menu(pressed_item: String):
match pressed_item:
"Add Layer":
editor.add_new_layer()
func handle_layer_menu(pressed_item: String):
match pressed_item:
"Add Layer":
editor.add_new_layer()
"Delete Layer":
editor.remove_active_layer()
"Duplicate Layer":
editor.duplicate_active_layer()
func handle_grid_menu(pressed_item: String):
match pressed_item:
"Add Layer":
editor.add_new_layer()
func handle_magic_menu(pressed_item: String):
match pressed_item:
"Add Layer":
editor.add_new_layer()
func handle_editor_menu(pressed_item: String):
match pressed_item:
"Settings":
owner.get_node("Settings").show()
"Toggle Grid":
var grids_node = owner.find_node("Grids")
2019-08-04 09:57:42 +02:00
grids_node.visible = !grids_node.visible
2020-10-25 18:39:10 +01:00
"Reset Canvas Position":
owner.paint_canvas_node.rect_position = Vector2(0, 0)