From 70d5fad9fd0332cb07fc6e9abab0bb64d6335846 Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sun, 9 May 2021 00:56:23 +0300 Subject: [PATCH] Make selection tool options not editable when there is no selection --- src/Tools/SelectionTools/SelectionTool.gd | 19 ++++++++++++++----- src/UI/Canvas/Selection.gd | 5 +---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Tools/SelectionTools/SelectionTool.gd b/src/Tools/SelectionTools/SelectionTool.gd index 6774e9277..5aa3dba56 100644 --- a/src/Tools/SelectionTools/SelectionTool.gd +++ b/src/Tools/SelectionTools/SelectionTool.gd @@ -21,11 +21,7 @@ onready var hspinbox : SpinBox = find_node("HSpinBox") func _ready() -> void: - var select_rect : Rect2 = selection_node.big_bounding_rectangle - xspinbox.value = select_rect.position.x - yspinbox.value = select_rect.position.y - wspinbox.value = select_rect.size.x - hspinbox.value = select_rect.size.y + set_spinbox_values() func _input(event : InputEvent) -> void: @@ -41,6 +37,19 @@ func _input(event : InputEvent) -> void: _snap_to_grid = false +func set_spinbox_values() -> void: + var select_rect : Rect2 = selection_node.big_bounding_rectangle + xspinbox.editable = !select_rect.has_no_area() + yspinbox.editable = !select_rect.has_no_area() + wspinbox.editable = !select_rect.has_no_area() + hspinbox.editable = !select_rect.has_no_area() + + xspinbox.value = select_rect.position.x + yspinbox.value = select_rect.position.y + wspinbox.value = select_rect.size.x + hspinbox.value = select_rect.size.y + + func draw_start(position : Vector2) -> void: if selection_node.arrow_key_move: return diff --git a/src/UI/Canvas/Selection.gd b/src/UI/Canvas/Selection.gd index 9585f3193..16a1c1a54 100644 --- a/src/UI/Canvas/Selection.gd +++ b/src/UI/Canvas/Selection.gd @@ -229,10 +229,7 @@ func _big_bounding_rectangle_changed(value : Rect2) -> void: big_bounding_rectangle = value for slot in Tools._slots.values(): if slot.tool_node is SelectionTool: - slot.tool_node.xspinbox.value = value.position.x - slot.tool_node.yspinbox.value = value.position.y - slot.tool_node.wspinbox.value = value.size.x - slot.tool_node.hspinbox.value = value.size.y + slot.tool_node.set_spinbox_values() update_gizmos()