Viewports: Backport a few constructs from 'docking' branch.
Viewports: Added ImGuiViewportFlags_IsPlatformWindow, ImGuiViewportFlags_IsPlatformMonitor, ImGuiViewportFlags_OwnedByApp (none of them were in docking branch yet). ImGuiViewportFlags_IsPlatformMonitor is merely there to convey future intent, not yet used.
Reduce uses of io.DisplaySize.
MainMenuBar: Backport work area handling code from 'docking' branch.
Metrics: Backported "Viewports" debug visualizer from 'docking' branch.
Demo: Rework 'Examples->Fullscreen Window'.
Demo: 'Simple Overlay' demo now moves under main menu-bar (if any) using GetMainViewport()'s work area.
// We are using scissoring to clip some objects. All low-level graphics API should supports it.
// We are using scissoring to clip some objects. All low-level graphics API should supports it.
// - If your engine doesn't support scissoring yet, you may ignore this at first. You will get some small glitches
// - If your engine doesn't support scissoring yet, you may ignore this at first. You will get some small glitches
// (some elements visible outside their bounds) but you can fix that once everything else works!
// (some elements visible outside their bounds) but you can fix that once everything else works!
// - Clipping coordinates are provided in imgui coordinates space (from draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize)
// - Clipping coordinates are provided in imgui coordinates space:
// In a single viewport application, draw_data->DisplayPos will always be (0,0) and draw_data->DisplaySize will always be == io.DisplaySize.
// - For a given viewport, draw_data->DisplayPos == viewport->Pos and draw_data->DisplaySize == viewport->Size
// However, in the interest of supporting multi-viewport applications in the future (see 'viewport' branch on github),
// - In a single viewport application, draw_data->DisplayPos == (0,0) and draw_data->DisplaySize == io.DisplaySize, but always use GetMainViewport()->Pos/Size instead of hardcoding those values.
// - In the interest of supporting multi-viewport applications (see 'docking' branch on github),
// always subtract draw_data->DisplayPos from clipping bounds to convert them to your viewport space.
// always subtract draw_data->DisplayPos from clipping bounds to convert them to your viewport space.
// - Note that pcmd->ClipRect contains Min+Max bounds. Some graphics API may use Min+Max, other may use Min+Size (size being Max-Min)
// - Note that pcmd->ClipRect contains Min+Max bounds. Some graphics API may use Min+Max, other may use Min+Size (size being Max-Min)
if(windows_to_render_top_most[n]&&IsWindowActiveAndVisible(windows_to_render_top_most[n]))// NavWindowingTarget is always temporarily displayed as the top-most window
if(windows_to_render_top_most[n]&&IsWindowActiveAndVisible(windows_to_render_top_most[n]))// NavWindowingTarget is always temporarily displayed as the top-most window
if(is_popup||is_menu)// Popups and menus bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups)
if(is_popup||is_menu)// Popups and menus bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups)
// r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.)
// r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.)
// r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it.
// r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it.
// (r_outer is usually equivalent to the viewport rectangle minus padding, but when multi-viewports are enabled and monitor
// information are available, it may represent the entire platform monitor from the frame of reference of the current viewport.
// this allows us to have tooltips/popups displayed out of the parent viewport.)
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.
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.
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
IMGUI_APIImVec2GetCursorStartPos();// initial cursor position in window coordinates
IMGUI_APIImVec2GetCursorStartPos();// initial cursor position in window coordinates
IMGUI_APIImVec2GetCursorScreenPos();// cursor position in absolute screen coordinates [0..io.DisplaySize] (useful to work with ImDrawList API)
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 screen coordinates [0..io.DisplaySize]
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_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_APIfloatGetTextLineHeight();// ~ FontSize
IMGUI_APIfloatGetTextLineHeightWithSpacing();// ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text)
IMGUI_APIfloatGetTextLineHeightWithSpacing();// ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text)
@ -787,6 +790,12 @@ namespace ImGui
IMGUI_APIImVec2GetItemRectSize();// get size of last item
IMGUI_APIImVec2GetItemRectSize();// get size of last item
IMGUI_APIvoidSetItemAllowOverlap();// allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area.
IMGUI_APIvoidSetItemAllowOverlap();// allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area.
// Viewports
// - Currently represents the Platform Window created by the application which is hosting our Dear ImGui windows.
// - In 'docking' branch with multi-viewport enabled, we extend this concept to have multiple active viewports.
// - In the future we will extend this concept further to also represent Platform Monitor and support a "no main platform window" operation mode.
IMGUI_APIboolIsRectVisible(constImVec2&size);// test if rectangle (of given size, starting from cursor position) is visible / not clipped.
IMGUI_APIboolIsRectVisible(constImVec2&size);// test if rectangle (of given size, starting from cursor position) is visible / not clipped.
IMGUI_APIboolIsRectVisible(constImVec2&rect_min,constImVec2&rect_max);// test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
IMGUI_APIboolIsRectVisible(constImVec2&rect_min,constImVec2&rect_max);// test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side.
@ -1736,7 +1745,7 @@ struct ImGuiIO
ImGuiConfigFlagsConfigFlags;// = 0 // See ImGuiConfigFlags_ enum. Set by user/application. Gamepad/keyboard navigation options, etc.
ImGuiConfigFlagsConfigFlags;// = 0 // See ImGuiConfigFlags_ enum. Set by user/application. Gamepad/keyboard navigation options, etc.
ImGuiBackendFlagsBackendFlags;// = 0 // See ImGuiBackendFlags_ enum. Set by backend (imgui_impl_xxx files or custom backend) to communicate features supported by the backend.
ImGuiBackendFlagsBackendFlags;// = 0 // See ImGuiBackendFlags_ enum. Set by backend (imgui_impl_xxx files or custom backend) to communicate features supported by the backend.
ImVec2DisplaySize;// <unset> // Main display size, in pixels.
ImVec2DisplaySize;// <unset> // Main display size, in pixels (generally == GetMainViewport()->Size)
floatDeltaTime;// = 1.0f/60.0f // Time elapsed since last frame, in seconds.
floatDeltaTime;// = 1.0f/60.0f // Time elapsed since last frame, in seconds.
floatIniSavingRate;// = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds.
floatIniSavingRate;// = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds.
constchar*IniFilename;// = "imgui.ini" // Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory.
constchar*IniFilename;// = "imgui.ini" // Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory.
@ -2334,7 +2343,8 @@ enum ImDrawListFlags_
// Each dear imgui window contains its own ImDrawList. You can use ImGui::GetWindowDrawList() to
// Each dear imgui window contains its own ImDrawList. You can use ImGui::GetWindowDrawList() to
// access the current window draw list and draw custom primitives.
// access the current window draw list and draw custom primitives.
// You can interleave normal ImGui:: calls and adding primitives to the current draw list.
// You can interleave normal ImGui:: calls and adding primitives to the current draw list.
// All positions are generally in pixel coordinates (top-left at (0,0), bottom-right at io.DisplaySize), but you are totally free to apply whatever transformation matrix to want to the data (if you apply such transformation you'll want to apply it to ClipRect as well)
// In single viewport mode, top-left is == GetMainViewport()->Pos (generally 0,0), bottom-right is == GetMainViewport()->Pos+Size (generally io.DisplaySize).
// You are totally free to apply whatever transformation matrix to want to the data (depending on the use of the transformation you may want to apply it to ClipRect as well!)
// Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions), if you use this API a lot consider coarse culling your drawn objects.
// Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions), if you use this API a lot consider coarse culling your drawn objects.
structImDrawList
structImDrawList
{
{
@ -2465,8 +2475,8 @@ struct ImDrawData
intTotalIdxCount;// For convenience, sum of all ImDrawList's IdxBuffer.Size
intTotalIdxCount;// For convenience, sum of all ImDrawList's IdxBuffer.Size
intTotalVtxCount;// For convenience, sum of all ImDrawList's VtxBuffer.Size
intTotalVtxCount;// For convenience, sum of all ImDrawList's VtxBuffer.Size
ImDrawList**CmdLists;// Array of ImDrawList* to render. The ImDrawList are owned by ImGuiContext and only pointed to from here.
ImDrawList**CmdLists;// Array of ImDrawList* to render. The ImDrawList are owned by ImGuiContext and only pointed to from here.
ImVec2DisplayPos;// Upper-left position of the viewport to render (== upper-left of the orthogonal projection matrix to use)
ImVec2DisplayPos;// Top-left position of the viewport to render (== top-left of the orthogonal projection matrix to use) (== GetMainViewport()->Pos for the main viewport, == (0.0) in most single-viewport applications)
ImVec2DisplaySize;// Size of the viewport to render (== io.DisplaySize for the main viewport) (DisplayPos + DisplaySize == lower-right of the orthogonal projection matrix to use)
ImVec2DisplaySize;// Size of the viewport to render (== GetMainViewport()->Size for the main viewport, == io.DisplaySize in most single-viewport applications)
ImVec2FramebufferScale;// Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
ImVec2FramebufferScale;// Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display.
ImGui::Checkbox("Use work area instead of main area",&use_work_area);
ImGui::SameLine();
HelpMarker("Main Area = entire viewport,\nWork Area = entire viewport minus sections used by the main menu bars, task bars etc.\n\nEnable the main-menu bar in Examples menu to see the difference.");
// ImGuiViewport Private/Internals fields (cardinal sin: we are using inheritance!)
// <this is filled in 'docking' branch>
// Every instance of ImGuiViewport is in fact a ImGuiViewportP.
#endif // #ifdef IMGUI_HAS_VIEWPORT
structImGuiViewportP:publicImGuiViewport
{
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;
ImVec2WorkOffsetMin;// Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!)
ImVec2WorkOffsetMax;// Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height).
ImVec2CurrWorkOffsetMin;// Work Area: Offset being built/increased during current frame
ImVec2CurrWorkOffsetMax;// Work Area: Offset being built/decreased during current frame
ImVector<ImGuiPopupData>OpenPopupStack;// Which popups are open (persistent)
ImVector<ImGuiPopupData>OpenPopupStack;// Which popups are open (persistent)
ImVector<ImGuiPopupData>BeginPopupStack;// Which level of BeginPopup() we are in (reset every frame)
ImVector<ImGuiPopupData>BeginPopupStack;// Which level of BeginPopup() we are in (reset every frame)
// Viewports
ImVector<ImGuiViewportP*>Viewports;// Active viewports (Size==1 in 'master' branch). Each viewports hold their copy of ImDrawData.
// Gamepad/keyboard Navigation
// Gamepad/keyboard Navigation
ImGuiWindow*NavWindow;// Focused window for navigation. Could be called 'FocusWindow'
ImGuiWindow*NavWindow;// Focused window for navigation. Could be called 'FocusWindow'
ImGuiIDNavId;// Focused item for navigation
ImGuiIDNavId;// Focused item for navigation
@ -1389,11 +1410,7 @@ struct ImGuiContext
boolFocusTabPressed;//
boolFocusTabPressed;//
// Render
// Render
ImDrawDataDrawData;// Main ImDrawData instance to pass render information to the user
ImDrawDataBuilderDrawDataBuilder;
floatDimBgRatio;// 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
floatDimBgRatio;// 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list)
ImDrawListBackgroundDrawList;// First draw list to be rendered.
ImDrawListForegroundDrawList;// Last draw list to be rendered. This is where we the render software mouse cursor (if io.MouseDrawCursor is set) and most debug overlays.
inlineImDrawList*GetForegroundDrawList(ImGuiWindow*window){IM_UNUSED(window);ImGuiContext&g=*GImGui;return&g.ForegroundDrawList;}// This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches.
inlineImDrawList*GetForegroundDrawList(ImGuiWindow*window){IM_UNUSED(window);returnGetForegroundDrawList();}// This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches.
IMGUI_APIImDrawList*GetBackgroundDrawList(ImGuiViewport*viewport);// get background draw list for the given viewport. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents.
IMGUI_APIImDrawList*GetForegroundDrawList(ImGuiViewport*viewport);// get foreground draw list for the given viewport. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents.
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.