diff --git a/Scripts/Rulers/HorizontalRuler.gd b/Scripts/Rulers/HorizontalRuler.gd index fa93ddaa2..3ce3ff7de 100644 --- a/Scripts/Rulers/HorizontalRuler.gd +++ b/Scripts/Rulers/HorizontalRuler.gd @@ -9,14 +9,25 @@ var minor_subdivision := 4 var first : Vector2 var last : Vector2 +onready var _prev_camera_offset := Global.camera.offset +onready var _prev_camera_zoom := Global.camera.zoom + +func _ready() -> void: + Global.main_viewport.connect("item_rect_changed", self, "update") + # warning-ignore:unused_argument func _process(delta : float) -> void: - update() var mouse_pos := get_local_mouse_position() if mouse_pos.x < RULER_WIDTH: #For double guides mouse_default_cursor_shape = Control.CURSOR_FDIAGSIZE else: mouse_default_cursor_shape = Control.CURSOR_VSPLIT + if Global.camera.offset != _prev_camera_offset: + _prev_camera_offset = Global.camera.offset + update() + if Global.camera.zoom != _prev_camera_zoom: + _prev_camera_zoom = Global.camera.zoom + update() #Code taken and modified from Godot's source code func _draw() -> void: @@ -71,3 +82,4 @@ func _on_HorizontalRuler_pressed() -> void: guide.add_point(Vector2(99999, Global.canvas.current_pixel.y)) Global.canvas.add_child(guide) Global.has_focus = false + update() diff --git a/Scripts/Rulers/TimelineSeconds.gd b/Scripts/Rulers/TimelineSeconds.gd index 911e1d741..23e4324b1 100644 --- a/Scripts/Rulers/TimelineSeconds.gd +++ b/Scripts/Rulers/TimelineSeconds.gd @@ -9,9 +9,6 @@ var minor_subdivision := 3 var first : Vector2 var last : Vector2 -# warning-ignore:unused_argument -func _process(delta : float) -> void: - update() #Code taken and modified from Godot's source code func _draw() -> void: @@ -54,4 +51,4 @@ func _draw() -> void: if i % minor_subdivision == 0: draw_line(Vector2(position.x + RULER_WIDTH, RULER_WIDTH * 0.33), Vector2(position.x + RULER_WIDTH, RULER_WIDTH), color) else: - draw_line(Vector2(position.x + RULER_WIDTH, RULER_WIDTH * 0.66), Vector2(position.x + RULER_WIDTH, RULER_WIDTH), color) \ No newline at end of file + draw_line(Vector2(position.x + RULER_WIDTH, RULER_WIDTH * 0.66), Vector2(position.x + RULER_WIDTH, RULER_WIDTH), color) diff --git a/Scripts/Rulers/VerticalRuler.gd b/Scripts/Rulers/VerticalRuler.gd index 220e40e94..886fb3d80 100644 --- a/Scripts/Rulers/VerticalRuler.gd +++ b/Scripts/Rulers/VerticalRuler.gd @@ -9,9 +9,20 @@ var minor_subdivision := 4 var first : Vector2 var last : Vector2 +onready var _prev_camera_offset := Global.camera.offset +onready var _prev_camera_zoom := Global.camera.zoom + +func _ready() -> void: + Global.main_viewport.connect("item_rect_changed", self, "update") + # warning-ignore:unused_argument func _process(delta : float) -> void: - update() + if Global.camera.offset != _prev_camera_offset: + _prev_camera_offset = Global.camera.offset + update() + if Global.camera.zoom != _prev_camera_zoom: + _prev_camera_zoom = Global.camera.zoom + update() #Code taken and modified from Godot's source code func _draw() -> void: @@ -66,3 +77,4 @@ func _on_VerticalRuler_pressed() -> void: guide.add_point(Vector2(Global.canvas.current_pixel.x, 99999)) Global.canvas.add_child(guide) Global.has_focus = false + update()