mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 13:35:49 +02:00
Misc: Comments and shallow/small changes (merged from viewport branch to minimize branch drift).
This commit is contained in:
111
imgui.cpp
111
imgui.cpp
@ -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.
|
||||
@ -757,8 +757,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);
|
||||
}
|
||||
@ -830,7 +830,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.
|
||||
@ -1939,8 +1939,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;
|
||||
@ -2257,10 +2257,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.
|
||||
{
|
||||
@ -2268,8 +2269,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
|
||||
@ -2731,7 +2733,7 @@ void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
|
||||
}
|
||||
}
|
||||
|
||||
static ImVec2 NavCalcPreferredMousePos()
|
||||
static ImVec2 NavCalcPreferredRefPos()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.NavWindow;
|
||||
@ -3068,10 +3070,10 @@ 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();
|
||||
g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredRefPos();
|
||||
g.IO.WantSetMousePos = true;
|
||||
}
|
||||
g.NavMousePosDirty = false;
|
||||
@ -3253,12 +3255,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)
|
||||
@ -3296,12 +3298,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);
|
||||
@ -3410,7 +3412,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");
|
||||
@ -3422,7 +3424,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.");
|
||||
|
||||
@ -3496,7 +3498,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];
|
||||
@ -3505,7 +3507,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)
|
||||
@ -3515,7 +3517,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))
|
||||
@ -3895,7 +3897,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 +3927,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 +4006,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 +4850,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 = (!g.NavDisableHighlight && g.NavDisableMouseHover) ? NavCalcPreferredRefPos() : g.IO.MousePos;
|
||||
|
||||
//printf("[%05d] OpenPopupEx(0x%08X)\n", g.FrameCount, id);
|
||||
if (g.OpenPopupStack.Size < current_stack_size + 1)
|
||||
@ -5237,7 +5239,7 @@ enum ImGuiPopupPositionPolicy
|
||||
ImGuiPopupPositionPolicy_ComboBox
|
||||
};
|
||||
|
||||
static ImRect FindScreenRectForWindow(ImGuiWindow*)
|
||||
static ImRect FindAllowedExtentRectForWindow(ImGuiWindow*)
|
||||
{
|
||||
ImVec2 padding = GImGui->Style.DisplaySafeAreaPadding;
|
||||
ImRect r_screen = GetViewportRect();
|
||||
@ -5304,37 +5306,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->Pos, 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->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1);
|
||||
return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_screen, r_avoid);
|
||||
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 = (!g.NavDisableHighlight && g.NavDisableMouseHover) ? NavCalcPreferredRefPos() : g.IO.MousePos;
|
||||
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;
|
||||
@ -5447,24 +5449,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)
|
||||
@ -6051,7 +6051,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);
|
||||
@ -6149,7 +6149,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);
|
||||
@ -10480,7 +10480,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
|
||||
{
|
||||
@ -10787,7 +10787,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);
|
||||
}
|
||||
@ -11379,6 +11379,7 @@ 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);
|
||||
menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||
@ -13219,7 +13220,7 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HELP
|
||||
// HELP, METRICS
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
@ -13247,8 +13248,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;
|
||||
|
Reference in New Issue
Block a user