@ -807,7 +807,7 @@ CODE
// Debug options
# define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL
# define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window
# define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file
# define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower)
// Visual Studio warnings
# ifdef _MSC_VER
@ -983,7 +983,7 @@ ImGuiStyle::ImGuiStyle()
ColorButtonPosition = ImGuiDir_Right ; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
ButtonTextAlign = ImVec2 ( 0.5f , 0.5f ) ; // Alignment of button text when button is larger than text.
SelectableTextAlign = ImVec2 ( 0.0f , 0.0f ) ; // Alignment of selectable text when button is larger than text.
DisplayWindowPadding = ImVec2 ( 19 , 19 ) ; // Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows.
DisplayWindowPadding = ImVec2 ( 19 , 19 ) ; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to 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.
@ -2621,6 +2621,7 @@ ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
SkipItems = false ;
Appearing = false ;
Hidden = false ;
IsFallbackWindow = false ;
HasCloseButton = false ;
ResizeBorderHeld = - 1 ;
BeginCount = 0 ;
@ -2835,18 +2836,17 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFla
// An active popup disable hovering on other windows (apart from its own children)
// FIXME-OPT: This could be cached/stored within the window.
ImGuiContext & g = * GImGui ;
if ( ! g . NavWindow )
return true ;
if ( ImGuiWindow * focused_root_window = g . NavWindow - > RootWindow )
if ( focused_root_window - > WasActive & & focused_root_window ! = window - > RootWindow )
{
// For the purpose of those flags we differentiate "standard popup" from "modal popup"
// NB: The order of those two tests is important because Modal windows are also Popups.
if ( focused_root_window - > Flags & ImGuiWindowFlags_Modal )
return false ;
if ( ( focused_root_window - > Flags & ImGuiWindowFlags_Popup ) & & ! ( flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup ) )
return false ;
}
if ( g . NavWindow )
if ( ImGuiWindow * focused_root_window = g . NavWindow - > RootWindow )
if ( focused_root_window - > WasActive & & focused_root_window ! = window - > RootWindow )
{
// For the purpose of those flags we differentiate "standard popup" from "modal popup"
// NB: The order of those two tests is important because Modal windows are also Popups.
if ( focused_root_window - > Flags & ImGuiWindowFlags_Modal )
return false ;
if ( ( focused_root_window - > Flags & ImGuiWindowFlags_Popup ) & & ! ( flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup ) )
return false ;
}
return true ;
}
@ -3290,10 +3290,10 @@ void ImGui::UpdateMouseMovingWindowNewFrame()
}
}
// Initiate moving window, handle left-click and right-click focus
// Initiate moving window when clicking on empty space or title bar.
// Handle left-click and right-click focus.
void ImGui : : UpdateMouseMovingWindowEndFrame ( )
{
// Initiate moving window
ImGuiContext & g = * GImGui ;
if ( g . ActiveId ! = 0 | | g . HoveredId ! = 0 )
return ;
@ -3787,9 +3787,10 @@ void ImGui::NewFrame()
// Create implicit/fallback window - which we will only render it if the user has added something to it.
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
// This fallback is particularly important as it avoid ImGui:: calls from crashing.
g . WithinFrameScopeWithImplicitWindow = true ;
SetNextWindowSize ( ImVec2 ( 400 , 400 ) , ImGuiCond_FirstUseEver ) ;
Begin ( " Debug##Default " ) ;
g. WithinFrameScopeWithImplicitWindow = true ;
IM_ASSERT( g . CurrentWindow - > IsFallbackWindow = = true ) ;
# ifdef IMGUI_ENABLE_TEST_ENGINE
ImGuiTestEngineHook_PostNewFrame ( & g ) ;
@ -4014,10 +4015,8 @@ static void AddWindowToDrawData(ImVector<ImDrawList*>* out_render_list, ImGuiWin
static void AddRootWindowToDrawData ( ImGuiWindow * window )
{
ImGuiContext & g = * GImGui ;
if ( window - > Flags & ImGuiWindowFlags_Tooltip )
AddWindowToDrawData ( & g . DrawDataBuilder . Layers [ 1 ] , window ) ;
else
AddWindowToDrawData ( & g . DrawDataBuilder . Layers [ 0 ] , window ) ;
int layer = ( window - > Flags & ImGuiWindowFlags_Tooltip ) ? 1 : 0 ;
AddWindowToDrawData ( & g . DrawDataBuilder . Layers [ layer ] , window ) ;
}
void ImDrawDataBuilder : : FlattenIntoSingleLayer ( )
@ -4156,16 +4155,17 @@ void ImGui::Render()
if ( g . FrameCountEnded ! = g . FrameCount )
EndFrame ( ) ;
g . FrameCountRendered = g . FrameCount ;
// Gather ImDrawList to render (for each active window)
g . IO . MetricsRenderWindows = 0 ;
g . DrawDataBuilder . Clear ( ) ;
// Add background ImDrawList
if ( ! g . BackgroundDrawList . VtxBuffer . empty ( ) )
AddDrawListToDrawData ( & g . DrawDataBuilder . Layers [ 0 ] , & g . BackgroundDrawList ) ;
// Add ImDrawList to render
ImGuiWindow * windows_to_render_top_most [ 2 ] ;
windows_to_render_top_most [ 0 ] = ( g . NavWindowingTarget & & ! ( g . NavWindowingTarget - > Flags & ImGuiWindowFlags_NoBringToFrontOnFocus ) ) ? g . NavWindowingTarget - > RootWindow : NULL ;
windows_to_render_top_most [ 1 ] = g . NavWindowingTarget ? g . NavWindowingList : NULL ;
windows_to_render_top_most [ 1 ] = ( g . NavWindowingTarget ? g . NavWindowingList : NULL ) ;
for ( int n = 0 ; n ! = g . Windows . Size ; n + + )
{
ImGuiWindow * window = g . Windows [ n ] ;
@ -4181,6 +4181,7 @@ void ImGui::Render()
if ( g . IO . MouseDrawCursor )
RenderMouseCursor ( & g . ForegroundDrawList , g . IO . MousePos , g . Style . MouseCursorScale , g . MouseCursor , IM_COL32_WHITE , IM_COL32_BLACK , IM_COL32 ( 0 , 0 , 0 , 48 ) ) ;
// Add foreground ImDrawList
if ( ! g . ForegroundDrawList . VtxBuffer . empty ( ) )
AddDrawListToDrawData ( & g . DrawDataBuilder . Layers [ 0 ] , & g . ForegroundDrawList ) ;
@ -4837,8 +4838,9 @@ static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size
// Minimum size
if ( ! ( window - > Flags & ( ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize ) ) )
{
ImGuiWindow * window_for_height = window ;
new_size = ImMax ( new_size , g . Style . WindowMinSize ) ;
new_size . y = ImMax ( new_size . y , window - > TitleBarHeight ( ) + window - > MenuBarHeight ( ) + ImMax ( 0.0f , g . Style . WindowRounding - 1.0f ) ) ; // Reduce artifacts with very small windows
new_size . y = ImMax ( new_size . y , window _for_height - > TitleBarHeight ( ) + window _for_height - > MenuBarHeight ( ) + ImMax ( 0.0f , g . Style . WindowRounding - 1.0f ) ) ; // Reduce artifacts with very small windows
}
return new_size ;
}
@ -5045,6 +5047,10 @@ static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
}
PopID ( ) ;
// Restore nav layer
window - > DC . NavLayerCurrent = ImGuiNavLayer_Main ;
window - > DC . NavLayerCurrentMask = ( 1 < < ImGuiNavLayer_Main ) ;
// Navigation resize (keyboard/gamepad)
if ( g . NavWindowingTarget & & g . NavWindowingTarget - > RootWindow = = window )
{
@ -5077,10 +5083,6 @@ static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_au
MarkIniSettingsDirty ( window ) ;
}
// Resize nav layer
window - > DC . NavLayerCurrent = ImGuiNavLayer_Main ;
window - > DC . NavLayerCurrentMask = ( 1 < < ImGuiNavLayer_Main ) ;
window - > Size = window - > SizeFull ;
return ret_auto_fit ;
}
@ -5129,6 +5131,8 @@ static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window)
}
}
// Draw background and borders
// Draw and handle scrollbars
void ImGui : : RenderWindowDecorations ( ImGuiWindow * window , const ImRect & title_bar_rect , bool title_bar_is_highlight , int resize_grip_count , const ImU32 resize_grip_col [ 4 ] , float resize_grip_draw_size )
{
ImGuiContext & g = * GImGui ;
@ -5340,6 +5344,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
const int current_frame = g . FrameCount ;
const bool first_begin_of_the_frame = ( window - > LastFrameActive ! = current_frame ) ;
window - > IsFallbackWindow = ( g . CurrentWindowStack . Size = = 0 & & g . WithinFrameScopeWithImplicitWindow ) ;
// Update the Appearing flag
bool window_just_activated_by_user = ( window - > LastFrameActive < current_frame - 1 ) ; // Not using !WasActive because the implicit "Debug" window would always toggle off->on
@ -5485,6 +5490,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
}
}
// SELECT VIEWPORT
// FIXME-VIEWPORT: In the docking/viewport branch, this is the point where we select the current viewport (which may affect the style)
SetCurrentWindow ( window ) ;
@ -5595,14 +5601,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
window - > Pos = FindBestWindowPosForPopup ( window ) ;
// Clamp position/size so window stays visible within its viewport or monitor
// Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
ImRect viewport_rect ( GetViewportRect ( ) ) ;
if ( ! window_pos_set_by_api & & ! ( flags & ImGuiWindowFlags_ChildWindow ) & & window - > AutoFitFramesX < = 0 & & window - > AutoFitFramesY < = 0 )
{
if ( 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 clamp_padding = ImMax ( style . DisplayWindowPadding , style . DisplaySafeAreaPadding ) ;
if ( viewport_rect . GetWidth ( ) > 0 & & viewport_rect . GetHeight ( ) > 0.0f )
{
ImVec2 clamp_padding = ImMax ( style . DisplayWindowPadding , style . DisplaySafeAreaPadding ) ;
ClampWindowRect ( window , viewport_rect , clamp_padding ) ;
}
}
@ -5739,20 +5744,22 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping child.
// We also disabled this when we have dimming overlay behind this specific one child.
// FIXME: More code may rely on explicit sorting of overlapping child window and would need to disable this somehow. Please get in contact if you are affected.
bool render_decorations_in_parent = false ;
if ( ( flags & ImGuiWindowFlags_ChildWindow ) & & ! ( flags & ImGuiWindowFlags_Popup ) & & ! window_is_child_tooltip )
if ( window - > DrawList - > CmdBuffer . back ( ) . ElemCount = = 0 & & parent_window - > DrawList - > VtxBuffer . Size > 0 )
render_decorations_in_parent = true ;
if ( render_decorations_in_parent )
window - > DrawList = parent_window - > DrawList ;
{
bool render_decorations_in_parent = false ;
if ( ( flags & ImGuiWindowFlags_ChildWindow ) & & ! ( flags & ImGuiWindowFlags_Popup ) & & ! window_is_child_tooltip )
if ( window - > DrawList - > CmdBuffer . back ( ) . ElemCount = = 0 & & parent_window - > DrawList - > VtxBuffer . Size > 0 )
render_decorations_in_parent = true ;
if ( render_decorations_in_parent )
window - > DrawList = parent_window - > DrawList ;
// Handle title bar, scrollbar, resize grips and resize borders
const ImGuiWindow * window_to_highlight = g . NavWindowingTarget ? g . NavWindowingTarget : g . NavWindow ;
const bool title_bar_is_highlight = want_focus | | ( window_to_highlight & & window - > RootWindowForTitleBarHighlight = = window_to_highlight - > RootWindowForTitleBarHighlight ) ;
RenderWindowDecorations ( window , title_bar_rect , title_bar_is_highlight , resize_grip_count , resize_grip_col , resize_grip_draw_size ) ;
// Handle title bar, scrollbar, resize grips and resize borders
const ImGuiWindow * window_to_highlight = g . NavWindowingTarget ? g . NavWindowingTarget : g . NavWindow ;
const bool title_bar_is_highlight = want_focus | | ( window_to_highlight & & window - > RootWindowForTitleBarHighlight = = window_to_highlight - > RootWindowForTitleBarHighlight ) ;
RenderWindowDecorations ( window , title_bar_rect , title_bar_is_highlight , resize_grip_count , resize_grip_col , resize_grip_draw_size ) ;
if ( render_decorations_in_parent )
window - > DrawList = & window - > DrawListInst ;
if ( render_decorations_in_parent )
window - > DrawList = & window - > DrawListInst ;
}
// Draw navigation selection/windowing rectangle border
if ( g . NavWindowingTargetAnim = = window )
@ -7568,7 +7575,7 @@ void ImGui::CloseCurrentPopup()
window - > DC . NavHideHighlightOneFrame = true ;
}
bool ImGui : : BeginPopupEx ( ImGuiID id , ImGuiWindowFlags extra_ flags)
bool ImGui : : BeginPopupEx ( ImGuiID id , ImGuiWindowFlags flags)
{
ImGuiContext & g = * GImGui ;
if ( ! IsPopupOpen ( id ) )
@ -7578,12 +7585,13 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
}
char name [ 20 ] ;
if ( extra_ flags & ImGuiWindowFlags_ChildMenu )
if ( flags & ImGuiWindowFlags_ChildMenu )
ImFormatString ( name , IM_ARRAYSIZE ( name ) , " ##Menu_%02d " , g . BeginPopupStack . Size ) ; // Recycle windows based on depth
else
ImFormatString ( name , IM_ARRAYSIZE ( name ) , " ##Popup_%08x " , id ) ; // Not recycling, so we can close/open during the same frame
bool is_open = Begin ( name , NULL , extra_flags | ImGuiWindowFlags_Popup ) ;
flags | = ImGuiWindowFlags_Popup ;
bool is_open = Begin ( name , NULL , flags ) ;
if ( ! is_open ) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
EndPopup ( ) ;
@ -10077,7 +10085,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
char buf [ 256 ] ;
char * p = buf ;
const char * buf_end = buf + IM_ARRAYSIZE ( buf ) ;
ImFormatString( p , buf_end - p , " TabBar (%d tabs)%s " , tab_bar - > Tabs . Size , ( tab_bar - > PrevFrameVisible < ImGui : : GetFrameCount ( ) - 2 ) ? " *Inactive* " : " " ) ;
p + = ImFormatString( p , buf_end - p , " TabBar (%d tabs)%s " , tab_bar - > Tabs . Size , ( tab_bar - > PrevFrameVisible < ImGui : : GetFrameCount ( ) - 2 ) ? " *Inactive* " : " " ) ;
if ( ImGui : : TreeNode ( tab_bar , " %s " , buf ) )
{
for ( int tab_n = 0 ; tab_n < tab_bar - > Tabs . Size ; tab_n + + )