Skip to content

Commit

Permalink
Moved GetColorU32 out of imgui_internal.h to avoid inlining mess (oco…
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed Aug 6, 2016
1 parent 907265d commit a7f6ea5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 14 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,20 @@ ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in)
return out;
}

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);
}

ImU32 ImGui::GetColorU32(const ImVec4& col)
{
ImVec4 c = col;
c.w *= GImGui->Style.Alpha;
return ImGui::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
// Optimized http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv
void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v)
Expand Down
3 changes: 0 additions & 3 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,6 @@ namespace ImGui

IMGUI_API void OpenPopupEx(const char* str_id, bool reopen_existing);

inline IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul) { ImVec4 c = GImGui->Style.Colors[idx]; c.w *= GImGui->Style.Alpha * alpha_mul; return ImGui::ColorConvertFloat4ToU32(c); }
inline IMGUI_API ImU32 GetColorU32(const ImVec4& col) { ImVec4 c = col; c.w *= GImGui->Style.Alpha; return ImGui::ColorConvertFloat4ToU32(c); }

// NB: All position are in absolute pixels coordinates (not window coordinates)
// FIXME: All those functions are a mess and needs to be refactored into something decent. Avoid use outside of imgui.cpp!
// We need: a sort of symbol library, preferably baked into font atlas when possible + decent text rendering helpers.
Expand Down

0 comments on commit a7f6ea5

Please sign in to comment.