mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
Clarification about Im helpers + moving GetColorXXX functions outside of that block.
This commit is contained in:
parent
3a800f2dc9
commit
10fdc03a46
66
imgui.cpp
66
imgui.cpp
@ -1726,38 +1726,6 @@ void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float&
|
||||
}
|
||||
}
|
||||
|
||||
ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul)
|
||||
{
|
||||
ImGuiStyle& style = GImGui->Style;
|
||||
ImVec4 c = style.Colors[idx];
|
||||
c.w *= style.Alpha * alpha_mul;
|
||||
return ColorConvertFloat4ToU32(c);
|
||||
}
|
||||
|
||||
ImU32 ImGui::GetColorU32(const ImVec4& col)
|
||||
{
|
||||
ImGuiStyle& style = GImGui->Style;
|
||||
ImVec4 c = col;
|
||||
c.w *= style.Alpha;
|
||||
return ColorConvertFloat4ToU32(c);
|
||||
}
|
||||
|
||||
const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx)
|
||||
{
|
||||
ImGuiStyle& style = GImGui->Style;
|
||||
return style.Colors[idx];
|
||||
}
|
||||
|
||||
ImU32 ImGui::GetColorU32(ImU32 col)
|
||||
{
|
||||
float style_alpha = GImGui->Style.Alpha;
|
||||
if (style_alpha >= 1.0f)
|
||||
return col;
|
||||
ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT;
|
||||
a = (ImU32)(a * style_alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range.
|
||||
return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] ImGuiStorage
|
||||
// Helper: Key->value storage
|
||||
@ -2215,10 +2183,42 @@ bool ImGuiListClipper::Step()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] RENDER HELPERS
|
||||
// Those (internal) functions are currently quite a legacy mess - their signature and behavior will change.
|
||||
// Some of those (internal) functions are currently quite a legacy mess - their signature and behavior will change.
|
||||
// Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: state.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul)
|
||||
{
|
||||
ImGuiStyle& style = GImGui->Style;
|
||||
ImVec4 c = style.Colors[idx];
|
||||
c.w *= style.Alpha * alpha_mul;
|
||||
return ColorConvertFloat4ToU32(c);
|
||||
}
|
||||
|
||||
ImU32 ImGui::GetColorU32(const ImVec4& col)
|
||||
{
|
||||
ImGuiStyle& style = GImGui->Style;
|
||||
ImVec4 c = col;
|
||||
c.w *= style.Alpha;
|
||||
return ColorConvertFloat4ToU32(c);
|
||||
}
|
||||
|
||||
const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx)
|
||||
{
|
||||
ImGuiStyle& style = GImGui->Style;
|
||||
return style.Colors[idx];
|
||||
}
|
||||
|
||||
ImU32 ImGui::GetColorU32(ImU32 col)
|
||||
{
|
||||
ImGuiStyle& style = GImGui->Style;
|
||||
if (style.Alpha >= 1.0f)
|
||||
return col;
|
||||
ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT;
|
||||
a = (ImU32)(a * style.Alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range.
|
||||
return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT);
|
||||
}
|
||||
|
||||
const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
|
||||
{
|
||||
const char* text_display_end = text;
|
||||
|
@ -192,6 +192,8 @@ extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Generic helpers
|
||||
// Note that the ImXXX helpers functions are lower-level than ImGui functions.
|
||||
// ImGui functions or the ImGui context are never called/used from other ImXXX functions.
|
||||
//-----------------------------------------------------------------------------
|
||||
// - Helpers: Misc
|
||||
// - Helpers: Bit manipulation
|
||||
|
Loading…
Reference in New Issue
Block a user