Compare commits

..

1 Commits

Author SHA1 Message Date
2affff0962 Premake: experimental premake5 script.
(neater vs project output but certainly less standard than cmake)
2022-02-07 18:20:42 +01:00
8 changed files with 306 additions and 1223 deletions

View File

@ -0,0 +1,7 @@
project "imgui"
kind "StaticLib"
files { "../*.h", "../*.cpp" }
vpaths { ["imgui"] = { "../*.cpp", "../*.h", "../misc/debuggers/*.natvis" } }
filter { "toolset:msc*" }
files { "../misc/debuggers/*.natvis" }

298
examples/premake5.lua Normal file
View File

@ -0,0 +1,298 @@
-- We use Premake5 to generate project files (Visual Studio solutions, XCode solutions, Makefiles, etc.)
-- Download Premake5: at https://premake.github.io/download
-- YOU NEED PREMAKE 5.0.0-alpha10 or later
--------- HELP
-- To reduce friction for people who don't aren't used to Premake, we list some concrete usage examples.
if _ACTION == nil then
print "-----------------------------------------"
print " DEAR IMGUI EXAMPLES - PROJECT GENERATOR"
print "-----------------------------------------"
print "Usage:"
print " premake5 [generator] [options]"
print "Examples:"
print " premake5 vs2010"
print " premake5 vs2019 --with-sdl --with-vulkan"
print " premake5 xcode4 --with-glfw"
print " premake5 gmake2 --with-glfw --cc=clang"
print "Generators:"
print " codelite gmake gmake2 vs2008 vs2010 vs2012 vs2013 vs2015 vs2017 xcode4 etc."
print "Options:"
print " --with-dx9 Enable dear imgui DirectX 9 example"
print " --with-dx10 Enable dear imgui DirectX 10 example"
print " --with-dx11 Enable dear imgui DirectX 11 example"
print " --with-dx12 Enable dear imgui DirectX 12 example (vs2015+)"
print " --with-glfw Enable dear imgui GLFW examples"
print " --with-sdl Enable dear imgui SDL examples"
print " --with-vulkan Enable dear imgui Vulkan example"
print " --cc=clang Compile with Clang"
print " --cc=gcc Compile with GCC"
print "Project and object files will be created in the build/ folder. You can delete your build/ folder at any time."
print ""
end
---------- OPTIONS
newoption { trigger = "with-dx9", description="Enable dear imgui DirectX 9 example" }
newoption { trigger = "with-dx10", description="Enable dear imgui DirectX 10 example" }
newoption { trigger = "with-dx11", description="Enable dear imgui DirectX 11 example" }
newoption { trigger = "with-dx12", description="Enable dear imgui DirectX 12 example" }
newoption { trigger = "with-glfw", description="Enable dear imgui GLFW examples" }
newoption { trigger = "with-sdl", description="Enable dear imgui SDL examples" }
newoption { trigger = "with-vulkan", description="Enable dear imgui Vulkan example" }
-- Enable/detect default options under Windows
if _ACTION ~= nil and ((os.istarget ~= nil and os.istarget("windows")) or (os.is ~= nil and os.is("windows"))) then
print("( enabling --with-dx9 )");
print("( enabling --with-dx10 )");
print("( enabling --with-dx11 )");
_OPTIONS["with-dx9"] = 1
_OPTIONS["with-dx10"] = 1
_OPTIONS["with-dx11"] = 1
if _ACTION >= "vs2015" then
print("( enabling --with-dx12 because compiler is " .. _ACTION .. " )");
_OPTIONS["with-dx12"] = 1
end
print("( enabling --with-glfw because GLFW is included in the libs/ folder )");
_OPTIONS["with-glfw"] = 1
if os.getenv("SDL2_DIR") then
print("( enabling --with-sdl because SDL2_DIR environment variable was found )");
_OPTIONS["with-sdl"] = 1
end
if os.getenv("VULKAN_SDK") then
print("( enabling --with-vulkan because VULKAN_SDK environment variable was found )");
_OPTIONS["with-vulkan"] = 1
end
end
--------- HELPER FUNCTIONS
-- Helper function: add dear imgui source files into project
function imgui_as_src(fs_path, project_path)
if (project_path == nil) then project_path = fs_path; end; -- default to same virtual folder as the file system folder (in this project it would be ".." !)
files { fs_path .. "/*.cpp", fs_path .. "/*.h" }
includedirs { fs_path, fs_path .. "/backends" }
vpaths { [project_path] = { fs_path .. "/*.*", fs_path .. "/misc/debuggers/*.natvis" } } -- add in a specific folder of the Visual Studio project
filter { "toolset:msc*" }
files { fs_path .. "/misc/debuggers/*.natvis" }
filter {}
end
-- Helper function: add dear imgui as a library (uncomment the 'include "premake5-lib"' line)
--include "premake5-lib"
function imgui_as_lib(fs_path)
includedirs { fs_path, fs_path .. "/backends" }
links "imgui"
end
--------- SOLUTION, PROJECTS
workspace "imgui_examples"
configurations { "Debug", "Release" }
platforms { "x86", "x86_64" }
location "build/"
symbols "On"
warnings "Extra"
--flags { "FatalCompileWarnings"}
filter { "configurations:Debug" }
optimize "Off"
filter { "configurations:Release" }
optimize "On"
filter { "toolset:clang", "system:windows" }
buildoptions { "-Xclang", "-flto-visibility-public-std" } -- Remove "warning LNK4049: locally defined symbol ___std_terminate imported"
-- example_win32_directx11 (Win32 + DirectX 11)
-- We have DX11 as the first project because this is what Visual Studio uses
if (_OPTIONS["with-dx11"]) then
project "example_win32_directx11"
kind "ConsoleApp"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
files { "../backends/imgui_impl_win32.*", "../backends/imgui_impl_dx11.*", "example_win32_directx11/*.cpp", "example_win32_directx11/*.h", "README.txt" }
vpaths { ["sources"] = "./**" }
filter { "system:windows", "toolset:msc-v80 or msc-v90 or msc-v100" }
includedirs { "$(DXSDK_DIR)/Include" }
filter { "system:windows", "toolset:msc-v80 or msc-v90 or msc-v100", "platforms:x86" }
libdirs { "$(DXSDK_DIR)/Lib/x86" }
filter { "system:windows", "toolset:msc-v80 or msc-v90 or msc-v100", "platforms:x86_64" }
libdirs { "$(DXSDK_DIR)/Lib/x64" }
filter { "system:windows" }
links { "d3d11", "d3dcompiler", "dxgi" }
end
-- example_win32_directx9 (Win32 + DirectX 9)
if (_OPTIONS["with-dx9"]) then
project "example_win32_directx9"
kind "ConsoleApp"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
files { "../backends/imgui_impl_win32.*", "../backends/imgui_impl_dx9.*", "example_win32_directx9/*.cpp", "example_win32_directx9/*.h", "README.txt" }
vpaths { ["sources"] = "./**" }
filter { "system:windows" }
links { "d3d9" }
end
-- example_win32_directx10 (Win32 + DirectX 10)
if (_OPTIONS["with-dx10"]) then
project "example_win32_directx10"
kind "ConsoleApp"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
files { "../backends/imgui_impl_win32.*", "../backends/imgui_impl_dx10.*", "example_win32_directx10/*.cpp", "example_win32_directx10/*.h", "README.txt" }
vpaths { ["sources"] = "./**" }
filter { "system:windows", "toolset:msc-v80 or msc-v90 or msc-v100" }
includedirs { "$(DXSDK_DIR)/Include" }
filter { "system:windows", "toolset:msc-v80 or msc-v90 or msc-v100", "platforms:x86" }
libdirs { "$(DXSDK_DIR)/Lib/x86" }
filter { "system:windows", "toolset:msc-v80 or msc-v90 or msc-v100", "platforms:x86_64" }
libdirs { "$(DXSDK_DIR)/Lib/x64" }
filter { "system:windows" }
links { "d3d10", "d3dcompiler", "dxgi" }
end
-- example_win32_directx12 (Win32 + DirectX 12)
if (_OPTIONS["with-dx12"]) then
project "example_win32_directx12"
kind "ConsoleApp"
systemversion "10.0.16299.0"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
files { "../backends/imgui_impl_win32.*", "../backends/imgui_impl_dx12.*", "example_win32_directx12/*.cpp", "example_win32_directx12/*.h", "README.txt" }
vpaths { ["sources"] = "./**" }
filter { "system:windows" }
links { "d3d12", "d3dcompiler", "dxgi" }
end
-- example_glfw_opengl2 (GLFW + OpenGL2)
if (_OPTIONS["with-glfw"]) then
project "example_glfw_opengl2"
kind "ConsoleApp"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
files { "../backends/imgui_impl_glfw.*", "../backends/imgui_impl_opengl2.*", "example_glfw_opengl2/*.h", "example_glfw_opengl2/*.cpp", "README.txt"}
vpaths { ["sources"] = "./**" }
includedirs { "libs/glfw/include" }
filter { "system:windows", "platforms:x86" }
libdirs { "libs/glfw/lib-vc2010-32" }
filter { "system:windows", "platforms:x86_64" }
libdirs { "libs/glfw/lib-vc2010-64" }
filter { "system:windows" }
ignoredefaultlibraries { "msvcrt" }
links { "opengl32", "glfw3" }
filter { "system:macosx" }
libdirs { "/usr/local/lib" }
links { "glfw" }
linkoptions { "-framework OpenGL" }
end
-- example_glfw_opengl3 (GLFW + OpenGL3)
if (_OPTIONS["with-glfw"]) then
project "example_glfw_opengl3"
kind "ConsoleApp"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
vpaths { ["sources"] = "./**" }
files { "../backends/imgui_impl_glfw.*", "../backends/imgui_impl_opengl3.*", "example_glfw_opengl3/*.h", "example_glfw_opengl3/*.cpp", "./README.txt", "libs/gl3w/GL/gl3w.c" }
includedirs { "libs/glfw/include", "libs/gl3w" }
filter { "system:windows", "platforms:x86" }
libdirs { "libs/glfw/lib-vc2010-32" }
filter { "system:windows", "platforms:x86_64" }
libdirs { "libs/glfw/lib-vc2010-64" }
filter { "system:windows" }
ignoredefaultlibraries { "msvcrt" }
links { "opengl32", "glfw3" }
filter { "system:macosx" }
libdirs { "/usr/local/lib" }
links { "glfw" }
linkoptions { "-framework OpenGL" }
end
-- example_glfw_vulkan (GLFW + Vulkan)
if (_OPTIONS["with-vulkan"]) then
project "example_glfw_vulkan"
kind "ConsoleApp"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
vpaths { ["sources"] = "./**" }
files { "../backends/imgui_impl_glfw*", "../backends/imgui_impl_vulkan.*", "example_glfw_vulkan/*.h", "example_glfw_vulkan/*.cpp", "./README.txt" }
includedirs { "libs/glfw/include", "%VULKAN_SDK%/include" }
filter { "system:windows", "platforms:x86" }
libdirs { "libs/glfw/lib-vc2010-32", "%VULKAN_SDK%/lib32" }
filter { "system:windows", "platforms:x86_64" }
libdirs { "libs/glfw/lib-vc2010-64", "%VULKAN_SDK%/lib" }
filter { "system:windows" }
ignoredefaultlibraries { "msvcrt" }
links { "vulkan-1", "glfw3" }
end
-- example_null (no rendering)
if (true) then
project "example_null"
kind "ConsoleApp"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
vpaths { ["sources"] = "./**" }
files { "example_null/*.h", "example_null/*.cpp", "./README.txt" }
filter { "system:windows" }
ignoredefaultlibraries { "msvcrt" }
end
-- example_sdl_opengl2 (SDL + OpenGL2)
if (_OPTIONS["with-sdl"]) then
project "example_sdl_opengl2"
kind "ConsoleApp"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
vpaths { ["sources"] = "./**" }
files { "../backends/imgui_impl_sdl*", "../backends/imgui_impl_opengl2.*", "example_sdl_opengl2/*.h", "example_sdl_opengl2/*.cpp", "./README.txt" }
includedirs { "%SDL2_DIR%/include" }
filter { "system:windows", "platforms:x86" }
libdirs { "%SDL2_DIR%/lib/x86" }
filter { "system:windows", "platforms:x86_64" }
libdirs { "%SDL2_DIR%/lib/x64" }
filter { "system:windows" }
ignoredefaultlibraries { "msvcrt" }
links { "SDL2", "SDL2main", "opengl32" }
end
-- example_sdl_opengl3 (SDL + OpenGL3)
if (_OPTIONS["with-sdl"]) then
project "example_sdl_opengl3"
kind "ConsoleApp"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
vpaths { ["sources"] = "./**" }
files { "../backends/imgui_impl_sdl*", "../backends/imgui_impl_opengl3.*", "example_sdl_opengl3/*.h", "example_sdl_opengl3/*.cpp", "./README.txt", "libs/gl3w/GL/gl3w.c" }
includedirs { "%SDL2_DIR%/include", "libs/gl3w" }
filter { "system:windows", "platforms:x86" }
libdirs { "%SDL2_DIR%/lib/x86" }
filter { "system:windows", "platforms:x86_64" }
libdirs { "%SDL2_DIR%/lib/x64" }
filter { "system:windows" }
ignoredefaultlibraries { "msvcrt" }
links { "SDL2", "SDL2main", "opengl32" }
end
-- example_sdl_vulkan (SDL + Vulkan)
if (_OPTIONS["with-vulkan"]) then
project "example_sdl_vulkan"
kind "ConsoleApp"
imgui_as_src ("..", "imgui")
--imgui_as_lib ("..")
vpaths { ["sources"] = "./**" }
files { "../backends/imgui_impl_sdl*", "../backends/imgui_impl_vulkan.*", "example_sdl_vulkan/*.h", "example_sdl_vulkan/*.cpp", "./README.txt" }
includedirs { "%SDL2_DIR%/include", "%VULKAN_SDK%/include" }
filter { "system:windows", "platforms:x86" }
libdirs { "%SDL2_DIR%/lib/x86", "%VULKAN_SDK%/lib32" }
filter { "system:windows", "platforms:x86_64" }
libdirs { "%SDL2_DIR%/lib/x64", "%VULKAN_SDK%/lib" }
filter { "system:windows" }
ignoredefaultlibraries { "msvcrt" }
links { "SDL2", "SDL2main", "vulkan-1" }
end

View File

@ -972,7 +972,6 @@ static void UpdateKeyboardInputs();
static void UpdateMouseInputs();
static void UpdateMouseWheel();
static bool UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, 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, 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);
@ -1073,9 +1072,6 @@ 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).
// Default theme
ImGui::StyleColorsDark(this);
@ -2945,7 +2941,6 @@ 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";
@ -5764,11 +5759,6 @@ 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))
{
@ -5811,16 +5801,6 @@ 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)
{
@ -6833,8 +6813,6 @@ void ImGui::SetCurrentFont(ImFont* font)
g.DrawListSharedData.TexUvLines = atlas->TexUvLines;
g.DrawListSharedData.Font = g.Font;
g.DrawListSharedData.FontSize = g.FontSize;
g.DrawListSharedData.ShadowRectIds = &atlas->ShadowRectIds[0];
g.DrawListSharedData.ShadowRectUvs = &atlas->ShadowRectUvs[0];
}
void ImGui::PushFont(ImFont* font)

47
imgui.h
View File

@ -1579,7 +1579,6 @@ 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
};
@ -1878,9 +1877,6 @@ 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];
IMGUI_API ImGuiStyle();
@ -2477,8 +2473,7 @@ enum ImDrawFlags_
ImDrawFlags_RoundCornersRight = ImDrawFlags_RoundCornersBottomRight | ImDrawFlags_RoundCornersTopRight,
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.
ImDrawFlags_RoundCornersMask_ = ImDrawFlags_RoundCornersAll | ImDrawFlags_RoundCornersNone
};
// Flags for ImDrawList instance. Those are set automatically by ImGui:: functions from ImGuiIO settings, and generally not manipulated directly.
@ -2567,23 +2562,6 @@ 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()
inline void PathClear() { _Path.Size = 0; }
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
@ -2666,24 +2644,6 @@ 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
@ -2872,11 +2832,6 @@ 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+

View File

@ -6328,22 +6328,6 @@ 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();
}
@ -7615,165 +7599,6 @@ 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
draw_list->AddRectFilled(ImVec2(ImGui::GetCursorScreenPos().x, ImGui::GetCursorScreenPos().y), ImVec2(ImGui::GetCursorScreenPos().x + ImGui::GetWindowContentRegionMax().x, ImGui::GetCursorScreenPos().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;

File diff suppressed because it is too large Load Diff

View File

@ -132,7 +132,6 @@ struct ImGuiPopupData; // Storage for current popup stack
struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file
struct ImGuiStackSizes; // Storage of stack sizes for debugging/asserting
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
@ -439,7 +438,6 @@ 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 ImFloor(float f) { return (float)(int)(f); }
static inline float ImFloorSigned(float f) { return (float)((f >= 0 || (float)(int)f == f) ? (int)f : (int)f - 1); } // Decent replacement for floorf()
@ -727,9 +725,6 @@ 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);
};

View File

@ -6780,14 +6780,10 @@ 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;
}