mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-30 20:51:06 +01:00 
			
		
		
		
	ColorEdit4: Fixed a bug when text input or drag and drop leading to unsaturated HSL values would erroneously alter the resulting color. (#2050)
This commit is contained in:
		
							
								
								
									
										13
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -12944,13 +12944,20 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl | ||||
|         ColorConvertHSVtoRGB(H >= 1.0f ? H - 10 * 1e-6f : H, S > 0.0f ? S : 10*1e-6f, V > 0.0f ? V : 1e-6f, col[0], col[1], col[2]); | ||||
|  | ||||
|     // R,G,B and H,S,V slider color editor | ||||
|     bool value_changed_fix_hue_wrap = false; | ||||
|     if ((flags & ImGuiColorEditFlags_NoInputs) == 0) | ||||
|     { | ||||
|         PushItemWidth((alpha_bar ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x); | ||||
|         ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf; | ||||
|         ImGuiColorEditFlags sub_flags = (flags & sub_flags_to_forward) | ImGuiColorEditFlags_NoPicker; | ||||
|         if (flags & ImGuiColorEditFlags_RGB || (flags & ImGuiColorEditFlags__InputsMask) == 0) | ||||
|             value_changed |= ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_RGB); | ||||
|             if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_RGB)) | ||||
|             { | ||||
|                 // FIXME: Hackily differenciating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget. | ||||
|                 // For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050) | ||||
|                 value_changed_fix_hue_wrap = (g.ActiveId != 0 && !g.ActiveIdAllowOverlap); | ||||
|                 value_changed = true; | ||||
|             } | ||||
|         if (flags & ImGuiColorEditFlags_HSV || (flags & ImGuiColorEditFlags__InputsMask) == 0) | ||||
|             value_changed |= ColorEdit4("##hsv", col, sub_flags | ImGuiColorEditFlags_HSV); | ||||
|         if (flags & ImGuiColorEditFlags_HEX || (flags & ImGuiColorEditFlags__InputsMask) == 0) | ||||
| @@ -12958,8 +12965,8 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl | ||||
|         PopItemWidth(); | ||||
|     } | ||||
|  | ||||
|     // Try to cancel hue wrap (after ColorEdit), if any | ||||
|     if (value_changed) | ||||
|     // Try to cancel hue wrap (after ColorEdit4 call), if any | ||||
|     if (value_changed_fix_hue_wrap) | ||||
|     { | ||||
|         float new_H, new_S, new_V; | ||||
|         ColorConvertRGBtoHSV(col[0], col[1], col[2], new_H, new_S, new_V); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user