|
|
@@ -1,4 +1,4 @@
|
|
|
-// dear imgui, v1.90 WIP
|
|
|
+// dear imgui, v1.90.1 WIP
|
|
|
// (main code and documentation)
|
|
|
|
|
|
// Help:
|
|
|
@@ -357,7 +357,7 @@ CODE
|
|
|
|
|
|
To decide whether to dispatch mouse/keyboard inputs to Dear ImGui to the rest of your application,
|
|
|
you should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags!
|
|
|
- Please read the FAQ and example applications for details about this!
|
|
|
+ Please read the FAQ entry "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?" about this.
|
|
|
|
|
|
|
|
|
HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE
|
|
|
@@ -424,6 +424,9 @@ CODE
|
|
|
When you are not sure about an 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.
|
|
|
|
|
|
+ - 2023/11/09 (1.90.0) - removed IM_OFFSETOF() macro in favor of using offsetof() available in C++11. Kept redirection define (will obsolete).
|
|
|
+ - 2023/11/07 (1.90.0) - removed BeginChildFrame()/EndChildFrame() in favor of using BeginChild() with the ImGuiChildFlags_FrameStyle flag. kept inline redirection function (will obsolete).
|
|
|
+ those functions were merely PushStyle/PopStyle helpers, the removal isn't so much motivated by needing to add the feature in BeginChild(), but by the necessity to avoid BeginChildFrame() signature mismatching BeginChild() signature and features.
|
|
|
- 2023/11/02 (1.90.0) - BeginChild: upgraded 'bool border = true' parameter to 'ImGuiChildFlags flags' type, added ImGuiChildFlags_Border equivalent. As with our prior "bool-to-flags" API updates, the ImGuiChildFlags_Border value is guaranteed to be == true forever to ensure a smoother transition, meaning all existing calls will still work.
|
|
|
- old: BeginChild("Name", size, true)
|
|
|
- new: BeginChild("Name", size, ImGuiChildFlags_Border)
|
|
|
@@ -1943,6 +1946,8 @@ void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end,
|
|
|
if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0)
|
|
|
{
|
|
|
const char* buf = va_arg(args, const char*); // Skip formatting when using "%s"
|
|
|
+ if (buf == NULL)
|
|
|
+ buf = "(null)";
|
|
|
*out_buf = buf;
|
|
|
if (out_buf_end) { *out_buf_end = buf + strlen(buf); }
|
|
|
}
|
|
|
@@ -1950,6 +1955,11 @@ void ImFormatStringToTempBufferV(const char** out_buf, const char** out_buf_end,
|
|
|
{
|
|
|
int buf_len = va_arg(args, int); // Skip formatting when using "%.*s"
|
|
|
const char* buf = va_arg(args, const char*);
|
|
|
+ if (buf == NULL)
|
|
|
+ {
|
|
|
+ buf = "(null)";
|
|
|
+ buf_len = ImMin(buf_len, 6);
|
|
|
+ }
|
|
|
*out_buf = buf;
|
|
|
*out_buf_end = buf + buf_len; // Disallow not passing 'out_buf_end' here. User is expected to use it.
|
|
|
}
|
|
|
@@ -3121,35 +3131,35 @@ void ImGui::PopStyleColor(int count)
|
|
|
|
|
|
static const ImGuiDataVarInfo GStyleVarInfo[] =
|
|
|
{
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, DisabledAlpha) }, // ImGuiStyleVar_DisabledAlpha
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, CellPadding) }, // ImGuiStyleVar_CellPadding
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabBarBorderSize) }, // ImGuiStyleVar_TabBarBorderSize
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign
|
|
|
- { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextBorderSize) },// ImGuiStyleVar_SeparatorTextBorderSize
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextAlign) }, // ImGuiStyleVar_SeparatorTextAlign
|
|
|
- { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SeparatorTextPadding) }, // ImGuiStyleVar_SeparatorTextPadding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, DisabledAlpha) }, // ImGuiStyleVar_DisabledAlpha
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, CellPadding) }, // ImGuiStyleVar_CellPadding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, TabBarBorderSize) }, // ImGuiStyleVar_TabBarBorderSize
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign
|
|
|
+ { ImGuiDataType_Float, 1, (ImU32)offsetof(ImGuiStyle, SeparatorTextBorderSize)},// ImGuiStyleVar_SeparatorTextBorderSize
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, SeparatorTextAlign) }, // ImGuiStyleVar_SeparatorTextAlign
|
|
|
+ { ImGuiDataType_Float, 2, (ImU32)offsetof(ImGuiStyle, SeparatorTextPadding) }, // ImGuiStyleVar_SeparatorTextPadding
|
|
|
};
|
|
|
|
|
|
const ImGuiDataVarInfo* ImGui::GetStyleVarInfo(ImGuiStyleVar idx)
|
|
|
@@ -5337,6 +5347,9 @@ bool ImGui::IsItemToggledSelection()
|
|
|
return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_ToggledSelection) ? true : false;
|
|
|
}
|
|
|
|
|
|
+// IMPORTANT: If you are trying to check whether your mouse should be dispatched to Dear ImGui or to your underlying app,
|
|
|
+// you should not use this function! Use the 'io.WantCaptureMouse' boolean for that!
|
|
|
+// Refer to FAQ entry "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?" for details.
|
|
|
bool ImGui::IsAnyItemHovered()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
@@ -5444,22 +5457,43 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, I
|
|
|
IM_ASSERT(id != 0);
|
|
|
|
|
|
// Sanity check as it is likely that some user will accidentally pass ImGuiWindowFlags into the ImGuiChildFlags argument.
|
|
|
- const ImGuiChildFlags ImGuiChildFlags_SupportedMask_ = ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysUseWindowPadding | ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY;
|
|
|
+ const ImGuiChildFlags ImGuiChildFlags_SupportedMask_ = ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysUseWindowPadding | ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY | ImGuiChildFlags_AlwaysAutoResize | ImGuiChildFlags_FrameStyle;
|
|
|
IM_UNUSED(ImGuiChildFlags_SupportedMask_);
|
|
|
IM_ASSERT((child_flags & ~ImGuiChildFlags_SupportedMask_) == 0 && "Illegal ImGuiChildFlags value. Did you pass ImGuiWindowFlags values instead of ImGuiChildFlags?");
|
|
|
- if (window_flags & ImGuiWindowFlags_AlwaysAutoResize)
|
|
|
- IM_ASSERT((child_flags & (ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY)) == 0 && "Cannot combine ImGuiChildFlags_ResizeX/ImGuiChildFlags_ResizeY with ImGuiWindowFlags_AlwaysAutoResize.");
|
|
|
+ IM_ASSERT((window_flags & ImGuiWindowFlags_AlwaysAutoResize) == 0 && "Cannot specify ImGuiWindowFlags_AlwaysAutoResize for BeginChild(). Use ImGuiChildFlags_AlwaysAutoResize!");
|
|
|
+ if (child_flags & ImGuiChildFlags_AlwaysAutoResize)
|
|
|
+ {
|
|
|
+ IM_ASSERT((child_flags & (ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY)) == 0 && "Cannot use ImGuiChildFlags_ResizeX or ImGuiChildFlags_ResizeY with ImGuiChildFlags_AlwaysAutoResize!");
|
|
|
+ IM_ASSERT((child_flags & (ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY)) != 0 && "Must use ImGuiChildFlags_AutoResizeX or ImGuiChildFlags_AutoResizeY with ImGuiChildFlags_AlwaysAutoResize!");
|
|
|
+ }
|
|
|
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
|
|
if (window_flags & ImGuiWindowFlags_AlwaysUseWindowPadding)
|
|
|
child_flags |= ImGuiChildFlags_AlwaysUseWindowPadding;
|
|
|
#endif
|
|
|
+ if (child_flags & ImGuiChildFlags_AutoResizeX)
|
|
|
+ child_flags &= ~ImGuiChildFlags_ResizeX;
|
|
|
+ if (child_flags & ImGuiChildFlags_AutoResizeY)
|
|
|
+ child_flags &= ~ImGuiChildFlags_ResizeY;
|
|
|
|
|
|
+ // Set window flags
|
|
|
window_flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoTitleBar;
|
|
|
window_flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag
|
|
|
-
|
|
|
+ if (child_flags & (ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY | ImGuiChildFlags_AlwaysAutoResize))
|
|
|
+ window_flags |= ImGuiWindowFlags_AlwaysAutoResize;
|
|
|
if ((child_flags & (ImGuiChildFlags_ResizeX | ImGuiChildFlags_ResizeY)) == 0)
|
|
|
window_flags |= ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings;
|
|
|
|
|
|
+ // Special framed style
|
|
|
+ if (child_flags & ImGuiChildFlags_FrameStyle)
|
|
|
+ {
|
|
|
+ PushStyleColor(ImGuiCol_ChildBg, g.Style.Colors[ImGuiCol_FrameBg]);
|
|
|
+ PushStyleVar(ImGuiStyleVar_ChildRounding, g.Style.FrameRounding);
|
|
|
+ PushStyleVar(ImGuiStyleVar_ChildBorderSize, g.Style.FrameBorderSize);
|
|
|
+ PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.FramePadding);
|
|
|
+ child_flags |= ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysUseWindowPadding;
|
|
|
+ window_flags |= ImGuiWindowFlags_NoMove;
|
|
|
+ }
|
|
|
+
|
|
|
// Forward child flags
|
|
|
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasChildFlags;
|
|
|
g.NextWindowData.ChildFlags = child_flags;
|
|
|
@@ -5467,30 +5501,38 @@ bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, I
|
|
|
// Forward size
|
|
|
// Important: Begin() has special processing to switch condition to ImGuiCond_FirstUseEver for a given axis when ImGuiChildFlags_ResizeXXX is set.
|
|
|
// (the alternative would to store conditional flags per axis, which is possible but more code)
|
|
|
- const ImVec2 content_avail = GetContentRegionAvail();
|
|
|
- ImVec2 size = ImTrunc(size_arg);
|
|
|
- if (size.x <= 0.0f)
|
|
|
- size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too many issues)
|
|
|
- if (size.y <= 0.0f)
|
|
|
- size.y = ImMax(content_avail.y + size.y, 4.0f);
|
|
|
+ const ImVec2 size_avail = GetContentRegionAvail();
|
|
|
+ const ImVec2 size_default((child_flags & ImGuiChildFlags_AutoResizeX) ? 0.0f : size_avail.x, (child_flags & ImGuiChildFlags_AutoResizeY) ? 0.0f : size_avail.y);
|
|
|
+ const ImVec2 size = CalcItemSize(size_arg, size_default.x, size_default.y);
|
|
|
SetNextWindowSize(size);
|
|
|
|
|
|
// Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value.
|
|
|
+ // FIXME: 2023/11/14: commented out shorted version. We had an issue with multiple ### in child window path names, which the trailing hash helped workaround.
|
|
|
+ // e.g. "ParentName###ParentIdentifier/ChildName###ChildIdentifier" would get hashed incorrectly by ImHashStr(), trailing _%08X somehow fixes it.
|
|
|
const char* temp_window_name;
|
|
|
- if (name && parent_window->IDStack.back() == parent_window->ID)
|
|
|
+ /*if (name && parent_window->IDStack.back() == parent_window->ID)
|
|
|
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%s", parent_window->Name, name); // May omit ID if in root of ID stack
|
|
|
- else if (name)
|
|
|
+ else*/
|
|
|
+ if (name)
|
|
|
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%s_%08X", parent_window->Name, name, id);
|
|
|
else
|
|
|
ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%08X", parent_window->Name, id);
|
|
|
|
|
|
+ // Set style
|
|
|
const float backup_border_size = g.Style.ChildBorderSize;
|
|
|
if ((child_flags & ImGuiChildFlags_Border) == 0)
|
|
|
g.Style.ChildBorderSize = 0.0f;
|
|
|
|
|
|
// Begin into window
|
|
|
const bool ret = Begin(temp_window_name, NULL, window_flags);
|
|
|
+
|
|
|
+ // Restore style
|
|
|
g.Style.ChildBorderSize = backup_border_size;
|
|
|
+ if (child_flags & ImGuiChildFlags_FrameStyle)
|
|
|
+ {
|
|
|
+ PopStyleVar(3);
|
|
|
+ PopStyleColor();
|
|
|
+ }
|
|
|
|
|
|
ImGuiWindow* child_window = g.CurrentWindow;
|
|
|
child_window->ChildId = id;
|
|
|
@@ -5556,26 +5598,6 @@ void ImGui::EndChild()
|
|
|
g.LogLinePosY = -FLT_MAX; // To enforce a carriage return
|
|
|
}
|
|
|
|
|
|
-// Helper to create a child window / scrolling region that looks like a normal widget frame.
|
|
|
-bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags)
|
|
|
-{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- const ImGuiStyle& style = g.Style;
|
|
|
- PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]);
|
|
|
- PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding);
|
|
|
- PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize);
|
|
|
- PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
|
|
|
- bool ret = BeginChild(id, size, ImGuiChildFlags_Border | ImGuiChildFlags_AlwaysUseWindowPadding, ImGuiWindowFlags_NoMove | extra_flags);
|
|
|
- PopStyleVar(3);
|
|
|
- PopStyleColor();
|
|
|
- return ret;
|
|
|
-}
|
|
|
-
|
|
|
-void ImGui::EndChildFrame()
|
|
|
-{
|
|
|
- EndChild();
|
|
|
-}
|
|
|
-
|
|
|
static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled)
|
|
|
{
|
|
|
window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags);
|
|
|
@@ -5684,6 +5706,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags)
|
|
|
static inline ImVec2 CalcWindowMinSize(ImGuiWindow* window)
|
|
|
{
|
|
|
// Popups, menus and childs bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups)
|
|
|
+ // FIXME: the if/else could probably be removed, "reduce artifacts" section for all windows.
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImVec2 size_min;
|
|
|
if (window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_ChildWindow))
|
|
|
@@ -5694,7 +5717,8 @@ static inline ImVec2 CalcWindowMinSize(ImGuiWindow* window)
|
|
|
else
|
|
|
{
|
|
|
ImGuiWindow* window_for_height = window;
|
|
|
- size_min = g.Style.WindowMinSize;
|
|
|
+ size_min.x = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.x : 4.0f;
|
|
|
+ size_min.y = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.x : 4.0f;
|
|
|
size_min.y = ImMax(size_min.y, window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows
|
|
|
}
|
|
|
return size_min;
|
|
|
@@ -5706,7 +5730,7 @@ static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& s
|
|
|
ImVec2 new_size = size_desired;
|
|
|
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint)
|
|
|
{
|
|
|
- // Using -1,-1 on either X/Y axis to preserve the current size.
|
|
|
+ // See comments in SetNextWindowSizeConstraints() for details about setting size_min an size_max.
|
|
|
ImRect cr = g.NextWindowData.SizeConstraintRect;
|
|
|
new_size.x = (cr.Min.x >= 0 && cr.Max.x >= 0) ? ImClamp(new_size.x, cr.Min.x, cr.Max.x) : window->SizeFull.x;
|
|
|
new_size.y = (cr.Min.y >= 0 && cr.Max.y >= 0) ? ImClamp(new_size.y, cr.Min.y, cr.Max.y) : window->SizeFull.y;
|
|
|
@@ -6019,8 +6043,13 @@ static int ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& si
|
|
|
ImVec2 clamp_min(border_n == ImGuiDir_Right ? clamp_rect.Min.x : -FLT_MAX, border_n == ImGuiDir_Down || (border_n == ImGuiDir_Up && window_move_from_title_bar) ? clamp_rect.Min.y : -FLT_MAX);
|
|
|
ImVec2 clamp_max(border_n == ImGuiDir_Left ? clamp_rect.Max.x : +FLT_MAX, border_n == ImGuiDir_Up ? clamp_rect.Max.y : +FLT_MAX);
|
|
|
border_target = ImClamp(border_target, clamp_min, clamp_max);
|
|
|
- if (window->Flags & ImGuiWindowFlags_ChildWindow) // Clamp resizing of childs within parent
|
|
|
- border_target = ImClamp(border_target, window->ParentWindow->InnerClipRect.Min, window->ParentWindow->InnerClipRect.Max);
|
|
|
+ if (flags & ImGuiWindowFlags_ChildWindow) // Clamp resizing of childs within parent
|
|
|
+ {
|
|
|
+ if ((flags & (ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar)) == 0 || (flags & ImGuiWindowFlags_NoScrollbar))
|
|
|
+ border_target.x = ImClamp(border_target.x, window->ParentWindow->InnerClipRect.Min.x, window->ParentWindow->InnerClipRect.Max.x);
|
|
|
+ if (flags & ImGuiWindowFlags_NoScrollbar)
|
|
|
+ border_target.y = ImClamp(border_target.y, window->ParentWindow->InnerClipRect.Min.y, window->ParentWindow->InnerClipRect.Max.y);
|
|
|
+ }
|
|
|
if (!ignore_resize)
|
|
|
CalcResizePosSizeFromAnyCorner(window, border_target, ImMin(def.SegmentN1, def.SegmentN2), &pos_target, &size_target);
|
|
|
}
|
|
|
@@ -7006,7 +7035,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
const bool nav_request = (flags & ImGuiWindowFlags_NavFlattened) && (g.NavAnyRequest && g.NavWindow && g.NavWindow->RootWindowForNav == window->RootWindowForNav);
|
|
|
if (!g.LogEnabled && !nav_request)
|
|
|
if (window->OuterRectClipped.Min.x >= window->OuterRectClipped.Max.x || window->OuterRectClipped.Min.y >= window->OuterRectClipped.Max.y)
|
|
|
- window->HiddenFramesCanSkipItems = 1;
|
|
|
+ {
|
|
|
+ if (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0)
|
|
|
+ window->HiddenFramesCannotSkipItems = 1;
|
|
|
+ else
|
|
|
+ window->HiddenFramesCanSkipItems = 1;
|
|
|
+ }
|
|
|
|
|
|
// Hide along with parent or if parent is collapsed
|
|
|
if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCanSkipItems > 0))
|
|
|
@@ -7443,6 +7477,10 @@ bool ImGui::IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_b
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+// Is current window hovered and hoverable (e.g. not blocked by a popup/modal)? See ImGuiHoveredFlags_ for options.
|
|
|
+// IMPORTANT: If you are trying to check whether your mouse should be dispatched to Dear ImGui or to your underlying app,
|
|
|
+// you should not use this function! Use the 'io.WantCaptureMouse' boolean for that!
|
|
|
+// Refer to FAQ entry "How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?" for details.
|
|
|
bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
|
|
|
{
|
|
|
IM_ASSERT((flags & ~ImGuiHoveredFlags_AllowedMaskForIsWindowHovered) == 0 && "Invalid flags for IsWindowHovered()!");
|
|
|
@@ -7587,10 +7625,14 @@ void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond con
|
|
|
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
|
|
|
window->SetWindowSizeAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
|
|
|
|
|
|
+ // Enable auto-fit (not done in BeginChild() path unless appearing or combined with ImGuiChildFlags_AlwaysAutoResize)
|
|
|
+ if ((window->Flags & ImGuiWindowFlags_ChildWindow) == 0 || window->Appearing || (window->ChildFlags & ImGuiChildFlags_AlwaysAutoResize) != 0)
|
|
|
+ window->AutoFitFramesX = (size.x <= 0.0f) ? 2 : 0;
|
|
|
+ if ((window->Flags & ImGuiWindowFlags_ChildWindow) == 0 || window->Appearing || (window->ChildFlags & ImGuiChildFlags_AlwaysAutoResize) != 0)
|
|
|
+ window->AutoFitFramesY = (size.y <= 0.0f) ? 2 : 0;
|
|
|
+
|
|
|
// Set
|
|
|
ImVec2 old_size = window->SizeFull;
|
|
|
- window->AutoFitFramesX = (size.x <= 0.0f) ? 2 : 0;
|
|
|
- window->AutoFitFramesY = (size.y <= 0.0f) ? 2 : 0;
|
|
|
if (size.x <= 0.0f)
|
|
|
window->AutoFitOnlyGrows = false;
|
|
|
else
|
|
|
@@ -7698,6 +7740,10 @@ void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
|
|
|
g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always;
|
|
|
}
|
|
|
|
|
|
+// For each axis:
|
|
|
+// - Use 0.0f as min or FLT_MAX as max if you don't want limits, e.g. size_min = (500.0f, 0.0f), size_max = (FLT_MAX, FLT_MAX) sets a minimum width.
|
|
|
+// - Use -1 for both min and max of same axis to preserve current size which itself is a constraint.
|
|
|
+// - See "Demo->Examples->Constrained-resizing window" for examples.
|
|
|
void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
@@ -8492,6 +8538,13 @@ bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button)
|
|
|
return g.IO.MouseClickedCount[button] == 2 && TestKeyOwner(MouseButtonToKey(button), ImGuiKeyOwner_Any);
|
|
|
}
|
|
|
|
|
|
+bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button, ImGuiID owner_id)
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
|
|
|
+ return g.IO.MouseClickedCount[button] == 2 && TestKeyOwner(MouseButtonToKey(button), owner_id);
|
|
|
+}
|
|
|
+
|
|
|
int ImGui::GetMouseClickedCount(ImGuiMouseButton button)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
@@ -11364,7 +11417,7 @@ void ImGui::NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavM
|
|
|
g.NavMoveFlags = move_flags;
|
|
|
g.NavMoveScrollFlags = scroll_flags;
|
|
|
g.NavMoveForwardToNextFrame = false;
|
|
|
- g.NavMoveKeyMods = g.IO.KeyMods;
|
|
|
+ g.NavMoveKeyMods = (move_flags & ImGuiNavMoveFlags_FocusApi) ? 0 : g.IO.KeyMods;
|
|
|
g.NavMoveResultLocal.Clear();
|
|
|
g.NavMoveResultLocalVisible.Clear();
|
|
|
g.NavMoveResultOther.Clear();
|
|
|
@@ -14276,8 +14329,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
Text("KEY OWNERS");
|
|
|
{
|
|
|
Indent();
|
|
|
- if (BeginListBox("##owners", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6)))
|
|
|
- {
|
|
|
+ if (BeginChild("##owners", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_NoSavedSettings))
|
|
|
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
|
|
{
|
|
|
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
|
|
@@ -14287,15 +14339,13 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
owner_data->LockUntilRelease ? " LockUntilRelease" : owner_data->LockThisFrame ? " LockThisFrame" : "");
|
|
|
DebugLocateItemOnHover(owner_data->OwnerCurr);
|
|
|
}
|
|
|
- EndListBox();
|
|
|
- }
|
|
|
+ EndChild();
|
|
|
Unindent();
|
|
|
}
|
|
|
Text("SHORTCUT ROUTING");
|
|
|
{
|
|
|
Indent();
|
|
|
- if (BeginListBox("##routes", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6)))
|
|
|
- {
|
|
|
+ if (BeginChild("##routes", ImVec2(-FLT_MIN, GetTextLineHeightWithSpacing() * 6), ImGuiChildFlags_FrameStyle | ImGuiChildFlags_ResizeY, ImGuiWindowFlags_NoSavedSettings))
|
|
|
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
|
|
{
|
|
|
ImGuiKeyRoutingTable* rt = &g.KeysRoutingTable;
|
|
|
@@ -14309,8 +14359,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
idx = routing_data->NextEntryIndex;
|
|
|
}
|
|
|
}
|
|
|
- EndListBox();
|
|
|
- }
|
|
|
+ EndChild();
|
|
|
Text("(ActiveIdUsing: AllKeyboardKeys: %d, NavDirMask: 0x%X)", g.ActiveIdUsingAllKeyboardKeys, g.ActiveIdUsingNavDirMask);
|
|
|
Unindent();
|
|
|
}
|