mirror of
https://github.com/ocornut/imgui.git
synced 2025-10-26 12:27:30 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_sdl3.cpp # imgui.cpp
This commit is contained in:
36
imgui.cpp
36
imgui.cpp
@@ -1,4 +1,4 @@
|
||||
// dear imgui, v1.90.0
|
||||
// dear imgui, v1.90.1 WIP
|
||||
// (main code and documentation)
|
||||
|
||||
// Help:
|
||||
@@ -2003,6 +2003,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); }
|
||||
}
|
||||
@@ -2010,6 +2012,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.
|
||||
}
|
||||
@@ -4742,12 +4749,11 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
|
||||
}
|
||||
|
||||
// Update io.WantCaptureKeyboard for the user application (true = dispatch keyboard info to Dear ImGui only, false = dispatch keyboard info to Dear ImGui + underlying app)
|
||||
if (g.WantCaptureKeyboardNextFrame != -1)
|
||||
io.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0);
|
||||
else
|
||||
io.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL);
|
||||
io.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL);
|
||||
if (io.NavActive && (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && !(io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard))
|
||||
io.WantCaptureKeyboard = true;
|
||||
if (g.WantCaptureKeyboardNextFrame != -1) // Manual override
|
||||
io.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0);
|
||||
|
||||
// Update io.WantTextInput flag, this is to allow systems without a keyboard (e.g. mobile, hand-held) to show a software keyboard if possible
|
||||
io.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
|
||||
@@ -6076,13 +6082,11 @@ static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_cont
|
||||
{
|
||||
// Maximum window size is determined by the viewport size or monitor size
|
||||
ImVec2 size_min = CalcWindowMinSize(window);
|
||||
ImVec2 avail_size = window->Viewport->WorkSize;
|
||||
if (window->ViewportOwned)
|
||||
avail_size = ImVec2(FLT_MAX, FLT_MAX);
|
||||
ImVec2 size_max = (window->ViewportOwned || (window->Flags & ImGuiWindowFlags_ChildWindow)) ? ImVec2(FLT_MAX, FLT_MAX) : window->Viewport->WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
||||
const int monitor_idx = window->ViewportAllowPlatformMonitorExtend;
|
||||
if (monitor_idx >= 0 && monitor_idx < g.PlatformIO.Monitors.Size)
|
||||
avail_size = g.PlatformIO.Monitors[monitor_idx].WorkSize;
|
||||
ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, avail_size - style.DisplaySafeAreaPadding * 2.0f));
|
||||
if (monitor_idx >= 0 && monitor_idx < g.PlatformIO.Monitors.Size && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0)
|
||||
size_max = g.PlatformIO.Monitors[monitor_idx].WorkSize - style.DisplaySafeAreaPadding * 2.0f;
|
||||
ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, size_max));
|
||||
|
||||
// When the window cannot fit all contents (either because of constraints, either because screen is too small),
|
||||
// we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than ViewportSize-WindowPadding.
|
||||
@@ -13448,13 +13452,14 @@ bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
|
||||
|
||||
IM_ASSERT(g.DragDropWithinTarget == false);
|
||||
g.DragDropTargetRect = bb;
|
||||
g.DragDropTargetClipRect = window->ClipRect; // May want to be overriden by user depending on use case?
|
||||
g.DragDropTargetId = id;
|
||||
g.DragDropWithinTarget = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// We don't use BeginDragDropTargetCustom() and duplicate its code because:
|
||||
// 1) we use LastItemRectHoveredRect which handles items that push a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them.
|
||||
// 1) we use LastItemData's ImGuiItemStatusFlags_HoveredRect which handles items that push a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them.
|
||||
// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
|
||||
// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
|
||||
bool ImGui::BeginDragDropTarget()
|
||||
@@ -13482,6 +13487,7 @@ bool ImGui::BeginDragDropTarget()
|
||||
|
||||
IM_ASSERT(g.DragDropWithinTarget == false);
|
||||
g.DragDropTargetRect = display_rect;
|
||||
g.DragDropTargetClipRect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasClipRect) ? g.LastItemData.ClipRect : window->ClipRect;
|
||||
g.DragDropTargetId = id;
|
||||
g.DragDropWithinTarget = true;
|
||||
return true;
|
||||
@@ -13519,7 +13525,7 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
|
||||
payload.Preview = was_accepted_previously;
|
||||
flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that live for 1 frame)
|
||||
if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview)
|
||||
RenderDragDropTargetRect(r);
|
||||
RenderDragDropTargetRect(r, g.DragDropTargetClipRect);
|
||||
|
||||
g.DragDropAcceptFrameCount = g.FrameCount;
|
||||
payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting OS window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
|
||||
@@ -13531,12 +13537,12 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
|
||||
}
|
||||
|
||||
// FIXME-STYLE FIXME-DRAGDROP: Settle on a proper default visuals for drop target.
|
||||
void ImGui::RenderDragDropTargetRect(const ImRect& bb)
|
||||
void ImGui::RenderDragDropTargetRect(const ImRect& bb, const ImRect& item_clip_rect)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImRect bb_display = bb;
|
||||
bb_display.ClipWith(window->ClipRect); // Clip THEN expand so we have a way to visualize that target is not entirely visible.
|
||||
bb_display.ClipWith(item_clip_rect); // Clip THEN expand so we have a way to visualize that target is not entirely visible.
|
||||
bb_display.Expand(3.5f);
|
||||
bool push_clip_rect = !window->ClipRect.Contains(bb_display);
|
||||
if (push_clip_rect)
|
||||
|
||||
Reference in New Issue
Block a user