From 66bfa92e84e2334666eb453e33d2f16a353784d9 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 22 Oct 2019 23:22:20 +0200 Subject: [PATCH] Add a tooltip to Color properties in the editor inspector This makes it possible to view a color's raw R/G/B/A values without clicking the ColorPickerButton. --- editor/editor_properties.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index fbb66744a71..f3d203ef7f5 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -1884,6 +1884,23 @@ void EditorPropertyColor::_bind_methods() { void EditorPropertyColor::update_property() { picker->set_pick_color(get_edited_object()->get(get_edited_property())); + const Color color = picker->get_pick_color(); + + // Add a tooltip to display each channel's values without having to click the ColorPickerButton + if (picker->is_editing_alpha()) { + picker->set_tooltip(vformat( + "R: %s\nG: %s\nB: %s\nA: %s", + rtos(color.r).pad_decimals(2), + rtos(color.g).pad_decimals(2), + rtos(color.b).pad_decimals(2), + rtos(color.a).pad_decimals(2))); + } else { + picker->set_tooltip(vformat( + "R: %s\nG: %s\nB: %s", + rtos(color.r).pad_decimals(2), + rtos(color.g).pad_decimals(2), + rtos(color.b).pad_decimals(2))); + } } void EditorPropertyColor::setup(bool p_show_alpha) {