mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 00:09:55 +02:00
Compare commits
12 Commits
features/p
...
features/s
Author | SHA1 | Date | |
---|---|---|---|
1d933fbbd8 | |||
0b9ede2697 | |||
f61466890c | |||
e3dc0c4001 | |||
5ee0af776a | |||
598e66ca1c | |||
50abd45040 | |||
cc7387f680 | |||
01078a6077 | |||
542f1da1e2 | |||
f882102374 | |||
b306474a2f |
@ -31,20 +31,6 @@ HOW TO UPDATE?
|
||||
- Please report any issue!
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.88 WIP (In Progress)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Breaking changes:
|
||||
|
||||
Other Changes:
|
||||
|
||||
- Stack Tool: Added option to copy item path to clipboard. (#4631)
|
||||
- Misc: Added constexpr to ImVec2/ImVec4 inline constructors. (#4995) [@Myriachan]
|
||||
- ImVector: Fixed erase() with empty range. (#5009) [@thedmd]
|
||||
- Drawlist: Fixed PathArcTo() emitting terminating vertices too close to arc vertices. (#4993) [@thedmd]
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
VERSION 1.87 (Released 2022-02-07)
|
||||
-----------------------------------------------------------------------
|
||||
@ -117,6 +103,7 @@ Breaking Changes:
|
||||
better support for IME. Updated backends accordingly. Because the old field is set by existing backends,
|
||||
we are keeping it (marked as obsolete).
|
||||
|
||||
|
||||
Other Changes:
|
||||
|
||||
- IO: Added event based input queue API, which now trickles events to support low framerates. [@thedmd, @ocornut]
|
||||
|
@ -81,12 +81,12 @@
|
||||
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
|
||||
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
|
||||
/*
|
||||
#define IM_VEC2_CLASS_EXTRA \
|
||||
constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \
|
||||
#define IM_VEC2_CLASS_EXTRA \
|
||||
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
|
||||
operator MyVec2() const { return MyVec2(x,y); }
|
||||
|
||||
#define IM_VEC4_CLASS_EXTRA \
|
||||
constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \
|
||||
#define IM_VEC4_CLASS_EXTRA \
|
||||
ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
|
||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||
*/
|
||||
|
||||
|
135
imgui.cpp
135
imgui.cpp
@ -1,4 +1,4 @@
|
||||
// dear imgui, 1.88 WIP
|
||||
// dear imgui, v1.87
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
@ -972,6 +972,7 @@ 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);
|
||||
@ -1072,6 +1073,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).
|
||||
|
||||
// Default theme
|
||||
ImGui::StyleColorsDark(this);
|
||||
@ -1180,7 +1184,7 @@ void ImGuiIO::AddInputCharacter(unsigned int c)
|
||||
return;
|
||||
|
||||
ImGuiInputEvent e;
|
||||
e.Type = ImGuiInputEventType_Text;
|
||||
e.Type = ImGuiInputEventType_Char;
|
||||
e.Source = ImGuiInputSource_Keyboard;
|
||||
e.Text.Char = c;
|
||||
g.InputEventsQueue.push_back(e);
|
||||
@ -2941,6 +2945,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";
|
||||
@ -3193,32 +3198,6 @@ void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFl
|
||||
}
|
||||
}
|
||||
|
||||
void ImGui::RenderMouseCursor(ImVec2 base_pos, float base_scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT);
|
||||
for (int n = 0; n < g.Viewports.Size; n++)
|
||||
{
|
||||
ImGuiViewportP* viewport = g.Viewports[n];
|
||||
ImDrawList* draw_list = GetForegroundDrawList(viewport);
|
||||
ImFontAtlas* font_atlas = draw_list->_Data->Font->ContainerAtlas;
|
||||
ImVec2 offset, size, uv[4];
|
||||
if (font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2]))
|
||||
{
|
||||
const ImVec2 pos = base_pos - offset;
|
||||
const float scale = base_scale;
|
||||
ImTextureID tex_id = font_atlas->TexID;
|
||||
draw_list->PushTextureID(tex_id);
|
||||
draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow);
|
||||
draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow);
|
||||
draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border);
|
||||
draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill);
|
||||
draw_list->PopTextureID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -4914,10 +4893,6 @@ void ImGui::Render()
|
||||
if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window
|
||||
AddRootWindowToDrawData(windows_to_render_top_most[n]);
|
||||
|
||||
// Draw software mouse cursor if requested by io.MouseDrawCursor flag
|
||||
if (g.IO.MouseDrawCursor && first_render_of_frame && g.MouseCursor != ImGuiMouseCursor_None)
|
||||
RenderMouseCursor(g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48));
|
||||
|
||||
// Setup ImDrawData structures for end-user
|
||||
g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0;
|
||||
for (int n = 0; n < g.Viewports.Size; n++)
|
||||
@ -4925,6 +4900,10 @@ void ImGui::Render()
|
||||
ImGuiViewportP* viewport = g.Viewports[n];
|
||||
viewport->DrawDataBuilder.FlattenIntoSingleLayer();
|
||||
|
||||
// Draw software mouse cursor if requested by io.MouseDrawCursor flag
|
||||
if (g.IO.MouseDrawCursor && first_render_of_frame)
|
||||
RenderMouseCursor(GetForegroundDrawList(viewport), g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48));
|
||||
|
||||
// Add foreground ImDrawList (for each active viewport)
|
||||
if (viewport->DrawLists[1] != NULL)
|
||||
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
|
||||
@ -5785,6 +5764,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))
|
||||
{
|
||||
@ -5827,6 +5811,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)
|
||||
{
|
||||
@ -6839,6 +6833,8 @@ 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)
|
||||
@ -7882,7 +7878,7 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e->Type == ImGuiInputEventType_Text)
|
||||
else if (e->Type == ImGuiInputEventType_Char)
|
||||
{
|
||||
// Trickling Rule: Stop processing queued events if keys/mouse have been interacted with
|
||||
if (trickle_fast_inputs && (key_changed || mouse_button_changed != 0 || mouse_moved || mouse_wheeled))
|
||||
@ -13026,44 +13022,27 @@ void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* dat
|
||||
ImGuiStackLevelInfo* info = &tool->Results[tool->StackLevel];
|
||||
IM_ASSERT(info->ID == id && info->QueryFrameCount > 0);
|
||||
|
||||
int data_len;
|
||||
switch (data_type)
|
||||
{
|
||||
case ImGuiDataType_S32:
|
||||
ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "%d", (int)(intptr_t)data_id);
|
||||
break;
|
||||
case ImGuiDataType_String:
|
||||
ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "%.*s", data_id_end ? (int)((const char*)data_id_end - (const char*)data_id) : (int)strlen((const char*)data_id), (const char*)data_id);
|
||||
data_len = data_id_end ? (int)((const char*)data_id_end - (const char*)data_id) : (int)strlen((const char*)data_id);
|
||||
ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "\"%.*s\"", data_len, (const char*)data_id);
|
||||
break;
|
||||
case ImGuiDataType_Pointer:
|
||||
ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "(void*)0x%p", data_id);
|
||||
break;
|
||||
case ImGuiDataType_ID:
|
||||
if (info->Desc[0] != 0) // PushOverrideID() is often used to avoid hashing twice, which would lead to 2 calls to DebugHookIdInfo(). We prioritize the first one.
|
||||
return;
|
||||
ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "0x%08X [override]", id);
|
||||
if (info->Desc[0] == 0) // PushOverrideID() is often used to avoid hashing twice, which would lead to 2 calls to DebugHookIdInfo(). We prioritize the first one.
|
||||
ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "0x%08X [override]", id);
|
||||
break;
|
||||
default:
|
||||
IM_ASSERT(0);
|
||||
}
|
||||
info->QuerySuccess = true;
|
||||
info->DataType = data_type;
|
||||
}
|
||||
|
||||
static int StackToolFormatLevelInfo(ImGuiStackTool* tool, int n, bool format_for_ui, char* buf, size_t buf_size)
|
||||
{
|
||||
ImGuiStackLevelInfo* info = &tool->Results[n];
|
||||
ImGuiWindow* window = (info->Desc[0] == 0 && n == 0) ? ImGui::FindWindowByID(info->ID) : NULL;
|
||||
if (window) // Source: window name (because the root ID don't call GetID() and so doesn't get hooked)
|
||||
return ImFormatString(buf, buf_size, format_for_ui ? "\"%s\" [window]" : "%s", window->Name);
|
||||
if (info->QuerySuccess) // Source: GetID() hooks (prioritize over ItemInfo() because we frequently use patterns like: PushID(str), Button("") where they both have same id)
|
||||
return ImFormatString(buf, buf_size, (format_for_ui && info->DataType == ImGuiDataType_String) ? "\"%s\"" : "%s", info->Desc);
|
||||
if (tool->StackLevel < tool->Results.Size) // Only start using fallback below when all queries are done, so during queries we don't flickering ??? markers.
|
||||
return (*buf = 0);
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
if (const char* label = ImGuiTestEngine_FindItemDebugLabel(GImGui, info->ID)) // Source: ImGuiTestEngine's ItemInfo()
|
||||
return ImFormatString(buf, buf_size, format_for_ui ? "??? \"%s\"" : "%s", label);
|
||||
#endif
|
||||
return ImFormatString(buf, buf_size, "???");
|
||||
}
|
||||
|
||||
// Stack Tool: Display UI
|
||||
@ -13079,7 +13058,6 @@ void ImGui::ShowStackToolWindow(bool* p_open)
|
||||
}
|
||||
|
||||
// Display hovered/active status
|
||||
ImGuiStackTool* tool = &g.DebugStackTool;
|
||||
const ImGuiID hovered_id = g.HoveredIdPreviousFrame;
|
||||
const ImGuiID active_id = g.ActiveId;
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
@ -13090,33 +13068,8 @@ void ImGui::ShowStackToolWindow(bool* p_open)
|
||||
SameLine();
|
||||
MetricsHelpMarker("Hover an item with the mouse to display elements of the ID Stack leading to the item's final ID.\nEach level of the stack correspond to a PushID() call.\nAll levels of the stack are hashed together to make the final ID of a widget (ID displayed at the bottom level of the stack).\nRead FAQ entry about the ID stack for details.");
|
||||
|
||||
// CTRL+C to copy path
|
||||
const float time_since_copy = (float)g.Time - tool->CopyToClipboardLastTime;
|
||||
Checkbox("Ctrl+C: copy path to clipboard", &tool->CopyToClipboardOnCtrlC);
|
||||
SameLine();
|
||||
TextColored((time_since_copy >= 0.0f && time_since_copy < 0.75f && ImFmod(time_since_copy, 0.25f) < 0.25f * 0.5f) ? ImVec4(1.f, 1.f, 0.3f, 1.f) : ImVec4(), "*COPIED*");
|
||||
if (tool->CopyToClipboardOnCtrlC && IsKeyDown(ImGuiKey_ModCtrl) && IsKeyPressed(ImGuiKey_C))
|
||||
{
|
||||
tool->CopyToClipboardLastTime = (float)g.Time;
|
||||
char* p = g.TempBuffer;
|
||||
char* p_end = p + IM_ARRAYSIZE(g.TempBuffer);
|
||||
for (int stack_n = 0; stack_n < tool->Results.Size && p + 3 < p_end; stack_n++)
|
||||
{
|
||||
*p++ = '/';
|
||||
char level_desc[256];
|
||||
StackToolFormatLevelInfo(tool, stack_n, false, level_desc, IM_ARRAYSIZE(level_desc));
|
||||
for (int n = 0; level_desc[n] && p + 2 < p_end; n++)
|
||||
{
|
||||
if (level_desc[n] == '/')
|
||||
*p++ = '\\';
|
||||
*p++ = level_desc[n];
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
SetClipboardText(g.TempBuffer);
|
||||
}
|
||||
|
||||
// Display decorated stack
|
||||
ImGuiStackTool* tool = &g.DebugStackTool;
|
||||
tool->LastActiveFrame = g.FrameCount;
|
||||
if (tool->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders))
|
||||
{
|
||||
@ -13130,9 +13083,23 @@ void ImGui::ShowStackToolWindow(bool* p_open)
|
||||
ImGuiStackLevelInfo* info = &tool->Results[n];
|
||||
TableNextColumn();
|
||||
Text("0x%08X", (n > 0) ? tool->Results[n - 1].ID : 0);
|
||||
|
||||
TableNextColumn();
|
||||
StackToolFormatLevelInfo(tool, n, true, g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer));
|
||||
TextUnformatted(g.TempBuffer);
|
||||
ImGuiWindow* window = (info->Desc[0] == 0 && n == 0) ? FindWindowByID(info->ID) : NULL;
|
||||
if (window) // Source: window name (because the root ID don't call GetID() and so doesn't get hooked)
|
||||
Text("\"%s\" [window]", window->Name);
|
||||
else if (info->QuerySuccess) // Source: GetID() hooks (prioritize over ItemInfo() because we frequently use patterns like: PushID(str), Button("") where they both have same id)
|
||||
TextUnformatted(info->Desc);
|
||||
else if (tool->StackLevel >= tool->Results.Size) // Only start using fallback below when all queries are done, so during queries we don't flickering ??? markers.
|
||||
{
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
if (const char* label = ImGuiTestEngine_FindItemDebugLabel(&g, info->ID)) // Source: ImGuiTestEngine's ItemInfo()
|
||||
Text("??? \"%s\"", label);
|
||||
else
|
||||
#endif
|
||||
TextUnformatted("???");
|
||||
}
|
||||
|
||||
TableNextColumn();
|
||||
Text("0x%08X", info->ID);
|
||||
if (n == tool->Results.Size - 1)
|
||||
|
63
imgui.h
63
imgui.h
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.88 WIP
|
||||
// dear imgui, v1.87
|
||||
// (headers)
|
||||
|
||||
// Help:
|
||||
@ -64,8 +64,8 @@ Index of this file:
|
||||
|
||||
// Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||
#define IMGUI_VERSION "1.88 WIP"
|
||||
#define IMGUI_VERSION_NUM 18704
|
||||
#define IMGUI_VERSION "1.87"
|
||||
#define IMGUI_VERSION_NUM 18700
|
||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
@ -249,8 +249,8 @@ IM_MSVC_RUNTIME_CHECKS_OFF
|
||||
struct ImVec2
|
||||
{
|
||||
float x, y;
|
||||
constexpr ImVec2() : x(0.0f), y(0.0f) { }
|
||||
constexpr ImVec2(float _x, float _y) : x(_x), y(_y) { }
|
||||
ImVec2() { x = y = 0.0f; }
|
||||
ImVec2(float _x, float _y) { x = _x; y = _y; }
|
||||
float operator[] (size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
float& operator[] (size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine.
|
||||
#ifdef IM_VEC2_CLASS_EXTRA
|
||||
@ -261,9 +261,9 @@ struct ImVec2
|
||||
// ImVec4: 4D vector used to store clipping rectangles, colors etc. [Compile-time configurable type]
|
||||
struct ImVec4
|
||||
{
|
||||
float x, y, z, w;
|
||||
constexpr ImVec4() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) { }
|
||||
constexpr ImVec4(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) { }
|
||||
float x, y, z, w;
|
||||
ImVec4() { x = y = z = w = 0.0f; }
|
||||
ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; }
|
||||
#ifdef IM_VEC4_CLASS_EXTRA
|
||||
IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4.
|
||||
#endif
|
||||
@ -1579,6 +1579,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
|
||||
};
|
||||
|
||||
@ -1877,6 +1878,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];
|
||||
|
||||
IMGUI_API ImGuiStyle();
|
||||
@ -2473,7 +2477,8 @@ 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_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.
|
||||
@ -2562,6 +2567,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()
|
||||
inline void PathClear() { _Path.Size = 0; }
|
||||
inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); }
|
||||
@ -2644,6 +2666,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
|
||||
@ -2832,6 +2872,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+
|
||||
|
177
imgui_demo.cpp
177
imgui_demo.cpp
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.88 WIP
|
||||
// dear imgui, v1.87
|
||||
// (demo code)
|
||||
|
||||
// Help:
|
||||
@ -6328,6 +6328,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();
|
||||
}
|
||||
|
||||
@ -7599,6 +7615,165 @@ 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;
|
||||
|
1260
imgui_draw.cpp
1260
imgui_draw.cpp
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.88 WIP
|
||||
// dear imgui, v1.87
|
||||
// (internal structures/api)
|
||||
|
||||
// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility!
|
||||
@ -132,6 +132,7 @@ 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
|
||||
@ -438,6 +439,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 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()
|
||||
@ -469,17 +471,17 @@ IM_MSVC_RUNTIME_CHECKS_OFF
|
||||
struct ImVec1
|
||||
{
|
||||
float x;
|
||||
constexpr ImVec1() : x(0.0f) { }
|
||||
constexpr ImVec1(float _x) : x(_x) { }
|
||||
ImVec1() { x = 0.0f; }
|
||||
ImVec1(float _x) { x = _x; }
|
||||
};
|
||||
|
||||
// Helper: ImVec2ih (2D vector, half-size integer, for long-term packed storage)
|
||||
struct ImVec2ih
|
||||
{
|
||||
short x, y;
|
||||
constexpr ImVec2ih() : x(0), y(0) {}
|
||||
constexpr ImVec2ih(short _x, short _y) : x(_x), y(_y) {}
|
||||
constexpr explicit ImVec2ih(const ImVec2& rhs) : x((short)rhs.x), y((short)rhs.y) {}
|
||||
ImVec2ih() { x = y = 0; }
|
||||
ImVec2ih(short _x, short _y) { x = _x; y = _y; }
|
||||
explicit ImVec2ih(const ImVec2& rhs) { x = (short)rhs.x; y = (short)rhs.y; }
|
||||
};
|
||||
|
||||
// Helper: ImRect (2D axis aligned bounding-box)
|
||||
@ -489,10 +491,10 @@ struct IMGUI_API ImRect
|
||||
ImVec2 Min; // Upper-left
|
||||
ImVec2 Max; // Lower-right
|
||||
|
||||
constexpr ImRect() : Min(0.0f, 0.0f), Max(0.0f, 0.0f) {}
|
||||
constexpr ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {}
|
||||
constexpr ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {}
|
||||
constexpr ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {}
|
||||
ImRect() : Min(0.0f, 0.0f), Max(0.0f, 0.0f) {}
|
||||
ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {}
|
||||
ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {}
|
||||
ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {}
|
||||
|
||||
ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); }
|
||||
ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); }
|
||||
@ -725,6 +727,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);
|
||||
};
|
||||
@ -1171,7 +1176,7 @@ enum ImGuiInputEventType
|
||||
ImGuiInputEventType_MouseWheel,
|
||||
ImGuiInputEventType_MouseButton,
|
||||
ImGuiInputEventType_Key,
|
||||
ImGuiInputEventType_Text,
|
||||
ImGuiInputEventType_Char,
|
||||
ImGuiInputEventType_Focus,
|
||||
ImGuiInputEventType_COUNT
|
||||
};
|
||||
@ -1510,8 +1515,7 @@ struct ImGuiStackLevelInfo
|
||||
ImGuiID ID;
|
||||
ImS8 QueryFrameCount; // >= 1: Query in progress
|
||||
bool QuerySuccess; // Obtained result from DebugHookIdInfo()
|
||||
ImGuiDataType DataType : 8;
|
||||
char Desc[57]; // Arbitrarily sized buffer to hold a result (FIXME: could replace Results[] with a chunk stream?) FIXME: Now that we added CTRL+C this should be fixed.
|
||||
char Desc[58]; // Arbitrarily sized buffer to hold a result (FIXME: could replace Results[] with a chunk stream?)
|
||||
|
||||
ImGuiStackLevelInfo() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
@ -1523,10 +1527,8 @@ struct ImGuiStackTool
|
||||
int StackLevel; // -1: query stack and resize Results, >= 0: individual stack level
|
||||
ImGuiID QueryId; // ID to query details for
|
||||
ImVector<ImGuiStackLevelInfo> Results;
|
||||
bool CopyToClipboardOnCtrlC;
|
||||
float CopyToClipboardLastTime;
|
||||
|
||||
ImGuiStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; }
|
||||
ImGuiStackTool() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -2763,12 +2765,12 @@ namespace ImGui
|
||||
IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, ImDrawFlags flags = 0);
|
||||
IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight
|
||||
IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text.
|
||||
IMGUI_API void RenderMouseCursor(ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow);
|
||||
|
||||
// Render helpers (those functions don't access any ImGui state!)
|
||||
IMGUI_API void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale = 1.0f);
|
||||
IMGUI_API void RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col);
|
||||
IMGUI_API void RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz);
|
||||
IMGUI_API void RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow);
|
||||
IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
|
||||
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
|
||||
IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.88 WIP
|
||||
// dear imgui, v1.87
|
||||
// (tables and columns code)
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.88 WIP
|
||||
// dear imgui, v1.87
|
||||
// (widgets code)
|
||||
|
||||
/*
|
||||
@ -82,7 +82,6 @@ Index of this file:
|
||||
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
|
||||
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@ -6781,10 +6780,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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user