|
|
@@ -45,7 +45,8 @@ CODE
|
|
|
// [SECTION] FORWARD DECLARATIONS
|
|
|
// [SECTION] CONTEXT AND MEMORY ALLOCATORS
|
|
|
// [SECTION] MAIN USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
|
|
|
-// [SECTION] MISC HELPERS/UTILITIES (Geometry, String, Format, Hash, File functions)
|
|
|
+// [SECTION] MISC HELPERS/UTILITIES (Geometry functions)
|
|
|
+// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions)
|
|
|
// [SECTION] MISC HELPERS/UTILITIES (File functions)
|
|
|
// [SECTION] MISC HELPERS/UTILITIES (ImText* functions)
|
|
|
// [SECTION] MISC HELPERS/UTILITIES (Color functions)
|
|
|
@@ -353,6 +354,7 @@ CODE
|
|
|
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
|
|
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
|
|
|
|
|
+ - 2019/12/17 (1.75) - made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead.
|
|
|
- 2019/12/13 (1.75) - [imgui_internal.h] changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value.
|
|
|
- 2019/12/08 (1.75) - removed redirecting functions/enums that were marked obsolete in 1.53 (December 2017):
|
|
|
- ShowTestWindow() -> use ShowDemoWindow()
|
|
|
@@ -1107,9 +1109,77 @@ void ImGuiIO::ClearInputCharacters()
|
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
-// [SECTION] MISC HELPERS/UTILITIES (Geometry, String, Format, Hash, File functions)
|
|
|
+// [SECTION] MISC HELPERS/UTILITIES (Geometry functions)
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
+ImVec2 ImBezierClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments)
|
|
|
+{
|
|
|
+ IM_ASSERT(num_segments > 0); // Use ImBezierClosestPointCasteljau()
|
|
|
+ ImVec2 p_last = p1;
|
|
|
+ ImVec2 p_closest;
|
|
|
+ float p_closest_dist2 = FLT_MAX;
|
|
|
+ float t_step = 1.0f / (float)num_segments;
|
|
|
+ for (int i_step = 1; i_step <= num_segments; i_step++)
|
|
|
+ {
|
|
|
+ ImVec2 p_current = ImBezierCalc(p1, p2, p3, p4, t_step * i_step);
|
|
|
+ ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p);
|
|
|
+ float dist2 = ImLengthSqr(p - p_line);
|
|
|
+ if (dist2 < p_closest_dist2)
|
|
|
+ {
|
|
|
+ p_closest = p_line;
|
|
|
+ p_closest_dist2 = dist2;
|
|
|
+ }
|
|
|
+ p_last = p_current;
|
|
|
+ }
|
|
|
+ return p_closest;
|
|
|
+}
|
|
|
+
|
|
|
+// Closely mimics PathBezierToCasteljau() in imgui_draw.cpp
|
|
|
+static void BezierClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_closest, ImVec2& p_last, float& p_closest_dist2, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
|
|
|
+{
|
|
|
+ float dx = x4 - x1;
|
|
|
+ float dy = y4 - y1;
|
|
|
+ float d2 = ((x2 - x4) * dy - (y2 - y4) * dx);
|
|
|
+ float d3 = ((x3 - x4) * dy - (y3 - y4) * dx);
|
|
|
+ d2 = (d2 >= 0) ? d2 : -d2;
|
|
|
+ d3 = (d3 >= 0) ? d3 : -d3;
|
|
|
+ if ((d2+d3) * (d2+d3) < tess_tol * (dx*dx + dy*dy))
|
|
|
+ {
|
|
|
+ ImVec2 p_current(x4, y4);
|
|
|
+ ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p);
|
|
|
+ float dist2 = ImLengthSqr(p - p_line);
|
|
|
+ if (dist2 < p_closest_dist2)
|
|
|
+ {
|
|
|
+ p_closest = p_line;
|
|
|
+ p_closest_dist2 = dist2;
|
|
|
+ }
|
|
|
+ p_last = p_current;
|
|
|
+ }
|
|
|
+ else if (level < 10)
|
|
|
+ {
|
|
|
+ float x12 = (x1+x2)*0.5f, y12 = (y1+y2)*0.5f;
|
|
|
+ float x23 = (x2+x3)*0.5f, y23 = (y2+y3)*0.5f;
|
|
|
+ float x34 = (x3+x4)*0.5f, y34 = (y3+y4)*0.5f;
|
|
|
+ float x123 = (x12+x23)*0.5f, y123 = (y12+y23)*0.5f;
|
|
|
+ float x234 = (x23+x34)*0.5f, y234 = (y23+y34)*0.5f;
|
|
|
+ float x1234 = (x123+x234)*0.5f, y1234 = (y123+y234)*0.5f;
|
|
|
+ BezierClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1);
|
|
|
+ BezierClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// tess_tol is generally the same value you would find in ImGui::GetStyle().CurveTessellationTol
|
|
|
+// Because those ImXXX functions are lower-level than ImGui:: we cannot access this value automatically.
|
|
|
+ImVec2 ImBezierClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol)
|
|
|
+{
|
|
|
+ IM_ASSERT(tess_tol > 0.0f);
|
|
|
+ ImVec2 p_last = p1;
|
|
|
+ ImVec2 p_closest;
|
|
|
+ float p_closest_dist2 = FLT_MAX;
|
|
|
+ BezierClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, tess_tol, 0);
|
|
|
+ return p_closest;
|
|
|
+}
|
|
|
+
|
|
|
ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p)
|
|
|
{
|
|
|
ImVec2 ap = p - a;
|
|
|
@@ -1158,6 +1228,10 @@ ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c,
|
|
|
return proj_ca;
|
|
|
}
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions)
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
+
|
|
|
// Consider using _stricmp/_strnicmp under Windows or strcasecmp/strncasecmp. We don't actually use either ImStricmp/ImStrnicmp in the codebase any more.
|
|
|
int ImStricmp(const char* str1, const char* str2)
|
|
|
{
|
|
|
@@ -1728,38 +1802,6 @@ void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float&
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul)
|
|
|
-{
|
|
|
- ImGuiStyle& style = GImGui->Style;
|
|
|
- ImVec4 c = style.Colors[idx];
|
|
|
- c.w *= style.Alpha * alpha_mul;
|
|
|
- return ColorConvertFloat4ToU32(c);
|
|
|
-}
|
|
|
-
|
|
|
-ImU32 ImGui::GetColorU32(const ImVec4& col)
|
|
|
-{
|
|
|
- ImGuiStyle& style = GImGui->Style;
|
|
|
- ImVec4 c = col;
|
|
|
- c.w *= style.Alpha;
|
|
|
- return ColorConvertFloat4ToU32(c);
|
|
|
-}
|
|
|
-
|
|
|
-const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx)
|
|
|
-{
|
|
|
- ImGuiStyle& style = GImGui->Style;
|
|
|
- return style.Colors[idx];
|
|
|
-}
|
|
|
-
|
|
|
-ImU32 ImGui::GetColorU32(ImU32 col)
|
|
|
-{
|
|
|
- float style_alpha = GImGui->Style.Alpha;
|
|
|
- if (style_alpha >= 1.0f)
|
|
|
- return col;
|
|
|
- ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT;
|
|
|
- a = (ImU32)(a * style_alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range.
|
|
|
- return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT);
|
|
|
-}
|
|
|
-
|
|
|
//-----------------------------------------------------------------------------
|
|
|
// [SECTION] ImGuiStorage
|
|
|
// Helper: Key->value storage
|
|
|
@@ -2217,10 +2259,42 @@ bool ImGuiListClipper::Step()
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
// [SECTION] RENDER HELPERS
|
|
|
-// Those (internal) functions are currently quite a legacy mess - their signature and behavior will change.
|
|
|
+// Some of those (internal) functions are currently quite a legacy mess - their signature and behavior will change.
|
|
|
// Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: state.
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
+ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul)
|
|
|
+{
|
|
|
+ ImGuiStyle& style = GImGui->Style;
|
|
|
+ ImVec4 c = style.Colors[idx];
|
|
|
+ c.w *= style.Alpha * alpha_mul;
|
|
|
+ return ColorConvertFloat4ToU32(c);
|
|
|
+}
|
|
|
+
|
|
|
+ImU32 ImGui::GetColorU32(const ImVec4& col)
|
|
|
+{
|
|
|
+ ImGuiStyle& style = GImGui->Style;
|
|
|
+ ImVec4 c = col;
|
|
|
+ c.w *= style.Alpha;
|
|
|
+ return ColorConvertFloat4ToU32(c);
|
|
|
+}
|
|
|
+
|
|
|
+const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx)
|
|
|
+{
|
|
|
+ ImGuiStyle& style = GImGui->Style;
|
|
|
+ return style.Colors[idx];
|
|
|
+}
|
|
|
+
|
|
|
+ImU32 ImGui::GetColorU32(ImU32 col)
|
|
|
+{
|
|
|
+ ImGuiStyle& style = GImGui->Style;
|
|
|
+ if (style.Alpha >= 1.0f)
|
|
|
+ return col;
|
|
|
+ ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT;
|
|
|
+ a = (ImU32)(a * style.Alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range.
|
|
|
+ return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT);
|
|
|
+}
|
|
|
+
|
|
|
const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
|
|
|
{
|
|
|
const char* text_display_end = text;
|
|
|
@@ -3803,6 +3877,21 @@ void ImGui::Initialize(ImGuiContext* context)
|
|
|
ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll;
|
|
|
g.SettingsHandlers.push_back(ini_handler);
|
|
|
}
|
|
|
+
|
|
|
+#if 0 // FIXME-WIP: This is a placeholder to facilitate merging of Tables branch into multiple branches.
|
|
|
+
|
|
|
+ // Add .ini handle for ImGuiTable type
|
|
|
+ {
|
|
|
+ ImGuiSettingsHandler ini_handler;
|
|
|
+ ini_handler.TypeName = "Table";
|
|
|
+ ini_handler.TypeHash = ImHashStr("Table");
|
|
|
+ ini_handler.ReadOpenFn = TableSettingsHandler_ReadOpen;
|
|
|
+ ini_handler.ReadLineFn = TableSettingsHandler_ReadLine;
|
|
|
+ ini_handler.WriteAllFn = TableSettingsHandler_WriteAll;
|
|
|
+ g.SettingsHandlers.push_back(ini_handler);
|
|
|
+ }
|
|
|
+
|
|
|
+#endif
|
|
|
|
|
|
g.Initialized = true;
|
|
|
}
|
|
|
@@ -9734,12 +9823,18 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // State
|
|
|
+ // Debugging enums
|
|
|
enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type
|
|
|
const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentRegionRect" };
|
|
|
+ enum { TRT_OuterRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersDesired, TRT_ColumnsContentRowsFrozen, TRT_ColumnsContentRowsUnfrozen, TRT_Count }; // Tables Rect Type
|
|
|
+ const char* trt_rects_names[TRT_Count] = { "OuterRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersDesired", "ColumnsContentRowsFrozen", "ColumnsContentRowsUnfrozen" };
|
|
|
+
|
|
|
+ // State
|
|
|
static bool show_windows_rects = false;
|
|
|
static int show_windows_rect_type = WRT_WorkRect;
|
|
|
static bool show_windows_begin_order = false;
|
|
|
+ static bool show_tables_rects = false;
|
|
|
+ static int show_tables_rect_type = TRT_WorkRect;
|
|
|
static bool show_drawcmd_details = true;
|
|
|
|
|
|
// Basic info
|
|
|
@@ -9753,11 +9848,12 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
ImGui::Separator();
|
|
|
|
|
|
// Helper functions to display common structures:
|
|
|
- // - NodeDrawList
|
|
|
- // - NodeColumns
|
|
|
- // - NodeWindow
|
|
|
- // - NodeWindows
|
|
|
- // - NodeTabBar
|
|
|
+ // - NodeDrawList()
|
|
|
+ // - NodeColumns()
|
|
|
+ // - NodeWindow()
|
|
|
+ // - NodeWindows()
|
|
|
+ // - NodeTabBar()
|
|
|
+ // - NodeStorage()
|
|
|
struct Funcs
|
|
|
{
|
|
|
static ImRect GetWindowRect(ImGuiWindow* window, int rect_type)
|
|
|
@@ -9985,6 +10081,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
+ // Details for Popups
|
|
|
if (ImGui::TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size))
|
|
|
{
|
|
|
for (int i = 0; i < g.OpenPopupStack.Size; i++)
|
|
|
@@ -9995,6 +10092,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
+ // Details for TabBars
|
|
|
if (ImGui::TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.GetSize()))
|
|
|
{
|
|
|
for (int n = 0; n < g.TabBars.GetSize(); n++)
|
|
|
@@ -10002,20 +10100,26 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
+ // Details for Tables
|
|
|
+ IM_UNUSED(trt_rects_names);
|
|
|
+ IM_UNUSED(show_tables_rects);
|
|
|
+ IM_UNUSED(show_tables_rect_type);
|
|
|
#if 0
|
|
|
- if (ImGui::TreeNode("Docking"))
|
|
|
+ if (ImGui::TreeNode("Tables", "Tables (%d)", g.Tables.GetSize()))
|
|
|
{
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
+ // Details for Docking
|
|
|
#if 0
|
|
|
- if (ImGui::TreeNode("Tables", "Tables (%d)", g.Tables.GetSize()))
|
|
|
+ if (ImGui::TreeNode("Docking"))
|
|
|
{
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
#endif
|
|
|
-
|
|
|
+
|
|
|
+ // Misc Details
|
|
|
if (ImGui::TreeNode("Internal state"))
|
|
|
{
|
|
|
const char* input_source_names[] = { "None", "Mouse", "Nav", "NavKeyboard", "NavGamepad" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT);
|
|
|
@@ -10036,6 +10140,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
+ // Tools
|
|
|
if (ImGui::TreeNode("Tools"))
|
|
|
{
|
|
|
// The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted.
|
|
|
@@ -10048,7 +10153,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
ImGui::Checkbox("Show windows rectangles", &show_windows_rects);
|
|
|
ImGui::SameLine();
|
|
|
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 12);
|
|
|
- show_windows_rects |= ImGui::Combo("##show_windows_rect_type", &show_windows_rect_type, wrt_rects_names, WRT_Count);
|
|
|
+ show_windows_rects |= ImGui::Combo("##show_windows_rect_type", &show_windows_rect_type, wrt_rects_names, WRT_Count, WRT_Count);
|
|
|
if (show_windows_rects && g.NavWindow)
|
|
|
{
|
|
|
ImGui::BulletText("'%s':", g.NavWindow->Name);
|
|
|
@@ -10064,7 +10169,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
ImGui::TreePop();
|
|
|
}
|
|
|
|
|
|
- // Tool: Display windows Rectangles and Begin Order
|
|
|
+ // Overlay: Display windows Rectangles and Begin Order
|
|
|
if (show_windows_rects || show_windows_begin_order)
|
|
|
{
|
|
|
for (int n = 0; n < g.Windows.Size; n++)
|
|
|
@@ -10088,6 +10193,27 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // FIXME-WIP: This is a placeholder to facilitate merging of Tables branch into multiple branches.
|
|
|
+#if 0
|
|
|
+ // Overlay: Display Tables Rectangles
|
|
|
+ if (show_tables_rects)
|
|
|
+ {
|
|
|
+ for (int table_n = 0; table_n < g.Tables.GetSize(); table_n++)
|
|
|
+ {
|
|
|
+ ImGuiTable* table = g.Tables.GetByIndex(table_n);
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
+ // FIXME-WIP: This is a placeholder to facilitate merging of Docking branch into multiple branches.
|
|
|
+#if 0
|
|
|
+ // Overlay: Display Docking info
|
|
|
+ if (show_docking_nodes && g.IO.KeyCtrl)
|
|
|
+ {
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
ImGui::End();
|
|
|
}
|
|
|
|