|
|
@@ -124,7 +124,7 @@
|
|
|
- Call ImGui::NewFrame() to begin the frame
|
|
|
- You can use any ImGui function you want between NewFrame() and Render()
|
|
|
- Call ImGui::Render() as late as you can to end the frame and finalize render data. it will call your io.RenderDrawListFn handler.
|
|
|
- (Even if you don't render, call Render() and ignore the callback, or call EndFrame() instead. Otherwhise some features will break)
|
|
|
+ (Even if you don't render, call Render() and ignore the callback, or call EndFrame() instead. Otherwise some features will break)
|
|
|
- All rendering information are stored into command-lists until ImGui::Render() is called.
|
|
|
- Dear ImGui never touches or knows about your GPU state. the only function that knows about GPU is the RenderDrawListFn handler that you provide.
|
|
|
- Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" phases
|
|
|
@@ -272,7 +272,7 @@
|
|
|
- 2018/02/07 (1.60) - reorganized context handling to be more explicit,
|
|
|
- YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END.
|
|
|
- removed Shutdown() function, as DestroyContext() serve this purpose.
|
|
|
- - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwhise CreateContext() will create its own font atlas instance.
|
|
|
+ - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance.
|
|
|
- removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
|
|
|
- removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts.
|
|
|
- 2018/01/31 (1.60) - moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths.
|
|
|
@@ -433,7 +433,7 @@
|
|
|
perfectly fine, as the bool toggle fairly rarely. If you have on a touch device, you might find use for an early call to NewFrameUpdateHoveredWindowAndCaptureFlags().
|
|
|
Note: Text input widget releases focus on "Return KeyDown", so the subsequent "Return KeyUp" event that your application receive will typically
|
|
|
have 'io.WantCaptureKeyboard=false'. Depending on your application logic it may or not be inconvenient. You might want to track which key-downs
|
|
|
- were targetted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
|
|
|
+ were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
|
|
|
|
|
|
Q: How can I display an image? What is ImTextureID, how does it works?
|
|
|
A: ImTextureID is a void* used to pass renderer-agnostic texture references around until it hits your render function.
|
|
|
@@ -760,8 +760,8 @@ static void NavUpdate();
|
|
|
static void NavUpdateWindowing();
|
|
|
static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id);
|
|
|
|
|
|
-static void NewFrameUpdateMovingWindow();
|
|
|
-static void NewFrameUpdateMouseInputs();
|
|
|
+static void UpdateMovingWindow();
|
|
|
+static void UpdateMouseInputs();
|
|
|
static void UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
|
|
|
static void FocusFrontMostActiveWindow(ImGuiWindow* ignore_window);
|
|
|
}
|
|
|
@@ -778,7 +778,7 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y);
|
|
|
// Context
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
-// Current context pointer. Implicitely used by all ImGui functions. Always assumed to be != NULL.
|
|
|
+// Current context pointer. Implicitly used by all ImGui functions. Always assumed to be != NULL.
|
|
|
// CreateContext() will automatically set this pointer if it is NULL. Change to a different context by calling ImGui::SetCurrentContext().
|
|
|
// If you use DLL hotreloading you might need to call SetCurrentContext() after reloading code from this file.
|
|
|
// ImGui functions are not thread-safe because of this pointer. If you want thread-safety to allow N threads to access N different contexts, you can:
|
|
|
@@ -833,7 +833,7 @@ ImGuiStyle::ImGuiStyle()
|
|
|
GrabMinSize = 10.0f; // Minimum width/height of a grab box for slider/scrollbar
|
|
|
GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
|
|
ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text.
|
|
|
- DisplayWindowPadding = ImVec2(22,22); // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
|
|
|
+ DisplayWindowPadding = ImVec2(20,20); // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
|
|
|
DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
|
|
|
MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
|
|
|
AntiAliasedLines = true; // Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU.
|
|
|
@@ -1765,7 +1765,10 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
|
|
|
|
|
|
int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass.
|
|
|
if (len <= 0)
|
|
|
+ {
|
|
|
+ va_end(args_copy);
|
|
|
return;
|
|
|
+ }
|
|
|
|
|
|
const int write_off = Buf.Size;
|
|
|
const int needed_sz = write_off + len;
|
|
|
@@ -1777,6 +1780,7 @@ void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
|
|
|
|
|
|
Buf.resize(needed_sz);
|
|
|
ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy);
|
|
|
+ va_end(args_copy);
|
|
|
}
|
|
|
|
|
|
void ImGuiTextBuffer::appendf(const char* fmt, ...)
|
|
|
@@ -1927,7 +1931,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
|
|
|
ID = ImHash(name, 0);
|
|
|
IDStack.push_back(ID);
|
|
|
Flags = 0;
|
|
|
- PosFloat = Pos = ImVec2(0.0f, 0.0f);
|
|
|
+ Pos = ImVec2(0.0f, 0.0f);
|
|
|
Size = SizeFull = ImVec2(0.0f, 0.0f);
|
|
|
SizeContents = SizeContentsExplicit = ImVec2(0.0f, 0.0f);
|
|
|
WindowPadding = ImVec2(0.0f, 0.0f);
|
|
|
@@ -1938,8 +1942,8 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
|
|
|
Scroll = ImVec2(0.0f, 0.0f);
|
|
|
ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
|
|
|
ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f);
|
|
|
- ScrollbarX = ScrollbarY = false;
|
|
|
ScrollbarSizes = ImVec2(0.0f, 0.0f);
|
|
|
+ ScrollbarX = ScrollbarY = false;
|
|
|
Active = WasActive = false;
|
|
|
WriteAccessed = false;
|
|
|
Collapsed = false;
|
|
|
@@ -2256,10 +2260,11 @@ static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
|
|
if (ImGui::IsMouseHoveringRect(cand.Min, cand.Max))
|
|
|
{
|
|
|
ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]);
|
|
|
- g.OverlayDrawList.AddRect(curr.Min, curr.Max, IM_COL32(255, 200, 0, 100));
|
|
|
- g.OverlayDrawList.AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200));
|
|
|
- g.OverlayDrawList.AddRectFilled(cand.Max-ImVec2(4,4), cand.Max+ImGui::CalcTextSize(buf)+ImVec2(4,4), IM_COL32(40,0,0,150));
|
|
|
- g.OverlayDrawList.AddText(g.IO.FontDefault, 13.0f, cand.Max, ~0U, buf);
|
|
|
+ ImDrawList* draw_list = ImGui::GetOverlayDrawList();
|
|
|
+ draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100));
|
|
|
+ draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200));
|
|
|
+ draw_list->AddRectFilled(cand.Max-ImVec2(4,4), cand.Max+ImGui::CalcTextSize(buf)+ImVec2(4,4), IM_COL32(40,0,0,150));
|
|
|
+ draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Max, ~0U, buf);
|
|
|
}
|
|
|
else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate.
|
|
|
{
|
|
|
@@ -2267,8 +2272,9 @@ static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
|
|
|
if (quadrant == g.NavMoveDir)
|
|
|
{
|
|
|
ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center);
|
|
|
- g.OverlayDrawList.AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200));
|
|
|
- g.OverlayDrawList.AddText(g.IO.FontDefault, 13.0f, cand.Min, IM_COL32(255, 255, 255, 255), buf);
|
|
|
+ ImDrawList* draw_list = ImGui::GetOverlayDrawList();
|
|
|
+ draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200));
|
|
|
+ draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Min, IM_COL32(255, 255, 255, 255), buf);
|
|
|
}
|
|
|
}
|
|
|
#endif
|
|
|
@@ -2641,6 +2647,20 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx)
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
+// Helper function to verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit
|
|
|
+// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. you may see different structures from what imgui.cpp sees which is highly problematic.
|
|
|
+bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert)
|
|
|
+{
|
|
|
+ bool error = false;
|
|
|
+ if (strcmp(version, IMGUI_VERSION)!=0) { error = true; IM_ASSERT(strcmp(version,IMGUI_VERSION)==0 && "Mismatch version string!"); }
|
|
|
+ if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); }
|
|
|
+ if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); }
|
|
|
+ if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); }
|
|
|
+ if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); }
|
|
|
+ if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); }
|
|
|
+ return !error;
|
|
|
+}
|
|
|
+
|
|
|
void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void(*free_func)(void* ptr, void* user_data), void* user_data)
|
|
|
{
|
|
|
GImAllocatorAllocFunc = alloc_func;
|
|
|
@@ -2730,13 +2750,14 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static ImVec2 NavCalcPreferredMousePos()
|
|
|
+static ImVec2 NavCalcPreferredRefPos()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
- ImGuiWindow* window = g.NavWindow;
|
|
|
- if (!window)
|
|
|
- return g.IO.MousePos;
|
|
|
- const ImRect& rect_rel = window->NavRectRel[g.NavLayer];
|
|
|
+ if (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow)
|
|
|
+ return ImFloor(g.IO.MousePos);
|
|
|
+
|
|
|
+ // When navigation is active and mouse is disabled, decide on an arbitrary position around the bottom left of the currently navigated item
|
|
|
+ const ImRect& rect_rel = g.NavWindow->NavRectRel[g.NavLayer];
|
|
|
ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x*4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight()));
|
|
|
ImRect visible_rect = GetViewportRect();
|
|
|
return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in back-end might be lossy and result in undesirable non-zero delta.
|
|
|
@@ -2903,8 +2924,8 @@ static void ImGui::NavUpdateWindowing()
|
|
|
if (move_delta.x != 0.0f || move_delta.y != 0.0f)
|
|
|
{
|
|
|
const float NAV_MOVE_SPEED = 800.0f;
|
|
|
- const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y));
|
|
|
- g.NavWindowingTarget->PosFloat += move_delta * move_speed;
|
|
|
+ const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); // FIXME: Doesn't code variable framerate very well
|
|
|
+ g.NavWindowingTarget->Pos += move_delta * move_speed;
|
|
|
g.NavDisableMouseHover = true;
|
|
|
MarkIniSettingsDirty(g.NavWindowingTarget);
|
|
|
}
|
|
|
@@ -3067,10 +3088,11 @@ static void ImGui::NavUpdate()
|
|
|
// Apply application mouse position movement, after we had a chance to process move request result.
|
|
|
if (g.NavMousePosDirty && g.NavIdIsAlive)
|
|
|
{
|
|
|
- // Set mouse position given our knowledge of the nav widget position from last frame
|
|
|
+ // Set mouse position given our knowledge of the navigated item position from last frame
|
|
|
if ((g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (g.IO.BackendFlags & ImGuiBackendFlags_HasSetMousePos))
|
|
|
{
|
|
|
- g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredMousePos();
|
|
|
+ IM_ASSERT(!g.NavDisableHighlight && g.NavDisableMouseHover);
|
|
|
+ g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredRefPos();
|
|
|
g.IO.WantSetMousePos = true;
|
|
|
}
|
|
|
g.NavMousePosDirty = false;
|
|
|
@@ -3252,12 +3274,12 @@ static void ImGui::NavUpdate()
|
|
|
//g.OverlayDrawList.AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
|
|
|
g.NavScoringCount = 0;
|
|
|
#if IMGUI_DEBUG_NAV_RECTS
|
|
|
- if (g.NavWindow) { for (int layer = 0; layer < 2; layer++) g.OverlayDrawList.AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
|
|
|
+ if (g.NavWindow) { for (int layer = 0; layer < 2; layer++) GetOverlayDrawList()->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
|
|
|
if (g.NavWindow) { ImU32 col = (g.NavWindow->HiddenFrames == 0) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredMousePos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); g.OverlayDrawList.AddCircleFilled(p, 3.0f, col); g.OverlayDrawList.AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-static void ImGui::NewFrameUpdateMovingWindow()
|
|
|
+static void ImGui::UpdateMovingWindow()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
if (g.MovingWindow != NULL)
|
|
|
@@ -3267,13 +3289,13 @@ static void ImGui::NewFrameUpdateMovingWindow()
|
|
|
KeepAliveID(g.ActiveId);
|
|
|
IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
|
|
|
ImGuiWindow* moving_window = g.MovingWindow->RootWindow;
|
|
|
- if (g.IO.MouseDown[0])
|
|
|
+ if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos))
|
|
|
{
|
|
|
ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
|
|
|
- if (moving_window->PosFloat.x != pos.x || moving_window->PosFloat.y != pos.y)
|
|
|
+ if (moving_window->Pos.x != pos.x || moving_window->Pos.y != pos.y)
|
|
|
{
|
|
|
MarkIniSettingsDirty(moving_window);
|
|
|
- moving_window->PosFloat = pos;
|
|
|
+ SetWindowPos(moving_window, pos, ImGuiCond_Always);
|
|
|
}
|
|
|
FocusWindow(g.MovingWindow);
|
|
|
}
|
|
|
@@ -3295,12 +3317,12 @@ static void ImGui::NewFrameUpdateMovingWindow()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void ImGui::NewFrameUpdateMouseInputs()
|
|
|
+static void ImGui::UpdateMouseInputs()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
// If mouse just appeared or disappeared (usually denoted by -FLT_MAX component, but in reality we test for -256000.0f) we cancel out movement in MouseDelta
|
|
|
- if (ImGui::IsMousePosValid(&g.IO.MousePos) && ImGui::IsMousePosValid(&g.IO.MousePosPrev))
|
|
|
+ if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MousePosPrev))
|
|
|
g.IO.MouseDelta = g.IO.MousePos - g.IO.MousePosPrev;
|
|
|
else
|
|
|
g.IO.MouseDelta = ImVec2(0.0f, 0.0f);
|
|
|
@@ -3409,7 +3431,7 @@ void ImGui::NewFrame()
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
// Check user data
|
|
|
- // (We pass an error message in the assert expression as a trick to get it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
|
|
+ // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
|
|
IM_ASSERT(g.Initialized);
|
|
|
IM_ASSERT(g.IO.DeltaTime >= 0.0f && "Need a positive DeltaTime (zero is tolerated but will cause some timing issues)");
|
|
|
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value");
|
|
|
@@ -3421,7 +3443,7 @@ void ImGui::NewFrame()
|
|
|
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
|
|
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
|
|
|
|
|
- // Do a simple check for required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was super recently added in 1.60 WIP)
|
|
|
+ // Perform simple check for required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only recently added in 1.60 WIP)
|
|
|
if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard)
|
|
|
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
|
|
|
|
|
|
@@ -3495,7 +3517,7 @@ void ImGui::NewFrame()
|
|
|
NavUpdate();
|
|
|
|
|
|
// Update mouse input state
|
|
|
- NewFrameUpdateMouseInputs();
|
|
|
+ UpdateMouseInputs();
|
|
|
|
|
|
// Calculate frame-rate for the user, as a purely luxurious feature
|
|
|
g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx];
|
|
|
@@ -3504,7 +3526,7 @@ void ImGui::NewFrame()
|
|
|
g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame))) : FLT_MAX;
|
|
|
|
|
|
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering)
|
|
|
- NewFrameUpdateMovingWindow();
|
|
|
+ UpdateMovingWindow();
|
|
|
NewFrameUpdateHoveredWindowAndCaptureFlags();
|
|
|
|
|
|
if (GetFrontMostPopupModal() != NULL)
|
|
|
@@ -3514,7 +3536,7 @@ void ImGui::NewFrame()
|
|
|
|
|
|
g.MouseCursor = ImGuiMouseCursor_Arrow;
|
|
|
g.WantCaptureMouseNextFrame = g.WantCaptureKeyboardNextFrame = g.WantTextInputNextFrame = -1;
|
|
|
- g.OsImePosRequest = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default
|
|
|
+ g.PlatformImePos = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default
|
|
|
|
|
|
// Mouse wheel scrolling, scale
|
|
|
if (g.HoveredWindow && !g.HoveredWindow->Collapsed && (g.IO.MouseWheel != 0.0f || g.IO.MouseWheelH != 0.0f))
|
|
|
@@ -3537,7 +3559,6 @@ void ImGui::NewFrame()
|
|
|
|
|
|
const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size;
|
|
|
window->Pos += offset;
|
|
|
- window->PosFloat += offset;
|
|
|
window->Size *= scale;
|
|
|
window->SizeFull *= scale;
|
|
|
}
|
|
|
@@ -3895,7 +3916,7 @@ static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>* out_sorted_windows,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_render_list, ImDrawList* draw_list)
|
|
|
+static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
|
|
|
{
|
|
|
if (draw_list->CmdBuffer.empty())
|
|
|
return;
|
|
|
@@ -3925,7 +3946,7 @@ static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_render_list, ImDraw
|
|
|
if (sizeof(ImDrawIdx) == 2)
|
|
|
IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
|
|
|
|
|
|
- out_render_list->push_back(draw_list);
|
|
|
+ out_list->push_back(draw_list);
|
|
|
}
|
|
|
|
|
|
static void AddWindowToDrawData(ImVector<ImDrawList*>* out_render_list, ImGuiWindow* window)
|
|
|
@@ -4004,10 +4025,10 @@ void ImGui::EndFrame()
|
|
|
return;
|
|
|
|
|
|
// Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
|
|
|
- if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.OsImePosRequest - g.OsImePosSet) > 0.0001f)
|
|
|
+ if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f)
|
|
|
{
|
|
|
- g.IO.ImeSetInputScreenPosFn((int)g.OsImePosRequest.x, (int)g.OsImePosRequest.y);
|
|
|
- g.OsImePosSet = g.OsImePosRequest;
|
|
|
+ g.IO.ImeSetInputScreenPosFn((int)g.PlatformImePos.x, (int)g.PlatformImePos.y);
|
|
|
+ g.PlatformImeLastPos = g.PlatformImePos;
|
|
|
}
|
|
|
|
|
|
// Hide implicit "Debug" window if it hasn't been used
|
|
|
@@ -4848,7 +4869,7 @@ void ImGui::OpenPopupEx(ImGuiID id)
|
|
|
popup_ref.OpenFrameCount = g.FrameCount;
|
|
|
popup_ref.OpenParentId = parent_window->IDStack.back();
|
|
|
popup_ref.OpenMousePos = g.IO.MousePos;
|
|
|
- popup_ref.OpenPopupPos = (!g.NavDisableHighlight && g.NavDisableMouseHover) ? NavCalcPreferredMousePos() : g.IO.MousePos;
|
|
|
+ popup_ref.OpenPopupPos = NavCalcPreferredRefPos();
|
|
|
|
|
|
//printf("[%05d] OpenPopupEx(0x%08X)\n", g.FrameCount, id);
|
|
|
if (g.OpenPopupStack.Size < current_stack_size + 1)
|
|
|
@@ -5237,7 +5258,7 @@ enum ImGuiPopupPositionPolicy
|
|
|
ImGuiPopupPositionPolicy_ComboBox
|
|
|
};
|
|
|
|
|
|
-static ImRect FindScreenRectForWindow(ImGuiWindow*)
|
|
|
+static ImRect FindAllowedExtentRectForWindow(ImGuiWindow*)
|
|
|
{
|
|
|
ImVec2 padding = GImGui->Style.DisplaySafeAreaPadding;
|
|
|
ImRect r_screen = GetViewportRect();
|
|
|
@@ -5304,37 +5325,37 @@ static ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
- ImRect r_screen = FindScreenRectForWindow(window);
|
|
|
+ ImRect r_outer = FindAllowedExtentRectForWindow(window);
|
|
|
if (window->Flags & ImGuiWindowFlags_ChildMenu)
|
|
|
{
|
|
|
// Child menus typically request _any_ position within the parent menu item, and then our FindBestWindowPosForPopup() function will move the new menu outside the parent bounds.
|
|
|
// This is how we end up with child menus appearing (most-commonly) on the right of the parent menu.
|
|
|
IM_ASSERT(g.CurrentWindow == window);
|
|
|
- ImGuiWindow* parent_menu = g.CurrentWindowStack[g.CurrentWindowStack.Size - 2];
|
|
|
+ ImGuiWindow* parent_window = g.CurrentWindowStack[g.CurrentWindowStack.Size - 2];
|
|
|
float horizontal_overlap = g.Style.ItemSpacing.x; // We want some overlap to convey the relative depth of each menu (currently the amount of overlap is hard-coded to style.ItemSpacing.x).
|
|
|
ImRect r_avoid;
|
|
|
- if (parent_menu->DC.MenuBarAppending)
|
|
|
- r_avoid = ImRect(-FLT_MAX, parent_menu->Pos.y + parent_menu->TitleBarHeight(), FLT_MAX, parent_menu->Pos.y + parent_menu->TitleBarHeight() + parent_menu->MenuBarHeight());
|
|
|
+ if (parent_window->DC.MenuBarAppending)
|
|
|
+ r_avoid = ImRect(-FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight(), FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight() + parent_window->MenuBarHeight());
|
|
|
else
|
|
|
- r_avoid = ImRect(parent_menu->Pos.x + horizontal_overlap, -FLT_MAX, parent_menu->Pos.x + parent_menu->Size.x - horizontal_overlap - parent_menu->ScrollbarSizes.x, FLT_MAX);
|
|
|
- return FindBestWindowPosForPopupEx(window->PosFloat, window->Size, &window->AutoPosLastDirection, r_screen, r_avoid);
|
|
|
+ r_avoid = ImRect(parent_window->Pos.x + horizontal_overlap, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - horizontal_overlap - parent_window->ScrollbarSizes.x, FLT_MAX);
|
|
|
+ return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
|
|
|
}
|
|
|
if (window->Flags & ImGuiWindowFlags_Popup)
|
|
|
{
|
|
|
- ImRect r_avoid(window->PosFloat.x - 1, window->PosFloat.y - 1, window->PosFloat.x + 1, window->PosFloat.y + 1);
|
|
|
- return FindBestWindowPosForPopupEx(window->PosFloat, window->Size, &window->AutoPosLastDirection, r_screen, r_avoid);
|
|
|
+ ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1);
|
|
|
+ return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
|
|
|
}
|
|
|
if (window->Flags & ImGuiWindowFlags_Tooltip)
|
|
|
{
|
|
|
// Position tooltip (always follows mouse)
|
|
|
float sc = g.Style.MouseCursorScale;
|
|
|
- ImVec2 ref_pos = (!g.NavDisableHighlight && g.NavDisableMouseHover) ? NavCalcPreferredMousePos() : g.IO.MousePos;
|
|
|
+ ImVec2 ref_pos = NavCalcPreferredRefPos();
|
|
|
ImRect r_avoid;
|
|
|
if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos))
|
|
|
r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 16, ref_pos.y + 8);
|
|
|
else
|
|
|
r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * sc, ref_pos.y + 24 * sc); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
|
|
|
- ImVec2 pos = FindBestWindowPosForPopupEx(ref_pos, window->Size, &window->AutoPosLastDirection, r_screen, r_avoid);
|
|
|
+ ImVec2 pos = FindBestWindowPosForPopupEx(ref_pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
|
|
|
if (window->AutoPosLastDirection == ImGuiDir_None)
|
|
|
pos = ref_pos + ImVec2(2, 2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible.
|
|
|
return pos;
|
|
|
@@ -5367,7 +5388,7 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
|
|
g.WindowsById.SetVoidPtr(window->ID, window);
|
|
|
|
|
|
// Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
|
|
|
- window->Pos = window->PosFloat = ImVec2(60, 60);
|
|
|
+ window->Pos = ImVec2(60, 60);
|
|
|
|
|
|
// User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
|
|
|
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
|
|
|
@@ -5376,11 +5397,10 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl
|
|
|
if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
|
|
|
{
|
|
|
SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
|
|
|
- window->PosFloat = settings->Pos;
|
|
|
- window->Pos = ImFloor(window->PosFloat);
|
|
|
+ window->Pos = ImFloor(settings->Pos);
|
|
|
window->Collapsed = settings->Collapsed;
|
|
|
if (ImLengthSqr(settings->Size) > 0.00001f)
|
|
|
- size = settings->Size;
|
|
|
+ size = ImFloor(settings->Size);
|
|
|
}
|
|
|
}
|
|
|
window->Size = window->SizeFull = window->SizeFullAtLastBegin = size;
|
|
|
@@ -5448,24 +5468,22 @@ static ImVec2 CalcSizeAutoFit(ImGuiWindow* window, const ImVec2& size_contents)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiStyle& style = g.Style;
|
|
|
- ImGuiWindowFlags flags = window->Flags;
|
|
|
- ImVec2 size_auto_fit;
|
|
|
- if ((flags & ImGuiWindowFlags_Tooltip) != 0)
|
|
|
+ if (window->Flags & ImGuiWindowFlags_Tooltip)
|
|
|
{
|
|
|
- // Tooltip always resize. We keep the spacing symmetric on both axises for aesthetic purpose.
|
|
|
- size_auto_fit = size_contents;
|
|
|
+ // Tooltip always resize
|
|
|
+ return size_contents;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// 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 DisplaySize-WindowPadding.
|
|
|
- size_auto_fit = ImClamp(size_contents, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - g.Style.DisplaySafeAreaPadding * 2.0f));
|
|
|
+ ImVec2 size_auto_fit = ImClamp(size_contents, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - g.Style.DisplaySafeAreaPadding * 2.0f));
|
|
|
ImVec2 size_auto_fit_after_constraint = CalcSizeAfterConstraint(window, size_auto_fit);
|
|
|
- if (size_auto_fit_after_constraint.x < size_contents.x && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar))
|
|
|
+ if (size_auto_fit_after_constraint.x < size_contents.x && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && (window->Flags & ImGuiWindowFlags_HorizontalScrollbar))
|
|
|
size_auto_fit.y += style.ScrollbarSize;
|
|
|
- if (size_auto_fit_after_constraint.y < size_contents.y && !(flags & ImGuiWindowFlags_NoScrollbar))
|
|
|
+ if (size_auto_fit_after_constraint.y < size_contents.y && !(window->Flags & ImGuiWindowFlags_NoScrollbar))
|
|
|
size_auto_fit.x += style.ScrollbarSize;
|
|
|
+ return size_auto_fit;
|
|
|
}
|
|
|
- return size_auto_fit;
|
|
|
}
|
|
|
|
|
|
static float GetScrollMaxX(ImGuiWindow* window)
|
|
|
@@ -5646,7 +5664,7 @@ static void ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
|
|
|
}
|
|
|
if (pos_target.x != FLT_MAX)
|
|
|
{
|
|
|
- window->Pos = window->PosFloat = ImFloor(pos_target);
|
|
|
+ window->Pos = ImFloor(pos_target);
|
|
|
MarkIniSettingsDirty(window);
|
|
|
}
|
|
|
|
|
|
@@ -5743,14 +5761,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
{
|
|
|
SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond);
|
|
|
}
|
|
|
- g.NextWindowData.PosCond = 0;
|
|
|
}
|
|
|
if (g.NextWindowData.SizeCond)
|
|
|
{
|
|
|
window_size_x_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.x > 0.0f);
|
|
|
window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f);
|
|
|
SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond);
|
|
|
- g.NextWindowData.SizeCond = 0;
|
|
|
}
|
|
|
if (g.NextWindowData.ContentSizeCond)
|
|
|
{
|
|
|
@@ -5758,22 +5774,15 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->SizeContentsExplicit = g.NextWindowData.ContentSizeVal;
|
|
|
if (window->SizeContentsExplicit.y != 0.0f)
|
|
|
window->SizeContentsExplicit.y += window->TitleBarHeight() + window->MenuBarHeight();
|
|
|
- g.NextWindowData.ContentSizeCond = 0;
|
|
|
}
|
|
|
else if (first_begin_of_the_frame)
|
|
|
{
|
|
|
window->SizeContentsExplicit = ImVec2(0.0f, 0.0f);
|
|
|
}
|
|
|
if (g.NextWindowData.CollapsedCond)
|
|
|
- {
|
|
|
SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond);
|
|
|
- g.NextWindowData.CollapsedCond = 0;
|
|
|
- }
|
|
|
if (g.NextWindowData.FocusCond)
|
|
|
- {
|
|
|
- SetWindowFocus();
|
|
|
- g.NextWindowData.FocusCond = 0;
|
|
|
- }
|
|
|
+ FocusWindow(window);
|
|
|
if (window->Appearing)
|
|
|
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
|
|
|
|
|
|
@@ -5800,8 +5809,35 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->LastFrameActive = current_frame;
|
|
|
window->IDStack.resize(1);
|
|
|
|
|
|
- // Lock window rounding, border size and rounding so that altering the border sizes for children doesn't have side-effects.
|
|
|
- window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
|
|
|
+ // UPDATE CONTENTS SIZE, UPDATE HIDDEN STATUS
|
|
|
+
|
|
|
+ // Update contents size from last frame for auto-fitting (or use explicit size)
|
|
|
+ window->SizeContents = CalcSizeContents(window);
|
|
|
+ if (window->HiddenFrames > 0)
|
|
|
+ window->HiddenFrames--;
|
|
|
+
|
|
|
+ // Hide new windows for one frame until they calculate their size
|
|
|
+ if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api))
|
|
|
+ window->HiddenFrames = 1;
|
|
|
+
|
|
|
+ // Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows)
|
|
|
+ // We reset Size/SizeContents for reappearing popups/tooltips early in this function, so further code won't be tempted to use the old size.
|
|
|
+ if (window_just_activated_by_user && (flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0)
|
|
|
+ {
|
|
|
+ window->HiddenFrames = 1;
|
|
|
+ if (flags & ImGuiWindowFlags_AlwaysAutoResize)
|
|
|
+ {
|
|
|
+ if (!window_size_x_set_by_api)
|
|
|
+ window->Size.x = window->SizeFull.x = 0.f;
|
|
|
+ if (!window_size_y_set_by_api)
|
|
|
+ window->Size.y = window->SizeFull.y = 0.f;
|
|
|
+ window->SizeContents = ImVec2(0.f, 0.f);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SetCurrentWindow(window);
|
|
|
+
|
|
|
+ // Lock border size and padding for the frame (so that altering them doesn't cause inconsistencies)
|
|
|
window->WindowBorderSize = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildBorderSize : ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize;
|
|
|
window->WindowPadding = style.WindowPadding;
|
|
|
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
|
|
|
@@ -5829,29 +5865,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
|
|
|
// SIZE
|
|
|
|
|
|
- // Update contents size from last frame for auto-fitting (unless explicitly specified)
|
|
|
- window->SizeContents = CalcSizeContents(window);
|
|
|
-
|
|
|
- // Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows)
|
|
|
- if (window->HiddenFrames > 0)
|
|
|
- window->HiddenFrames--;
|
|
|
- if (window_just_activated_by_user && (flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0)
|
|
|
- {
|
|
|
- window->HiddenFrames = 1;
|
|
|
- if (flags & ImGuiWindowFlags_AlwaysAutoResize)
|
|
|
- {
|
|
|
- if (!window_size_x_set_by_api)
|
|
|
- window->Size.x = window->SizeFull.x = 0.f;
|
|
|
- if (!window_size_y_set_by_api)
|
|
|
- window->Size.y = window->SizeFull.y = 0.f;
|
|
|
- window->SizeContents = ImVec2(0.f, 0.f);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Hide new windows for one frame until they calculate their size
|
|
|
- if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api))
|
|
|
- window->HiddenFrames = 1;
|
|
|
-
|
|
|
// Calculate auto-fit size, handle automatic resize
|
|
|
const ImVec2 size_auto_fit = CalcSizeAutoFit(window, window->SizeContents);
|
|
|
ImVec2 size_full_modified(FLT_MAX, FLT_MAX);
|
|
|
@@ -5901,7 +5914,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
{
|
|
|
window->AutoPosLastDirection = ImGuiDir_None;
|
|
|
if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
|
|
|
- window->Pos = window->PosFloat = g.CurrentPopupStack.back().OpenPopupPos;
|
|
|
+ window->Pos = g.CurrentPopupStack.back().OpenPopupPos;
|
|
|
}
|
|
|
|
|
|
// Position child window
|
|
|
@@ -5910,18 +5923,18 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->BeginOrderWithinParent = parent_window->DC.ChildWindows.Size;
|
|
|
parent_window->DC.ChildWindows.push_back(window);
|
|
|
if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !window_is_child_tooltip)
|
|
|
- window->Pos = window->PosFloat = parent_window->DC.CursorPos;
|
|
|
+ window->Pos = parent_window->DC.CursorPos;
|
|
|
}
|
|
|
|
|
|
const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFrames == 0);
|
|
|
if (window_pos_with_pivot)
|
|
|
SetWindowPos(window, ImMax(style.DisplaySafeAreaPadding, window->SetWindowPosVal - window->SizeFull * window->SetWindowPosPivot), 0); // Position given a pivot (e.g. for centering)
|
|
|
else if ((flags & ImGuiWindowFlags_ChildMenu) != 0)
|
|
|
- window->PosFloat = FindBestWindowPosForPopup(window);
|
|
|
+ window->Pos = FindBestWindowPosForPopup(window);
|
|
|
else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize)
|
|
|
- window->PosFloat = FindBestWindowPosForPopup(window);
|
|
|
+ window->Pos = FindBestWindowPosForPopup(window);
|
|
|
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
|
|
- window->PosFloat = FindBestWindowPosForPopup(window);
|
|
|
+ window->Pos = FindBestWindowPosForPopup(window);
|
|
|
|
|
|
// Clamp position so it stays visible
|
|
|
if (!(flags & ImGuiWindowFlags_ChildWindow))
|
|
|
@@ -5929,11 +5942,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
if (!window_pos_set_by_api && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0 && g.IO.DisplaySize.x > 0.0f && g.IO.DisplaySize.y > 0.0f) // Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
|
|
|
{
|
|
|
ImVec2 padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding);
|
|
|
- window->PosFloat = ImMax(window->PosFloat + window->Size, padding) - window->Size;
|
|
|
- window->PosFloat = ImMin(window->PosFloat, g.IO.DisplaySize - padding);
|
|
|
+ window->Pos = ImMax(window->Pos + window->Size, padding) - window->Size;
|
|
|
+ window->Pos = ImMin(window->Pos, g.IO.DisplaySize - padding);
|
|
|
}
|
|
|
}
|
|
|
- window->Pos = ImFloor(window->PosFloat);
|
|
|
+ window->Pos = ImFloor(window->Pos);
|
|
|
+
|
|
|
+ // Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)
|
|
|
+ window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
|
|
|
|
|
|
// Prepare for focus requests
|
|
|
window->FocusIdxAllRequestCurrent = (window->FocusIdxAllRequestNext == INT_MAX || window->FocusIdxAllCounter == -1) ? INT_MAX : (window->FocusIdxAllRequestNext + (window->FocusIdxAllCounter+1)) % (window->FocusIdxAllCounter+1);
|
|
|
@@ -6052,7 +6068,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
|
|
|
// Borders
|
|
|
if (window_border_size > 0.0f)
|
|
|
- window->DrawList->AddRect(window->Pos, window->Pos+window->Size, GetColorU32(ImGuiCol_Border), window_rounding, ImDrawCornerFlags_All, window_border_size);
|
|
|
+ window->DrawList->AddRect(window->Pos, window->Pos + window->Size, GetColorU32(ImGuiCol_Border), window_rounding, ImDrawCornerFlags_All, window_border_size);
|
|
|
if (border_held != -1)
|
|
|
{
|
|
|
ImRect border = GetBorderRect(window, border_held, grip_draw_size, 0.0f);
|
|
|
@@ -6150,7 +6166,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
{
|
|
|
ImGuiID id = window->GetID("#COLLAPSE");
|
|
|
ImRect bb(window->Pos + style.FramePadding + ImVec2(1,1), window->Pos + style.FramePadding + ImVec2(g.FontSize,g.FontSize) - ImVec2(1,1));
|
|
|
- ItemAdd(bb, id); // To allow navigation
|
|
|
+ ItemAdd(bb, id);
|
|
|
if (ButtonBehavior(bb, id, NULL, NULL))
|
|
|
window->CollapseToggleWanted = true; // Defer collapsing to next frame as we are too far in the Begin() function
|
|
|
RenderNavHighlight(bb, id);
|
|
|
@@ -6226,7 +6242,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->WriteAccessed = false;
|
|
|
|
|
|
window->BeginCount++;
|
|
|
- g.NextWindowData.SizeConstraintCond = 0;
|
|
|
+ g.NextWindowData.Clear();
|
|
|
|
|
|
// Child window can be out of sight and have "negative" clip windows.
|
|
|
// Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar).
|
|
|
@@ -6903,7 +6919,6 @@ static void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond)
|
|
|
|
|
|
// Set
|
|
|
const ImVec2 old_pos = window->Pos;
|
|
|
- window->PosFloat = pos;
|
|
|
window->Pos = ImFloor(pos);
|
|
|
window->DC.CursorPos += (window->Pos - old_pos); // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
|
|
|
window->DC.CursorMaxPos += (window->Pos - old_pos); // And more importantly we need to adjust this so size calculation doesn't get affected.
|
|
|
@@ -8000,7 +8015,7 @@ bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
|
|
|
if (flags & ImGuiTreeNodeFlags_Leaf)
|
|
|
return true;
|
|
|
|
|
|
- // We only write to the tree storage if the user clicks (or explicitely use SetNextTreeNode*** functions)
|
|
|
+ // We only write to the tree storage if the user clicks (or explicitly use SetNextTreeNode*** functions)
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
ImGuiStorage* storage = window->DC.StateStorage;
|
|
|
@@ -10483,7 +10498,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|
|
|
|
|
// Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
|
|
|
if (is_editable)
|
|
|
- g.OsImePosRequest = ImVec2(cursor_screen_pos.x - 1, cursor_screen_pos.y - g.FontSize);
|
|
|
+ g.PlatformImePos = ImVec2(cursor_screen_pos.x - 1, cursor_screen_pos.y - g.FontSize);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -10790,7 +10805,7 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF
|
|
|
ImVec2 size_expected = CalcSizeAfterConstraint(popup_window, CalcSizeAutoFit(popup_window, size_contents));
|
|
|
if (flags & ImGuiComboFlags_PopupAlignLeft)
|
|
|
popup_window->AutoPosLastDirection = ImGuiDir_Left;
|
|
|
- ImRect r_outer = FindScreenRectForWindow(popup_window);
|
|
|
+ ImRect r_outer = FindAllowedExtentRectForWindow(popup_window);
|
|
|
ImVec2 pos = FindBestWindowPosForPopupEx(frame_bb.GetBL(), size_expected, &popup_window->AutoPosLastDirection, r_outer, frame_bb, ImGuiPopupPositionPolicy_ComboBox);
|
|
|
SetNextWindowPos(pos);
|
|
|
}
|
|
|
@@ -11382,8 +11397,9 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|
|
|
|
|
if (menu_is_open)
|
|
|
{
|
|
|
+ // Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
|
|
|
SetNextWindowPos(popup_pos, ImGuiCond_Always);
|
|
|
- ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ((window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) ? ImGuiWindowFlags_ChildMenu|ImGuiWindowFlags_ChildWindow : ImGuiWindowFlags_ChildMenu);
|
|
|
+ ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ((window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) ? ImGuiWindowFlags_ChildMenu|ImGuiWindowFlags_ChildWindow : ImGuiWindowFlags_ChildMenu);
|
|
|
menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
|
|
}
|
|
|
|
|
|
@@ -13222,7 +13238,7 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {}
|
|
|
#endif
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
-// HELP
|
|
|
+// HELP, METRICS
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
@@ -13250,8 +13266,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- ImDrawList* overlay_draw_list = ImGui::GetOverlayDrawList(); // Render additional visuals into the top-most draw list
|
|
|
- if (window && ImGui::IsItemHovered())
|
|
|
+ ImDrawList* overlay_draw_list = GetOverlayDrawList(); // Render additional visuals into the top-most draw list
|
|
|
+ if (window && IsItemHovered())
|
|
|
overlay_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
|
|
|
if (!node_open)
|
|
|
return;
|