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

only redraw HorizontalRuler and VerticalRuler when needed

This commit is contained in:
Martin Zabinski 2019-12-27 14:43:26 +01:00
parent 9c7b90bb96
commit 037a797afc
2 changed files with 26 additions and 2 deletions

View file

@ -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()

View file

@ -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()