// Child menus typically request _any_ position within the parent menu item, and then we 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.
ImGuiWindow*parent_window=window->ParentWindow;
floathorizontal_overlap=g.Style.ItemInnerSpacing.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).
ImRectr_outer=GetWindowAllowedExtentRect(window);
ImRectr_avoid;
if(parent_window->DC.MenuBarAppending)
r_avoid=ImRect(-FLT_MAX,parent_window->ClipRect.Min.y,FLT_MAX,parent_window->ClipRect.Max.y);// Avoid parent menu-bar. If we wanted multi-line menu-bar, we may instead want to have the calling window setup e.g. a NextWindowData.PosConstraintAvoidRect field
returnImFloor(ImClamp(pos,visible_rect.Min,visible_rect.Max));// ImFloor() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta.
ImGuiViewport*viewport =g.NavWindow->Viewport;
returnImFloor(ImClamp(pos,viewport->Pos,viewport->Pos+viewport->Size));// ImFloor() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta.
MetricsHelpMarker("Dear ImGui uses monitor data:\n- to query DPI settings on a per monitor basis\n- to position popup/tooltips so they don't straddle monitors.");
IMGUI_APIImVec2GetCursorStartPos();// initial cursor position in window coordinates
IMGUI_APIImVec2GetCursorScreenPos();// cursor position in absolute screen coordinates (0..io.DisplaySize) or natural OS coordinates when using multiple viewport. Useful to work with ImDrawList API.
IMGUI_APIvoidSetCursorScreenPos(constImVec2&pos);// cursor position in absolute screen coordinates (0..io.DisplaySize) or natural OS coordinates when using multiple viewport.
IMGUI_APIImVec2GetCursorScreenPos();// cursor position in absolute coordinates (useful to work with ImDrawList API). generally top-left == GetMainViewport()->Pos == (0,0) in single viewport mode, and bottom-right == GetMainViewport()->Pos+Size == io.DisplaySize in single-viewport mode.
IMGUI_APIvoidSetCursorScreenPos(constImVec2&pos);// cursor position in absolute coordinates
IMGUI_APIvoidAlignTextToFramePadding();// vertically align upcoming text baseline to FramePadding.y so that it will align properly to regularly framed items (call if you have text on a line before a framed item)
IMGUI_APIfloatGetTextLineHeight();// ~ FontSize
IMGUI_APIfloatGetTextLineHeightWithSpacing();// ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text)
// ImGuiViewport Private/Internals fields (cardinal sin: we are using inheritance!)
// Note that every instance of ImGuiViewport is in fact a ImGuiViewportP.
// Every instance of ImGuiViewport is in fact a ImGuiViewportP.
structImGuiViewportP:publicImGuiViewport
{
intIdx;
intLastFrameActive;// Last frame number this viewport was activated by a window
intLastFrameDrawLists[2];// Last frame number the background (0) and foreground (1) draw lists were used
intLastFrontMostStampCount;// Last stamp number from when a window hosted by this viewport was made front-most (by comparing this value between two viewport we have an implicit viewport z-order
intLastFrameActive;// Last frame number this viewport was activated by a window
intLastFrontMostStampCount;// Last stamp number from when a window hosted by this viewport was made front-most (by comparing this value between two viewport we have an implicit viewport z-order
ImGuiIDLastNameHash;
ImVec2LastPos;
floatAlpha;// Window opacity (when dragging dockable windows/viewports we make them transparent)
floatAlpha;// Window opacity (when dragging dockable windows/viewports we make them transparent)
floatLastAlpha;
shortPlatformMonitor;
boolPlatformWindowCreated;
ImGuiWindow*Window;// Set when the viewport is owned by a window (and ImGuiViewportFlags_CanHostOtherWindows is NOT set)
ImDrawList*DrawLists[2];// Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
ImGuiWindow*Window;// Set when the viewport is owned by a window (and ImGuiViewportFlags_CanHostOtherWindows is NOT set)
intDrawListsLastFrame[2];// Last frame number the background (0) and foreground (1) draw lists were used
ImDrawList*DrawLists[2];// Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays.
ImDrawDataDrawDataP;
ImDrawDataBuilderDrawDataBuilder;
ImVec2LastPlatformPos;
@ -1321,7 +1321,7 @@ struct ImGuiViewportP : public ImGuiViewport
ImVec2CurrWorkOffsetMin;// Work Area: Offset being built/increased during current frame
ImVec2CurrWorkOffsetMax;// Work Area: Offset being built/decreased during current frame
// We don't attempt to calculate our height ahead, as it depends on the per-viewport font size. However menu-bar will affect the minimum window size so we'll get the right height.
// We don't attempt to calculate our height ahead, as it depends on the per-viewport font size.
// However menu-bar will affect the minimum window size so we'll get the right height.
SetNextWindowViewport(viewport->ID);// Enforce viewport so we don't create our own viewport when ImGuiConfigFlags_ViewportsNoMerge is set.
PushStyleVar(ImGuiStyleVar_WindowRounding,0.0f);
PushStyleVar(ImGuiStyleVar_WindowMinSize,ImVec2(0,0));// Lift normal size constraint, however the presence of a menu-bar will give us the minimum height we want.
PushStyleVar(ImGuiStyleVar_WindowMinSize,ImVec2(0,0));// Lift normal size constraint, however the presence of a menu-bar will give us the minimum height we want.