diff --git a/imgui.cpp b/imgui.cpp index c1987be8f..5157a2cd4 100644 --- a/imgui.cpp +++ b/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); } //----------------------------------------------------------------------------- diff --git a/imgui.h b/imgui.h index 843b3beab..7ef8bd23a 100644 --- a/imgui.h +++ b/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)< 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 @@ -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)<