Added guides

- Added horizontal & vertical guides which can be dragged from their respective rulers
- Fixed bug when opening and importing files
This commit is contained in:
OverloadedOrama 2019-11-21 00:11:21 +02:00
parent 8b5ee21d01
commit 224316256c
10 changed files with 186 additions and 98 deletions

View file

@ -1,4 +1,4 @@
extends Panel
extends Button
const RULER_WIDTH := 16
@ -22,7 +22,7 @@ func _draw() -> void:
var zoom := 1 / Global.camera.zoom.x
transform.y = Vector2(zoom, zoom)
transform.origin = Global.main_viewport.rect_size / 2 + (Global.camera.offset) * -zoom
transform.origin = Global.main_viewport.rect_size / 2 + Global.camera.offset * -zoom
var basic_rule := 100.0
var i := 0
@ -53,3 +53,12 @@ func _draw() -> void:
draw_line(Vector2(RULER_WIDTH * 0.33, position.y), Vector2(RULER_WIDTH, position.y), Color.white)
else:
draw_line(Vector2(RULER_WIDTH * 0.66, position.y), Vector2(RULER_WIDTH, position.y), Color.white)
func _on_VerticalRuler_pressed() -> void:
var line_2d := Guide.new()
line_2d.type = line_2d.TYPE.VERTICAL
line_2d.default_color = Color.purple
line_2d.add_point(Vector2(Global.canvas.current_pixel.x, -99999))
line_2d.add_point(Vector2(Global.canvas.current_pixel.x, 99999))
Global.canvas.add_child(line_2d)
Global.has_focus = false