From d683d7560616e2cf4e3c1feafcdd7240fe0faed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 28 Dec 2016 20:27:16 -0800 Subject: [PATCH] ImGui: Added color edit helper. --- 3rdparty/ocornut-imgui/widgets/color_picker.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/3rdparty/ocornut-imgui/widgets/color_picker.h b/3rdparty/ocornut-imgui/widgets/color_picker.h index f9d9812f7..72a630dfd 100644 --- a/3rdparty/ocornut-imgui/widgets/color_picker.h +++ b/3rdparty/ocornut-imgui/widgets/color_picker.h @@ -3,4 +3,22 @@ namespace ImGui bool ColorPicker4(float* col, bool show_alpha); bool ColorPicker3(float col[3]); + inline bool ColorEdit4(const char* label, uint32_t* _rgba, bool show_alpha = true) + { + uint8_t* rgba = (uint8_t*)_rgba; + float col[4] = + { + rgba[0]/255.0f, + rgba[1]/255.0f, + rgba[2]/255.0f, + rgba[3]/255.0f, + }; + bool result = ColorEdit4(label, col, show_alpha); + rgba[0] = uint8_t(col[0]*255.0f); + rgba[1] = uint8_t(col[1]*255.0f); + rgba[2] = uint8_t(col[2]*255.0f); + rgba[3] = uint8_t(col[3]*255.0f); + return result; + } + } // namespace ImGui