summaryrefslogtreecommitdiff
path: root/editor/editor_properties.cpp
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2019-10-22 23:22:20 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2019-10-22 23:22:20 +0200
commit66bfa92e84e2334666eb453e33d2f16a353784d9 (patch)
treead76dd0e9feb4acf9e71ac6a35817d5ef71b7260 /editor/editor_properties.cpp
parent72dfa67dd3508f20592959d306e8f2ef159eea5f (diff)
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.
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r--editor/editor_properties.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index fbb66744a7..f3d203ef7f 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) {