Compare commits
13 Commits
master
...
features/s
Author | SHA1 | Date | |
---|---|---|---|
|
1d4c752c29 | ||
|
63c15058dc | ||
|
a2ee47852b | ||
|
e1f7a81150 | ||
|
66a94215b0 | ||
|
d170c874d3 | ||
|
ea911d83cb | ||
|
9516b8fc85 | ||
|
49523bb069 | ||
|
07fb4a87c8 | ||
|
b2698d69f8 | ||
|
09d0a94761 | ||
|
e21c21e3b9 |
22
imgui.cpp
22
imgui.cpp
@ -1237,6 +1237,7 @@ static void UpdateKeyRoutingTable(ImGuiKeyRoutingTable* rt);
|
||||
// Misc
|
||||
static void UpdateSettings();
|
||||
static int UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_hovered, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect);
|
||||
static void RenderWindowShadow(ImGuiWindow* window);
|
||||
static void RenderWindowOuterBorders(ImGuiWindow* window);
|
||||
static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, bool handle_borders_and_resize_grips, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
|
||||
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
|
||||
@ -1345,6 +1346,9 @@ ImGuiStyle::ImGuiStyle()
|
||||
AntiAliasedFill = true; // Enable anti-aliased filled shapes (rounded rectangles, circles, etc.).
|
||||
CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||
CircleTessellationMaxError = 0.30f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
||||
WindowShadowSize = 100.0f; // Size (in pixels) of window shadows.
|
||||
WindowShadowOffsetDist = 0.0f; // Offset distance (in pixels) of window shadows from casting window.
|
||||
WindowShadowOffsetAngle = IM_PI * 0.25f; // Offset angle of window shadows from casting window (0.0f = left, 0.5f*PI = bottom, 1.0f*PI = right, 1.5f*PI = top).
|
||||
|
||||
// Behaviors
|
||||
HoverStationaryDelay = 0.15f; // Delay for IsItemHovered(ImGuiHoveredFlags_Stationary). Time required to consider mouse stationary.
|
||||
@ -3487,6 +3491,7 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
|
||||
case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight";
|
||||
case ImGuiCol_NavWindowingDimBg: return "NavWindowingDimBg";
|
||||
case ImGuiCol_ModalWindowDimBg: return "ModalWindowDimBg";
|
||||
case ImGuiCol_WindowShadow: return "WindowShadow";
|
||||
}
|
||||
IM_ASSERT(0);
|
||||
return "Unknown";
|
||||
@ -6714,6 +6719,11 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
|
||||
window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? 0 : ImDrawFlags_RoundCornersBottom);
|
||||
}
|
||||
|
||||
// Draw window shadow
|
||||
if (style.WindowShadowSize > 0.0f && (!(flags & ImGuiWindowFlags_ChildWindow) || (flags & ImGuiWindowFlags_Popup)))
|
||||
if (style.Colors[ImGuiCol_WindowShadow].w > 0.0f)
|
||||
RenderWindowShadow(window);
|
||||
|
||||
// Title bar
|
||||
if (!(flags & ImGuiWindowFlags_NoTitleBar))
|
||||
{
|
||||
@ -6760,6 +6770,16 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::RenderWindowShadow(ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiStyle& style = g.Style;
|
||||
float shadow_size = style.WindowShadowSize;
|
||||
ImU32 shadow_col = GetColorU32(ImGuiCol_WindowShadow);
|
||||
ImVec2 shadow_offset = ImVec2(ImCos(style.WindowShadowOffsetAngle), ImSin(style.WindowShadowOffsetAngle)) * style.WindowShadowOffsetDist;
|
||||
window->DrawList->AddShadowRect(window->Pos, window->Pos + window->Size, shadow_col, shadow_size, shadow_offset, ImDrawFlags_ShadowCutOutShapeBackground, window->WindowRounding);
|
||||
}
|
||||
|
||||
// Render title text, collapse button, close button
|
||||
void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open)
|
||||
{
|
||||
@ -7941,6 +7961,8 @@ void ImGui::SetCurrentFont(ImFont* font)
|
||||
g.DrawListSharedData.Font = g.Font;
|
||||
g.DrawListSharedData.FontSize = g.FontSize;
|
||||
g.DrawListSharedData.FontScale = g.FontScale;
|
||||
g.DrawListSharedData.ShadowRectIds = &atlas->ShadowRectIds[0];
|
||||
g.DrawListSharedData.ShadowRectUvs = &atlas->ShadowRectUvs[0];
|
||||
}
|
||||
|
||||
// Use ImDrawList::_SetTextureID(), making our shared g.FontStack[] authorative against window-local ImDrawList.
|
||||
|
45
imgui.h
45
imgui.h
@ -1659,6 +1659,7 @@ enum ImGuiCol_
|
||||
ImGuiCol_NavWindowingHighlight, // Highlight window when using CTRL+TAB
|
||||
ImGuiCol_NavWindowingDimBg, // Darken/colorize entire screen behind the CTRL+TAB window list, when active
|
||||
ImGuiCol_ModalWindowDimBg, // Darken/colorize entire screen behind a modal window, when one is active
|
||||
ImGuiCol_WindowShadow, // Window shadows
|
||||
ImGuiCol_COUNT,
|
||||
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
@ -2165,6 +2166,9 @@ struct ImGuiStyle
|
||||
bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||
float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||
float CircleTessellationMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
||||
float WindowShadowSize; // Size (in pixels) of window shadows. Set this to zero to disable shadows.
|
||||
float WindowShadowOffsetDist; // Offset distance (in pixels) of window shadows from casting window.
|
||||
float WindowShadowOffsetAngle; // Offset angle of window shadows from casting window (0.0f = left, 0.5f*PI = bottom, 1.0f*PI = right, 1.5f*PI = top).
|
||||
ImVec4 Colors[ImGuiCol_COUNT];
|
||||
|
||||
// Behaviors
|
||||
@ -3020,6 +3024,7 @@ enum ImDrawFlags_
|
||||
ImDrawFlags_RoundCornersAll = ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersTopRight | ImDrawFlags_RoundCornersBottomLeft | ImDrawFlags_RoundCornersBottomRight,
|
||||
ImDrawFlags_RoundCornersDefault_ = ImDrawFlags_RoundCornersAll, // Default to ALL corners if none of the _RoundCornersXX flags are specified.
|
||||
ImDrawFlags_RoundCornersMask_ = ImDrawFlags_RoundCornersAll | ImDrawFlags_RoundCornersNone,
|
||||
ImDrawFlags_ShadowCutOutShapeBackground = 1 << 9, // Do not render the shadow shape under the objects to be shadowed to save on fill-rate or facilitate blending. Slower on CPU.
|
||||
};
|
||||
|
||||
// Flags for ImDrawList instance. Those are set automatically by ImGui:: functions from ImGuiIO settings, and generally not manipulated directly.
|
||||
@ -3117,6 +3122,23 @@ struct ImDrawList
|
||||
IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1 = ImVec2(0, 0), const ImVec2& uv2 = ImVec2(1, 0), const ImVec2& uv3 = ImVec2(1, 1), const ImVec2& uv4 = ImVec2(0, 1), ImU32 col = IM_COL32_WHITE);
|
||||
IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawFlags flags = 0);
|
||||
|
||||
// Shadows primitives
|
||||
// [BETA] API
|
||||
// - Add shadow for a object, with min/max or center/radius describing the object extents, and offset shifting the shadow.
|
||||
// - Rounding parameters refer to the object itself, not the shadow!
|
||||
// - By default, the area under the object is filled, because this is simpler to process.
|
||||
// Using the ImDrawFlags_ShadowCutOutShapeBackground flag makes the function not render this area and leave a hole under the object.
|
||||
// - Shadows w/ fill under the object: a bit faster for CPU, more pixels rendered, visible/darkening if used behind a transparent shape.
|
||||
// Typically used by: small, frequent objects, opaque objects, transparent objects if shadow darkening isn't an issue.
|
||||
// - Shadows w/ hole under the object: a bit slower for CPU, less pixels rendered, no difference if used behind a transparent shape.
|
||||
// Typically used by: large, infrequent objects, transparent objects if exact blending/color matter.
|
||||
// - FIXME-SHADOWS: 'offset' + ImDrawFlags_ShadowCutOutShapeBackground are not currently supported together with AddShadowCircle(), AddShadowConvexPoly(), AddShadowNGon().
|
||||
#define IMGUI_HAS_SHADOWS 1
|
||||
IMGUI_API void AddShadowRect(const ImVec2& obj_min, const ImVec2& obj_max, ImU32 shadow_col, float shadow_thickness, const ImVec2& shadow_offset, ImDrawFlags flags = 0, float obj_rounding = 0.0f);
|
||||
IMGUI_API void AddShadowCircle(const ImVec2& obj_center, float obj_radius, ImU32 shadow_col, float shadow_thickness, const ImVec2& shadow_offset, ImDrawFlags flags = 0, int obj_num_segments = 12);
|
||||
IMGUI_API void AddShadowConvexPoly(const ImVec2* points, int points_count, ImU32 shadow_col, float shadow_thickness, const ImVec2& shadow_offset, ImDrawFlags flags = 0);
|
||||
IMGUI_API void AddShadowNGon(const ImVec2& obj_center, float obj_radius, ImU32 shadow_col, float shadow_thickness, const ImVec2& shadow_offset, ImDrawFlags flags, int obj_num_segments);
|
||||
|
||||
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
|
||||
// - Important: filled shapes must always use clockwise winding order! The anti-aliasing fringe depends on it. Counter-clockwise shapes will have "inward" anti-aliasing.
|
||||
// so e.g. 'PathArcTo(center, radius, PI * -0.5f, PI)' is ok, whereas 'PathArcTo(center, radius, PI, PI * -0.5f)' won't have correct anti-aliasing when followed by PathFillConvex().
|
||||
@ -3218,6 +3240,24 @@ struct ImDrawData
|
||||
// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontAtlasFlags, ImFontAtlas, ImFontGlyphRangesBuilder, ImFont)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// [Internal] Shadow texture baking config
|
||||
struct ImFontAtlasShadowTexConfig
|
||||
{
|
||||
int TexCornerSize; // Size of the corner areas.
|
||||
int TexEdgeSize; // Size of the edge areas (and by extension the center). Changing this is normally unnecessary.
|
||||
float TexFalloffPower; // The power factor for the shadow falloff curve.
|
||||
float TexDistanceFieldOffset; // How much to offset the distance field by (allows over/under-shadowing, potentially useful for accommodating rounded corners on the "casting" shape).
|
||||
bool TexBlur; // Do we want to Gaussian blur the shadow texture?
|
||||
|
||||
inline ImFontAtlasShadowTexConfig() { memset(this, 0, sizeof(*this)); }
|
||||
IMGUI_API void SetupDefaults();
|
||||
int GetRectTexPadding() const { return 2; } // Number of pixels of padding to add to the rectangular texture to avoid sampling artifacts at the edges.
|
||||
int CalcRectTexSize() const { return TexCornerSize + TexEdgeSize + GetRectTexPadding(); } // The size of the texture area required for the actual 2x2 rectangle shadow texture (after the redundant corners have been removed). Padding is required here to avoid sampling artifacts at the edge adjoining the removed corners. int CalcConvexTexWidth() const; // The width of the texture area required for the convex shape shadow texture.
|
||||
int GetConvexTexPadding() const { return 8; } // Number of pixels of padding to add to the convex shape texture to avoid sampling artifacts at the edges. This also acts as padding for the expanded corner triangles.
|
||||
int CalcConvexTexWidth() const; // The width of the texture area required for the convex shape shadow texture.
|
||||
int CalcConvexTexHeight() const; // The height of the texture area required for the convex shape shadow texture.
|
||||
};
|
||||
|
||||
struct ImFontConfig
|
||||
{
|
||||
void* FontData; // // TTF/OTF data
|
||||
@ -3411,6 +3451,11 @@ struct ImFontAtlas
|
||||
int PackIdMouseCursors; // Custom texture rectangle ID for white pixel and mouse cursors
|
||||
int PackIdLines; // Custom texture rectangle ID for baked anti-aliased lines
|
||||
|
||||
// [Internal] Shadow data
|
||||
int ShadowRectIds[2]; // IDs of rect for shadow textures
|
||||
ImVec4 ShadowRectUvs[10]; // UV coordinates for shadow textures, 9 for the rectangle shadows and the final entry for the convex shape shadows
|
||||
ImFontAtlasShadowTexConfig ShadowTexConfig; // Shadow texture baking config
|
||||
|
||||
// [Obsolete]
|
||||
//typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+
|
||||
//typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+
|
||||
|
178
imgui_demo.cpp
178
imgui_demo.cpp
@ -8134,6 +8134,22 @@ void ImGui::ShowStyleEditor(ImGuiStyle* ref)
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Shadows"))
|
||||
{
|
||||
ImGui::Text("Window shadows:");
|
||||
ImGui::ColorEdit4("Color", (float*)&style.Colors[ImGuiCol_WindowShadow], ImGuiColorEditFlags_AlphaBar);
|
||||
ImGui::SameLine();
|
||||
HelpMarker("Same as 'WindowShadow' in Colors tab.");
|
||||
|
||||
ImGui::SliderFloat("Size", &style.WindowShadowSize, 0.0f, 128.0f, "%.1f");
|
||||
ImGui::SameLine();
|
||||
HelpMarker("Set shadow size to zero to disable shadows.");
|
||||
ImGui::SliderFloat("Offset distance", &style.WindowShadowOffsetDist, 0.0f, 64.0f, "%.0f");
|
||||
ImGui::SliderAngle("Offset angle", &style.WindowShadowOffsetAngle);
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
|
||||
@ -9595,6 +9611,168 @@ static void ShowExampleAppCustomRendering(bool* p_open)
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Shadows"))
|
||||
{
|
||||
static float shadow_thickness = 40.0f;
|
||||
static ImVec4 shadow_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
static bool shadow_filled = false;
|
||||
static ImVec4 shape_color = ImVec4(0.9f, 0.6f, 0.3f, 1.0f);
|
||||
static float shape_rounding = 0.0f;
|
||||
static ImVec2 shadow_offset(0.0f, 0.0f);
|
||||
static ImVec4 background_color = ImVec4(0.5f, 0.5f, 0.7f, 1.0f);
|
||||
static bool wireframe = false;
|
||||
static bool aa = true;
|
||||
static int poly_shape_index = 0;
|
||||
ImGui::Checkbox("Shadow filled", &shadow_filled);
|
||||
ImGui::SameLine();
|
||||
HelpMarker("This will fill the section behind the shape to shadow. It's often unnecessary and wasteful but provided for consistency.");
|
||||
ImGui::Checkbox("Wireframe shapes", &wireframe);
|
||||
ImGui::SameLine();
|
||||
HelpMarker("This draws the shapes in wireframe so you can see the shadow underneath.");
|
||||
ImGui::Checkbox("Anti-aliasing", &aa);
|
||||
|
||||
ImGui::DragFloat("Shadow Thickness", &shadow_thickness, 1.0f, 0.0f, 100.0f, "%.02f");
|
||||
ImGui::SliderFloat2("Offset", (float*)&shadow_offset, -32.0f, 32.0f);
|
||||
ImGui::SameLine();
|
||||
HelpMarker("Note that currently circles/convex shapes do not support non-zero offsets for unfilled shadows.");
|
||||
ImGui::ColorEdit4("Background Color", &background_color.x);
|
||||
ImGui::ColorEdit4("Shadow Color", &shadow_color.x);
|
||||
ImGui::ColorEdit4("Shape Color", &shape_color.x);
|
||||
ImGui::DragFloat("Shape Rounding", &shape_rounding, 1.0f, 0.0f, 20.0f, "%.02f");
|
||||
ImGui::Combo("Convex shape", &poly_shape_index, "Shape 1\0Shape 2\0Shape 3\0Shape 4\0Shape 4 (winding reversed)");
|
||||
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
ImDrawListFlags old_flags = draw_list->Flags;
|
||||
|
||||
if (aa)
|
||||
draw_list->Flags |= ~ImDrawListFlags_AntiAliasedFill;
|
||||
else
|
||||
draw_list->Flags &= ~ImDrawListFlags_AntiAliasedFill;
|
||||
|
||||
// Fill a strip of background
|
||||
{
|
||||
ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
draw_list->AddRectFilled(p, ImVec2(p.x + ImGui::GetContentRegionAvail().x, p.y + 200.0f), ImGui::GetColorU32(background_color));
|
||||
}
|
||||
|
||||
// Rectangle
|
||||
{
|
||||
ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
ImGui::Dummy(ImVec2(200.0f, 200.0f));
|
||||
|
||||
ImVec2 r1(p.x + 50.0f, p.y + 50.0f);
|
||||
ImVec2 r2(p.x + 150.0f, p.y + 150.0f);
|
||||
ImDrawFlags draw_flags = shadow_filled ? ImDrawFlags_None : ImDrawFlags_ShadowCutOutShapeBackground;
|
||||
draw_list->AddShadowRect(r1, r2, ImGui::GetColorU32(shadow_color), shadow_thickness, shadow_offset, draw_flags, shape_rounding);
|
||||
|
||||
if (wireframe)
|
||||
draw_list->AddRect(r1, r2, ImGui::GetColorU32(shape_color), shape_rounding);
|
||||
else
|
||||
draw_list->AddRectFilled(r1, r2, ImGui::GetColorU32(shape_color), shape_rounding);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
// Circle
|
||||
{
|
||||
ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
ImGui::Dummy(ImVec2(200.0f, 200.0f));
|
||||
|
||||
// FIXME-SHADOWS: Offset forced to zero when shadow is not filled because it isn't supported
|
||||
float off = 10.0f;
|
||||
ImVec2 r1(p.x + 50.0f + off, p.y + 50.0f + off);
|
||||
ImVec2 r2(p.x + 150.0f - off, p.y + 150.0f - off);
|
||||
ImVec2 center(p.x + 100.0f, p.y + 100.0f);
|
||||
ImDrawFlags draw_flags = shadow_filled ? ImDrawFlags_None : ImDrawFlags_ShadowCutOutShapeBackground;
|
||||
draw_list->AddShadowCircle(center, 50.0f, ImGui::GetColorU32(shadow_color), shadow_thickness, shadow_filled ? shadow_offset : ImVec2(0.0f, 0.0f), draw_flags, 0);
|
||||
|
||||
if (wireframe)
|
||||
draw_list->AddCircle(center, 50.0f, ImGui::GetColorU32(shape_color), 0);
|
||||
else
|
||||
draw_list->AddCircleFilled(center, 50.0f, ImGui::GetColorU32(shape_color), 0);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
// Convex shape
|
||||
{
|
||||
ImVec2 pos = ImGui::GetCursorScreenPos();
|
||||
ImGui::Dummy(ImVec2(200.0f, 200.0f));
|
||||
|
||||
const ImVec2 poly_centre(pos.x + 50.0f, pos.y + 100.0f);
|
||||
ImVec2 poly_points[8];
|
||||
int poly_points_count = 0;
|
||||
|
||||
switch (poly_shape_index)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
{
|
||||
poly_points[0] = ImVec2(poly_centre.x - 32.0f, poly_centre.y);
|
||||
poly_points[1] = ImVec2(poly_centre.x - 24.0f, poly_centre.y + 24.0f);
|
||||
poly_points[2] = ImVec2(poly_centre.x, poly_centre.y + 32.0f);
|
||||
poly_points[3] = ImVec2(poly_centre.x + 24.0f, poly_centre.y + 24.0f);
|
||||
poly_points[4] = ImVec2(poly_centre.x + 32.0f, poly_centre.y);
|
||||
poly_points[5] = ImVec2(poly_centre.x + 24.0f, poly_centre.y - 24.0f);
|
||||
poly_points[6] = ImVec2(poly_centre.x, poly_centre.y - 32.0f);
|
||||
poly_points[7] = ImVec2(poly_centre.x - 32.0f, poly_centre.y - 32.0f);
|
||||
poly_points_count = 8;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
poly_points[0] = ImVec2(poly_centre.x + 40.0f, poly_centre.y - 20.0f);
|
||||
poly_points[1] = ImVec2(poly_centre.x, poly_centre.y + 32.0f);
|
||||
poly_points[2] = ImVec2(poly_centre.x - 24.0f, poly_centre.y - 32.0f);
|
||||
poly_points_count = 3;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
poly_points[0] = ImVec2(poly_centre.x - 32.0f, poly_centre.y);
|
||||
poly_points[1] = ImVec2(poly_centre.x, poly_centre.y + 32.0f);
|
||||
poly_points[2] = ImVec2(poly_centre.x + 32.0f, poly_centre.y);
|
||||
poly_points[3] = ImVec2(poly_centre.x, poly_centre.y - 32.0f);
|
||||
poly_points_count = 4;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
poly_points[0] = ImVec2(poly_centre.x - 4.0f, poly_centre.y - 20.0f);
|
||||
poly_points[1] = ImVec2(poly_centre.x + 12.0f, poly_centre.y + 2.0f);
|
||||
poly_points[2] = ImVec2(poly_centre.x + 8.0f, poly_centre.y + 16.0f);
|
||||
poly_points[3] = ImVec2(poly_centre.x, poly_centre.y + 32.0f);
|
||||
poly_points[4] = ImVec2(poly_centre.x - 16.0f, poly_centre.y - 32.0f);
|
||||
poly_points_count = 5;
|
||||
break;
|
||||
}
|
||||
case 4: // Same as test case 3 but with reversed winding
|
||||
{
|
||||
poly_points[0] = ImVec2(poly_centre.x - 16.0f, poly_centre.y - 32.0f);
|
||||
poly_points[1] = ImVec2(poly_centre.x, poly_centre.y + 32.0f);
|
||||
poly_points[2] = ImVec2(poly_centre.x + 8.0f, poly_centre.y + 16.0f);
|
||||
poly_points[3] = ImVec2(poly_centre.x + 12.0f, poly_centre.y + 2.0f);
|
||||
poly_points[4] = ImVec2(poly_centre.x - 4.0f, poly_centre.y - 20.0f);
|
||||
poly_points_count = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME-SHADOWS: Offset forced to zero when shadow is not filled because it isn't supported
|
||||
ImDrawFlags draw_flags = shadow_filled ? ImDrawFlags_None : ImDrawFlags_ShadowCutOutShapeBackground;
|
||||
draw_list->AddShadowConvexPoly(poly_points, poly_points_count, ImGui::GetColorU32(shadow_color), shadow_thickness, shadow_filled ? shadow_offset : ImVec2(0.0f, 0.0f), draw_flags);
|
||||
|
||||
if (wireframe)
|
||||
draw_list->AddPolyline(poly_points, poly_points_count, ImGui::GetColorU32(shape_color), true, 1.0f);
|
||||
else
|
||||
draw_list->AddConvexPolyFilled(poly_points, poly_points_count, ImGui::GetColorU32(shape_color));
|
||||
}
|
||||
|
||||
draw_list->Flags = old_flags;
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("BG/FG draw lists"))
|
||||
{
|
||||
static bool draw_bg = true;
|
||||
|
971
imgui_draw.cpp
971
imgui_draw.cpp
File diff suppressed because it is too large
Load Diff
@ -149,6 +149,7 @@ struct ImGuiOldColumns; // Storage data for a columns set for legacy
|
||||
struct ImGuiPopupData; // Storage for current popup stack
|
||||
struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file
|
||||
struct ImGuiStyleMod; // Stacked style modifier, backup of modified data so we can restore it
|
||||
struct ImGuiStyleShadowTexConfig; // Shadow Texture baking config
|
||||
struct ImGuiTabBar; // Storage for a tab bar
|
||||
struct ImGuiTabItem; // Storage for a tab item (within a tab bar)
|
||||
struct ImGuiTable; // Storage for a table
|
||||
@ -470,6 +471,7 @@ static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t)
|
||||
static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; }
|
||||
static inline float ImLengthSqr(const ImVec2& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y); }
|
||||
static inline float ImLengthSqr(const ImVec4& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y) + (lhs.z * lhs.z) + (lhs.w * lhs.w); }
|
||||
static inline float ImLength(const ImVec2& lhs, float fail_value) { float d = (lhs.x * lhs.x) + (lhs.y * lhs.y); if (d > 0.0f) return ImSqrt(d); return fail_value; }
|
||||
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = (lhs.x * lhs.x) + (lhs.y * lhs.y); if (d > 0.0f) return ImRsqrt(d); return fail_value; }
|
||||
static inline float ImTrunc(float f) { return (float)(int)(f); }
|
||||
static inline ImVec2 ImTrunc(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); }
|
||||
@ -781,6 +783,9 @@ struct IMGUI_API ImDrawListSharedData
|
||||
ImU8 CircleSegmentCounts[64]; // Precomputed segment count for given radius before we calculate it dynamically (to avoid calculation overhead)
|
||||
const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas
|
||||
|
||||
int* ShadowRectIds; // IDs of rects for shadow texture (2 entries)
|
||||
const ImVec4* ShadowRectUvs; // UV coordinates for shadow texture (10 entries)
|
||||
|
||||
ImDrawListSharedData();
|
||||
void SetCircleTessellationMaxError(float max_error);
|
||||
};
|
||||
|
@ -8685,10 +8685,14 @@ bool ImGui::BeginViewportSideBar(const char* name, ImGuiViewport* viewport_p, Im
|
||||
}
|
||||
|
||||
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
|
||||
|
||||
// Create window
|
||||
PushStyleColor(ImGuiCol_WindowShadow, ImVec4(0, 0, 0, 0));
|
||||
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0)); // Lift normal size constraint
|
||||
bool is_open = Begin(name, NULL, window_flags);
|
||||
PopStyleVar(2);
|
||||
PopStyleColor();
|
||||
|
||||
return is_open;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user