mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	ColorEdit: Fixed tooltip not honoring the ImGuiColorEditFlags_NoAlpha contract of never reading the 4th float in the array (value was read and discarded). (#2384)
This commit is contained in:
		@@ -4648,9 +4648,7 @@ void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags
 | 
			
		||||
{
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
 | 
			
		||||
    int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]);
 | 
			
		||||
    BeginTooltipEx(0, true);
 | 
			
		||||
 | 
			
		||||
    const char* text_end = text ? FindRenderedTextEnd(text, NULL) : text;
 | 
			
		||||
    if (text_end > text)
 | 
			
		||||
    {
 | 
			
		||||
@@ -4659,7 +4657,9 @@ void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ImVec2 sz(g.FontSize * 3 + g.Style.FramePadding.y * 2, g.FontSize * 3 + g.Style.FramePadding.y * 2);
 | 
			
		||||
    ColorButton("##preview", ImVec4(col[0], col[1], col[2], col[3]), (flags & (ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)) | ImGuiColorEditFlags_NoTooltip, sz);
 | 
			
		||||
    ImVec4 cf(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]);
 | 
			
		||||
    int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]);
 | 
			
		||||
    ColorButton("##preview", cf, (flags & (ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)) | ImGuiColorEditFlags_NoTooltip, sz);
 | 
			
		||||
    SameLine();
 | 
			
		||||
    if (flags & ImGuiColorEditFlags_NoAlpha)
 | 
			
		||||
        Text("#%02X%02X%02X\nR: %d, G: %d, B: %d\n(%.3f, %.3f, %.3f)", cr, cg, cb, cr, cg, cb, col[0], col[1], col[2]);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user