mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 13:08:47 +02:00
Merge branch 'master' into navigation
# Conflicts: # imgui.cpp # imgui_internal.h
This commit is contained in:
@ -937,13 +937,8 @@ void ImDrawList::PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImV
|
||||
|
||||
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int rounding_corners)
|
||||
{
|
||||
const int corners_top = ImGuiCorner_TopLeft | ImGuiCorner_TopRight;
|
||||
const int corners_bottom = ImGuiCorner_BotLeft | ImGuiCorner_BotRight;
|
||||
const int corners_left = ImGuiCorner_TopLeft | ImGuiCorner_BotLeft;
|
||||
const int corners_right = ImGuiCorner_TopRight | ImGuiCorner_BotRight;
|
||||
|
||||
rounding = ImMin(rounding, fabsf(b.x - a.x) * ( ((rounding_corners & corners_top) == corners_top) || ((rounding_corners & corners_bottom) == corners_bottom) ? 0.5f : 1.0f ) - 1.0f);
|
||||
rounding = ImMin(rounding, fabsf(b.y - a.y) * ( ((rounding_corners & corners_left) == corners_left) || ((rounding_corners & corners_right) == corners_right) ? 0.5f : 1.0f ) - 1.0f);
|
||||
rounding = ImMin(rounding, fabsf(b.x - a.x) * ( ((rounding_corners & ImDrawCornerFlags_Top) == ImDrawCornerFlags_Top) || ((rounding_corners & ImDrawCornerFlags_Bot) == ImDrawCornerFlags_Bot) ? 0.5f : 1.0f ) - 1.0f);
|
||||
rounding = ImMin(rounding, fabsf(b.y - a.y) * ( ((rounding_corners & ImDrawCornerFlags_Left) == ImDrawCornerFlags_Left) || ((rounding_corners & ImDrawCornerFlags_Right) == ImDrawCornerFlags_Right) ? 0.5f : 1.0f ) - 1.0f);
|
||||
|
||||
if (rounding <= 0.0f || rounding_corners == 0)
|
||||
{
|
||||
@ -954,10 +949,10 @@ void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, int
|
||||
}
|
||||
else
|
||||
{
|
||||
const float rounding_tl = (rounding_corners & ImGuiCorner_TopLeft) ? rounding : 0.0f;
|
||||
const float rounding_tr = (rounding_corners & ImGuiCorner_TopRight) ? rounding : 0.0f;
|
||||
const float rounding_br = (rounding_corners & ImGuiCorner_BotRight) ? rounding : 0.0f;
|
||||
const float rounding_bl = (rounding_corners & ImGuiCorner_BotLeft) ? rounding : 0.0f;
|
||||
const float rounding_tl = (rounding_corners & ImDrawCornerFlags_TopLeft) ? rounding : 0.0f;
|
||||
const float rounding_tr = (rounding_corners & ImDrawCornerFlags_TopRight) ? rounding : 0.0f;
|
||||
const float rounding_br = (rounding_corners & ImDrawCornerFlags_BotRight) ? rounding : 0.0f;
|
||||
const float rounding_bl = (rounding_corners & ImDrawCornerFlags_BotLeft) ? rounding : 0.0f;
|
||||
PathArcToFast(ImVec2(a.x + rounding_tl, a.y + rounding_tl), rounding_tl, 6, 9);
|
||||
PathArcToFast(ImVec2(b.x - rounding_tr, a.y + rounding_tr), rounding_tr, 9, 12);
|
||||
PathArcToFast(ImVec2(b.x - rounding_br, b.y - rounding_br), rounding_br, 0, 3);
|
||||
@ -1130,7 +1125,6 @@ void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& a, const Im
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
|
||||
// FIXME-OPT: This is wasting draw calls.
|
||||
const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back();
|
||||
if (push_texture_id)
|
||||
PushTextureID(user_texture_id);
|
||||
@ -1158,6 +1152,31 @@ void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& a, cons
|
||||
PopTextureID();
|
||||
}
|
||||
|
||||
void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col, float rounding, int rounding_corners)
|
||||
{
|
||||
if ((col & IM_COL32_A_MASK) == 0)
|
||||
return;
|
||||
|
||||
if (rounding <= 0.0f || (rounding_corners & ImDrawCornerFlags_All) == 0)
|
||||
{
|
||||
AddImage(user_texture_id, a, b, uv_a, uv_b, col);
|
||||
return;
|
||||
}
|
||||
|
||||
const bool push_texture_id = _TextureIdStack.empty() || user_texture_id != _TextureIdStack.back();
|
||||
if (push_texture_id)
|
||||
PushTextureID(user_texture_id);
|
||||
|
||||
int vert_start_idx = VtxBuffer.Size;
|
||||
PathRect(a, b, rounding, rounding_corners);
|
||||
PathFillConvex(col);
|
||||
int vert_end_idx = VtxBuffer.Size;
|
||||
ImGui::ShadeVertsLinearUV(VtxBuffer.Data + vert_start_idx, VtxBuffer.Data + vert_end_idx, a, b, uv_a, uv_b, true);
|
||||
|
||||
if (push_texture_id)
|
||||
PopTextureID();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImDrawData
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1232,6 +1251,30 @@ void ImGui::ShadeVertsLinearAlphaGradientForLeftToRightText(ImDrawVert* vert_sta
|
||||
}
|
||||
}
|
||||
|
||||
// Distribute UV over (a, b) rectangle
|
||||
void ImGui::ShadeVertsLinearUV(ImDrawVert* vert_start, ImDrawVert* vert_end, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp)
|
||||
{
|
||||
const ImVec2 size = b - a;
|
||||
const ImVec2 uv_size = uv_b - uv_a;
|
||||
const ImVec2 scale = ImVec2(
|
||||
size.x ? (uv_size.x / size.x) : 0.0f,
|
||||
size.y ? (uv_size.y / size.y) : 0.0f);
|
||||
|
||||
if (clamp)
|
||||
{
|
||||
const ImVec2 min = ImMin(uv_a, uv_b);
|
||||
const ImVec2 max = ImMax(uv_a, uv_b);
|
||||
|
||||
for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex)
|
||||
vertex->uv = ImClamp(uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale), min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex)
|
||||
vertex->uv = uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImFontConfig
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user