ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.98k stars 10.19k forks source link

ColorEdit4: Show preview colors in sliders? #3520

Open jeffkdev opened 3 years ago

jeffkdev commented 3 years ago

Version/Branch of Dear ImGui:

Version: Dear ImGui 1.79 Branch: master

My Issue/Question:

Is there interest in expanding the color picker so it has the option to show preview colors in the RGB and/or HSV sliders?

Screenshots/Video Use case: image

Working prototype: image image

Standalone, minimal, complete and verifiable example: I only implemented this locally for RGB sliders. So probably would need to do something different for HSV:

IMGUI_API bool          SliderScalarGradient(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const ImU32 color_start, const ImU32 color_end, const char* format = NULL, ImGuiSliderFlags flags = 0);

I made calling this new function the default behavior in my ColorEdit4, but it could be made optional by using one of the few remaining ImGuiColorEditFlags_. Feel free to close if this is something best left outside the main library.

ocornut commented 10 months ago

It would probably be interesting to have this as an option, but seeing we don't have proper standardized support for sRGB/Linear the preview may be incorrect unless manually tesselated (the equivalent HSV preview would need manual tesselation either way). If you still have the code around may be nice posting.

jeffkdev commented 10 months ago

Sure, here is a gist of the code along with some TODO items:

https://gist.github.com/jeffkdev/ea8458af09c40271b7ba5c62cc8a3a78