|
@@ -1380,13 +1380,8 @@ void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, int*
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
// ImGuiStorage
|
|
// ImGuiStorage
|
|
|
-//-----------------------------------------------------------------------------
|
|
|
|
|
-
|
|
|
|
|
// Helper: Key->value storage
|
|
// Helper: Key->value storage
|
|
|
-void ImGuiStorage::Clear()
|
|
|
|
|
-{
|
|
|
|
|
- Data.clear();
|
|
|
|
|
-}
|
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// std::lower_bound but without the bullshit
|
|
// std::lower_bound but without the bullshit
|
|
|
static ImVector<ImGuiStorage::Pair>::iterator LowerBound(ImVector<ImGuiStorage::Pair>& data, ImGuiID key)
|
|
static ImVector<ImGuiStorage::Pair>::iterator LowerBound(ImVector<ImGuiStorage::Pair>& data, ImGuiID key)
|
|
@@ -1656,7 +1651,7 @@ void ImGuiTextBuffer::append(const char* fmt, ...)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
-// ImGuiSimpleColumns
|
|
|
|
|
|
|
+// ImGuiSimpleColumns (internal use only)
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ImGuiSimpleColumns::ImGuiSimpleColumns()
|
|
ImGuiSimpleColumns::ImGuiSimpleColumns()
|
|
@@ -4022,7 +4017,10 @@ static ImVec2 CalcSizeFullWithConstraint(ImGuiWindow* window, ImVec2 new_size)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize)))
|
|
if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize)))
|
|
|
|
|
+ {
|
|
|
new_size = ImMax(new_size, g.Style.WindowMinSize);
|
|
new_size = ImMax(new_size, g.Style.WindowMinSize);
|
|
|
|
|
+ new_size.y = ImMax(new_size.y, window->TitleBarHeight() + window->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows
|
|
|
|
|
+ }
|
|
|
return new_size;
|
|
return new_size;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -4247,17 +4245,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->SizeContents.x = (float)(int)((window->SizeContentsExplicit.x != 0.0f) ? window->SizeContentsExplicit.x : ((window_is_new ? 0.0f : window->DC.CursorMaxPos.x - window->Pos.x) + window->Scroll.x));
|
|
window->SizeContents.x = (float)(int)((window->SizeContentsExplicit.x != 0.0f) ? window->SizeContentsExplicit.x : ((window_is_new ? 0.0f : window->DC.CursorMaxPos.x - window->Pos.x) + window->Scroll.x));
|
|
|
window->SizeContents.y = (float)(int)((window->SizeContentsExplicit.y != 0.0f) ? window->SizeContentsExplicit.y : ((window_is_new ? 0.0f : window->DC.CursorMaxPos.y - window->Pos.y) + window->Scroll.y));
|
|
window->SizeContents.y = (float)(int)((window->SizeContentsExplicit.y != 0.0f) ? window->SizeContentsExplicit.y : ((window_is_new ? 0.0f : window->DC.CursorMaxPos.y - window->Pos.y) + window->Scroll.y));
|
|
|
|
|
|
|
|
- // Update scrollbar status based on the Size that was effective during last frame (and not the upcoming Size which we are updating below), so that user code consuming exactly the available size won't trigger scrollbars when e.g. manually resizing.
|
|
|
|
|
- if (!window->Collapsed)
|
|
|
|
|
- {
|
|
|
|
|
- window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((window->SizeContents.y > window->SizeFull.y + style.ItemSpacing.y) && !(flags & ImGuiWindowFlags_NoScrollbar));
|
|
|
|
|
- window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((window->SizeContents.x > window->SizeFull.x - (window->ScrollbarY ? style.ScrollbarSize : 0.0f) - window->WindowPadding.x) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar));
|
|
|
|
|
- if (window->ScrollbarX && !window->ScrollbarY)
|
|
|
|
|
- window->ScrollbarY = (window->SizeContents.y > window->SizeFull.y + style.ItemSpacing.y - style.ScrollbarSize) && !(flags & ImGuiWindowFlags_NoScrollbar);
|
|
|
|
|
- window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f);
|
|
|
|
|
- window->BorderSize = (flags & ImGuiWindowFlags_ShowBorders) ? 1.0f : 0.0f;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// Hide popup/tooltip window when first appearing while we measure size (because we recycle them)
|
|
// Hide popup/tooltip window when first appearing while we measure size (because we recycle them)
|
|
|
if (window->HiddenFrames > 0)
|
|
if (window->HiddenFrames > 0)
|
|
|
window->HiddenFrames--;
|
|
window->HiddenFrames--;
|
|
@@ -4308,7 +4295,25 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
// Apply minimum/maximum window size constraints and final size
|
|
// Apply minimum/maximum window size constraints and final size
|
|
|
window->SizeFull = CalcSizeFullWithConstraint(window, window->SizeFull);
|
|
window->SizeFull = CalcSizeFullWithConstraint(window, window->SizeFull);
|
|
|
window->Size = window->Collapsed ? window->TitleBarRect().GetSize() : window->SizeFull;
|
|
window->Size = window->Collapsed ? window->TitleBarRect().GetSize() : window->SizeFull;
|
|
|
-
|
|
|
|
|
|
|
+ if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup))
|
|
|
|
|
+ {
|
|
|
|
|
+ IM_ASSERT(window_size_set_by_api); // Submitted by BeginChild()
|
|
|
|
|
+ window->Size = window->SizeFull;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // SCROLLBAR STATUS
|
|
|
|
|
+
|
|
|
|
|
+ // Update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size). We need to do this before manual resize (below) is effective.
|
|
|
|
|
+ if (!window->Collapsed)
|
|
|
|
|
+ {
|
|
|
|
|
+ window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((window->SizeContents.y > window->SizeFull.y + style.ItemSpacing.y) && !(flags & ImGuiWindowFlags_NoScrollbar));
|
|
|
|
|
+ window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((window->SizeContents.x > window->SizeFull.x - (window->ScrollbarY ? style.ScrollbarSize : 0.0f) - window->WindowPadding.x) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar));
|
|
|
|
|
+ if (window->ScrollbarX && !window->ScrollbarY)
|
|
|
|
|
+ window->ScrollbarY = (window->SizeContents.y > window->SizeFull.y + style.ItemSpacing.y - style.ScrollbarSize) && !(flags & ImGuiWindowFlags_NoScrollbar);
|
|
|
|
|
+ window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f);
|
|
|
|
|
+ window->BorderSize = (flags & ImGuiWindowFlags_ShowBorders) ? 1.0f : 0.0f;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// POSITION
|
|
// POSITION
|
|
|
|
|
|
|
|
// Position child window
|
|
// Position child window
|
|
@@ -4317,12 +4322,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->OrderWithinParent = parent_window->DC.ChildWindows.Size;
|
|
window->OrderWithinParent = parent_window->DC.ChildWindows.Size;
|
|
|
parent_window->DC.ChildWindows.push_back(window);
|
|
parent_window->DC.ChildWindows.push_back(window);
|
|
|
}
|
|
}
|
|
|
- if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup))
|
|
|
|
|
- {
|
|
|
|
|
- IM_ASSERT(window_size_set_by_api); // Submitted by BeginChild()
|
|
|
|
|
|
|
+ if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api)
|
|
|
window->Pos = window->PosFloat = parent_window->DC.CursorPos;
|
|
window->Pos = window->PosFloat = parent_window->DC.CursorPos;
|
|
|
- window->Size = window->SizeFull;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFrames == 0);
|
|
const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFrames == 0);
|
|
|
if (window_pos_with_pivot)
|
|
if (window_pos_with_pivot)
|
|
@@ -4490,6 +4491,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->ContentsRegionRect.Max.y = -window->Scroll.y - window->WindowPadding.y + (window->SizeContentsExplicit.y != 0.0f ? window->SizeContentsExplicit.y : (window->Size.y - window->ScrollbarSizes.y));
|
|
window->ContentsRegionRect.Max.y = -window->Scroll.y - window->WindowPadding.y + (window->SizeContentsExplicit.y != 0.0f ? window->SizeContentsExplicit.y : (window->Size.y - window->ScrollbarSizes.y));
|
|
|
|
|
|
|
|
// Setup drawing context
|
|
// Setup drawing context
|
|
|
|
|
+ // (NB: That term "drawing context / DC" lost its meaning a long time ago. Initially was meant to hold transient data only. Nowadays difference between window-> and window->DC-> is dubious.)
|
|
|
window->DC.IndentX = 0.0f + window->WindowPadding.x - window->Scroll.x;
|
|
window->DC.IndentX = 0.0f + window->WindowPadding.x - window->Scroll.x;
|
|
|
window->DC.GroupOffsetX = 0.0f;
|
|
window->DC.GroupOffsetX = 0.0f;
|
|
|
window->DC.ColumnsOffsetX = 0.0f;
|
|
window->DC.ColumnsOffsetX = 0.0f;
|
|
@@ -4590,6 +4592,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x;
|
|
window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x;
|
|
|
window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y;
|
|
window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y;
|
|
|
//window->DrawList->AddRect(window->InnerRect.Min, window->InnerRect.Max, IM_COL32_WHITE);
|
|
//window->DrawList->AddRect(window->InnerRect.Min, window->InnerRect.Max, IM_COL32_WHITE);
|
|
|
|
|
+
|
|
|
|
|
+ // After Begin() we fill the last item / hovered data using the title bar data. Make that a standard behavior (to allow usage of context menus on title bar only, etc.).
|
|
|
|
|
+ window->DC.LastItemId = window->MoveId;
|
|
|
|
|
+ window->DC.LastItemRect = title_bar_rect;
|
|
|
|
|
+ window->DC.LastItemRectHoveredRect = IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Inner clipping rectangle
|
|
// Inner clipping rectangle
|
|
@@ -4783,10 +4790,12 @@ void ImGui::Scrollbar(ImGuiLayoutType direction)
|
|
|
|
|
|
|
|
// Render
|
|
// Render
|
|
|
const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab);
|
|
const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab);
|
|
|
|
|
+ ImRect grab_rect;
|
|
|
if (horizontal)
|
|
if (horizontal)
|
|
|
- window->DrawList->AddRectFilled(ImVec2(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y), ImVec2(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, bb.Max.y), grab_col, style.ScrollbarRounding);
|
|
|
|
|
|
|
+ grab_rect = ImRect(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y, ImMin(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, window_rect.Max.x), bb.Max.y);
|
|
|
else
|
|
else
|
|
|
- window->DrawList->AddRectFilled(ImVec2(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm)), ImVec2(bb.Max.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels), grab_col, style.ScrollbarRounding);
|
|
|
|
|
|
|
+ grab_rect = ImRect(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm), bb.Max.x, ImMin(ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels, window_rect.Max.y));
|
|
|
|
|
+ window->DrawList->AddRectFilled(grab_rect.Min, grab_rect.Max, grab_col, style.ScrollbarRounding);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Moving window to front of display (which happens to be back of our sorted list)
|
|
// Moving window to front of display (which happens to be back of our sorted list)
|
|
@@ -9187,10 +9196,12 @@ bool ImGui::BeginMenuBar()
|
|
|
if (!(window->Flags & ImGuiWindowFlags_MenuBar))
|
|
if (!(window->Flags & ImGuiWindowFlags_MenuBar))
|
|
|
return false;
|
|
return false;
|
|
|
|
|
|
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
IM_ASSERT(!window->DC.MenuBarAppending);
|
|
IM_ASSERT(!window->DC.MenuBarAppending);
|
|
|
BeginGroup(); // Save position
|
|
BeginGroup(); // Save position
|
|
|
PushID("##menubar");
|
|
PushID("##menubar");
|
|
|
ImRect rect = window->MenuBarRect();
|
|
ImRect rect = window->MenuBarRect();
|
|
|
|
|
+ rect.Max.x = ImMax(rect.Min.x, rect.Max.x - g.Style.WindowRounding);
|
|
|
PushClipRect(ImVec2(ImFloor(rect.Min.x+0.5f), ImFloor(rect.Min.y + window->BorderSize + 0.5f)), ImVec2(ImFloor(rect.Max.x+0.5f), ImFloor(rect.Max.y+0.5f)), false);
|
|
PushClipRect(ImVec2(ImFloor(rect.Min.x+0.5f), ImFloor(rect.Min.y + window->BorderSize + 0.5f)), ImVec2(ImFloor(rect.Max.x+0.5f), ImFloor(rect.Max.y+0.5f)), false);
|
|
|
window->DC.CursorPos = ImVec2(rect.Min.x + window->DC.MenuBarOffsetX, rect.Min.y);// + g.Style.FramePadding.y);
|
|
window->DC.CursorPos = ImVec2(rect.Min.x + window->DC.MenuBarOffsetX, rect.Min.y);// + g.Style.FramePadding.y);
|
|
|
window->DC.LayoutType = ImGuiLayoutType_Horizontal;
|
|
window->DC.LayoutType = ImGuiLayoutType_Horizontal;
|
|
@@ -9241,6 +9252,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|
|
{
|
|
{
|
|
|
// Menu inside an horizontal menu bar
|
|
// Menu inside an horizontal menu bar
|
|
|
// Selectable extend their highlight by half ItemSpacing in each direction.
|
|
// Selectable extend their highlight by half ItemSpacing in each direction.
|
|
|
|
|
+ // For ChildMenu, the popup position will be overwritten by the call to FindBestPopupWindowPos() in Begin()
|
|
|
popup_pos = ImVec2(pos.x - window->WindowPadding.x, pos.y - style.FramePadding.y + window->MenuBarHeight());
|
|
popup_pos = ImVec2(pos.x - window->WindowPadding.x, pos.y - style.FramePadding.y + window->MenuBarHeight());
|
|
|
window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f);
|
|
window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f);
|
|
|
PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f);
|
|
PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f);
|
|
@@ -10517,9 +10529,10 @@ void ImGui::EndColumns()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Draw column
|
|
// Draw column
|
|
|
|
|
+ // We clip the Y boundaries CPU side because very long triangles are mishandled by some GPU drivers.
|
|
|
const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator);
|
|
const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator);
|
|
|
const float xi = (float)(int)x;
|
|
const float xi = (float)(int)x;
|
|
|
- window->DrawList->AddLine(ImVec2(xi, y1 + 1.0f), ImVec2(xi, y2), col);
|
|
|
|
|
|
|
+ window->DrawList->AddLine(ImVec2(xi, ImMax(y1 + 1.0f, window->ClipRect.Min.y)), ImVec2(xi, ImMin(y2, window->ClipRect.Max.y)), col);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame.
|
|
// Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame.
|