From 7165f352b01d7590061eabadf8ad4d533da96488 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Thu, 4 Aug 2022 17:14:43 +0300 Subject: [PATCH] Make GradientEdit's color picker popup not get in the way of the preview --- src/UI/Nodes/GradientEdit.gd | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/UI/Nodes/GradientEdit.gd b/src/UI/Nodes/GradientEdit.gd index 403440de5..006f5335e 100644 --- a/src/UI/Nodes/GradientEdit.gd +++ b/src/UI/Nodes/GradientEdit.gd @@ -11,6 +11,7 @@ var active_cursor: GradientCursor # Showing a color picker popup to change a cu onready var x_offset: float = rect_size.x - GradientCursor.WIDTH onready var gradient: Gradient = texture.gradient +onready var color_picker: ColorPicker = $Popup.get_node("ColorPicker") class GradientCursor: @@ -132,8 +133,11 @@ func add_cursor(x: float, color: Color) -> void: func select_color(cursor: GradientCursor, position: Vector2) -> void: active_cursor = cursor - var color_picker = $Popup.get_node("ColorPicker") color_picker.color = cursor.color + if position.x > rect_global_position.x + (rect_size.x / 2.0): + position.x = rect_global_position.x + rect_size.x + else: + position.x = rect_global_position.x - $Popup.rect_size.x $Popup.rect_position = position $Popup.popup()