mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Merge pull request #94 from Martin1991zab/master
only redraw rulers when needed
This commit is contained in:
commit
61169f86ba
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
draw_line(Vector2(position.x + RULER_WIDTH, RULER_WIDTH * 0.66), Vector2(position.x + RULER_WIDTH, RULER_WIDTH), color)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue