-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ColorPicker: unable to update uint32_t color when saturation is zero #4014
Comments
Further investigation shows the problem may be due to this line: Line 5087 in 58075c4
Clicking the hue bar will give an My current solution is to set fallback saturation value to |
I think changing the underlying color storage from uint32_t to float4 is a better solution for me. This can avoid the precision lost when converting colors. But when uint32_t color is a must, can the color picker GUI be designed to avoid various jumping back/around? |
We already have mitigation code in the picker to temporarily preserve varying Hue while Saturation is 0.0f, but somehow this code doesn't work on a round-trip through int32 packing. So I would say on our end it is a bug that this mitigation code doesn't work and we could try to keep it working in that case. |
The reason why round-trip through int32 packing is not working is because the precision of int32 is not enough for editing Hue with zero Saturation when int32 is seen as RGB and converting to/from HSV must be performed. The edition (to RGB space) in HSV space is not uniformly equal under different saturation. Say we are editing color 0xD8D8D8, which is RGB(216, 216, 216)/HSV(0,0,216). If we change H to 100, HSV(100,0,216) stills corresponds to RGB(216,216,216) and thus color is not changed. However, if color is stored in float4, HSV(100,0,216) will change float4 value, even RGB (converted from float4) still looks the same. So just not use color picker to edit in32 color and the trouble is gone... |
* Fix inability to change hue when saturation is 0 by storing last color picker color as 32bit integer rgb value. This prevents failures of hue/saturation restoration due to lossy conversions. (ocornut#4014) * Fix hue resetting to 0 when it is set to 255 by explicitly restoring hue if it is 0 and previous value was 1. * Reduce hue jitter by restoring hue when color is modified using SV square.
* Change g.ColorEditLastColor type to float* and use pointer comparison to determine whether hue/saturation backup values belong to edited color. - Fixes inability to change hue when saturation is 0. (ocornut#4014) - Fixes edgecases where lossy color conversion prevent restoration of hue/saturation. - Fixes hue value jitter when modifying color using SV square. * Fix hue resetting to 0 when it is set to 255 by explicitly restoring hue if it is 0 and previous value was 1. * Further reduce hue jitter by restoring hue when color is modified using SV square.
* Change g.ColorEditLastColor type to float* and use pointer comparison to determine whether hue/saturation backup values belong to edited color. - Fixes inability to change hue when saturation is 0. (ocornut#4014) - Fixes edgecases where lossy color conversion prevent restoration of hue/saturation. - Fixes hue value jitter when modifying color using SV square. * Fix hue resetting to 0 when it is set to 255 by explicitly restoring hue if it is 0 and previous value was 1. * Further reduce hue jitter by restoring hue when color is modified using SV square.
* Change g.ColorEditLastColor type to ImU32 and store RGB color value. - Fixes inability to change hue when saturation is 0. (ocornut#4014) - Fixes edgecases where lossy color conversion prevent restoration of hue/saturation. - Fixes hue value jitter when modifying color using SV square. * Fix hue resetting to 0 when it is set to 255 by explicitly restoring hue if it is 0 and previous value was 1. * Further reduce hue jitter by restoring hue when color is modified using SV square.
* Change g.ColorEditLastColor type to ImU32 and store RGB color value. - Fixes inability to change hue when saturation is 0. (ocornut#4014) - Fixes edgecases where lossy color conversion prevent restoration of hue/saturation. - Fixes hue value jitter when modifying color using SV square. * Fix hue resetting to 0 when it is set to 255 by explicitly restoring hue if it is 0 and previous value was 1. * Further reduce hue jitter by restoring hue when color is modified using SV square.
* Change g.ColorEditLastColor type to ImU32 and store RGB color value. - Fixes inability to change hue when saturation is 0. (#4014) - Fixes edgecases where lossy color conversion prevent restoration of hue/saturation. - Fixes hue value jitter when modifying color using SV square. * Fix hue resetting to 0 when it is set to 255 by explicitly restoring hue if it is 0 and previous value was 1. * Further reduce hue jitter by restoring hue when color is modified using SV square.
Should now be fixed by 30546bc |
Version/Branch of Dear ImGui:
My Issue/Question:
When change a color with saturation==0 (which is converted from uint32_t), in color picker in RGB mode, clicking on the hue bar will temporarily change the color but the color is immediately reverted to the original.
The return value of
ImGui::ColorEdit4
is true, however, the color value is almost identical to the original. See code below.If the saturation is non-zero, the color can be changed successfully.
But the expected behaviour should be correctly changing the color no matter what the original color value is.
Screenshots/Video
Standalone, minimal, complete and verifiable example:
The text was updated successfully, but these errors were encountered: