mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +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 first : Vector2
|
||||||
var last : 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
|
# warning-ignore:unused_argument
|
||||||
func _process(delta : float) -> void:
|
func _process(delta : float) -> void:
|
||||||
update()
|
|
||||||
var mouse_pos := get_local_mouse_position()
|
var mouse_pos := get_local_mouse_position()
|
||||||
if mouse_pos.x < RULER_WIDTH: #For double guides
|
if mouse_pos.x < RULER_WIDTH: #For double guides
|
||||||
mouse_default_cursor_shape = Control.CURSOR_FDIAGSIZE
|
mouse_default_cursor_shape = Control.CURSOR_FDIAGSIZE
|
||||||
else:
|
else:
|
||||||
mouse_default_cursor_shape = Control.CURSOR_VSPLIT
|
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
|
#Code taken and modified from Godot's source code
|
||||||
func _draw() -> void:
|
func _draw() -> void:
|
||||||
|
@ -71,3 +82,4 @@ func _on_HorizontalRuler_pressed() -> void:
|
||||||
guide.add_point(Vector2(99999, Global.canvas.current_pixel.y))
|
guide.add_point(Vector2(99999, Global.canvas.current_pixel.y))
|
||||||
Global.canvas.add_child(guide)
|
Global.canvas.add_child(guide)
|
||||||
Global.has_focus = false
|
Global.has_focus = false
|
||||||
|
update()
|
||||||
|
|
|
@ -9,9 +9,6 @@ var minor_subdivision := 3
|
||||||
var first : Vector2
|
var first : Vector2
|
||||||
var last : Vector2
|
var last : Vector2
|
||||||
|
|
||||||
# warning-ignore:unused_argument
|
|
||||||
func _process(delta : float) -> void:
|
|
||||||
update()
|
|
||||||
|
|
||||||
#Code taken and modified from Godot's source code
|
#Code taken and modified from Godot's source code
|
||||||
func _draw() -> void:
|
func _draw() -> void:
|
||||||
|
|
|
@ -9,9 +9,20 @@ var minor_subdivision := 4
|
||||||
var first : Vector2
|
var first : Vector2
|
||||||
var last : 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
|
# warning-ignore:unused_argument
|
||||||
func _process(delta : float) -> void:
|
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
|
#Code taken and modified from Godot's source code
|
||||||
func _draw() -> void:
|
func _draw() -> void:
|
||||||
|
@ -66,3 +77,4 @@ func _on_VerticalRuler_pressed() -> void:
|
||||||
guide.add_point(Vector2(Global.canvas.current_pixel.x, 99999))
|
guide.add_point(Vector2(Global.canvas.current_pixel.x, 99999))
|
||||||
Global.canvas.add_child(guide)
|
Global.canvas.add_child(guide)
|
||||||
Global.has_focus = false
|
Global.has_focus = false
|
||||||
|
update()
|
||||||
|
|
Loading…
Reference in a new issue