mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-04 15:11:05 +01:00 
			
		
		
		
	Minor tidying up following merge BGRA color PR (#844)
This commit is contained in:
		
							
								
								
									
										12
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -1216,14 +1216,14 @@ ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul)
 | 
			
		||||
{ 
 | 
			
		||||
    ImVec4 c = GImGui->Style.Colors[idx]; 
 | 
			
		||||
    c.w *= GImGui->Style.Alpha * alpha_mul; 
 | 
			
		||||
    return ImGui::ColorConvertFloat4ToU32(c); 
 | 
			
		||||
    return ColorConvertFloat4ToU32(c); 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ImU32 ImGui::GetColorU32(const ImVec4& col)
 | 
			
		||||
{ 
 | 
			
		||||
    ImVec4 c = col; 
 | 
			
		||||
    c.w *= GImGui->Style.Alpha; 
 | 
			
		||||
    return ImGui::ColorConvertFloat4ToU32(c); 
 | 
			
		||||
    return ColorConvertFloat4ToU32(c); 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Convert rgb floats ([0-1],[0-1],[0-1]) to hsv floats ([0-1],[0-1],[0-1]), from Foley & van Dam p592
 | 
			
		||||
@@ -9546,13 +9546,7 @@ void ImGui::ValueColor(const char* prefix, ImU32 v)
 | 
			
		||||
{
 | 
			
		||||
    Text("%s: %08X", prefix, v);
 | 
			
		||||
    SameLine();
 | 
			
		||||
 | 
			
		||||
    ImVec4 col;
 | 
			
		||||
    col.x = (float)((v >> IM_COL32_R_SHIFT) & 0xFF) / 255.0f;
 | 
			
		||||
    col.y = (float)((v >> IM_COL32_G_SHIFT) & 0xFF) / 255.0f;
 | 
			
		||||
    col.z = (float)((v >> IM_COL32_B_SHIFT) & 0xFF) / 255.0f;
 | 
			
		||||
    col.w = (float)((v >> IM_COL32_A_SHIFT) & 0xFF) / 255.0f;
 | 
			
		||||
    ColorButton(col, true);
 | 
			
		||||
    ColorButton(ColorConvertU32ToFloat4(v), true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//-----------------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										34
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								imgui.h
									
									
									
									
									
								
							@@ -827,23 +827,6 @@ struct ImGuiIO
 | 
			
		||||
// Helpers
 | 
			
		||||
//-----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
// Helpers macros to generate 32-bits encoded colors
 | 
			
		||||
#ifdef IMGUI_USE_BGRA_PACKED_COLOR
 | 
			
		||||
#define IM_COL32_R_SHIFT    16
 | 
			
		||||
#define IM_COL32_G_SHIFT    8
 | 
			
		||||
#define IM_COL32_B_SHIFT    0
 | 
			
		||||
#define IM_COL32_A_SHIFT    24
 | 
			
		||||
#else
 | 
			
		||||
#define IM_COL32_R_SHIFT    0
 | 
			
		||||
#define IM_COL32_G_SHIFT    8
 | 
			
		||||
#define IM_COL32_B_SHIFT    16
 | 
			
		||||
#define IM_COL32_A_SHIFT    24
 | 
			
		||||
#endif
 | 
			
		||||
#define IM_COL32(R,G,B,A)    (((ImU32)(A)<<IM_COL32_A_SHIFT) | ((ImU32)(B)<<IM_COL32_B_SHIFT) | ((ImU32)(G)<<IM_COL32_G_SHIFT) | ((ImU32)(R)<<IM_COL32_R_SHIFT))
 | 
			
		||||
#define IM_COL32_WHITE       (IM_COL32(255,255,255,255))
 | 
			
		||||
#define IM_COL32_BLACK       (IM_COL32(0,0,0,255))
 | 
			
		||||
#define IM_COL32_BLACK_TRANS (IM_COL32(0,0,0,0))    // Transparent black
 | 
			
		||||
 | 
			
		||||
// Lightweight std::vector<> like class to avoid dragging dependencies (also: windows implementation of STL with debug enabled is absurdly slow, so let's bypass it so our code runs fast in debug).
 | 
			
		||||
// Our implementation does NOT call c++ constructors because we don't use them in ImGui. Don't use this class as a straight std::vector replacement in your code!
 | 
			
		||||
template<typename T>
 | 
			
		||||
@@ -1051,6 +1034,23 @@ struct ImGuiSizeConstraintCallbackData
 | 
			
		||||
    ImVec2  DesiredSize;    // Read-write.  Desired size, based on user's mouse position. Write to this field to restrain resizing.
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Helpers macros to generate 32-bits encoded colors
 | 
			
		||||
#ifdef IMGUI_USE_BGRA_PACKED_COLOR
 | 
			
		||||
#define IM_COL32_R_SHIFT    16
 | 
			
		||||
#define IM_COL32_G_SHIFT    8
 | 
			
		||||
#define IM_COL32_B_SHIFT    0
 | 
			
		||||
#define IM_COL32_A_SHIFT    24
 | 
			
		||||
#else
 | 
			
		||||
#define IM_COL32_R_SHIFT    0
 | 
			
		||||
#define IM_COL32_G_SHIFT    8
 | 
			
		||||
#define IM_COL32_B_SHIFT    16
 | 
			
		||||
#define IM_COL32_A_SHIFT    24
 | 
			
		||||
#endif
 | 
			
		||||
#define IM_COL32(R,G,B,A)    (((ImU32)(A)<<IM_COL32_A_SHIFT) | ((ImU32)(B)<<IM_COL32_B_SHIFT) | ((ImU32)(G)<<IM_COL32_G_SHIFT) | ((ImU32)(R)<<IM_COL32_R_SHIFT))
 | 
			
		||||
#define IM_COL32_WHITE       IM_COL32(255,255,255,255)  // Opaque white
 | 
			
		||||
#define IM_COL32_BLACK       IM_COL32(0,0,0,255)        // Opaque black
 | 
			
		||||
#define IM_COL32_BLACK_TRANS IM_COL32(0,0,0,0)          // Transparent black
 | 
			
		||||
 | 
			
		||||
// ImColor() helper to implicity converts colors to either ImU32 (packed 4x1 byte) or ImVec4 (4x1 float)
 | 
			
		||||
// Prefer using IM_COL32() macros if you want a guaranteed compile-time ImU32 for usage with ImDrawList API.
 | 
			
		||||
// Avoid storing ImColor! Store either u32 of ImVec4. This is not a full-featured color class.
 | 
			
		||||
 
 | 
			
		||||
@@ -602,7 +602,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
 | 
			
		||||
    {
 | 
			
		||||
        // Anti-aliased Fill
 | 
			
		||||
        const float AA_SIZE = 1.0f;
 | 
			
		||||
        const ImU32 col_trans = col & IM_COL32(255, 255, 255, 0);
 | 
			
		||||
        const ImU32 col_trans = col & IM_COL32(255,255,255,0);
 | 
			
		||||
        const int idx_count = (points_count-2)*3 + points_count*6;
 | 
			
		||||
        const int vtx_count = (points_count*2);
 | 
			
		||||
        PrimReserve(idx_count, vtx_count);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user