imgui icon indicating copy to clipboard operation
imgui copied to clipboard

ColorEdit4: Show preview colors in sliders?

Open jeffkdev opened this issue 5 years ago • 2 comments

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.

jeffkdev avatar Oct 10 '20 18:10 jeffkdev

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.

ocornut avatar Dec 07 '23 15:12 ocornut

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

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

ADMIN added a copy: ea8458af09c40271b7ba5c62cc8a3a78-491f6d170f0f62abadd42e63e4f0867e5a1fa508.zip

jeffkdev avatar Dec 07 '23 16:12 jeffkdev