瀏覽代碼

Changed HTML input color_changed logic.
Made the HTML field send change events based on whether the new color's string is different from the previous color's string (instead of whether the new string parses to the current color value).
Previously, updating the color value even when the corresponding string hadn't changed would unnecessarily quantize the color value to 8 bits just by opening/closing the Color Picker.

(cherry picked from commit 21d778b0c3f7b1cb20f07dfe1e16a90097d7012e)

Michael Wörner 1 年之前
父節點
當前提交
d01c60c178
共有 1 個文件被更改,包括 5 次插入4 次删除
  1. 5 4
      scene/gui/color_picker.cpp

+ 5 - 4
scene/gui/color_picker.cpp

@@ -556,16 +556,17 @@ void ColorPicker::_html_submitted(const String &p_html) {
 		return;
 		return;
 	}
 	}
 
 
-	const Color previous_color = color;
-	color = Color::from_string(p_html.strip_edges(), previous_color);
+	Color new_color = Color::from_string(p_html.strip_edges(), color);
 
 
 	if (!is_editing_alpha()) {
 	if (!is_editing_alpha()) {
-		color.a = previous_color.a;
+		new_color.a = color.a;
 	}
 	}
 
 
-	if (color == previous_color) {
+	if (new_color.to_argb32() == color.to_argb32()) {
 		return;
 		return;
 	}
 	}
+	color = new_color;
+
 	if (!is_inside_tree()) {
 	if (!is_inside_tree()) {
 		return;
 		return;
 	}
 	}